@alexsun-top/opencode-chat-room 0.8.0 → 0.8.1

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 (161) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +2 -2
  3. package/README.md +38 -6
  4. package/README.zh-CN.md +38 -6
  5. package/cli.ts +27 -1
  6. package/dist/cli.js +5074 -3212
  7. package/package.json +23 -3
  8. package/packages/chat-room-channeld/README.md +98 -25
  9. package/packages/chat-room-channeld/dist/feishu-adapter.js +912 -149
  10. package/packages/chat-room-channeld/src/adapter.ts +36 -2
  11. package/packages/chat-room-channeld/src/config.ts +63 -1
  12. package/packages/chat-room-channeld/src/delivery.ts +6 -1
  13. package/packages/chat-room-channeld/src/feishu-adapter.ts +122 -292
  14. package/packages/chat-room-channeld/src/feishu-card.ts +27 -0
  15. package/packages/chat-room-channeld/src/feishu-inbound.ts +158 -0
  16. package/packages/chat-room-channeld/src/feishu-live.ts +355 -0
  17. package/packages/chat-room-channeld/src/feishu-send.ts +342 -0
  18. package/packages/chat-room-channeld/src/feishu-ws-frames.ts +173 -0
  19. package/packages/chat-room-channeld/src/host-helpers.ts +11 -0
  20. package/packages/chat-room-channeld/src/host.ts +120 -2
  21. package/packages/chat-room-channeld/src/inbound.ts +26 -0
  22. package/packages/chat-room-channeld/src/state.ts +17 -0
  23. package/packages/chat-room-channeld/src/stats.ts +43 -1
  24. package/server/admin-state.ts +13 -13
  25. package/server/app.ts +95 -0
  26. package/server/assets/NOTICE.txt +2 -1
  27. package/server/assets/base.css +15 -9
  28. package/server/assets/chat/announcements.js +70 -7
  29. package/server/assets/chat/doc-preview.js +184 -35
  30. package/server/assets/chat/events.js +3 -0
  31. package/server/assets/chat/files.js +46 -4
  32. package/server/assets/chat/index.js +2 -0
  33. package/server/assets/chat/integration-editor.js +163 -0
  34. package/server/assets/chat/integration-values.js +124 -0
  35. package/server/assets/chat/integrations.js +498 -0
  36. package/server/assets/chat/locales/de.js +40 -4
  37. package/server/assets/chat/locales/es.js +40 -4
  38. package/server/assets/chat/locales/fr.js +40 -4
  39. package/server/assets/chat/locales/it.js +40 -4
  40. package/server/assets/chat/locales/ja.js +40 -4
  41. package/server/assets/chat/locales/ko.js +40 -4
  42. package/server/assets/chat/markdown.js +22 -8
  43. package/server/assets/chat/messages.js +5 -5
  44. package/server/assets/chat/office-preview.js +69 -0
  45. package/server/assets/chat/panels.js +36 -0
  46. package/server/assets/chat/recall.js +58 -7
  47. package/server/assets/chat/receipts.js +15 -3
  48. package/server/assets/chat/reminders.js +69 -8
  49. package/server/assets/chat/resource-format.js +11 -0
  50. package/server/assets/chat/settings.js +30 -2
  51. package/server/assets/chat/side-pane.js +1 -2
  52. package/server/assets/chat/state.js +93 -10
  53. package/server/assets/chat/system-events.js +32 -0
  54. package/server/assets/chat/system-messages.js +23 -14
  55. package/server/assets/chat/task-row.js +0 -6
  56. package/server/assets/chat/tasks.js +121 -33
  57. package/server/assets/code-highlight.css +55 -32
  58. package/server/assets/conversation.css +123 -23
  59. package/server/assets/doc-preview.css +35 -3
  60. package/server/assets/files.css +5 -0
  61. package/server/assets/fluent-icons.svg +2 -0
  62. package/server/assets/monaco/LICENSE +21 -0
  63. package/server/assets/monaco/ThirdPartyNotices.txt +448 -0
  64. package/server/assets/monaco/codicon-jdswhhtn.ttf +0 -0
  65. package/server/assets/monaco/editor.worker.js +45 -0
  66. package/server/assets/monaco/integration-rules.css +1 -0
  67. package/server/assets/monaco/integration-rules.js +1297 -0
  68. package/server/assets/monaco/json.worker.js +77 -0
  69. package/server/assets/office/THIRD-PARTY-NOTICES.txt +11 -0
  70. package/server/assets/office/docx.bundle.js +33 -0
  71. package/server/assets/office/licenses/docx-preview-LICENSE.txt +201 -0
  72. package/server/assets/office/licenses/echarts-LICENSE.txt +222 -0
  73. package/server/assets/office/licenses/jszip-LICENSE.txt +651 -0
  74. package/server/assets/office/licenses/lodash-LICENSE.txt +47 -0
  75. package/server/assets/office/licenses/pptx-preview-LICENSE.txt +8 -0
  76. package/server/assets/office/licenses/tslib-LICENSE.txt +12 -0
  77. package/server/assets/office/licenses/uuid-LICENSE.txt +9 -0
  78. package/server/assets/office/licenses/xlsx-LICENSE.txt +201 -0
  79. package/server/assets/office/licenses/zrender-LICENSE.txt +29 -0
  80. package/server/assets/office/pptx.bundle.js +104 -0
  81. package/server/assets/office/xlsx.bundle.js +141 -0
  82. package/server/assets/recall.css +5 -4
  83. package/server/assets/responsive.css +50 -11
  84. package/server/assets/settings.css +73 -1
  85. package/server/assets/tasks.css +57 -7
  86. package/server/channel-integration.ts +519 -0
  87. package/server/channel-settings.ts +77 -0
  88. package/server/channels.ts +261 -18
  89. package/server/chat-server.ts +32 -580
  90. package/server/chat.html +187 -21
  91. package/server/http-server.ts +3 -182
  92. package/server/resource-routes.ts +16 -16
  93. package/server/routes/inbox.ts +100 -0
  94. package/server/routes/pages.ts +83 -0
  95. package/server/routes/questions.ts +39 -0
  96. package/server/routes/room-actions.ts +162 -0
  97. package/server/routes/rooms.ts +160 -0
  98. package/server/startup.ts +84 -0
  99. package/server/sw.js +4 -0
  100. package/server/task-routes.ts +1 -1
  101. package/src/center/center-client.ts +2 -10
  102. package/src/config/file-config.ts +7 -54
  103. package/src/platform/http-server.ts +182 -0
  104. package/src/protocol/addressing.ts +21 -0
  105. package/src/protocol/config.ts +58 -0
  106. package/src/protocol/room.ts +51 -0
  107. package/src/rooms/resources.ts +26 -16
  108. package/src/rooms/room-service.ts +2 -48
  109. package/src/rooms/storage.ts +329 -0
  110. package/src/rooms/tasks.ts +21 -5
  111. package/src/runtime/watch.ts +1 -1
  112. package/src/state/pg-database.ts +183 -0
  113. package/src/state/pg-migrate.ts +175 -0
  114. package/src/state/pg-sql.mjs +175 -0
  115. package/src/state/pg-worker.mjs +148 -0
  116. package/src/state/sqlite-announcements.ts +25 -0
  117. package/src/state/sqlite-database.ts +121 -0
  118. package/src/state/sqlite-legacy.ts +90 -0
  119. package/src/state/sqlite-members.ts +155 -0
  120. package/src/state/sqlite-messages.ts +288 -0
  121. package/src/state/sqlite-resources.ts +39 -0
  122. package/src/state/sqlite-rooms.ts +87 -0
  123. package/src/state/sqlite-schema.ts +80 -0
  124. package/src/state/sqlite-state-store.ts +33 -0
  125. package/src/state/sqlite-state.ts +15 -897
  126. package/src/state/sqlite-tasks.ts +65 -0
  127. package/src/state/sqlite-transaction.ts +13 -0
  128. package/src/state/sqlite.ts +21 -1
  129. package/src/state/store.ts +5 -1
  130. package/src/tui/app.mjs +32 -19
  131. package/src/tui/config.mjs +12 -4
  132. package/src/tui/i18n.mjs +38 -0
  133. package/src/tui/info-app.mjs +50 -51
  134. package/src/tui/info-content.mjs +79 -44
  135. package/src/tui/join-app.mjs +9 -9
  136. package/src/tui/locales/en.mjs +349 -0
  137. package/src/tui/locales/zh-CN.mjs +349 -0
  138. package/src/tui/main.mjs +85 -37
  139. package/src/tui/markdown.mjs +3 -2
  140. package/src/tui/mentions.mjs +3 -1
  141. package/src/tui/message-app.mjs +22 -21
  142. package/src/tui/message-view.mjs +2 -1
  143. package/src/tui/palette-app.mjs +9 -8
  144. package/src/tui/palette.mjs +30 -24
  145. package/src/tui/prefs.mjs +92 -0
  146. package/src/tui/reminder-app.mjs +18 -17
  147. package/src/tui/room-settings-app.mjs +30 -28
  148. package/src/tui/settings-app.mjs +153 -0
  149. package/src/tui/ui-content.mjs +65 -86
  150. package/src/tui/ui-help.mjs +73 -0
  151. package/src/tui/ui-overlay-view.mjs +23 -7
  152. package/src/tui/ui-suggest.mjs +6 -5
  153. package/src/tui/ui-theme.mjs +37 -33
  154. package/src/tui/ui-view.mjs +22 -7
  155. package/src/tui/ui.mjs +15 -3
  156. package/src/web/editor.worker.ts +1 -0
  157. package/src/web/integration-rules-editor.ts +439 -0
  158. package/src/web/integration-rules.ts +22 -0
  159. package/src/web/integration-schema.ts +228 -0
  160. package/src/web/json.worker.ts +1 -0
  161. package/src/web/office-viewer.ts +221 -0
@@ -3,9 +3,9 @@
3
3
  // name, description and join-policy patches through api.updateRoom.
4
4
  import { roomSettingsMarkdown } from "./info-content.mjs";
5
5
  import { createInfoPalette } from "./info-app.mjs";
6
+ import { t } from "./i18n.mjs";
6
7
 
7
8
  const errorText = (error) => (error instanceof Error ? error.message : String(error ?? "unknown error"));
8
- const EDIT_HINT = "r rename · d desc · j policy · Esc close";
9
9
 
10
10
  export function attachRoomSettings(Class) {
11
11
  Object.assign(Class.prototype, {
@@ -13,15 +13,15 @@ export function attachRoomSettings(Class) {
13
13
  const current = this.state.current;
14
14
  if (!current || !this.state.joined) {
15
15
  this.state.palette = null;
16
- this.setStatus("open a joined room first", "error");
16
+ this.setStatus(t("info.joinFirst"), "error");
17
17
  return;
18
18
  }
19
19
  this.roomSettings = null;
20
20
  const palette = {
21
- ...createInfoPalette("room-settings", "Room settings", `#${current.name}`),
21
+ ...createInfoPalette("room-settings", t("room.title"), `#${current.name}`),
22
22
  mode: "detail",
23
- detail: { title: "Room settings", markdown: "Loading...", kind: "room-settings" },
24
- hint: "Esc close",
23
+ detail: { title: t("room.title"), markdown: t("common.loading"), kind: "room-settings" },
24
+ hint: t("palette.detailHint"),
25
25
  };
26
26
  this.state.palette = palette;
27
27
  this.touch();
@@ -39,7 +39,7 @@ export function attachRoomSettings(Class) {
39
39
  this.roomSettings = { room, canEdit, canDelete };
40
40
  palette.roomMeta = room;
41
41
  palette.detail = {
42
- title: "Room settings",
42
+ title: t("room.title"),
43
43
  markdown: roomSettingsMarkdown(room, {
44
44
  participant: this.participant,
45
45
  sessionID: this.sessionID,
@@ -48,20 +48,22 @@ export function attachRoomSettings(Class) {
48
48
  }),
49
49
  kind: "room-settings",
50
50
  };
51
- palette.hint = canEdit ? EDIT_HINT : "Read-only · Esc close";
51
+ palette.hint = canEdit ? t("room.editHint") : t("room.readOnlyHint");
52
52
  if (canDelete) {
53
- palette.hint = canEdit
54
- ? "r rename · d desc · j policy · x delete · Esc close"
55
- : "x delete room · Esc close";
53
+ palette.hint = canEdit ? t("room.editDeleteHint") : t("room.deleteOnlyHint");
56
54
  }
57
55
  palette.error = "";
58
56
  this.touch();
59
57
  } catch (error) {
60
58
  if (this.state.palette !== palette) return;
61
59
  this.roomSettings = null;
62
- palette.detail = { title: "Room settings", markdown: `**Unable to load room settings**\n\n${errorText(error)}`, kind: "room-settings" };
60
+ palette.detail = {
61
+ title: t("room.title"),
62
+ markdown: `${t("room.loadFailed")}\n\n${errorText(error)}`,
63
+ kind: "room-settings",
64
+ };
63
65
  palette.error = errorText(error);
64
- palette.hint = "Esc close";
66
+ palette.hint = t("room.readOnlyHint");
65
67
  this.touch();
66
68
  }
67
69
  },
@@ -75,7 +77,7 @@ export function attachRoomSettings(Class) {
75
77
  || settings.room.id !== this.state.current?.id
76
78
  ) {
77
79
  if (palette) {
78
- palette.error = "only the room owner or an admin can edit these settings";
80
+ palette.error = t("room.guardEdit");
79
81
  this.touch();
80
82
  }
81
83
  return null;
@@ -88,9 +90,9 @@ export function attachRoomSettings(Class) {
88
90
  const palette = this.state.palette;
89
91
  if (!settings || !palette) return;
90
92
  palette.mode = "prompt";
91
- palette.prompt = { label: "Room name", value: settings.room.name, action: "room-name", data: {} };
93
+ palette.prompt = { label: t("room.namePrompt"), value: settings.room.name, action: "room-name", data: {} };
92
94
  palette.error = "";
93
- palette.hint = "Enter save · Esc cancel";
95
+ palette.hint = t("palette.enterSaveHint");
94
96
  this.touch();
95
97
  },
96
98
 
@@ -100,13 +102,13 @@ export function attachRoomSettings(Class) {
100
102
  if (!settings || !palette) return;
101
103
  palette.mode = "prompt";
102
104
  palette.prompt = {
103
- label: "Room description",
105
+ label: t("room.descriptionPrompt"),
104
106
  value: settings.room.description ?? "",
105
107
  action: "room-description",
106
108
  data: {},
107
109
  };
108
110
  palette.error = "";
109
- palette.hint = "Enter save · empty clears · Esc cancel";
111
+ palette.hint = t("room.descriptionHint");
110
112
  this.touch();
111
113
  },
112
114
 
@@ -118,12 +120,12 @@ export function attachRoomSettings(Class) {
118
120
  palette.mode = "confirm";
119
121
  palette.previous = { mode: "detail", hint: palette.hint };
120
122
  palette.confirm = {
121
- text: `Set join policy to ${next}?`,
123
+ text: t("room.policyConfirm", { policy: next }),
122
124
  action: "room-join-policy",
123
125
  data: { joinPolicy: next },
124
126
  };
125
127
  palette.error = "";
126
- palette.hint = "Enter or y applies · n or Esc cancels";
128
+ palette.hint = t("room.policyHint");
127
129
  this.touch();
128
130
  },
129
131
 
@@ -138,7 +140,7 @@ export function attachRoomSettings(Class) {
138
140
  || palette.kind !== "room-settings"
139
141
  ) {
140
142
  if (palette) {
141
- palette.error = "only the room owner can delete the room";
143
+ palette.error = t("room.guardDelete");
142
144
  this.touch();
143
145
  }
144
146
  return;
@@ -146,12 +148,12 @@ export function attachRoomSettings(Class) {
146
148
  palette.mode = "confirm";
147
149
  palette.previous = { mode: "detail", hint: palette.hint };
148
150
  palette.confirm = {
149
- text: `Delete #${settings.room.name} and its messages? This cannot be undone.`,
151
+ text: t("room.deleteConfirm", { name: settings.room.name }),
150
152
  action: "room-delete",
151
153
  data: { id: settings.room.id, name: settings.room.name },
152
154
  };
153
155
  palette.error = "";
154
- palette.hint = "Enter or y deletes · n or Esc cancels";
156
+ palette.hint = t("palette.deleteHint");
155
157
  this.touch();
156
158
  },
157
159
 
@@ -162,21 +164,21 @@ export function attachRoomSettings(Class) {
162
164
  if (prompt.action === "room-name") {
163
165
  const name = String(value ?? "").trim();
164
166
  if (!name || Array.from(name).length > 64) {
165
- palette.error = "room name must contain 1 to 64 characters";
167
+ palette.error = t("room.nameInvalid");
166
168
  this.touch();
167
169
  return;
168
170
  }
169
- await this.applyRoomPatch({ name }, `renamed to ${name}`);
171
+ await this.applyRoomPatch({ name }, t("room.renamed", { name }));
170
172
  return;
171
173
  }
172
174
  if (prompt.action === "room-description") {
173
175
  const description = String(value ?? "").trim();
174
176
  if (Array.from(description).length > 2000) {
175
- palette.error = "description is limited to 2000 characters";
177
+ palette.error = t("room.descriptionInvalid");
176
178
  this.touch();
177
179
  return;
178
180
  }
179
- await this.applyRoomPatch({ description }, "description updated");
181
+ await this.applyRoomPatch({ description }, t("room.descriptionUpdated"));
180
182
  }
181
183
  },
182
184
 
@@ -229,7 +231,7 @@ export function attachRoomSettings(Class) {
229
231
  this.state.pending = null;
230
232
  this.state.selected = Math.min(this.state.selected, Math.max(0, this.state.rooms.length - 1));
231
233
  this.closePalette();
232
- this.setStatus(`deleted #${confirm.data.name}`, "success");
234
+ this.setStatus(t("room.deleted", { name: confirm.data.name }), "success");
233
235
  } catch (error) {
234
236
  if (this.state.palette === palette) {
235
237
  palette.searching = false;
@@ -242,7 +244,7 @@ export function attachRoomSettings(Class) {
242
244
  if (confirm.action !== "room-join-policy") return;
243
245
  await this.applyRoomPatch(
244
246
  { joinPolicy: confirm.data.joinPolicy },
245
- `join policy set to ${confirm.data.joinPolicy}`,
247
+ t("room.policySet", { policy: confirm.data.joinPolicy }),
246
248
  );
247
249
  },
248
250
  });
@@ -0,0 +1,153 @@
1
+ // Editable TUI preferences over the shared palette. The old read-only facts
2
+ // stay available as "Connection details" and from the Settings detail page.
3
+ import { createInfoPalette } from "./info-app.mjs";
4
+ import { settingsMarkdown } from "./info-content.mjs";
5
+ import { normalizeLanguage, setLanguage, t } from "./i18n.mjs";
6
+ import { normalizeTheme } from "./prefs.mjs";
7
+
8
+ const errorText = (error) => (error instanceof Error ? error.message : String(error ?? "unknown error"));
9
+ const LANGUAGE_INPUTS = ["en", "zh", "zh-cn", "zh_cn"];
10
+
11
+ function languageLabel(language) {
12
+ return t(normalizeLanguage(language) === "zh-CN" ? "settings.langZh" : "settings.langEn");
13
+ }
14
+
15
+ function themeLabel(theme) {
16
+ return t(normalizeTheme(theme) === "light" ? "settings.themeLight" : "settings.themeDark");
17
+ }
18
+
19
+ function factsMarkdown(app) {
20
+ return settingsMarkdown({
21
+ ...app.settings,
22
+ participant: app.participant,
23
+ language: app.state.language,
24
+ theme: app.state.theme,
25
+ token: app.token,
26
+ });
27
+ }
28
+
29
+ export function attachSettings(Class) {
30
+ Object.assign(Class.prototype, {
31
+ // Read-only summary kept for the palette "Settings" docs and the e key.
32
+ openSettings() {
33
+ const text = factsMarkdown(this);
34
+ this.state.help = false;
35
+ this.state.palette = {
36
+ ...createInfoPalette("settings", t("settings.title"), t("settings.readOnlyHint")),
37
+ mode: "detail",
38
+ detail: { title: t("settings.title"), markdown: text, kind: "settings" },
39
+ hint: t("settings.readOnlyHint"),
40
+ };
41
+ this.touch();
42
+ },
43
+
44
+ openSettingsEditor() {
45
+ this.state.help = false;
46
+ const palette = createInfoPalette("settings", t("settings.title"), t("settings.subtitle"));
47
+ palette.hint = t("settings.editHint");
48
+ palette.items = this.settingsItems();
49
+ palette.selected = 0;
50
+ this.state.palette = palette;
51
+ this.touch();
52
+ },
53
+
54
+ settingsItems() {
55
+ const server = this.prefs.url || this.settings.server || t("common.notSet");
56
+ return [
57
+ { name: `${t("settings.language")}: ${languageLabel(this.prefs.language)}`, value: "language" },
58
+ { name: `${t("settings.name")}: ${this.participant}`, value: "name" },
59
+ { name: `${t("settings.server")}: ${server}`, value: "server" },
60
+ { name: `${t("settings.theme")}: ${themeLabel(this.prefs.theme)}`, value: "theme" },
61
+ { name: t("settings.details"), value: "details" },
62
+ ];
63
+ },
64
+
65
+ editSetting(item) {
66
+ const palette = this.state.palette;
67
+ if (!palette || !item) return;
68
+ if (item.value === "details") {
69
+ palette.mode = "detail";
70
+ palette.previous = { mode: "info", hint: palette.hint };
71
+ palette.detail = { title: t("settings.title"), markdown: factsMarkdown(this), kind: "settings" };
72
+ palette.hint = t("palette.detailHint");
73
+ this.touch();
74
+ return;
75
+ }
76
+ const prompts = {
77
+ language: { label: t("settings.languagePrompt"), value: this.prefs.language, action: "settings-language" },
78
+ name: { label: t("settings.namePrompt"), value: this.participant, action: "settings-name" },
79
+ server: { label: t("settings.serverPrompt"), value: this.prefs.url || this.settings.server || "", action: "settings-server" },
80
+ theme: { label: t("settings.themePrompt"), value: this.prefs.theme, action: "settings-theme" },
81
+ };
82
+ const prompt = prompts[item.value];
83
+ if (!prompt) return;
84
+ palette.mode = "prompt";
85
+ palette.prompt = { ...prompt, data: {} };
86
+ palette.error = "";
87
+ palette.hint = t("palette.enterSaveHint");
88
+ this.touch();
89
+ },
90
+
91
+ /** Validate and persist one preference, then apply what can change live. */
92
+ async submitPreferencePrompt(prompt, value) {
93
+ const palette = this.state.palette;
94
+ if (!palette) return;
95
+ const raw = String(value ?? "").trim();
96
+ let patch;
97
+ let status = t("settings.saved");
98
+ if (prompt.action === "settings-language") {
99
+ if (!LANGUAGE_INPUTS.includes(raw.toLowerCase())) {
100
+ palette.error = t("settings.invalidLanguage");
101
+ this.touch();
102
+ return;
103
+ }
104
+ patch = { language: normalizeLanguage(raw) };
105
+ } else if (prompt.action === "settings-theme") {
106
+ const theme = raw.toLowerCase();
107
+ if (theme !== "dark" && theme !== "light") {
108
+ palette.error = t("settings.invalidTheme");
109
+ this.touch();
110
+ return;
111
+ }
112
+ patch = { theme };
113
+ } else if (prompt.action === "settings-name") {
114
+ if (!raw || Array.from(raw).length > 64) {
115
+ palette.error = t("settings.invalidName");
116
+ this.touch();
117
+ return;
118
+ }
119
+ patch = { participant: raw };
120
+ } else if (prompt.action === "settings-server") {
121
+ if (!/^https?:\/\/[^/]+/i.test(raw)) {
122
+ palette.error = t("settings.invalidServer");
123
+ this.touch();
124
+ return;
125
+ }
126
+ patch = { url: raw.replace(/\/+$/, "") };
127
+ status = t("settings.restartForServer");
128
+ } else {
129
+ return;
130
+ }
131
+ const next = { ...this.prefs, ...patch };
132
+ try {
133
+ const saved = this.savePrefs?.(next);
134
+ this.prefs = saved ?? next;
135
+ } catch (error) {
136
+ palette.error = t("settings.saveFailed", { error: errorText(error) });
137
+ this.touch();
138
+ return;
139
+ }
140
+ if (patch.language) {
141
+ this.state.language = patch.language;
142
+ setLanguage(patch.language);
143
+ }
144
+ if (patch.theme) this.state.theme = patch.theme;
145
+ if (patch.participant) {
146
+ this.participant = patch.participant;
147
+ this.state.participant = patch.participant;
148
+ }
149
+ this.setStatus(status, "success");
150
+ this.openSettingsEditor();
151
+ },
152
+ });
153
+ }
@@ -5,6 +5,7 @@ import { formatMessage, messageStamp, sanitizeText } from "./messages.mjs";
5
5
  import { addNotice, buildMessageBlock, hashText, markdownStyle } from "./message-view.mjs";
6
6
  import { syncMentionHighlights } from "./ui-mentions.mjs";
7
7
  import { connectionStyle } from "./ui-theme.mjs";
8
+ import { t } from "./i18n.mjs";
8
9
 
9
10
  const clear = (container) => {
10
11
  for (const child of container.getChildren()) {
@@ -13,14 +14,14 @@ const clear = (container) => {
13
14
  }
14
15
  };
15
16
 
16
- const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
17
-
18
17
  export function syncLayout(ui) {
19
18
  const { renderer, theme } = ui;
20
19
  const narrow = renderer.width < 70;
21
20
  const showRooms = !narrow;
21
+ const railWidth = renderer.width >= 120 ? 32 : renderer.width >= 100 ? 28 : 24;
22
22
  ui.roomsPane.visible = showRooms;
23
- ui.roomsPane.width = showRooms ? Math.min(30, Math.max(22, Math.floor(renderer.width * 0.3))) : 0;
23
+ ui.roomsPane.width = showRooms ? railWidth : 0;
24
+ ui.roomsFooter.visible = showRooms;
24
25
  ui.roomsPane.borderColor = theme.border;
25
26
  ui.headerBox.borderColor = theme.border;
26
27
  ui.headerBox.paddingX = narrow ? 1 : 2;
@@ -32,18 +33,24 @@ export function syncLayout(ui) {
32
33
  ui.textarea.height = ui.composer.height - 2;
33
34
  ui.prompt.height = ui.textarea.height;
34
35
  ui.statusHints.visible = !narrow;
35
- ui.paletteBox.left = narrow ? 0 : 1;
36
- ui.paletteBox.right = narrow ? 0 : 1;
37
- ui.paletteBox.bottom = narrow ? 0 : 1;
36
+ // Dialogs keep the OpenCode v2 habit: inset, readable measure and a top-third seat.
37
+ const paletteMargin = narrow ? 0 : Math.max(1, Math.floor((renderer.width - 76) / 2));
38
+ ui.paletteBox.left = paletteMargin;
39
+ ui.paletteBox.right = paletteMargin;
40
+ ui.paletteBox.bottom = narrow ? 1 : Math.max(1, Math.floor(renderer.height / 4));
38
41
  ui.paletteBox.height = Math.min(16, Math.max(9, Math.floor(renderer.height / 2) + 1));
39
42
  ui.helpBox.left = narrow ? 0 : 1;
40
43
  ui.helpBox.right = narrow ? 0 : 1;
41
44
  ui.helpBox.bottom = narrow ? 0 : 1;
42
- ui.helpBox.height = Math.min(13, Math.max(8, renderer.height - 4));
45
+ ui.helpBox.height = Math.min(16, Math.max(8, renderer.height - 4));
43
46
  ui.helpBody.gap = narrow ? 1 : 4;
44
47
  ui.helpBody.paddingX = narrow ? 1 : 2;
48
+ ui.helpBody.paddingY = renderer.height < 22 ? 0 : 1;
45
49
  ui.roomsTitle.fg = theme.muted;
50
+ ui.roomsTitle.content = t("rooms.title");
46
51
  ui.roomsCount.fg = theme.muted;
52
+ ui.roomsFooter.fg = theme.faint;
53
+ ui.roomsFooter.content = ` ${t("rooms.refreshHint")}`;
47
54
  ui.chatMeta.fg = theme.muted;
48
55
  }
49
56
 
@@ -53,7 +60,7 @@ export function syncHeader(ui, state) {
53
60
  const left = [bold(fg(theme.accent)("opencode-chat-room"))];
54
61
  if (!narrow) {
55
62
  left.push(fg(theme.muted)(" · "));
56
- left.push(fg(theme.muted)(sanitizeText(state.host || "server")));
63
+ left.push(fg(theme.muted)(sanitizeText(state.host || t("common.server"))));
57
64
  }
58
65
  ui.headerLeft.content = new StyledText(left);
59
66
 
@@ -94,7 +101,7 @@ export function updateRoomStyles(ui, state) {
94
101
 
95
102
  export function syncRooms(ui, state) {
96
103
  const pendingID = state.pending?.roomId;
97
- const signature = `${ui.theme.mode}|${pendingID ?? ""}|${state.rooms
104
+ const signature = `${ui.theme.mode}|${state.language}|${state.connection}|${pendingID ?? ""}|${state.rooms
98
105
  .map((room) => `${room.id}:${room.name}:${room.joined}:${room.participants.length}`)
99
106
  .join("|")}`;
100
107
  ui.roomsCount.content = state.rooms.length ? String(state.rooms.length) : "";
@@ -103,13 +110,18 @@ export function syncRooms(ui, state) {
103
110
  clear(ui.roomContent);
104
111
  ui.roomRows.clear();
105
112
  if (!state.rooms.length) {
113
+ const emptyLabel = state.connection === "connecting"
114
+ ? t("connection.connecting")
115
+ : state.connection === "offline"
116
+ ? t("connection.offline")
117
+ : t("rooms.empty");
106
118
  ui.roomContent.add(new TextRenderable(ui.renderer, {
107
119
  id: "room-empty",
108
120
  height: 1,
109
121
  wrapMode: "none",
110
122
  fg: ui.theme.muted,
111
123
  paddingX: 1,
112
- content: "No rooms yet",
124
+ content: emptyLabel,
113
125
  }));
114
126
  }
115
127
  for (const [index, room] of state.rooms.entries()) {
@@ -165,14 +177,15 @@ export function syncMessages(ui, state) {
165
177
  const messageKey = messages
166
178
  .map((message) => `${message.id}:${message.recalledAt ? 1 : 0}:${message.isQuestion ? 1 : 0}:${message.text?.length ?? 0}`)
167
179
  .join("|");
168
- const signature = `${ui.theme.mode}:${current?.id ?? ""}:${joined}:${pending?.roomId ?? ""}:${pending?.message ?? ""}:${highlight ?? ""}:${messageKey}`;
180
+ const signature = `${ui.theme.mode}:${state.language}:${current?.id ?? ""}:${joined}:${pending?.roomId ?? ""}:${pending?.message ?? ""}:${highlight ?? ""}:${messageKey}`;
169
181
 
170
182
  if (current) {
171
183
  ui.chatTitle.content = new StyledText([bold(fg(ui.theme.accent)(`# ${sanitizeText(current.name)}`))]);
172
- ui.chatMeta.content = plural(current.participants.length, "member");
184
+ const count = current.participants.length;
185
+ ui.chatMeta.content = t(count === 1 ? "common.member" : "common.members", { count });
173
186
  ui.chatMeta.fg = ui.theme.muted;
174
187
  } else {
175
- ui.chatTitle.content = new StyledText([fg(ui.theme.muted)("# no room selected")]);
188
+ ui.chatTitle.content = new StyledText([fg(ui.theme.muted)(t("chat.noRoom"))]);
176
189
  ui.chatMeta.content = "";
177
190
  }
178
191
 
@@ -188,19 +201,19 @@ export function syncMessages(ui, state) {
188
201
  clear(ui.messageContent);
189
202
  ui.messageBlocks = [];
190
203
  addNotice(ui, "pending", sanitizeText(pending.message), ui.theme.warning);
191
- addNotice(ui, "pending-wait", "Waiting for approval...", ui.theme.muted);
204
+ addNotice(ui, "pending-wait", t("chat.waitingApproval"), ui.theme.muted);
192
205
  } else if (!current) {
193
206
  clear(ui.messageContent);
194
207
  ui.messageBlocks = [];
195
- addNotice(ui, "empty", "Select a room and press Enter.", ui.theme.muted);
208
+ addNotice(ui, "empty", t("chat.selectRoom"), ui.theme.muted);
196
209
  } else if (!joined) {
197
210
  clear(ui.messageContent);
198
211
  ui.messageBlocks = [];
199
- addNotice(ui, "empty", "Not joined · press Enter to join again.", ui.theme.muted);
212
+ addNotice(ui, "empty", t("chat.notJoined"), ui.theme.muted);
200
213
  } else if (!messages.length) {
201
214
  clear(ui.messageContent);
202
215
  ui.messageBlocks = [];
203
- addNotice(ui, "empty", "No messages yet. Say hello.", ui.theme.muted);
216
+ addNotice(ui, "empty", t("chat.noMessages"), ui.theme.muted);
204
217
  } else {
205
218
  if (!ui.messageBlocks.length && ui.messageContent.getChildren().length) clear(ui.messageContent);
206
219
  const nextBlocks = [];
@@ -253,6 +266,7 @@ export function syncMessages(ui, state) {
253
266
 
254
267
  export function syncComposer(ui, state) {
255
268
  const draft = String(state.draft ?? "");
269
+ ui.textarea.placeholder = t("chat.composerPlaceholder");
256
270
  ui.textarea.placeholderColor = ui.theme.faint;
257
271
  ui.textarea.textColor = ui.theme.text;
258
272
  ui.textarea.focusedTextColor = ui.theme.text;
@@ -276,18 +290,20 @@ export function syncComposer(ui, state) {
276
290
 
277
291
  export function syncStatus(ui, state) {
278
292
  const { theme } = ui;
279
- const text = state.status || "Ready";
293
+ const connection = connectionStyle(theme, state.connection);
294
+ const text = state.status
295
+ || (state.connection === "online" ? t("status.ready") : `${connection.dot} ${connection.label}`);
280
296
  ui.statusLine.content = sanitizeText(text);
281
297
  ui.statusLine.fg = state.statusKind === "error"
282
298
  ? theme.error
283
299
  : state.statusKind === "success"
284
300
  ? theme.success
285
301
  : theme.muted;
286
- const status = connectionStyle(theme, state.connection);
287
- ui.statusHints.content = ui.renderer.width < 70
288
- ? "? help"
289
- : `${status.dot} ${status.label} · Tab focus · Alt+Space palette · ? help`;
290
- ui.statusHints.fg = theme.muted;
302
+ const hints = state.focus === "composer"
303
+ ? t("status.composerHints")
304
+ : t("status.roomHints");
305
+ ui.statusHints.content = ui.renderer.width < 70 ? t("status.hintsShort") : hints;
306
+ ui.statusHints.fg = theme.faint;
291
307
  }
292
308
 
293
309
  export function syncFocus(ui, state) {
@@ -343,20 +359,20 @@ export function syncPalette(ui, state) {
343
359
  ui.paletteList.selectedBackgroundColor = theme.selectedBg;
344
360
  ui.paletteList.selectedTextColor = theme.selectedFg;
345
361
 
346
- const scope = palette.scope === "all" ? "all joined rooms" : "this room";
362
+ const scope = palette.scope === "all" ? t("palette.scopeAll") : t("palette.scopeRoom");
347
363
  const defaultTitle = mode === "prompt"
348
- ? "New room"
364
+ ? t("palette.newRoom")
349
365
  : mode === "search"
350
- ? "Search messages"
351
- : "Palette";
352
- ui.paletteTitle.content = palette.title || defaultTitle;
366
+ ? t("palette.searchMessages")
367
+ : t("palette.title");
368
+ ui.paletteTitle.content = new StyledText([bold(fg(theme.text)(palette.title || defaultTitle))]);
353
369
  ui.paletteScope.content = palette.subtitle
354
- || (mode === "prompt" ? "create" : mode === "search" ? scope : "commands");
370
+ || (mode === "prompt" ? t("palette.create") : mode === "search" ? scope : t("palette.commands"));
355
371
  ui.paletteInput.placeholder = mode === "prompt"
356
- ? palette.prompt?.label || "Enter a value"
372
+ ? palette.prompt?.label || t("palette.valuePlaceholder")
357
373
  : mode === "search"
358
- ? "Type to search messages"
359
- : "Type to search or run a command";
374
+ ? t("palette.searchPlaceholder")
375
+ : t("palette.commandPlaceholder");
360
376
 
361
377
  const value = mode === "prompt" ? palette.prompt?.value ?? "" : palette.query ?? "";
362
378
  if (ui.paletteInput.value !== value) {
@@ -373,9 +389,9 @@ export function syncPalette(ui, state) {
373
389
  options = ui.app.paletteCommands().map((command) => ({ name: command.label, description: "", value: command.id }));
374
390
  } else if (mode === "search") {
375
391
  options = !String(palette.query ?? "").trim()
376
- ? [{ name: "Type to search messages", description: "", value: "" }]
392
+ ? [{ name: t("palette.searchPlaceholder"), description: "", value: "" }]
377
393
  : !palette.results.length
378
- ? [{ name: palette.searching ? "Searching..." : "No matches", description: "", value: "" }]
394
+ ? [{ name: palette.searching ? t("palette.searching") : t("palette.noMatches"), description: "", value: "" }]
379
395
  : palette.results.map((result) => {
380
396
  const info = formatMessage(result.message, null);
381
397
  return {
@@ -386,17 +402,17 @@ export function syncPalette(ui, state) {
386
402
  });
387
403
  } else if (mode === "info") {
388
404
  options = palette.loading
389
- ? [{ name: "Loading...", description: "", value: "" }]
405
+ ? [{ name: t("common.loading"), description: "", value: "" }]
390
406
  : palette.items.length
391
407
  ? palette.items.map((item) => ({ name: item.name, description: "", value: item.value }))
392
- : [{ name: palette.error ? "Unavailable" : "Nothing here", description: "", value: "" }];
408
+ : [{ name: palette.error ? t("palette.unavailable") : t("palette.nothing"), description: "", value: "" }];
393
409
  }
394
410
  ui.paletteList.options = options;
395
411
  if (isList) ui.paletteList.setSelectedIndex(Math.min(palette.selected ?? 0, Math.max(0, options.length - 1)));
396
412
 
397
413
  let desiredHeight;
398
414
  if (mode === "commands" || mode === "info") {
399
- desiredHeight = Math.min(ui.renderer.height - 2, Math.max(9, options.length + 5));
415
+ desiredHeight = Math.min(16, ui.renderer.height - 2, Math.max(9, options.length + 4));
400
416
  } else if (isDetail) {
401
417
  desiredHeight = Math.min(ui.renderer.height - 2, Math.max(12, Math.floor(ui.renderer.height * 0.8)));
402
418
  } else if (isConfirm) {
@@ -404,12 +420,14 @@ export function syncPalette(ui, state) {
404
420
  } else {
405
421
  desiredHeight = Math.min(16, Math.max(9, Math.floor(ui.renderer.height / 2) + 1));
406
422
  }
423
+ desiredHeight = Math.max(4, Math.min(desiredHeight, ui.renderer.height - Math.max(1, Math.floor(ui.renderer.height / 4)) - 1));
424
+ paletteBox.bottom = Math.max(1, ui.renderer.height - Math.max(1, Math.floor(ui.renderer.height / 4)) - desiredHeight);
407
425
  if (paletteBox.height !== desiredHeight) paletteBox.height = desiredHeight;
408
426
 
409
427
  ui.paletteDetailMarkdown.syntaxStyle = markdownStyle(ui);
410
428
  ui.paletteDetailMarkdown.fg = theme.text;
411
429
  if (isDetail) {
412
- const signature = `${theme.mode}:${palette.detail?.title}:${palette.detail?.markdown}`;
430
+ const signature = `${theme.mode}:${state.language}:${palette.detail?.title}:${palette.detail?.markdown}`;
413
431
  if (signature !== ui.detailSignature) {
414
432
  ui.detailSignature = signature;
415
433
  ui.paletteDetailMarkdown.content = palette.detail?.markdown ?? "";
@@ -423,56 +441,17 @@ export function syncPalette(ui, state) {
423
441
 
424
442
  const footer = palette.error
425
443
  || (mode === "prompt"
426
- ? palette.hint || "Enter confirm · Esc cancel"
444
+ ? palette.hint || t("palette.promptHint")
427
445
  : mode === "search"
428
- ? `↑↓ select · Enter open · Tab: ${palette.scope === "all" ? "this room" : "all rooms"} · Esc close${palette.searching ? " · searching..." : ""}`
446
+ ? t("palette.searchHint", {
447
+ scope: palette.scope === "all" ? t("palette.scopeRoom") : t("palette.scopeAll"),
448
+ searching: palette.searching ? t("palette.searchingSuffix") : "",
449
+ })
429
450
  : mode === "detail"
430
- ? palette.hint || "↑↓ scroll · Esc back"
451
+ ? palette.hint || t("palette.detailHint")
431
452
  : mode === "confirm"
432
- ? palette.hint || "Enter or y confirms · n or Esc cancels"
433
- : palette.hint || (mode === "info" ? "↑↓ select · Enter open · Esc close" : "↑↓ select · Enter run · Esc close"));
434
- ui.paletteHint.content = ` ${sanitizeText(footer)}${palette.searching && mode !== "search" ? " · working..." : ""}`;
453
+ ? palette.hint || t("palette.confirmHint")
454
+ : palette.hint || (mode === "info" ? t("palette.listHint") : t("palette.runHint")));
455
+ ui.paletteHint.content = ` ${sanitizeText(footer)}${palette.searching && mode !== "search" ? ` · ${t("palette.working")}` : ""}`;
435
456
  ui.paletteHint.fg = palette.error ? theme.error : theme.muted;
436
457
  }
437
-
438
- function shortcutChunks(title, rows, theme) {
439
- const chunks = [bold(fg(theme.accent)(`${title}\n`))];
440
- for (const [key, label] of rows) {
441
- chunks.push(fg(theme.accent)(key.padEnd(12)));
442
- chunks.push(fg(theme.text)(`${label}\n`));
443
- }
444
- return chunks;
445
- }
446
-
447
- export function syncHelp(ui, state) {
448
- const show = Boolean(state.help) && !state.palette;
449
- ui.helpBox.visible = show;
450
- if (!show) return;
451
- ui.helpBox.borderColor = ui.theme.border;
452
- ui.helpBox.backgroundColor = ui.theme.surface;
453
- ui.helpBar.backgroundColor = ui.theme.raised;
454
- ui.helpTitle.fg = ui.theme.text;
455
- ui.helpClose.fg = ui.theme.muted;
456
- ui.helpFooter.fg = ui.theme.muted;
457
- const signature = ui.theme.mode;
458
- if (signature === ui.helpSignature) return;
459
- ui.helpSignature = signature;
460
- ui.helpLeft.content = new StyledText(shortcutChunks("Navigation", [
461
- ["↑ / ↓", "select room"],
462
- ["Enter", "open / join"],
463
- ["Tab", "focus composer"],
464
- ["PgUp / PgDn", "scroll messages"],
465
- ["Alt+Home", "first message"],
466
- ["Alt+End", "last message"],
467
- ], ui.theme));
468
- ui.helpRight.content = new StyledText(shortcutChunks("Composer", [
469
- ["Enter", "send message"],
470
- ["Ctrl+J", "insert newline"],
471
- ["Esc", "clear / blur"],
472
- ["/", "inline commands"],
473
- ["@", "mention members"],
474
- ["Alt+Space", "palette / search"],
475
- ["Ctrl+R", "refresh rooms"],
476
- ["Ctrl+C", "quit"],
477
- ], ui.theme));
478
- }