web: chat — session list, open/close, history paging, markdown, scroll (C1/C3/C4/C7/C14)

Browser Chat destination for parity with the Android app:
- session list grouped by directory (closed grouped under "Closed"), kind
  chip, activity badge, work-label meta line, "Search chats" filter (C1)
- open/close/reopen with the Android copy verbatim (C3)
- conversation history paging via the opaque next_cursor (C4)
- markdown subset renderer + code blocks (C7)
- scroll follow / "Jump to latest" / per-session saved position (C14)

Request builders in src/repository.js; pure merge/format/markdown/paging
logic in src/chat.js and src/markdown.js; view in app.js. Every server
string set with textContent, markdown built as DOM nodes.
This commit is contained in:
2026-10-19 05:39:29 +01:00
parent 3d98c60de6
commit 0688127253
10 changed files with 2863 additions and 6 deletions
+24
View File
@@ -34,10 +34,34 @@ export const Protocol = Object.freeze({
DECIDE_RUN: "decide_run",
SET_RUN_TITLE: "set_run_title",
// Brokered OpenCode chat (C1/C3/C4), mirroring internal/protocol/chat.go and
// Message.kt. The session-scoped commands carry their body in `chat_query`;
// the list replies in `chat_sessions`, history in `chat_history` (an opaque
// `next_cursor` + `has_more`) and a close/reopen echoes the updated session in
// `chat_session` (with the `chat_close` outcome alongside).
CHAT_SESSIONS: "chat_sessions",
CHAT_MESSAGES: "chat_messages",
CHAT_CLOSE: "chat_close",
CHAT_REOPEN: "chat_reopen",
SUCCESS_END: "#success",
FAILURE_END: "#failure",
});
/**
* The envelope field names the chat commands read and write
* (internal/protocol/message.go). Kept beside the command constants so a rename
* in the Go envelope cannot drift silently.
*/
export const ChatKeys = Object.freeze({
SESSIONS: "chat_sessions",
SESSION: "chat_session",
QUERY: "chat_query",
HISTORY: "chat_history",
MESSAGES: "chat_messages",
CLOSE: "chat_close",
});
/**
* The integer wire protocol this page speaks. Mirrors `ProtocolVersion` in
* internal/protocol/identity.go and the value the Android client compares in