Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a88b6cf98d | ||
|
|
41e50322be | ||
|
|
f1db46ecbe | ||
|
|
c0904e6aaa | ||
|
|
1d9492aff5 | ||
|
|
9416fa6518 |
@@ -0,0 +1,85 @@
|
||||
package com.neatstudio.tmuxandroid;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
final class ConversationMessage {
|
||||
final String messageId;
|
||||
final String sessionName;
|
||||
final String role;
|
||||
final String contentType;
|
||||
final String content;
|
||||
final String status;
|
||||
final String toolName;
|
||||
final String parentMessageId;
|
||||
final String createdAt;
|
||||
final boolean local;
|
||||
|
||||
ConversationMessage(
|
||||
String messageId,
|
||||
String sessionName,
|
||||
String role,
|
||||
String contentType,
|
||||
String content,
|
||||
String status,
|
||||
String toolName,
|
||||
String parentMessageId,
|
||||
String createdAt,
|
||||
boolean local
|
||||
) {
|
||||
this.messageId = messageId;
|
||||
this.sessionName = sessionName;
|
||||
this.role = role;
|
||||
this.contentType = contentType;
|
||||
this.content = content;
|
||||
this.status = status;
|
||||
this.toolName = toolName;
|
||||
this.parentMessageId = parentMessageId;
|
||||
this.createdAt = createdAt;
|
||||
this.local = local;
|
||||
}
|
||||
|
||||
static ConversationMessage fromJson(JSONObject object) {
|
||||
return new ConversationMessage(
|
||||
value(object, "messageId", object.optString("id", "")),
|
||||
object.optString("sessionName", ""),
|
||||
object.optString("role", "assistant"),
|
||||
object.optString("contentType", "text"),
|
||||
object.optString("content", ""),
|
||||
object.optString("status", "complete"),
|
||||
object.optString("toolName", ""),
|
||||
value(object, "parentMessageId", ""),
|
||||
object.optString("createdAt", ""),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
static ConversationMessage localUser(String sessionName, String content) {
|
||||
long now = System.currentTimeMillis();
|
||||
return new ConversationMessage(
|
||||
"local-" + now,
|
||||
sessionName,
|
||||
"user",
|
||||
"text",
|
||||
content,
|
||||
"sending",
|
||||
"",
|
||||
"",
|
||||
"~" + now,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
boolean isTool() {
|
||||
return "tool".equals(role)
|
||||
|| "tool".equals(contentType)
|
||||
|| "command".equals(contentType)
|
||||
|| "code".equals(contentType);
|
||||
}
|
||||
|
||||
private static String value(JSONObject object, String key, String fallback) {
|
||||
if (!object.has(key) || object.isNull(key)) {
|
||||
return fallback;
|
||||
}
|
||||
return object.optString(key, fallback);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -130,6 +130,20 @@ final class TerminalScreenBuffer {
|
||||
return output;
|
||||
}
|
||||
|
||||
String renderTail(int maxRows) {
|
||||
List<String> visible = new ArrayList<>();
|
||||
for (int row = rows - 1; row >= 0 && visible.size() < maxRows; row--) {
|
||||
String text = rowText(row).trim();
|
||||
if (!text.isEmpty()) {
|
||||
visible.add(0, text);
|
||||
}
|
||||
}
|
||||
if (visible.isEmpty()) {
|
||||
return "Waiting for terminal output";
|
||||
}
|
||||
return String.join("\n", visible);
|
||||
}
|
||||
|
||||
CharSequence renderFocused(Set<String> expandedBlocks, FocusToggle toggle) {
|
||||
SpannableStringBuilder output = new SpannableStringBuilder();
|
||||
List<String> hiddenRows = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user