ai_co_discuss 0.4.55 → 0.4.56

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.
package/docs/runner.md CHANGED
@@ -57,7 +57,7 @@ Windows 上在终端运行 `codiscuss setup` 时,“安装配置”一步有
57
57
 
58
58
  房间设置了项目目录后,左栏“房间”下方的“文件”页可浏览电脑上的文件夹与文件,查看大小和修改时间。点击文件打开悬浮预览,支持文本、Markdown 渲染与 HTML 静态渲染,并可切换源码。图片可缩放、旋转(聊天里点开图片附件也一样);视频和音频用带倍速、全屏的播放器直接播放(聊天里的音视频附件同样)(浏览器解不了的格式如 AVI、WMV 请下载后用本机软件打开);CSV 显示为表格,字幕(SRT、VTT、ASS、LRC)显示为时间轴;Word、Excel、PowerPoint 与 PDF 文档只读预览(Word 和 PDF 按窗口宽度显示整页)(Excel 只显示数值,不含样式与图表;PowerPoint 的还原度因文件而异);Premiere 工程解压后显示其 XML,fcpxml 等文本格式的剪辑工程按文本显示。在其他设备上经电脑查看时,图片、音视频和文档整份传过去再显示,单个文件最多 64 MB。Markdown 里用相对路径引用的项目图片(PNG、JPEG、GIF 动图、WebP、SVG 等)会直接显示,其他设备经电脑查看时同样能看到;找不到或在项目目录外的图片在预览顶部列出。可同时打开多个文件,以标签切换;标题栏的“收起”(手机上也可按住标签栏下拉,或正文在顶部时下拉)把预览缩成内容区左上角的悬浮按钮,悬浮按钮可拖到左侧或右侧;切到其他频道或其他房间后点它回到原处(打开的文件、模式和滚动位置都保留),关闭才清空。未设置项目目录时入口灰显。
59
59
 
60
- 在 Markdown 预览或成员回答正文中选中文字后点“添加到对话”,选中处上方出现批注框(可留空),回车后这段文字成为一条摘录,原文末尾标上编号;文件摘录随即收起预览、回到“消息”页。输入框上方显示“N 条摘录”,点开可逐条查看、修改批注或删除,悬停时的 × 一次移除全部;点原文上的编号也能重新编辑批注或删除该条。发送时每段摘录以“文件路径 + 行号”或“成员名 + 消息编号”加引用原文与批注附在正文之后,引用中的 @ 不会唤醒成员。
60
+ 在 Markdown 预览或成员回答正文中选中文字后点“添加到对话”,选中处上方出现批注框(可留空),回车后这段文字成为一条注释,原文末尾标上编号;文件注释随即收起预览、回到“消息”页。输入框上方显示“N 条注释”,点开可逐条查看、修改批注或删除,悬停时的 × 一次移除全部;点原文上的编号也能重新编辑批注或删除该条。发送时每段注释以“文件路径 + 行号”或“成员名 + 消息编号”加引用原文与批注附在正文之后,引用中的 @ 不会唤醒成员。
61
61
 
62
62
  其他设备通过已配对电脑的加密连接读取同一目录。文件内容最多预览前 128 KB,支持 UTF-8 和带 BOM 的 UTF-16;HTML 展示内联样式与内嵌图片。文件访问限于房间项目目录,目录外的链接灰显。
63
63
 
@@ -102,11 +102,11 @@
102
102
  "发言快速导航": "Quick message navigation",
103
103
  "· 主持人": "· Host",
104
104
  "· 运行回执": "· Run receipt",
105
- "把选中的文字作为摘录添加到对话": "Add selected text to the conversation as an excerpt",
105
+ "把选中的文字作为注释添加到对话": "Add selected text to the conversation as a note",
106
106
  "添加到对话": "Add to conversation",
107
107
  "从选中处开始朗读": "Read from selection",
108
108
  "添加批注(可选)": "Add a comment (optional)",
109
- "摘录的批注(可选)": "Excerpt annotation (optional)",
109
+ "注释的批注(可选)": "Note annotation (optional)",
110
110
  "取消添加": "Cancel adding",
111
111
  "取消": "Cancel",
112
112
  "添加到对话(Enter)": "Add to conversation (Enter)",
@@ -182,8 +182,8 @@
182
182
  "编辑后的消息": "Edited message",
183
183
  "正在读取回退范围…": "Reading rollback scope…",
184
184
  "回退并发送": "Roll back and send",
185
- "摘录 {value1}:点击修改批注": "Excerpt {value1}: click to edit annotation",
186
- "修改摘录 {value1} 的批注": "Edit annotation for excerpt {value1}",
185
+ "注释 {value1}:点击修改批注": "Note {value1}: click to edit annotation",
186
+ "修改注释 {value1} 的批注": "Edit annotation for note {value1}",
187
187
  "展开全文": "Show full text",
188
188
  "收起回答": "Collapse reply",
189
189
  "展开完整回答": "Expand full reply",
@@ -250,15 +250,15 @@
250
250
  "没有匹配的成员": "No matching members",
251
251
  "发消息到 # {value1}": "Message # {value1}",
252
252
  "留言正文": "Message text",
253
- "查看摘录、修改批注": "View excerpts and edit annotations",
254
- "{value1} 条摘录": "{value1} excerpts",
255
- "移除全部摘录": "Remove all excerpts",
256
- "摘录": "Excerpts",
253
+ "查看注释、修改批注": "View notes and edit annotations",
254
+ "{value1} 条注释": "{value1} notes",
255
+ "移除全部注释": "Remove all notes",
256
+ "注释": "Notes",
257
257
  "选中文字 · {value1}": "Selected text · {value1}",
258
258
  "批注": "Annotation",
259
- "摘录的批注": "Excerpt comment",
259
+ "注释的批注": "Note comment",
260
260
  "修改批注": "Edit annotation",
261
- "移除摘录 {value1}": "Remove excerpt {value1}",
261
+ "移除注释 {value1}": "Remove note {value1}",
262
262
  "移除": "Remove",
263
263
  "项目文件夹": "Project folder",
264
264
  "移除 {value1}": "Remove {value1}",
@@ -33,9 +33,9 @@
33
33
  "允许并重发": "Allow and resend",
34
34
  "把这些操作加入该成员的放行规则(下次执行起生效),并把原消息填回输入框": "Allow these operations for this member starting with the next run, and restore the original message in the composer",
35
35
  "添加批注(可选)": "Add a comment (optional)",
36
- "摘录的批注": "Excerpt comment",
37
- "移除这条摘录": "Remove this excerpt",
38
- "移除摘录": "Remove excerpt",
36
+ "注释的批注": "Note comment",
37
+ "移除这条注释": "Remove this note",
38
+ "移除注释": "Remove note",
39
39
  "沿用这个目标重新开启 Goal,需本机接入程序在运行": "Restart Goal with this objective; the local runner must be running",
40
40
  "过程说明": "Progress notes",
41
41
  "正在读取过程说明": "Loading progress notes",
@@ -407,13 +407,13 @@
407
407
  "内容": "Contents",
408
408
  "正在载入页面引用的文件…": "Loading files referenced by the page…",
409
409
  "HTML 文件预览": "HTML file preview",
410
- "摘录 {value1}:点击修改批注": "Excerpt {value1}: click to edit annotation",
411
- "修改摘录 {value1} 的批注": "Edit annotation for excerpt {value1}",
412
- "把选中的文字作为摘录添加到对话": "Add selected text to the conversation as an excerpt",
410
+ "注释 {value1}:点击修改批注": "Note {value1}: click to edit annotation",
411
+ "修改注释 {value1} 的批注": "Edit annotation for note {value1}",
412
+ "把选中的文字作为注释添加到对话": "Add selected text to the conversation as a note",
413
413
  "添加到对话": "Add to conversation",
414
414
  "从选中处开始朗读": "Read from selection",
415
415
  "添加批注(可选)": "Add a comment (optional)",
416
- "摘录的批注(可选)": "Excerpt annotation (optional)",
416
+ "注释的批注(可选)": "Note annotation (optional)",
417
417
  "取消添加": "Cancel adding",
418
418
  "添加到对话(Enter)": "Add to conversation (Enter)",
419
419
  "手动滚动即取消跟随": "Scroll manually to stop following",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai_co_discuss",
3
- "version": "0.4.55",
3
+ "version": "0.4.56",
4
4
  "bin": {
5
5
  "codiscuss": "runner/codiscuss.mjs"
6
6
  },
package/web/app.js CHANGED
@@ -15,6 +15,10 @@ const SAFETY_REFRESH_MS = 5 * 60 * 1000;
15
15
  const WORKING_STATUSES = ["dispatched", "started"];
16
16
  const UPDATE_BATCH_MS = 100;
17
17
  const UPDATE_DRAG_RETRY_MS = 500;
18
+ // A page back from the background after this long shows the opening load until its first full read, instead of old
19
+ // cards that then change all at once; the cap keeps the cards from staying hidden behind a read that never ends.
20
+ const RESUME_LOADING_AFTER_MS = 10000;
21
+ const RESUME_LOADING_MAX_MS = 15000;
18
22
  const TOAST_DURATION_MS = 3500;
19
23
  // How long an archived room can be taken back before the archive is saved.
20
24
  const ARCHIVE_UNDO_MS = 4000;
@@ -110,7 +114,9 @@ const state = { rooms: [], folders: [], room: null, page: 1, pages: 1, query: ""
110
114
  reply_to: null, tab: "discussion", refresh_version: 0, context_dirty: false, topic_dirty: false,
111
115
  snapshot_id: 0, pending_submission: null, pending_room: null, toast_timer: null, queued_taken: 0,
112
116
  // When live room data stopped (page hidden, connection lost); null while it is current. Silence is judged only up to here.
113
- observed_until: null };
117
+ observed_until: null,
118
+ // Back from the background: the transcript shows the opening load until the next full read finishes.
119
+ resuming: false };
114
120
  const live_updates = { source: null, connected: false, enabled: false, timer: null, poll_timer: null,
115
121
  running: false, dirty: false, full: false, revisions: "", refreshed_at: 0 };
116
122
  state.messages = [];
@@ -2014,7 +2020,8 @@ function attachment_file_icon(file_name) {
2014
2020
 
2015
2021
  /**
2016
2022
  * Keep original files in memory until sending; reject an invalid selection as a whole. Each file also puts its
2017
- * placeholder (`[图片 #n]` / `[文件 #n]`, n its position) into the text where it was pasted or dropped, else at the end,
2023
+ * placeholder (`[图片 #n]` / `[文件 #n]`, n its position) into the text where it was pasted or dropped, or at the caret the
2024
+ * file picker was opened from, else at the end,
2018
2025
  * as Claude Code does with a pasted screenshot: the text says where each file belongs, and members read it the same way.
2019
2026
  */
2020
2027
  function add_attachments(files, target = null) {
@@ -2034,6 +2041,15 @@ function add_attachments(files, target = null) {
2034
2041
  publish_view();
2035
2042
  }
2036
2043
 
2044
+ // The composer's textarea the file picker was opened from: its files' placeholders go where its caret was.
2045
+ let attachment_target = null;
2046
+
2047
+ /** Open the file picker; `target` is the textarea whose caret takes the chosen files' placeholders. */
2048
+ function choose_attachments(target = null) {
2049
+ attachment_target = target;
2050
+ element("attachment-input").click();
2051
+ }
2052
+
2037
2053
  /** `[图片 #n]` for an image the page previews, `[文件 #n]` for any other file. */
2038
2054
  function draft_placeholder(item, number) {
2039
2055
  return `[${item.preview_url ? "图片" : "文件"} #${number}]`;
@@ -2051,7 +2067,10 @@ function insert_placeholders(text, target) {
2051
2067
  if (editor !== element("message-input")) return;
2052
2068
  }
2053
2069
  const input = element("message-input");
2054
- if (!editor) input.value = input.value ? `${input.value.replace(/\s*$/, "")} ${text} ` : `${text} `;
2070
+ if (editor) return;
2071
+ // Trailing spaces give way to the separating space; a trailing line break is the user's own and stays.
2072
+ const base = input.value.replace(/[ \t]+$/, "");
2073
+ input.value = `${base}${base && !base.endsWith("\n") ? " " : ""}${text} `;
2055
2074
  }
2056
2075
 
2057
2076
  /** Deleting a file's placeholder while typing removes that file, as in Claude Code's own prompt; true when one went. */
@@ -2323,7 +2342,7 @@ async function render_attachment_pdf() {
2323
2342
  /** Bind the shared picker, paste/drop handlers, and accessible preview dialog once. */
2324
2343
  function bind_attachment_controls() {
2325
2344
  element("choose-attachments").addEventListener("click", () => element("attachment-input").click());
2326
- element("attachment-input").addEventListener("change", event => { add_attachments(event.target.files); event.target.value = ""; });
2345
+ element("attachment-input").addEventListener("change", event => { add_attachments(event.target.files, attachment_target); attachment_target = null; event.target.value = ""; });
2327
2346
  for (const event of ["dragover", "drop"]) element("message-form").addEventListener(event, drop_attachments);
2328
2347
  element("message-input").addEventListener("paste", paste_attachments);
2329
2348
  document.addEventListener("click", event => {
@@ -3057,12 +3076,26 @@ async function relay_room_request_once(path, payload, etag) {
3057
3076
  return answer;
3058
3077
  }
3059
3078
 
3079
+ /**
3080
+ * Read one part of a room file through the relay, asked again after a dropped or timed-out exchange as other reads
3081
+ * are: a large image takes several parts, and one lost frame would otherwise leave it failed until the page reloads.
3082
+ */
3083
+ async function relay_file_part(path, offset) {
3084
+ for (let attempt = 0; ; attempt += 1) {
3085
+ try { return await relay_exchange("room-api", { method: "GET", path, offset }); }
3086
+ catch (error) {
3087
+ if (attempt >= RELAY_READ_RETRY_MS.length) throw error;
3088
+ await new Promise((resolve) => setTimeout(resolve, RELAY_READ_RETRY_MS[attempt]));
3089
+ }
3090
+ }
3091
+ }
3092
+
3060
3093
  /** Read a whole file of the computer's rooms through the relay; larger files come in several parts. */
3061
3094
  async function relay_room_bytes(path) {
3062
3095
  const parts = [];
3063
3096
  let offset = 0, total = 0, type = "";
3064
3097
  do {
3065
- const answer = await relay_exchange("room-api", { method: "GET", path, offset });
3098
+ const answer = await relay_file_part(path, offset);
3066
3099
  if (answer.status >= 400) throw Object.assign(new Error(server_text(answer.body?.error_text, answer.body?.error) || t('文件读取失败')), { status: answer.status });
3067
3100
  if (typeof answer.body_base64 !== "string") throw new Error(t('文件读取失败'));
3068
3101
  const bytes = base64_to_bytes(answer.body_base64);
@@ -5154,7 +5187,9 @@ async function flush_live_refresh() {
5154
5187
  while (state.opening) await state.opening.catch(() => {});
5155
5188
  await refresh_room({ room: full });
5156
5189
  if (full && state.observed_until !== null) { state.observed_until = null; publish_view(); }
5190
+ if (full) end_resuming();
5157
5191
  } catch (error) {
5192
+ end_resuming();
5158
5193
  console.warn("refresh failed", error);
5159
5194
  if (state.reconnecting) show_toast(t('仍未连接:{value1}', { value1: error.message }), true);
5160
5195
  set_connection(false);
@@ -5278,6 +5313,24 @@ function stop_live_updates() {
5278
5313
  live_updates.poll_timer = null;
5279
5314
  }
5280
5315
 
5316
+ let resuming_timer = null;
5317
+ /** After a long stay in the background, show the opening load instead of old cards until the room is read again. */
5318
+ function begin_resuming() {
5319
+ if (!state.room || state.observed_until === null || Date.now() - state.observed_until < RESUME_LOADING_AFTER_MS) return;
5320
+ state.resuming = true;
5321
+ clearTimeout(resuming_timer);
5322
+ resuming_timer = setTimeout(end_resuming, RESUME_LOADING_MAX_MS);
5323
+ publish_view();
5324
+ }
5325
+
5326
+ /** Show the cards again: the room has been read, the read failed, or it took too long. */
5327
+ function end_resuming() {
5328
+ clearTimeout(resuming_timer);
5329
+ if (!state.resuming) return;
5330
+ state.resuming = false;
5331
+ publish_view();
5332
+ }
5333
+
5281
5334
  /** Initialize forms and the shared discussion controller. */
5282
5335
  async function initialize() {
5283
5336
  render_identities();
@@ -5339,7 +5392,7 @@ async function initialize() {
5339
5392
  start_live_updates();
5340
5393
  document.addEventListener("visibilitychange", () => {
5341
5394
  if (document.hidden) stop_live_updates();
5342
- else { start_live_updates(); load_admin_state(); }
5395
+ else { begin_resuming(); start_live_updates(); load_admin_state(); }
5343
5396
  });
5344
5397
  window.addEventListener("pagehide", stop_live_updates);
5345
5398
  // The network coming back (a phone leaving a lift, a laptop waking) reconnects at once.
@@ -5364,7 +5417,7 @@ function view_snapshot() {
5364
5417
  room_site: room_site(), rooms: ordered_rooms(), folders: state.folders, folder_groups: ordered_folders(), room: state.room, archive_view: state.archive_view, directory_sort: state.directory_sort, messages: state.messages, history_cards: state.history_cards, total: state.message_total,
5365
5418
  archive_pending: [...state.archive_changes.keys()], import_progress: structuredClone(state.import_progress),
5366
5419
  directory_pending: [...state.directory_pending.keys()], folder_pending: [...state.folder_moves.keys()], creating_room: state.creating_room,
5367
- connected: state.connected, reconnecting: state.reconnecting, rooms_loading: state.rooms_loading, observed_until: state.observed_until, backup_pending: Boolean(state.backup_pending), page: state.page, pages: state.pages, query: state.query,
5420
+ connected: state.connected, reconnecting: state.reconnecting, rooms_loading: state.rooms_loading, observed_until: state.observed_until, resuming: state.resuming, backup_pending: Boolean(state.backup_pending), page: state.page, pages: state.pages, query: state.query,
5368
5421
  attachment_drafts: state.attachment_drafts.map(item => ({ id: item.id, file_name: item.file.name, size: item.file.size, preview_url: item.preview_url, placeholder: item.placeholder || "" })),
5369
5422
  upload_status: state.upload_status, sending_message: state.sending_message, sending_preview: state.sending_preview, queueing_preview: state.queueing_preview,
5370
5423
  failed_sends: state.failed_sends.map((failed) => ({ id: failed.id, ...failed.preview })),
@@ -5604,7 +5657,7 @@ async function execute_view_action(name, value) {
5604
5657
  const event = { preventDefault() {} };
5605
5658
  const actions = { refresh: refresh_room, room: select_room, tab: select_tab,
5606
5659
  archives: toggle_archives, backup: backup_room, backup_rooms, import_rooms, manage_channel, move_channel, create_folder, move_folder, rename_folder, delete_folder, sort_directory,
5607
- send: () => send_from_composer(event), discard_sending, retry_sending, choose_attachments: () => element("attachment-input").click(), remove_attachment, preview_attachment,
5660
+ send: () => send_from_composer(event), discard_sending, retry_sending, choose_attachments, remove_attachment, preview_attachment,
5608
5661
  create: (folder_id) => submit_room(event, folder_id), quick_create: quick_create_room, welcome: open_welcome,
5609
5662
  save_context: () => save_context(event), save_topic: () => save_topic(event),
5610
5663
  filter: filter_view, reply: set_view_reply, cancel_reply, skip_turn,