@songsid/agend 2.4.0-beta.20 → 2.4.0-beta.21

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 (176) hide show
  1. package/dist/agent-cli-instructions.md +1 -1
  2. package/dist/backend/claude-carry.d.ts +11 -0
  3. package/dist/backend/claude-carry.js +88 -6
  4. package/dist/backend/claude-carry.js.map +1 -1
  5. package/dist/build-provenance.json +1 -1
  6. package/dist/channel/mcp-tools.js +6 -4
  7. package/dist/channel/mcp-tools.js.map +1 -1
  8. package/dist/contact-change-proposals.d.ts +47 -0
  9. package/dist/contact-change-proposals.js +131 -0
  10. package/dist/contact-change-proposals.js.map +1 -0
  11. package/dist/fleet-manager.d.ts +25 -1
  12. package/dist/fleet-manager.js +166 -3
  13. package/dist/fleet-manager.js.map +1 -1
  14. package/dist/general-knowledge/skills/concepts/SKILL.md +2 -1
  15. package/dist/general-knowledge/skills/hub/SKILL.md +39 -2
  16. package/dist/general-knowledge/skills/task-board/SKILL.md +4 -0
  17. package/dist/general-knowledge/skills/web-appearance/SKILL.md +1 -1
  18. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +16 -6
  19. package/dist/hub/agent-pictures-model.d.ts +147 -0
  20. package/dist/hub/agent-pictures-model.js +64 -0
  21. package/dist/hub/agent-pictures-model.js.map +1 -0
  22. package/dist/hub/agent-pictures.d.ts +52 -0
  23. package/dist/hub/agent-pictures.js +202 -0
  24. package/dist/hub/agent-pictures.js.map +1 -0
  25. package/dist/hub/client.d.ts +2 -0
  26. package/dist/hub/client.js +16 -2
  27. package/dist/hub/client.js.map +1 -1
  28. package/dist/hub/compose/member.d.ts +10 -2
  29. package/dist/hub/compose/member.js +32 -8
  30. package/dist/hub/compose/member.js.map +1 -1
  31. package/dist/hub/compose/server.d.ts +1 -0
  32. package/dist/hub/compose/server.js +4 -2
  33. package/dist/hub/compose/server.js.map +1 -1
  34. package/dist/hub/direct-posts-model.d.ts +1 -0
  35. package/dist/hub/direct-posts-model.js +2 -0
  36. package/dist/hub/direct-posts-model.js.map +1 -0
  37. package/dist/hub/direct-posts.d.ts +36 -0
  38. package/dist/hub/direct-posts.js +145 -0
  39. package/dist/hub/direct-posts.js.map +1 -0
  40. package/dist/hub/http/compose.d.ts +2 -0
  41. package/dist/hub/http/compose.js +155 -19
  42. package/dist/hub/http/compose.js.map +1 -1
  43. package/dist/hub/http/core.d.ts +9 -1
  44. package/dist/hub/http/core.js +21 -1
  45. package/dist/hub/http/core.js.map +1 -1
  46. package/dist/hub/http/schema.js +6 -0
  47. package/dist/hub/http/schema.js.map +1 -1
  48. package/dist/hub/join/service.d.ts +2 -0
  49. package/dist/hub/join/service.js +7 -3
  50. package/dist/hub/join/service.js.map +1 -1
  51. package/dist/hub/mcp/policy.d.ts +1 -1
  52. package/dist/hub/member/agent-pictures.d.ts +43 -0
  53. package/dist/hub/member/agent-pictures.js +125 -0
  54. package/dist/hub/member/agent-pictures.js.map +1 -0
  55. package/dist/hub/member/direct-rooms.d.ts +9 -0
  56. package/dist/hub/member/direct-rooms.js +14 -0
  57. package/dist/hub/member/direct-rooms.js.map +1 -0
  58. package/dist/hub/member/room-post.d.ts +11 -10
  59. package/dist/hub/member/room-post.js +51 -7
  60. package/dist/hub/member/room-post.js.map +1 -1
  61. package/dist/hub/policy.d.ts +11 -2
  62. package/dist/hub/policy.js +60 -7
  63. package/dist/hub/policy.js.map +1 -1
  64. package/dist/hub/protocol.d.ts +123 -1
  65. package/dist/hub/protocol.js +17 -7
  66. package/dist/hub/protocol.js.map +1 -1
  67. package/dist/hub/representative.d.ts +28 -0
  68. package/dist/hub/representative.js +127 -12
  69. package/dist/hub/representative.js.map +1 -1
  70. package/dist/hub/rooms/agents.d.ts +2 -0
  71. package/dist/hub/rooms/agents.js +14 -3
  72. package/dist/hub/rooms/agents.js.map +1 -1
  73. package/dist/hub/rooms/direct-view.d.ts +3 -2
  74. package/dist/hub/rooms/direct-view.js +23 -8
  75. package/dist/hub/rooms/direct-view.js.map +1 -1
  76. package/dist/hub/rooms/office.d.ts +9 -0
  77. package/dist/hub/rooms/office.js +10 -2
  78. package/dist/hub/rooms/office.js.map +1 -1
  79. package/dist/hub/rooms/service.d.ts +32 -1
  80. package/dist/hub/rooms/service.js +37 -3
  81. package/dist/hub/rooms/service.js.map +1 -1
  82. package/dist/hub/rooms/types.d.ts +5 -2
  83. package/dist/hub/rooms.d.ts +9 -0
  84. package/dist/hub/rooms.js +97 -26
  85. package/dist/hub/rooms.js.map +1 -1
  86. package/dist/hub/runtime.d.ts +1 -1
  87. package/dist/hub/server.js +19 -2
  88. package/dist/hub/server.js.map +1 -1
  89. package/dist/hub/session-directory-transition.d.ts +1 -0
  90. package/dist/hub/session-directory-transition.js +15 -9
  91. package/dist/hub/session-directory-transition.js.map +1 -1
  92. package/dist/hub/session-limits.d.ts +58 -0
  93. package/dist/hub/session-limits.js +121 -0
  94. package/dist/hub/session-limits.js.map +1 -0
  95. package/dist/hub/sessions.d.ts +1 -1
  96. package/dist/hub/sessions.js +13 -7
  97. package/dist/hub/sessions.js.map +1 -1
  98. package/dist/hub/settings-directory-decision.js +1 -1
  99. package/dist/hub/settings-directory-decision.js.map +1 -1
  100. package/dist/hub/types.d.ts +8 -2
  101. package/dist/hub-picture-reduce.d.ts +14 -0
  102. package/dist/hub-picture-reduce.js +49 -0
  103. package/dist/hub-picture-reduce.js.map +1 -0
  104. package/dist/hub-picture-worker.d.ts +1 -0
  105. package/dist/hub-picture-worker.js +11 -0
  106. package/dist/hub-picture-worker.js.map +1 -0
  107. package/dist/hub-report-target.d.ts +6 -0
  108. package/dist/hub-report-target.js +6 -0
  109. package/dist/hub-report-target.js.map +1 -1
  110. package/dist/locale.js +90 -2
  111. package/dist/locale.js.map +1 -1
  112. package/dist/needs-you.d.ts +4 -0
  113. package/dist/needs-you.js +2 -0
  114. package/dist/needs-you.js.map +1 -1
  115. package/dist/outbound-handlers.d.ts +4 -0
  116. package/dist/outbound-handlers.js +37 -4
  117. package/dist/outbound-handlers.js.map +1 -1
  118. package/dist/outbound-schemas.d.ts +2 -0
  119. package/dist/outbound-schemas.js +6 -4
  120. package/dist/outbound-schemas.js.map +1 -1
  121. package/dist/task-board-tool.d.ts +17 -0
  122. package/dist/task-board-tool.js +58 -6
  123. package/dist/task-board-tool.js.map +1 -1
  124. package/dist/tool-permissions.js +2 -2
  125. package/dist/tool-permissions.js.map +1 -1
  126. package/dist/ui/contact-tool-groups.js +1 -1
  127. package/dist/ui/fleet-canvas.js +2 -1
  128. package/dist/ui/fleet-office-card.js +20 -5
  129. package/dist/ui/fleet-office-dialogue.d.ts +6 -3
  130. package/dist/ui/fleet-office-dialogue.js +13 -3
  131. package/dist/ui/fleet-office-layout.js +13 -13
  132. package/dist/ui/fleet-office-model.js +3 -2
  133. package/dist/ui/fleet-office-overview.js +1 -1
  134. package/dist/ui/fleet-office-pack.d.ts +17 -7
  135. package/dist/ui/fleet-office-pack.js +106 -38
  136. package/dist/ui/fleet-office-play.js +11 -4
  137. package/dist/ui/fleet-office-skin.js +25 -11
  138. package/dist/ui/fleet-office-store.js +10 -1
  139. package/dist/ui/fleet-office-talk.js +423 -0
  140. package/dist/ui/fleet-office-view.js +26 -17
  141. package/dist/ui/fleet-office-zones.js +20 -12
  142. package/dist/ui/fleet-office.js +173 -44
  143. package/dist/ui/fleet-task-common.js +1 -1
  144. package/dist/ui/fleet-task-sort.js +88 -0
  145. package/dist/ui/fleet-task-view.js +38 -9
  146. package/dist/ui/fleet-tasks.js +47 -15
  147. package/dist/ui/hub-chat-store.js +4 -3
  148. package/dist/ui/hub-chat-strings.js +2 -0
  149. package/dist/ui/hub-client.js +3 -0
  150. package/dist/ui/hub-my-agents-strings.js +2 -2
  151. package/dist/ui/hub-my-agents.js +3 -0
  152. package/dist/ui/hub-room-composer.js +24 -4
  153. package/dist/ui/hub-room-members.js +7 -3
  154. package/dist/ui/hub-room-office.js +2 -1
  155. package/dist/ui/hub-room-presence.js +9 -0
  156. package/dist/ui/hub-room-strings.js +18 -2
  157. package/dist/ui/hub-room-thread.js +82 -13
  158. package/dist/ui/hub-room-working.js +37 -0
  159. package/dist/ui/hub-session-limits.js +79 -0
  160. package/dist/ui/panel-hub.js +41 -6
  161. package/dist/ui/panel-needs.js +28 -2
  162. package/dist/ui/shared/app.css +84 -3
  163. package/dist/ui/shared/chat-strings.js +1 -1
  164. package/dist/ui/shared/hub-owner.css +5 -0
  165. package/dist/ui/shared/hub-rooms-u2.css +3 -0
  166. package/dist/ui/shared/office-dialogue.css +110 -0
  167. package/dist/ui/shared/task-board.css +103 -7
  168. package/dist/web-api.d.ts +5 -0
  169. package/dist/web-api.js +29 -0
  170. package/dist/web-api.js.map +1 -1
  171. package/dist/web-office-skins.d.ts +8 -2
  172. package/dist/web-office-skins.js +33 -14
  173. package/dist/web-office-skins.js.map +1 -1
  174. package/dist/web-office-store.js +5 -3
  175. package/dist/web-office-store.js.map +1 -1
  176. package/package.json +1 -1
@@ -40,8 +40,13 @@ register("hubRoom", {
40
40
  searchResults: "Results", searchRooms: "Rooms and chats", searchBadgeRoom: "Room", searchBadgeChat: "Chat", searchCount: "{0} results",
41
41
  searchOlder: "Search older messages", searchKeys: "↑↓ move · Enter open · Esc close", jumpMissing: "That message is no longer in this room.",
42
42
  filterPh: "Filter: name or owner", filterClear: "Clear the filter",
43
- laterAnswer: "{0} ({1}) · answers after they come online", noAnswer: "No answer", noAnswerUnanswered:"No answer: The agent finished without answering here", noAnswerStopped: "No answer: {0} stopped sharing this agent.",
43
+ laterAnswer: "{0} ({1}) · answers after they come online", noAnswer: "No answer", noAnswerReshare: "This agent is unavailable right now. Its owner needs to share it again.", noAnswerUnanswered:"No answer: The agent finished without answering here", noAnswerStopped: "No answer: {0} stopped sharing this agent.",
44
44
  workingOne: "{0} is working on it", workingMany: "{0} agents are working",
45
+ waitBehindOne: "Waiting: {0} is answering another question first", waitBehindMany: "Waiting: {0} has {1} questions to answer first",
46
+ waitBusy: "Waiting: {0} is busy with other work", waitPaused: "Waiting: {0} is paused; it gets your question when it resumes",
47
+ waitOffline: "Waiting: {0} is offline; it gets your question when it's back", waitStart: "Sent to {0}; waiting for it to start", elapsedTitle: "Time since it started",
48
+ handedUnknown: "Handed to {0}; waiting for its answer",
49
+ workPaused: "Paused: {0} continues with your question when it resumes", workOffline: "Offline: {0} continues with your question when it's back",
45
50
  // §4 composer
46
51
  composer: "Speak in “{0}”; @ an agent to have it answer",
47
52
  composerShort: "Message, or @ an agent to ask", // Lumen (spec §4): a phone's width
@@ -55,6 +60,9 @@ register("hubRoom", {
55
60
  errAssistant: "The room assistant cannot answer right now.",
56
61
  notSentBecause: "Not sent: {0}",
57
62
  sendNoConnection: "it did not reach AgEnD — check the connection", retrySend: "Retry send",
63
+ sendSignedOut: "you are signed out — sign in again, then send it", sendSession: "this page's sign-in changed — reload the page, then send it",
64
+ sendBusy: "the Hub is busy just now — try again in a moment", sendUnavailable: "the Hub can't take it just now — try again",
65
+ sendDenied: "you can't ask this agent any more", sendInvalid: "the Hub didn't accept this message", sendRefused: "the Hub refused it ({0})",
58
66
  // §5 members rail
59
67
  membersHead: "Members · {0} (online {1})", roleYou: "You", roleManager: "Manager",
60
68
  agentsHead: "Agents · {0} (online {1})", moreN: "… {0} more",
@@ -189,8 +197,13 @@ register("hubRoom", {
189
197
  searchResults: "結果", searchRooms: "房間與聊天", searchBadgeRoom: "房間", searchBadgeChat: "聊天", searchCount: "{0} 筆結果",
190
198
  searchOlder: "搜尋更早的訊息", searchKeys: "↑↓ 移動 · Enter 開啟 · Esc 關閉", jumpMissing: "這則訊息已不在這個房間裡。",
191
199
  filterPh: "篩選:名稱或擁有者", filterClear: "清除篩選",
192
- laterAnswer: "{0}({1})· 上線後回答", noAnswer: "沒有回答", noAnswerUnanswered:"沒有回答:Agent 已結束處理,但沒有在這裡回答。", noAnswerStopped: "沒有回答:{0} 已停止分享這個 Agent。",
200
+ laterAnswer: "{0}({1})· 上線後回答", noAnswer: "沒有回答", noAnswerReshare: "這個 Agent 暫時無法回答,擁有者需要重新分享。", noAnswerUnanswered:"沒有回答:Agent 已結束處理,但沒有在這裡回答。", noAnswerStopped: "沒有回答:{0} 已停止分享這個 Agent。",
193
201
  workingOne: "{0} 正在處理", workingMany: "{0} 個 Agent 正在處理",
202
+ waitBehindOne: "等待中:{0} 正在先回答另一個問題", waitBehindMany: "等待中:{0} 前面還有 {1} 個問題",
203
+ waitBusy: "等待中:{0} 正在處理其他工作", waitPaused: "等待中:{0} 已暫停,恢復後會收到你的問題",
204
+ waitOffline: "等待中:{0} 離線中,上線後會收到你的問題", waitStart: "已送給 {0},等它開始處理", elapsedTitle: "開始處理後經過的時間",
205
+ handedUnknown: "已交給 {0},等它回答",
206
+ workPaused: "已暫停:{0} 恢復後會繼續處理你的問題", workOffline: "離線:{0} 上線後會繼續處理你的問題",
194
207
  composer: "在「{0}」說話;@ 一個 Agent 請它回答",
195
208
  composerShort: "說話,或 @ Agent 請它回答",
196
209
  mentionAllHint: "{0} 個都會回答", mentionAssistant: "@房間助理",
@@ -203,6 +216,9 @@ register("hubRoom", {
203
216
  errAssistant: "房間助理暫時無法回答。",
204
217
  notSentBecause: "沒有送出:{0}",
205
218
  sendNoConnection: "沒有送到 AgEnD,請檢查網路連線", retrySend: "重試傳送",
219
+ sendSignedOut: "你已登出,請重新登入後再傳送", sendSession: "這個頁面的登入狀態已變更,請重新整理頁面後再傳送",
220
+ sendBusy: "Hub 目前忙碌,請稍候再試", sendUnavailable: "Hub 暫時無法接收,請再試一次",
221
+ sendDenied: "你已經不能再問這個 Agent", sendInvalid: "Hub 不接受這則訊息", sendRefused: "Hub 拒絕了這則訊息({0})",
206
222
  membersHead: "成員 · {0}(線上 {1})", roleYou: "你", roleManager: "管理",
207
223
  agentsHead: "Agent · {0}(線上 {1})", moreN: "… 其餘 {0} 個",
208
224
  whoSees: "誰看得到",
@@ -31,16 +31,22 @@ import { notifyStore, notifySupport, setNotify } from "/assets/app-needs.js";
31
31
  import { HubNotifyToggle } from "./hub-room-notify.js";
32
32
  import { createHubButtonActions } from "./hub-button-actions.js";
33
33
  import { linkRoomsU2Css } from "./hub-room-new-strings.js";
34
- import { workingLine } from "./hub-room-working.js";
34
+ import { directStatus, workingLine } from "./hub-room-working.js";
35
35
  import { roomSource, mountSourceAuthor } from "./hub-room-source.js";
36
36
  import { countsLine } from "./hub-room-list.js";
37
37
  import { DropOverlay, MAX_FILES, PendingFiles, hf, hubFileAttachment, pageCarriesFiles, putBackText, roomTakesFiles, uploadChosen, useFileDrop } from "./hub-attachments.js";
38
38
  import { LightboxHost, openLightbox } from "/assets/image-lightbox.js";
39
39
  import { ROOM_PINS_MAX, RoomPinsButton, RoomPinsDialog } from "./hub-room-pins.js";
40
40
  import { RoomOffice } from "./hub-room-office.js";
41
+ // M-3591: an HTML page in a room opens in the side panel, as in a one-to-one chat (panel-hub.js HubRoomView).
42
+ import { PreviewPanel, closePanel, panelStore } from "/assets/preview-panel.js";
43
+ import { msgKey } from "/assets/chat-thread.js";
44
+ import { bindRoomFeedback, bootHubPreview, downloadHtml, draftWithLine, panelOpenFor, roomPanelKey, setHubPreviewOptIn } from "./hub-preview.js";
41
45
  // M-3125 PR3: the one quote target an annotated room picture has (here, so a page with an older dictionary has the words).
42
46
  register("hubRoomAnnotate", { en: { quote: "Quote in this room" }, "zh-TW": { quote: "引用到這個房間" } });
43
47
 
48
+ register("hubDirectPosts",{en:{mute:"Mute this agent’s own messages",muted:"{0}’s own messages are off.",mutedNotice:"{0}’s own messages are off; your questions still get answers.",unmuted:"This agent can send you messages again.",failed:"Could not change this preference. Please try again."},"zh-TW":{mute:"關閉這個 Agent 主動發來的訊息",muted:"已關閉 {0} 主動發來的訊息。",mutedNotice:"已關閉 {0} 主動發來的訊息;你問的問題仍會回答。",unmuted:"這個 Agent 現在可以再次主動發來訊息。",failed:"無法變更這項設定,請再試一次。"}});
49
+
44
50
  linkRoomsU2Css(); // M-3127: the reaction chips and picker are drawn from hub-rooms-u2.css (a room opened before any U2 panel)
45
51
  /**
46
52
  * M-3311 (3): the Fleet chat's 「全寬」 for a Hub conversation — this device's choice (as the Fleet keeps its own), its own key:
@@ -110,7 +116,7 @@ export function systemText(m) {
110
116
  * child counts as failed.
111
117
  */
112
118
  const count = (v) => (Number.isSafeInteger(v) && v > 0 ? v : 0);
113
- const REASON = { "finished-without-answer":"reasonUnanswered",expired: "reasonExpired", unavailable: "reasonUnavailable", interrupted: "reasonInterrupted", retired: "reasonRetired", unknown: "reasonUnknown" };
119
+ const REASON = { "share-needs-reshare":"noAnswerReshare", "finished-without-answer":"reasonUnanswered",expired: "reasonExpired", unavailable: "reasonUnavailable", interrupted: "reasonInterrupted", retired: "reasonRetired", unknown: "reasonUnknown" };
114
120
  export function askReason(code) { return REASON[code] ? hroom(REASON[code]) : ""; }
115
121
  export function askState(ask) {
116
122
  if (!ask || !Number.isSafeInteger(ask.total) || ask.total < 1) return null;
@@ -205,7 +211,9 @@ export function toThreadMessages(messages, { meId, ids, direct = false, expanded
205
211
  ...(!direct && Array.isArray(m.reactions) && m.reactions.length ? { reactionBar: reactionBar(m.reactions, { meId, names }) } : {}),
206
212
  ...(!direct && kind !== "person" && m.buttons ? { buttons: roomButtons(m.buttons, meId) } : {}),
207
213
  ...(quotedId ? { replyTo: { boot: BOOT, id: num(quotedId), sender: quoted ? authorLine(quoted.author, quoted.author?.id === meId, direct) : "", text: quoted ? String(quoted.text || "").slice(0, 120) : "" } } : {}),
208
- ...(m.stage === "not-answered" ? { text: m.reasonCode === "owner-stopped-sharing" ? hroom("noAnswerStopped", author.owner?.name || "") : m.reasonCode==="finished-without-answer"?hroom("noAnswerUnanswered"):hroom("noAnswer") } : {}) });
214
+ ...(m.stage === "not-answered" && !(kind === "person" && m.reasonCode === "share-needs-reshare") ? { text: m.reasonCode === "share-needs-reshare" ? hroom("noAnswerReshare") : m.reasonCode === "owner-stopped-sharing" ? hroom("noAnswerStopped", author.owner?.name || "") : m.reasonCode==="finished-without-answer"?hroom("noAnswerUnanswered"):hroom("noAnswer") } : {}) });
215
+ if (kind === "person" && m.stage === "not-answered" && m.reasonCode === "share-needs-reshare")
216
+ out.push({ boot: BOOT, id: num(`unavailable:${m.id}`), role: "status", sender: "", text: hroom("noAnswerReshare"), bare: true, wrap: true });
209
217
  if (foldAfter) out.push({ boot: BOOT, id: num(`expand:${foldAfter.arg}`), role: "status", sender: "", text: "", bare: true, fold: true, action: foldAfter });
210
218
  // Spec §10: once an @所有 Agent has answers, under the last one shown, 「請房間助理整理」 (it sends 「@房間助理 整理上面的回答」).
211
219
  if (summarise && lastShown && byId.get(m.answerTo)?.mentions?.includes("all"))
@@ -213,7 +221,7 @@ export function toThreadMessages(messages, { meId, ids, direct = false, expanded
213
221
  const line = state?.line, why = !line && mine ? askReason(state?.reason) : "";
214
222
  // Its status, not an event: under it, without a time of its own.
215
223
  if (line) out.push({ boot: BOOT, id: id + 1, role: "status", sender: "", text: line, progressOf: m.id, bare: true });
216
- else if (why) out.push({ boot: BOOT, id: id + 1, role: "status", sender: "", text: why, progressOf: m.id, bare: true });
224
+ else if (why) out.push({ boot: BOOT, id: id + 1, role: "status", sender: "", text: why, progressOf: m.id, bare: true, wrap: state?.reason === "share-needs-reshare" });
217
225
  if (mine && m.warning === "assistant-unavailable") out.push({ boot: BOOT, id: id + 1, role: "status", sender: "", ts: iso(m.at), text: hroom("errAssistant"), bare: true });
218
226
  }
219
227
  return out;
@@ -351,6 +359,8 @@ export function createRoomStore(roomId, { client, meId = "", pinsOn = false } =
351
359
  expand(messageId) { if (typeof messageId === "string" && !expanded.has(messageId)) { expanded.add(messageId); changed(); } },
352
360
  /** Who is working on an answer in this room now (its answer row has no text yet): their names, in arrival order. */
353
361
  working() { return this.workers().map((w) => w.name); },
362
+ /** M-3596: the answer rows still without text (a 1:1 room's open question: working or queued), for its status line. */
363
+ pendingAnswers() { return st.messages.filter((m) => m.answerTo && !m.text && (m.stage === "working" || m.stage === "queued")); },
354
364
  /** The same, as members ({ kind, name }) — what workingLine() words (the room assistant by its own name). */
355
365
  workers() { return st.messages.filter((m) => m.answerTo && !m.text && m.stage === "working" && m.author?.name).map((m) => ({ kind: m.author.kind === "assistant" ? "assistant" : "agent", name: String(m.author.name) })); },
356
366
  /**
@@ -420,8 +430,28 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
420
430
  useEffect(() => { alive.current = true; return () => { alive.current = false; }; }, []);
421
431
  useEffect(() => { setFiles([]); setFileMsg(""); }, [roomId]);
422
432
  const wide = useRailWide();
423
- const input = useRef(null), threadRef = useRef(null), insert = useRef(null);
433
+ const input = useRef(null), threadRef = useRef(null), insert = useRef(null), editDraft = useRef(null);
424
434
  const Panel = useMembersPanel();
435
+ // M-3591: the room's side panel for its HTML pages — the one-to-one chat's (panel-hub.js HubRoomView): the previews set
436
+ // up for this page, the panel's "Reply about this page" / Point at it lines into this room's box. Leaving the room
437
+ // closes it (PreviewPanel closes on unmount; the page is keyed by the room).
438
+ const split = useRef(null), panelKey = roomPanelKey(roomId);
439
+ const [panelOpen, setPanelOpen] = useState(() => panelOpenFor(panelKey));
440
+ useEffect(() => { bootHubPreview(); }, []);
441
+ useEffect(() => {
442
+ setPanelOpen(panelOpenFor(panelKey));
443
+ const off = panelStore.subscribe(() => setPanelOpen(panelOpenFor(panelKey)));
444
+ const release = bindRoomFeedback({
445
+ findMsg: (key) => store.messages().find((x) => msgKey(x) === key) || null,
446
+ addLine: (line) => editDraft.current?.((d) => draftWithLine(d, line)),
447
+ focus: () => {
448
+ const el = input.current; if (!el) return;
449
+ el.focus();
450
+ setTimeout(() => { try { const n = el.value.length; el.setSelectionRange(n, n); } catch { /* not a text field */ } }, 0);
451
+ },
452
+ });
453
+ return () => { off(); release(); };
454
+ }, [store]);
425
455
  // dev-claude2's room settings (hub-room-settings.js), opened from the header or the members panel.
426
456
  const [settings, setSettings] = useState(null);
427
457
  const openSettings = () => { import("./hub-room-settings.js").then((m) => { if (typeof m.RoomSettings === "function") setSettings(() => m.RoomSettings); }, () => {}); };
@@ -573,7 +603,15 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
573
603
  // M-3311 (3): the header's menu — a group room's Room settings and Leave, and on a desk the Fleet chat's 「全寬」 for any room.
574
604
  const [fullWidth, setFullWidth] = useState(hubChatWide);
575
605
  const textSize = useStore(textSizeStore), notify = useStore(notifyStore), narrow = useNarrowScreen();
606
+ const [muteBusy,setMuteBusy]=useState(false);
607
+ async function toggleDirectMute(){
608
+ if(muteBusy)return;setMuteBusy(true);
609
+ try{const muted=!room.directMessagesMuted,r=await client.updateRoom(roomId,{directMessagesMuted:muted});
610
+ if(r.ok){await store.refresh();toast(t(`hubDirectPosts.${muted?"muted":"unmuted"}`,title));}else toast(t("hubDirectPosts.failed"),false);
611
+ }finally{setMuteBusy(false);}
612
+ }
576
613
  const menuItems = [
614
+ !group&&room.kind==="direct"&&room.state==="active"&&typeof room.directMessagesMuted==="boolean"?{key:"directMute",checkbox:true,checked:room.directMessagesMuted,disabled:muteBusy,label:t("hubDirectPosts.mute"),onSelect:()=>{void toggleDirectMute();}}:null,
577
615
  // M-3533 R1: a phone has no tab row — Office is the first item of ⋯ (in the office, its back returns to the chat).
578
616
  narrow && officeOn && !inOffice ? { key: "office", label: hroom("tabOffice"), icon: "org", onSelect: () => onView("office") } : null,
579
617
  // In the office a phone's options (hide paused, bedtime, dialogue, key, fit, fill) are one sheet, not rows over the scene.
@@ -591,17 +629,25 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
591
629
  ].filter(Boolean);
592
630
  const line2 = narrow && inOffice ? hroom("tabOffice") : group ? `${countsLine(room.people, room.agents)}${hasAssistant ? ` · ${hroom("roomAssistant")}` : ""}`
593
631
  : room.assistant ? hroom("providedByHub") : room.agent?.answerOnly ? hp("answerOnlyAsker") : String(room.agent?.owner?.name || "");
594
- const showRail = wide && rail && Panel && group && detail;
632
+ // M-3591: the panel takes the members rail's place while it shows a page (the members button brings the rail back).
633
+ const showRail = wide && rail && Panel && group && detail && !(panelOpen && !inOffice);
595
634
  // The Fleet chat's working bar (Lumen): 「Notes 正在處理」, or 「2 個 Agent 正在處理」 — the answer row only when it arrives.
596
635
  // Who: this room's answers being worked on; the words: workingLine() (#3857), the one place that says it.
597
636
  const working = workingLine({ members: store.workers().map((w) => ({ ...w, presence: "working" })) });
637
+ // M-3596: a 1:1 room says what its own question is doing — the Fleet chat's bar: working (with the time since the agent got
638
+ // it), or waiting and why (behind another question, busy, paused, offline, or just sent). The asker's own questions only.
639
+ const statusOf = (now) => room.kind === "direct" && typeof store.pendingAnswers === "function"
640
+ ? directStatus(store.pendingAnswers(), { name: room.agent?.name || room.name, presence: room.agent?.presence, reported: room.agent?.reported === true }, now) : null;
641
+ const status = statusOf(Date.now());
598
642
  // M-3565: a message's agent name → its card in the members panel: the panel opened (a phone's sheet), the card open.
599
643
  const [focus, setFocus] = useState(null), wideNow = useRef(wide);
600
644
  wideNow.current = wide; // read when pressed: the thread keeps the sender hook from its first render
601
645
  const focusMember = (id) => {
602
646
  const m = (store.detail()?.members || []).find((x) => x && x.kind === "agent" && x.id === id);
603
647
  if (!m) return false;
604
- if (wideNow.current) setRail(true); else setSheet(true);
648
+ // M-3591 (#4407 review): on a desk the rail is where a shown page's panel is — close the page first, as the members
649
+ // button does (read when pressed: the thread keeps this hook from its first render).
650
+ if (wideNow.current) { if (panelOpenFor(panelKey)) closePanel(); setRail(true); } else setSheet(true);
605
651
  setFocus({ id, n: Date.now() });
606
652
  return true;
607
653
  };
@@ -616,7 +662,7 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
616
662
  onMention=${(m) => { setSheet(false); insertMention(m); }}
617
663
  onOpenChat=${chatWith} focus=${focus}
618
664
  onSettings=${() => { setSheet(false); openSettings(); }} />` : null;
619
- return html`<div class=${`hub-chat hub-room-page${showRail ? " with-rail" : ""}`} data-room=${roomId} data-width=${fullWidth ? "full" : undefined}>
665
+ return html`<div class=${`hub-chat hub-room-page${showRail ? " with-rail" : ""}`} data-room=${roomId} data-width=${fullWidth ? "full" : undefined} ref=${split}>
620
666
  <${LightboxHost} />
621
667
  ${pinsOpen ? html`<${RoomPinsDialog} pins=${store.pins()} onClose=${() => setPinsOpen(false)} onJump=${(p) => void showPin(p)} onUnpin=${(p) => void togglePin(p.messageId)} />` : null}
622
668
  <section class="hub-chat-main" ref=${mainRef}>
@@ -634,8 +680,8 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
634
680
  return html`<a key=${v} class=${`seg-item${on ? " active" : ""}`} href=${officeHref(v)} aria-current=${on ? "page" : undefined} data-label=${label}
635
681
  onClick=${(e) => { if (e.metaKey || e.ctrlKey || e.shiftKey || e.button > 0) return; e.preventDefault(); onView(v); }}>${label}</a>`; })}</nav>` : null}
636
682
  <span class="hub-head-tools"><${RoomPinsButton} count=${pinCount} onOpen=${() => setPinsOpen(true)} /><${TextSizeButton} /><${HubNotifyToggle} /></span>
637
- ${group && Panel ? html`<button type="button" class="icon-btn hub-room-rail-toggle" aria-pressed=${(wide ? rail : sheet) ? "true" : "false"} title=${hroom("members")} aria-label=${hroom("members")}
638
- onClick=${() => (wide ? setRail(!rail) : setSheet(true))}><${Icon} name="team" size=${18} /></button>` : null}
683
+ ${group && Panel ? html`<button type="button" class="icon-btn hub-room-rail-toggle" aria-pressed=${(wide ? showRail : sheet) ? "true" : "false"} title=${hroom("members")} aria-label=${hroom("members")}
684
+ onClick=${() => { if (!wide) { setSheet(true); return; } if (panelOpen && !inOffice) { closePanel(); setRail(true); return; } setRail(!rail); }}><${Icon} name="team" size=${18} /></button>` : null}
639
685
  ${menuItems.length ? html`<${Menu} cls="hub-room-menu" label=${hroom("menu")} fit=${true} ownerKey=${roomId} items=${menuItems} />` : null}
640
686
  </header>
641
687
  ${inOffice ? html`<${RoomOffice} key=${roomId} client=${client} roomId=${roomId} members=${detail?.members || []}
@@ -644,21 +690,44 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
644
690
  onEdit=${detail?.me?.role === "manager" && client.roomPurposeV1 === true ? openSettings : undefined} />` : null}
645
691
  ${leaveError ? html`<p class="err hub-room-leave-err" role="alert">${leaveError}</p>` : null}
646
692
  ${room.closureReason === "owner-stopped-sharing" ? html`<p class="note" role="status">${hroom("noAnswerStopped", room.ownerName || room.agent?.owner?.name || "")}</p>` : null}
647
- ${inOffice ? null : html`<${Thread} store=${store} name=${title} panelKey=${`hub-room:${roomId}`} threadRef=${threadRef} extra=${extra}
693
+ ${inOffice ? null : html`<${Thread} store=${store} name=${title} panelKey=${panelKey} threadRef=${threadRef} extra=${extra}
648
694
  emptyView=${room.assistant ? html`<div class="hub-assistant-empty"><${Empty} icon="bot" title=${hroom("hubAssistant")} hint=${hroom("hubAssistantEmpty")} /></div>`
649
695
  : group ? html`<p class="note">${hroom("composerHint")}</p>` : null} />`}
650
696
  ${/* M-3117: under the thread, the Fleet chat's dock — its column, its padding, the working line and the box in it.
651
697
  M-3533 R1: the office shows none (design §2.1: no message box under it; to ask, back to Chat). It stays mounted, hidden,
652
698
  so a draft and the mentions picked into it are still there when Chat comes back. */ ""}
653
699
  ${html`<div class="dock hub-dock" data-trust="composer" hidden=${inOffice}><div class="dock-col">
654
- ${working ? html`<${WorkBarView} kind="working" label=${working.text} elapsed="" elapsedTitle="" />` : null}
655
- <${RoomComposer} store=${sendStore} detail=${detail} reply=${reply} onReply=${setReply} closed=${store.closed()} inputRef=${input} insertRef=${insert}
700
+ ${room.kind === "direct" ? (status ? html`<${DirectStatusBar} statusOf=${statusOf} />` : null)
701
+ : working ? html`<${WorkBarView} kind="working" label=${working.text} elapsed="" elapsedTitle="" />` : null}
702
+ ${room.kind==="direct"&&room.directMessagesMuted?html`<p class="note" role="status">${t("hubDirectPosts.mutedNotice",title)}</p>`:null}
703
+ <${RoomComposer} store=${sendStore} detail=${detail} reply=${reply} onReply=${setReply} closed=${store.closed()} inputRef=${input} insertRef=${insert} editRef=${editDraft}
656
704
  attach=${attach} pending=${pending} canSendEmpty=${files.some((f) => f.state === "ready")} />
657
705
  </div></div>`}
658
706
  </section>
707
+ ${/* M-3591: the office has no thread, so no page panel beside it (leaving for the office closes it). */ ""}
708
+ ${inOffice ? null : html`<${PreviewPanel} name=${panelKey} split=${split} msgs=${() => store.messages()} subscribe=${(fn) => store.subscribe(() => fn(panelKey, "msgs"))}
709
+ keyOf=${msgKey} reveal=${(k) => threadRef.current && threadRef.current.reveal(k)} download=${downloadHtml} allow=${(commit) => setHubPreviewOptIn(true, commit)} />`}
659
710
  ${showRail ? html`<${RailFrame} trust="hub-context" label=${hroom("members")} title=${hroom("members")} closeLabel=${hroom("cancel")} onClose=${() => setRail(false)}>${panel}</${RailFrame}>` : null}
660
711
  ${!wide && sheet && panel && group ? html`<${Dialog} title=${hroom("members")} label=${hroom("members")} onClose=${() => setSheet(false)}><div class="hub-rail-sheet">${panel}</div></${Dialog}>` : null}
661
712
  ${settings && detail ? html`<${settings} client=${client} roomId=${roomId} detail=${detail} assistant=${hasAssistant}
662
713
  onClose=${() => setSettings(null)} onChanged=${() => { void store.refresh(); }} />` : null}
663
714
  </div>`;
664
715
  }
716
+
717
+ /** M-3596: a 1:1 room's status line — the Fleet chat's work bar (working, its elapsed time ticking; or waiting, and why). */
718
+ function DirectStatusBar({ statusOf }) {
719
+ // Worked out again on every tick (its elapsed time; a hand-off the agent never took turns back to waiting after the grace).
720
+ const [, tick] = useState(0);
721
+ const status = statusOf(Date.now());
722
+ const kind = status ? status.kind : null;
723
+ useEffect(() => {
724
+ if (kind !== "working") return undefined;
725
+ const h = setInterval(() => tick((n) => n + 1), 1000);
726
+ return () => clearInterval(h);
727
+ }, [kind]);
728
+ if (!status) return null;
729
+ if (status.kind !== "working") return html`<${WorkBarView} kind="awaiting" label=${status.text} note="" noteTitle="" />`;
730
+ const R = globalThis.AgendChatRender;
731
+ const elapsed = R && typeof status.since === "number" ? R.formatElapsed(Math.max(0, Date.now() - status.since)) : "";
732
+ return html`<${WorkBarView} kind="working" label=${status.text} elapsed=${elapsed} elapsedTitle=${hroom("elapsedTitle")} />`;
733
+ }
@@ -27,3 +27,40 @@ export function assistantFootnote(message) {
27
27
  if (author && author.kind === "assistant" && message.answerTo) return hroom("basedOnRecent");
28
28
  return "";
29
29
  }
30
+
31
+ /** M-3596: how long after a hand-off (the Hub's begin lease) an agent may still report idle before the question reads as
32
+ * not started (a hand-off held before any input never reaches the agent). */
33
+ export const HANDOFF_GRACE_MS = 60_000;
34
+
35
+ /**
36
+ * M-3596: a 1:1 room's status line, as the Fleet chat's work bar says it — from the open question's answer row (no text
37
+ * yet: working once the agent was handed it, else queued with how many came first) and the agent's presence (`reported`:
38
+ * its state came from its fleet; an older one never says). A paused or offline agent wins over working; a hand-off the
39
+ * agent still reports idle after HANDOFF_GRACE_MS never reached it (held before input) and reads as not started. With no
40
+ * reported state at all the Hub knows only that a hand-off was tried (a hold before input never reaches it): it says so,
41
+ * never "working" (Prism #4400). Words from hroom, never copied. → { kind: "working", text, since } | { kind: "awaiting", text } | null (nothing open).
42
+ */
43
+ export function directStatus(messages, agent, now = Date.now()) {
44
+ const rows = Array.isArray(messages) ? messages.filter((m) => m && m.answerTo && !m.text && m.author && m.author.kind === "agent"
45
+ && (m.stage === "working" || m.stage === "queued")) : [];
46
+ const name = String((agent && agent.name) || (rows[0] && rows[0].author.name) || "");
47
+ const presence = agent && agent.presence, reported = !!(agent && agent.reported);
48
+ const working = rows.find((m) => m.stage === "working");
49
+ if (working) {
50
+ if (presence === "paused") return { kind: "awaiting", text: hroom("workPaused", name) };
51
+ if (presence === "offline" || presence === "later") return { kind: "awaiting", text: hroom("workOffline", name) };
52
+ // No state from its fleet: a hand-off was tried, nothing more is known (it may have been held before input).
53
+ if (!reported) return { kind: "awaiting", text: hroom("handedUnknown", name) };
54
+ const since = typeof working.startedAt === "number" ? working.startedAt : working.at;
55
+ if (!(presence === "idle" && now - since > HANDOFF_GRACE_MS)) return { kind: "working", text: hroom("workingOne", name), since };
56
+ return { kind: "awaiting", text: hroom("waitStart", name) };
57
+ }
58
+ const queued = rows.find((m) => m.stage === "queued");
59
+ if (!queued) return null;
60
+ const ahead = typeof queued.ahead === "number" ? queued.ahead : 0;
61
+ const text = presence === "paused" ? hroom("waitPaused", name)
62
+ : presence === "offline" || presence === "later" ? hroom("waitOffline", name)
63
+ : ahead > 1 ? hroom("waitBehindMany", name, ahead) : ahead === 1 ? hroom("waitBehindOne", name)
64
+ : presence === "working" ? hroom("waitBusy", name) : hroom("waitStart", name);
65
+ return { kind: "awaiting", text };
66
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * M-3592: Administration → Sign-in — how long a Hub sign-in lasts, the administrator's (GET/PUT
3
+ * /hub/v1/admin/session-limits). Two lengths from a list within the server's bounds; the server checks them again.
4
+ */
5
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
6
+ import { register, t } from "/assets/app-i18n.js";
7
+
8
+ register("hubSessionLimits", {
9
+ en: {
10
+ title: "Sign-in", absolute: "Sign people out after", idle: "Or after this long without using the Hub",
11
+ note: "A longer sign-in time applies to new sign-ins; a shorter one also signs out anyone already signed in longer than it. The without-use limit applies to everyone at once.",
12
+ activity: "An open Hub page counts as using it: people are signed out for not using it only when no Hub page is open.",
13
+ save: "Save", saving: "Saving…", saved: "Saved.", failed: "Couldn’t save. Try again.", conflict: "Someone else changed this. The current setting is shown; try again.",
14
+ denied: "Only an administrator can change this.", tooLong: "The time without use can’t be longer than the sign-in itself.",
15
+ dflt: "{0} (default)", min: "{0} minutes", hour: "1 hour", hours: "{0} hours", day: "1 day", days: "{0} days",
16
+ },
17
+ "zh-TW": {
18
+ title: "登入時間", absolute: "登入多久後要重新登入", idle: "或多久沒使用 Hub 就登出",
19
+ note: "「登入多久後要重新登入」改長只套用於之後的登入;改短時,已登入超過這個時間的人也會被登出。「多久沒使用 Hub 就登出」會立即套用到所有人。",
20
+ activity: "開著 Hub 頁面就算在使用:只有沒開任何 Hub 頁面時,才會因為沒使用而登出。",
21
+ save: "儲存", saving: "儲存中…", saved: "已儲存。", failed: "無法儲存,請再試一次。", conflict: "這項設定已被其他人修改,已顯示目前的設定,請再試一次。",
22
+ denied: "只有管理員可以修改這項設定。", tooLong: "沒使用的時間不能比登入時間還長。",
23
+ dflt: "{0}(預設)", min: "{0} 分鐘", hour: "1 小時", hours: "{0} 小時", day: "1 天", days: "{0} 天",
24
+ },
25
+ });
26
+ const ts = (key, ...a) => t(`hubSessionLimits.${key}`, ...a);
27
+ /** The lengths offered (minutes), all within the server's bounds. */
28
+ export const ABSOLUTE_CHOICES = Object.freeze([60, 120, 240, 480, 720, 1440, 4320, 10080]);
29
+ export const IDLE_CHOICES = Object.freeze([15, 30, 60, 120, 240, 480, 1440]);
30
+ /** A length in minutes as words: "15 minutes", "8 hours", "7 days". */
31
+ export function minutesText(m) {
32
+ if (m % 1440 === 0) return m === 1440 ? ts("day") : ts("days", m / 1440);
33
+ if (m % 60 === 0) return m === 60 ? ts("hour") : ts("hours", m / 60);
34
+ return ts("min", m);
35
+ }
36
+ const refusal = (r) => r?.status === 409 || r?.code === "revision-conflict" ? ts("conflict")
37
+ : r?.code === "idle-longer-than-absolute" ? ts("tooLong") : r?.status === 401 || r?.status === 403 ? ts("denied") : ts("failed");
38
+
39
+ /** The card; nothing while the setting cannot be read (an older Hub, or not an administrator). */
40
+ export function HubSessionLimitsCard({ client }) {
41
+ const [state, setState] = useState(null), [absolute, setAbsolute] = useState(480), [idle, setIdle] = useState(60);
42
+ const [busy, setBusy] = useState(false), [msg, setMsg] = useState(null);
43
+ const epoch = useRef(0);
44
+ const load = async () => {
45
+ const r = typeof client?.sessionLimits === "function" ? await client.sessionLimits() : { ok: false };
46
+ if (!r || r.ok === false || !Number.isInteger(r.absoluteMinutes)) { setState({ missing: true }); return; }
47
+ setState(r); setAbsolute(r.absoluteMinutes); setIdle(r.idleMinutes);
48
+ };
49
+ useEffect(() => { void load(); return () => { epoch.current++; }; }, []);
50
+ if (!state || state.missing) return null;
51
+ const b = state.bounds || { absolute: { default: 480 }, idle: { default: 60 } };
52
+ // A saved length not in the list (set through the API) is offered as it is.
53
+ const choices = (list, current) => (list.includes(current) ? list : [...list, current].sort((x, y) => x - y));
54
+ const option = (m, def, disabled = false) => html`<option key=${m} value=${String(m)} disabled=${disabled}>${m === def ? ts("dflt", minutesText(m)) : minutesText(m)}</option>`;
55
+ const changed = absolute !== state.absoluteMinutes || idle !== state.idleMinutes;
56
+ const save = async () => {
57
+ if (busy) return;
58
+ if (idle > absolute) { setMsg({ ok: false, text: ts("tooLong") }); return; }
59
+ setBusy(true); setMsg(null); const mine = ++epoch.current;
60
+ let r; try { r = await client.saveSessionLimits({ absoluteMinutes: absolute, idleMinutes: idle, ifRevision: state.revision }); } catch { r = { ok: false }; }
61
+ if (mine !== epoch.current) return;
62
+ setBusy(false);
63
+ if (r && r.ok !== false && Number.isInteger(r.absoluteMinutes)) { setState(r); setAbsolute(r.absoluteMinutes); setIdle(r.idleMinutes); setMsg({ ok: true, text: ts("saved") }); return; }
64
+ setMsg({ ok: false, text: refusal(r) });
65
+ if (r?.status === 409 || r?.code === "revision-conflict") await load();
66
+ };
67
+ return html`<section class="card hub-session-limits" id="hub-admin-sign-in"><h3>${ts("title")}</h3>
68
+ <label class="field"><span>${ts("absolute")}</span>
69
+ <select class="hub-session-absolute" value=${String(absolute)} disabled=${busy} onChange=${(e) => { setAbsolute(Number(e.target.value)); setMsg(null); }}>
70
+ ${choices(ABSOLUTE_CHOICES, state.absoluteMinutes).map((m) => option(m, b.absolute.default))}</select></label>
71
+ <label class="field"><span>${ts("idle")}</span>
72
+ <select class="hub-session-idle" value=${String(idle)} disabled=${busy} onChange=${(e) => { setIdle(Number(e.target.value)); setMsg(null); }}>
73
+ ${choices(IDLE_CHOICES, state.idleMinutes).map((m) => option(m, b.idle.default, m > absolute))}</select></label>
74
+ <p class="note">${ts("note")}</p>
75
+ <p class="note">${ts("activity")}</p>
76
+ ${msg ? html`<p class=${msg.ok ? "note" : "err"} role=${msg.ok ? "status" : "alert"}>${msg.text}</p>` : null}
77
+ <button type="button" class="btn hub-session-save" disabled=${busy || !changed} onClick=${save}>${ts(busy ? "saving" : "save")}</button>
78
+ </section>`;
79
+ }
@@ -372,11 +372,16 @@ export function rememberLogin(login, password) {
372
372
  }
373
373
 
374
374
  /** Load a list from the client; `reload` reads it again. null while loading, { error } on failure. */
375
- function useRead(read) {
375
+ export function useRead(read) {
376
376
  const [data, setData] = useState(null);
377
- const live = useRef(true);
378
- const failed = (error) => { if (live.current) setData((old) => ({ ...old, error })); };
379
- const reload = () => read().then((r) => { if (live.current) { if (r.ok) setData(r); else failed(errText(r)); } }, () => failed(hw("errFailed")));
377
+ const live = useRef(true), latest = useRef(0);
378
+ // M-3567 (Prism): only the newest read may answer. A return reads again while the first read can still be on its way; that
379
+ // older answer, success or failure, landing last must not undo the fresh one (a grant given while away would vanish).
380
+ const reload = () => {
381
+ const n = ++latest.current, current = () => live.current && n === latest.current;
382
+ const failed = (error) => { if (current()) setData((old) => ({ ...old, error })); };
383
+ return read().then((r) => { if (current()) { if (r.ok) setData(r); else failed(errText(r)); } }, () => failed(hw("errFailed")));
384
+ };
380
385
  useEffect(() => { live.current = true; reload(); return () => { live.current = false; }; }, []);
381
386
  return [data, reload];
382
387
  }
@@ -405,7 +410,32 @@ function noteUnread(d) {
405
410
  // Read through (0): its @ mark goes too; the next list read has the Hub's own answer for both.
406
411
  roomsStore.set({ ...s, rooms: s.rooms.map((r) => (r.id === d.roomId ? { ...r, unread: n, ...(n === 0 ? { mentioned: false } : {}) } : r)) });
407
412
  }
408
- /** Keeps the list fresh while something shows it (every ROOMS_MS, paused while the page is hidden). */
413
+ /** M-3567: the gap between a page left and a page back (another tab, another window) is when a grant or a new room lands. */
414
+ export const RETURN_MIN_MS = 5_000;
415
+ /**
416
+ * M-3567: `fn` when the person comes back to the page — it is shown again (visibilitychange) or its window gains focus —
417
+ * at most once per RETURN_MIN_MS (both fire on one return). The 30 s poll pauses while the page is hidden, so a grant
418
+ * given meanwhile showed only after a reload.
419
+ */
420
+ export function useOnReturn(fn) {
421
+ const latest = useRef(fn);
422
+ latest.current = fn;
423
+ useEffect(() => {
424
+ if (typeof document === "undefined") return undefined;
425
+ let last = -Infinity;
426
+ const back = () => {
427
+ if (document.hidden) return;
428
+ const now = typeof performance !== "undefined" ? performance.now() : Date.now(); // a gap, not a date
429
+ if (now - last < RETURN_MIN_MS) return;
430
+ last = now; latest.current();
431
+ };
432
+ document.addEventListener("visibilitychange", back);
433
+ const w = typeof window !== "undefined" ? window : null;
434
+ w?.addEventListener?.("focus", back);
435
+ return () => { document.removeEventListener("visibilitychange", back); w?.removeEventListener?.("focus", back); };
436
+ }, []);
437
+ }
438
+ /** Keeps the list fresh while something shows it (every ROOMS_MS, paused while the page is hidden; again on return). */
409
439
  function useRooms() {
410
440
  const rs = useStore(roomsStore);
411
441
  useEffect(() => {
@@ -413,6 +443,7 @@ function useRooms() {
413
443
  const tick = setInterval(() => { if (session && (typeof document === "undefined" || !document.hidden)) refreshRooms(); }, ROOMS_MS);
414
444
  return () => clearInterval(tick);
415
445
  }, []);
446
+ useOnReturn(() => { if (session) refreshRooms(); });
416
447
  return rs;
417
448
  }
418
449
  // A room's id as the list gives it (today's are UUIDs; a Hub with rooms may name them otherwise): matched against the list
@@ -655,6 +686,8 @@ function HubChats() {
655
686
  function ChatLauncher() {
656
687
  const s = useSession(), rs = useRooms();
657
688
  const [cat, reloadCat] = useRead(() => hubClient().catalog());
689
+ // M-3567: a grant given while the page was away (a Team's, a person's) is listed on return, with no reload.
690
+ useOnReturn(() => reloadCat());
658
691
  const [inRooms, setInRooms] = useState([]);
659
692
  const [q, setQ] = useState(""), [busy, setBusy] = useState(false), [msg, setMsg] = useState(null), [newRoom, setNewRoom] = useState(false);
660
693
  const groups = rs.rooms.filter((r) => r.kind === "group" && !r.archived).sort((a, b) => (b.lastAt || 0) - (a.lastAt || 0)).slice(0, 5);
@@ -729,7 +762,7 @@ function HubRoomLoading({ error } = {}) {
729
762
  }
730
763
  /** The thread's words are the fleet chat's; its delivery marks say the Hub's stages. */
731
764
  const threadT = (key, ...a) => (key.startsWith("chat.tick_") ? hc(key.slice(5), ...a) : t(key, ...a));
732
- const REASONS = { expired: "reason_expired", revoked: "reason_revoked", frozen: "reason_frozen", withdrawn: "reason_withdrawn" };
765
+ const REASONS = { "share-needs-reshare": "reason_reshare", expired: "reason_expired", revoked: "reason_revoked", frozen: "reason_frozen", withdrawn: "reason_withdrawn" };
733
766
  const reasonText = (code, stage) => (stage === "uncertain" ? hc("uncertain") : hc("notAnswered", hc(REASONS[code] || "reason_unknown")));
734
767
  async function copyText(text) { try { await navigator.clipboard.writeText(text); return true; } catch { return false; } }
735
768
 
@@ -1348,6 +1381,8 @@ function HubAdminPage({ groups = false, companyJoin = false, directory = false }
1348
1381
  ${fullAdmin && teamsLive() ? html`<${LazyRoomPart} load=${() => import("./hub-teams.js")} name="HubTeamsEntry" props=${{ client: hubClient() }} />` : null}
1349
1382
  ${fullAdmin && roomsLive() ? html`<${LazyRoomPart} load=${() => import("./hub-admin-rooms.js")} name="AdminRooms" props=${{ client: hubClient() }} />` : null}
1350
1383
  ${fullAdmin && assistantSession?.features?.includes("room-assistant-v1") && hubClient().assistantAdminV1 === true ? html`<${LazyAssistantAdmin} />` : null}
1384
+ ${/* M-3592: how long a sign-in lasts; nothing from a Hub without the setting (the card's read fails). */ ""}
1385
+ ${fullAdmin ? html`<${LazyRoomPart} load=${() => import("./hub-session-limits.js")} name="HubSessionLimitsCard" props=${{ client: hubClient() }} />` : null}
1351
1386
  ${view.error ? html`<${ErrorState} message=${view.error} onRetry=${reload} />` : null}
1352
1387
  ${msg ? html`<p class="err" role="alert">${msg}</p>` : null}
1353
1388
  ${/* M-3141 (versions spec §3.1): the recommended version, a small card above the list. */ ""}
@@ -44,6 +44,9 @@ register("needs", {
44
44
  otherEmpty: "No other items are waiting for you.", title: "Needs you", empty: "Nothing needs you right now", emptyHint: "When an agent waits for you, it shows here — and in your chat app's General.", emptyHintWeb: "When an agent waits for you, it shows here.",
45
45
  open: "Open chat", kiroOpen: "Open agent", kiroMigration: "Migration instructions", openCard: "Open the card", noAssignee: "Task board (nobody assigned)", fleetSignIns: "AI accounts", signIn: "Connect account",
46
46
  gap: "not wrapped up: {0}", gapUnchecked: "{0} checklist item(s) unchecked", gapNoResult: "no result", gapJoin: ", ", acknowledge: "Acknowledge", acknowledging: "Acknowledging…", answering: "Answering…",
47
+ hubRetry: "Try again", hubRetrying: "Trying again…", hubRetryDone: "Asked the Hub again.",
48
+ hubRetryGone: "This item has already changed. The list will refresh.", hubRetryNot: "This one can't be tried again: the Hub refused it, or the agent changed. Ask the person to send the question again.",
49
+ hubHoldDetail: "The Hub could not confirm this question before it reached the agent. Try again asks the Hub again; nothing is sent without its OK.",
47
50
  ageNow: "just now", ageMin: "{0} min ago", ageHour: "{0} h ago", ageDay: "{0} d ago",
48
51
  notifySection: "This device", notifyTitle: "Notify me on this device", notifyOn: "Notifications are on for this browser while a tab is open.",
49
52
  notifyOff: "Get a desktop notification when something new needs you while this tab is in the background.",
@@ -69,6 +72,9 @@ register("needs", {
69
72
  otherEmpty: "沒有其他待處理事項。", title: "等你處理", empty: "目前沒有需要你處理的事", emptyHint: "agent 在等你時,會出現在這裡——也會出現在聊天 app 的 General。", emptyHintWeb: "agent 在等你時,會出現在這裡。",
70
73
  open: "開啟聊天", kiroOpen: "開啟 Agent", kiroMigration: "遷移說明", openCard: "打開卡片", noAssignee: "任務看板(沒有負責人)", fleetSignIns: "AI 帳號", signIn: "連接帳號",
71
74
  gap: "還沒補齊:{0}", gapUnchecked: "還有 {0} 項沒勾", gapNoResult: "沒有產出總結", gapJoin: "、", acknowledge: "確認", acknowledging: "確認中…", answering: "回覆中…",
75
+ hubRetry: "再試一次", hubRetrying: "重試中…", hubRetryDone: "已重新詢問 Hub。",
76
+ hubRetryGone: "這個項目已經有變化,清單會重新整理。", hubRetryNot: "這則無法再試:Hub 已拒絕,或 Agent 已變更。請提問的人重新送出問題。",
77
+ hubHoldDetail: "Hub 在問題交給 Agent 之前無法確認。按「再試一次」會重新詢問 Hub,未經 Hub 同意不會送出。",
72
78
  ageNow: "剛剛", ageMin: "{0} 分鐘前", ageHour: "{0} 小時前", ageDay: "{0} 天前",
73
79
  notifySection: "這台裝置", notifyTitle: "在這台裝置通知我", notifyOn: "這個瀏覽器的通知已開啟(需要開著分頁)。",
74
80
  notifyOff: "分頁在背景時,有新的事等你處理就跳出桌面通知。",
@@ -107,11 +113,14 @@ function itemReason(item) {
107
113
  * review): a second click in the same turn, the panel left and opened again, or a list that has not caught up yet all
108
114
  * see the same claim.
109
115
  * - `acks[id]`: "busy" while its POST is out, "done" once the server took it, until the server's next list drops the
110
- * item (then forgotten); a failure gives it back.
116
+ * item (then forgotten); a failure gives it back. M-3632: a held Hub item's Try again is claimed per hold, under
117
+ * hubRetryKey(item) (its id and since): the same question held again is a new hold with its own button.
111
118
  * - `prompts[nonce]`: the same, for a prompt answered while the page has no chat store yet (before Chat boots). When
112
119
  * it arrives, each such claim is handed to it (holdPrompt) — one claim, never two — and its outcome settles there.
113
120
  */
114
121
  export const claims = createStore({ acks: {}, prompts: {} });
122
+ /** M-3632: one held Hub question's hold, as Try again claims it (a re-hold of the same question has a newer `since`). */
123
+ export const hubRetryKey = (item) => `${item.id}@${item.since}`;
115
124
  const chatOwner = () => appStore.get().chatOwner || null;
116
125
  let handedTo = null;
117
126
  appStore.subscribe((st) => {
@@ -124,7 +133,7 @@ appStore.subscribe((st) => {
124
133
  }
125
134
  }
126
135
  const items = Array.isArray(st.needs) ? st.needs : [];
127
- const listed = new Set(items.map((i) => i.id)), nonces = new Set(items.map((i) => i.nonce).filter(Boolean));
136
+ const listed = new Set([...items.map((i) => i.id), ...items.filter((i) => i.hubRetry).map(hubRetryKey)]), nonces = new Set(items.map((i) => i.nonce).filter(Boolean));
128
137
  const c = claims.get();
129
138
  const acks = Object.fromEntries(Object.entries(c.acks).filter(([id, v]) => v === "busy" || listed.has(id)));
130
139
  const prompts = Object.fromEntries(Object.entries(c.prompts).filter(([n, v]) => v === "busy" || nonces.has(n)));
@@ -279,17 +288,34 @@ function NeedsItem({ item, nowMs, owner }) {
279
288
  setClaim("acks", item.id, res && res.ok ? "done" : null);
280
289
  toast((body && (body.message || body.error)) || t("app.failed"), !!(res && res.ok));
281
290
  };
291
+ // M-3632: held Hub work → back through the Hub's checks (the server re-asks the Hub for its lease; never delivered blind).
292
+ const hubKey = hubRetryKey(item), hubAck = item.hubRetry ? c.acks[hubKey] : undefined;
293
+ const retryHub = async () => {
294
+ if (claims.get().acks[hubKey]) return; // this hold's claim, taken synchronously
295
+ setClaim("acks", hubKey, "busy");
296
+ let res = null, body = null;
297
+ try {
298
+ res = await fetch("/ui/needs/hub-retry", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id: item.id }) });
299
+ body = await res.json().catch(() => ({}));
300
+ } catch { body = null; }
301
+ const ok = !!(res && res.ok);
302
+ setClaim("acks", hubKey, ok ? "done" : null);
303
+ toast(ok ? tn("hubRetryDone") : res && res.status === 404 ? tn("hubRetryGone") : res && res.status === 409 ? tn("hubRetryNot") : t("app.failed"), ok);
304
+ };
282
305
  return html`<article data-trust="permission" class=${`n-item${BAD.has(item.reason) ? " bad" : ""}`}>
283
306
  <span class="n-icon"><${Icon} name=${ICON[item.type] || "alert"} size=${18} /></span>
284
307
  <div class="n-body">
285
308
  <div class="n-title"><strong>${item.type==='host'?hostAlertName(item.hostAlert):itemReason(item)}</strong><span class="n-age">${item.type==='host'?hostAlertText('started')+age(item.since, nowMs):age(item.since, nowMs)}</span></div>
286
309
  ${item.type==='host'&&item.hostAlert?html`<p class="n-detail">${hostAlertText(item.hostAlert.level)} · ${hostAlertDescription(item.hostAlert)}</p>`:item.type==='host'?html`<p class="n-detail">${hostAlertText('failed')}</p>`:detailOf(item)?html`<p class="n-detail">${detailOf(item)}</p>`:null}
310
+ ${item.type === "hub" && item.hubRetry ? html`<p class="n-detail">${tn("hubHoldDetail")}</p>` : null}
287
311
  ${item.type === "hub" && item.hubProposal ? html`<p class="n-detail">${item.hubProposal.action}</p><pre>${item.hubProposal.arguments}</pre><p class="n-detail">${item.hubProposal.consequences}</p>` : null}
288
312
  ${item.generalLocation ? html`<${GeneralLocation} name=${item.instance} attentionOnly=${true} />` : null}
289
313
  ${item.type==='host'?(item.hostAlert?html`<${HostAlertActions} record=${item.hostAlert}/>`:html`<a class="btn btn-sm" href=${fleetPath('host-health')}>${hostAlertText('open')}</a>`):null}
290
314
  <div class="n-actions">
291
315
  ${item.type === "prompt" && Array.isArray(item.actions) ? item.actions.filter((a) => !a.input).map((a) => html`<button key=${a.id} type="button" class="btn btn-sm"
292
316
  disabled=${promptBusy} onClick=${() => answer(a.id)}>${(p ? p.busy && !p.confirming : fallback === "busy") ? tn("answering") : a.label}</button>`) : null}
317
+ ${item.type === "hub" && item.hubRetry ? html`<button type="button" class="btn btn-sm btn-primary" disabled=${!!hubAck} onClick=${retryHub}>
318
+ <${Icon} name="restart" size=${14} />${hubAck === "busy" ? tn("hubRetrying") : tn("hubRetry")}</button>` : null}
293
319
  ${item.type === "delivery" || item.type === "missed" ? html`<button type="button" class="btn btn-sm" disabled=${!!ack} onClick=${acknowledge}>
294
320
  <${Icon} name="check" size=${14} />${ack === "busy" ? tn("acknowledging") : tn("acknowledge")}</button>` : null}
295
321
  ${(item.reason === "auth_paused" || item.reason === "backend_signin") && item.signIn && signInOffered() ? html`<button type="button" class="btn btn-sm btn-primary" onClick=${() => openSignIn(item.signIn)}>${tn("signIn")}</button>` : null}