@alexsun-top/opencode-chat-room 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/README.md +4 -4
  3. package/README.zh-CN.md +4 -4
  4. package/cli.ts +1 -1
  5. package/dist/cli.js +35 -16
  6. package/package.json +14 -11
  7. package/packages/chat-room-channeld/README.md +3 -2
  8. package/packages/chat-room-channeld/src/inbound.ts +3 -6
  9. package/packages/chat-room-channeld/src/pg/sql.mjs +157 -142
  10. package/packages/chat-room-channeld/src/pg/sql.mts +175 -0
  11. package/packages/chat-room-channeld/src/pg/worker.mjs +107 -99
  12. package/packages/chat-room-channeld/src/pg/worker.mts +166 -0
  13. package/plugin.ts +1 -1
  14. package/server/assets/chat/admin.js +4 -1
  15. package/server/assets/chat/announcements.js +3 -0
  16. package/server/assets/chat/attachments.js +3 -3
  17. package/server/assets/chat/clipboard.js +1 -1
  18. package/server/assets/chat/copy-action.js +1 -1
  19. package/server/assets/chat/doc-preview.js +1 -1
  20. package/server/assets/chat/editor.js +11 -7
  21. package/server/assets/chat/events.js +7 -5
  22. package/server/assets/chat/files.js +5 -1
  23. package/server/assets/chat/integration-editor.js +2 -0
  24. package/server/assets/chat/integrations.js +1 -1
  25. package/server/assets/chat/join-requests.js +1 -1
  26. package/server/assets/chat/markdown-footnotes.js +8 -7
  27. package/server/assets/chat/markdown.js +6 -5
  28. package/server/assets/chat/members.js +3 -3
  29. package/server/assets/chat/mentions.js +8 -5
  30. package/server/assets/chat/message-cache.js +1 -1
  31. package/server/assets/chat/message-polling.js +2 -2
  32. package/server/assets/chat/message-window.js +1 -1
  33. package/server/assets/chat/messages.js +17 -3
  34. package/server/assets/chat/office-preview.js +3 -3
  35. package/server/assets/chat/palette.js +5 -3
  36. package/server/assets/chat/panels.js +19 -0
  37. package/server/assets/chat/questions.js +3 -2
  38. package/server/assets/chat/reminders.js +3 -0
  39. package/server/assets/chat/replies.js +6 -3
  40. package/server/assets/chat/resource-format.js +2 -2
  41. package/server/assets/chat/rooms.js +7 -4
  42. package/server/assets/chat/settings.js +4 -3
  43. package/server/assets/chat/shortcuts.js +3 -1
  44. package/server/assets/chat/side-pane.js +1 -1
  45. package/server/assets/chat/state.js +30 -11
  46. package/server/assets/chat/system-events.js +3 -2
  47. package/server/assets/chat/system-messages.js +15 -15
  48. package/server/assets/chat/tasks.js +4 -3
  49. package/server/assets/chat/window-controls.js +3 -2
  50. package/server/assets/conversation.css +14 -2
  51. package/server/assets/doc-preview.css +6 -0
  52. package/server/assets/office/THIRD-PARTY-NOTICES.txt +23 -1
  53. package/server/assets/office/licenses/docx-preview-HEADER.txt +6 -0
  54. package/server/assets/office/licenses/echarts-LICENSE-d3.txt +27 -0
  55. package/server/assets/office/licenses/echarts-NOTICE.txt +5 -0
  56. package/server/assets/office/licenses/immediate-LICENSE.txt +20 -0
  57. package/server/assets/office/licenses/lie-LICENSE.txt +7 -0
  58. package/server/assets/office/licenses/pako-LICENSE.txt +21 -0
  59. package/server/assets/office/licenses/pako-ZLIB.txt +18 -0
  60. package/server/assets/office/licenses/setimmediate-LICENSE.txt +20 -0
  61. package/server/sw.js +3 -1
  62. package/skills/chatroom/SKILL.md +9 -0
  63. package/src/README.md +1 -1
  64. package/src/agent/agent-receipts.ts +12 -4
  65. package/src/center/center-client.ts +1 -1
  66. package/src/state/pg-sql.mjs +157 -142
  67. package/src/state/pg-sql.mts +175 -0
  68. package/src/state/pg-worker.mjs +107 -99
  69. package/src/state/pg-worker.mts +166 -0
  70. package/src/state/store.ts +21 -7
  71. package/src/tui/app-types.mjs +1 -0
  72. package/src/tui/app-types.mts +175 -0
  73. package/src/tui/app.mjs +426 -423
  74. package/src/tui/app.mts +500 -0
  75. package/src/tui/config.mjs +166 -158
  76. package/src/tui/config.mts +247 -0
  77. package/src/tui/http.mjs +239 -206
  78. package/src/tui/http.mts +412 -0
  79. package/src/tui/i18n.mjs +17 -20
  80. package/src/tui/i18n.mts +42 -0
  81. package/src/tui/info-app.mjs +431 -427
  82. package/src/tui/info-app.mts +500 -0
  83. package/src/tui/info-content.mjs +205 -199
  84. package/src/tui/info-content.mts +341 -0
  85. package/src/tui/join-app.mjs +75 -64
  86. package/src/tui/join-app.mts +99 -0
  87. package/src/tui/locales/en.mjs +302 -320
  88. package/src/tui/locales/en.mts +349 -0
  89. package/src/tui/locales/zh-CN.mjs +302 -320
  90. package/src/tui/locales/zh-CN.mts +349 -0
  91. package/src/tui/main.mjs +219 -213
  92. package/src/tui/main.mts +255 -0
  93. package/src/tui/markdown.mjs +128 -272
  94. package/src/tui/markdown.mts +152 -0
  95. package/src/tui/mentions.mjs +181 -184
  96. package/src/tui/mentions.mts +251 -0
  97. package/src/tui/message-app.mjs +181 -173
  98. package/src/tui/message-app.mts +213 -0
  99. package/src/tui/message-view.mjs +90 -111
  100. package/src/tui/message-view.mts +151 -0
  101. package/src/tui/messages.mjs +55 -49
  102. package/src/tui/messages.mts +106 -0
  103. package/src/tui/palette-app.mjs +364 -344
  104. package/src/tui/palette-app.mts +388 -0
  105. package/src/tui/palette.mjs +100 -98
  106. package/src/tui/palette.mts +176 -0
  107. package/src/tui/prefs.mjs +56 -63
  108. package/src/tui/prefs.mts +126 -0
  109. package/src/tui/reminder-app.mjs +191 -181
  110. package/src/tui/reminder-app.mts +228 -0
  111. package/src/tui/room-settings-app.mjs +257 -242
  112. package/src/tui/room-settings-app.mts +301 -0
  113. package/src/tui/session.mjs +30 -29
  114. package/src/tui/session.mts +51 -0
  115. package/src/tui/settings-app.mjs +151 -138
  116. package/src/tui/settings-app.mts +179 -0
  117. package/src/tui/ui-content.mjs +426 -421
  118. package/src/tui/ui-content.mts +499 -0
  119. package/src/tui/ui-help.mjs +58 -67
  120. package/src/tui/ui-help.mts +87 -0
  121. package/src/tui/ui-mentions.mjs +34 -36
  122. package/src/tui/ui-mentions.mts +60 -0
  123. package/src/tui/ui-overlay-view.mjs +259 -267
  124. package/src/tui/ui-overlay-view.mts +322 -0
  125. package/src/tui/ui-suggest-view.mjs +54 -57
  126. package/src/tui/ui-suggest-view.mts +78 -0
  127. package/src/tui/ui-suggest.mjs +164 -167
  128. package/src/tui/ui-suggest.mts +248 -0
  129. package/src/tui/ui-theme.mjs +52 -57
  130. package/src/tui/ui-theme.mts +98 -0
  131. package/src/tui/ui-view.mjs +267 -275
  132. package/src/tui/ui-view.mts +308 -0
  133. package/src/tui/ui.mjs +372 -359
  134. package/src/tui/ui.mts +440 -0
  135. package/src/tui/wire.mjs +215 -0
  136. package/src/tui/wire.mts +383 -0
@@ -0,0 +1,87 @@
1
+ // Keyboard help overlay: themed shortcut columns, compact on short terminals.
2
+ import { StyledText, bold, fg } from "@opentui/core";
3
+ import type { BoxRenderable, CliRenderer, TextChunk, TextRenderable } from "@opentui/core";
4
+ import { t } from "./i18n.mjs";
5
+ import type { TuiTheme } from "./ui-theme.mjs";
6
+
7
+ export interface HelpUi {
8
+ helpBox: BoxRenderable;
9
+ helpBar: BoxRenderable;
10
+ helpTitle: TextRenderable;
11
+ helpClose: TextRenderable;
12
+ helpFooter: TextRenderable;
13
+ helpLeft: TextRenderable;
14
+ helpRight: TextRenderable;
15
+ theme: TuiTheme;
16
+ helpSignature: string;
17
+ renderer: CliRenderer;
18
+ }
19
+
20
+ export interface HelpState {
21
+ help?: unknown;
22
+ palette?: unknown;
23
+ language?: string;
24
+ }
25
+
26
+ type ShortcutRows = readonly (readonly [string, string])[];
27
+
28
+ function shortcutChunks(title: string, rows: ShortcutRows, theme: TuiTheme): TextChunk[] {
29
+ const chunks = [bold(fg(theme.accent)(`${title}\n`))];
30
+ for (const [key, label] of rows) {
31
+ chunks.push(fg(theme.accent)(key.padEnd(12)));
32
+ chunks.push(fg(theme.text)(`${label}\n`));
33
+ }
34
+ return chunks;
35
+ }
36
+
37
+ export function syncHelp(ui: HelpUi, state: HelpState): void {
38
+ const show = Boolean(state.help) && !state.palette;
39
+ ui.helpBox.visible = show;
40
+ if (!show) return;
41
+ ui.helpBox.borderColor = ui.theme.border;
42
+ ui.helpBox.backgroundColor = ui.theme.surface;
43
+ ui.helpBar.backgroundColor = ui.theme.raised;
44
+ ui.helpTitle.fg = ui.theme.text;
45
+ ui.helpClose.fg = ui.theme.muted;
46
+ ui.helpFooter.fg = ui.theme.muted;
47
+ const signature = `${ui.theme.mode}:${state.language}`;
48
+ if (signature === ui.helpSignature) return;
49
+ ui.helpSignature = signature;
50
+ const compact = ui.renderer.height < 22;
51
+ const navigation: ShortcutRows = compact
52
+ ? [
53
+ ["↑ / ↓", t("help.selectRoom")],
54
+ ["Enter", t("help.openJoin")],
55
+ ["Tab", t("help.focusComposer")],
56
+ ["PgUp / PgDn", t("help.scrollMessages")],
57
+ ]
58
+ : [
59
+ ["↑ / ↓", t("help.selectRoom")],
60
+ ["Enter", t("help.openJoin")],
61
+ ["Tab", t("help.focusComposer")],
62
+ ["PgUp / PgDn", t("help.scrollMessages")],
63
+ ["Alt+Home", t("help.firstMessage")],
64
+ ["Alt+End", t("help.lastMessage")],
65
+ ];
66
+ const composer: ShortcutRows = compact
67
+ ? [
68
+ ["Enter", t("help.sendMessage")],
69
+ ["Esc", t("help.clearBlur")],
70
+ ["/", t("help.inlineCommands")],
71
+ ["@", t("help.mentionMembers")],
72
+ ["Ctrl+C", t("help.quit")],
73
+ ]
74
+ : [
75
+ ["Enter", t("help.sendMessage")],
76
+ ["Ctrl+J", t("help.newline")],
77
+ ["Esc", t("help.clearBlur")],
78
+ ["/", t("help.inlineCommands")],
79
+ ["@", t("help.mentionMembers")],
80
+ ["Alt+Space", t("help.paletteSearch")],
81
+ ["Ctrl+R", t("help.refreshRooms")],
82
+ ["/exit", t("help.quit")],
83
+ ["Ctrl+C", t("help.quit")],
84
+ ];
85
+ ui.helpLeft.content = new StyledText(shortcutChunks(t("help.navigation"), navigation, ui.theme));
86
+ ui.helpRight.content = new StyledText(shortcutChunks(t("help.composer"), composer, ui.theme));
87
+ }
@@ -2,43 +2,41 @@
2
2
  // to the text; we rebuild them only when the visible ranges or theme change.
3
3
  import { SyntaxStyle } from "@opentui/core";
4
4
  import { mentionNames, mentionRanges } from "./mentions.mjs";
5
-
6
5
  function styleFor(ui) {
7
- let style = ui.mentionStyles.get(ui.theme.mode);
8
- if (!style) {
9
- style = SyntaxStyle.fromStyles({
10
- mention: { fg: ui.theme.accent, bold: true },
11
- });
12
- ui.mentionStyles.set(ui.theme.mode, style);
13
- }
14
- return style;
6
+ let style = ui.mentionStyles.get(ui.theme.mode);
7
+ if (!style) {
8
+ style = SyntaxStyle.fromStyles({
9
+ mention: { fg: ui.theme.accent, bold: true },
10
+ }, ui.renderer.nativeScene);
11
+ ui.mentionStyles.set(ui.theme.mode, style);
12
+ }
13
+ return style;
15
14
  }
16
-
17
15
  export function syncMentionHighlights(ui, state) {
18
- const textarea = ui.textarea;
19
- const text = textarea.plainText;
20
- const ranges = mentionRanges(text, state.current?.participants);
21
- const names = mentionNames(state.current?.participants).join(",");
22
- const signature = `${ui.theme.mode}:${names}:${ranges.map((range) => `${range.start}-${range.end}`).join(",")}`;
23
- if (signature === ui.mentionSignature) return;
24
- if (!ranges.length) {
25
- textarea.extmarks.clear();
16
+ const textarea = ui.textarea;
17
+ const text = textarea.plainText;
18
+ const ranges = mentionRanges(text, state.current?.participants);
19
+ const names = mentionNames(state.current?.participants).join(",");
20
+ const signature = `${ui.theme.mode}:${names}:${ranges.map((range) => `${range.start}-${range.end}`).join(",")}`;
21
+ if (signature === ui.mentionSignature)
22
+ return;
23
+ if (!ranges.length) {
24
+ textarea.extmarks.clear();
25
+ ui.mentionSignature = signature;
26
+ return;
27
+ }
28
+ const style = styleFor(ui);
29
+ const styleId = style.getStyleId("mention") ?? style.registerStyle("mention", {
30
+ fg: ui.theme.accent,
31
+ bold: true,
32
+ });
33
+ textarea.syntaxStyle = style;
34
+ const extmarks = textarea.extmarks;
35
+ const typeId = ui.mentionTypeId ??= extmarks.registerType("mention");
36
+ extmarks.clear();
37
+ for (const range of ranges) {
38
+ extmarks.create({ start: range.start, end: range.end, styleId, typeId });
39
+ }
26
40
  ui.mentionSignature = signature;
27
- return;
28
- }
29
-
30
- const style = styleFor(ui);
31
- const styleId = style.getStyleId("mention") ?? style.registerStyle("mention", {
32
- fg: ui.theme.accent,
33
- bold: true,
34
- });
35
- textarea.syntaxStyle = style;
36
- const extmarks = textarea.extmarks;
37
- const typeId = ui.mentionTypeId ??= extmarks.registerType("mention");
38
- extmarks.clear();
39
- for (const range of ranges) {
40
- extmarks.create({ start: range.start, end: range.end, styleId, typeId });
41
- }
42
- ui.mentionSignature = signature;
43
- ui.renderer.requestRender();
44
- }
41
+ ui.renderer.requestRender();
42
+ }
@@ -0,0 +1,60 @@
1
+ // Accent-colored mention chips inside the composer. Extmarks keep ranges tied
2
+ // to the text; we rebuild them only when the visible ranges or theme change.
3
+ import { SyntaxStyle } from "@opentui/core";
4
+ import type { CliRenderer, TextareaRenderable, ThemeMode } from "@opentui/core";
5
+ import { mentionNames, mentionRanges } from "./mentions.mjs";
6
+ import type { Participant } from "./mentions.mjs";
7
+ import type { TuiTheme } from "./ui-theme.mjs";
8
+
9
+ export interface MentionUi {
10
+ textarea: TextareaRenderable;
11
+ theme: TuiTheme;
12
+ mentionStyles: Map<ThemeMode, SyntaxStyle>;
13
+ mentionSignature: string;
14
+ mentionTypeId: number | null;
15
+ renderer: CliRenderer;
16
+ }
17
+
18
+ export interface MentionState {
19
+ current?: { participants?: readonly Participant[] } | null;
20
+ }
21
+
22
+ function styleFor(ui: MentionUi): SyntaxStyle {
23
+ let style = ui.mentionStyles.get(ui.theme.mode);
24
+ if (!style) {
25
+ style = SyntaxStyle.fromStyles({
26
+ mention: { fg: ui.theme.accent, bold: true },
27
+ }, ui.renderer.nativeScene);
28
+ ui.mentionStyles.set(ui.theme.mode, style);
29
+ }
30
+ return style;
31
+ }
32
+
33
+ export function syncMentionHighlights(ui: MentionUi, state: MentionState): void {
34
+ const textarea = ui.textarea;
35
+ const text = textarea.plainText;
36
+ const ranges = mentionRanges(text, state.current?.participants);
37
+ const names = mentionNames(state.current?.participants).join(",");
38
+ const signature = `${ui.theme.mode}:${names}:${ranges.map((range) => `${range.start}-${range.end}`).join(",")}`;
39
+ if (signature === ui.mentionSignature) return;
40
+ if (!ranges.length) {
41
+ textarea.extmarks.clear();
42
+ ui.mentionSignature = signature;
43
+ return;
44
+ }
45
+
46
+ const style = styleFor(ui);
47
+ const styleId = style.getStyleId("mention") ?? style.registerStyle("mention", {
48
+ fg: ui.theme.accent,
49
+ bold: true,
50
+ });
51
+ textarea.syntaxStyle = style;
52
+ const extmarks = textarea.extmarks;
53
+ const typeId = ui.mentionTypeId ??= extmarks.registerType("mention");
54
+ extmarks.clear();
55
+ for (const range of ranges) {
56
+ extmarks.create({ start: range.start, end: range.end, styleId, typeId });
57
+ }
58
+ ui.mentionSignature = signature;
59
+ ui.renderer.requestRender();
60
+ }