@xmoon76/dsh-pi-tui 0.5.7 → 0.5.9

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 (78) hide show
  1. package/README.en.md +64 -26
  2. package/README.md +64 -26
  3. package/cordis.patch.yml +13 -0
  4. package/dist/acp-stdio.mjs +151 -0
  5. package/dist/{bootstrap-C9nl6e13.mjs → bootstrap-CVyHGQDX.mjs} +22330 -6888
  6. package/dist/browser-CDUSHIIr.mjs +76 -0
  7. package/dist/builtins.mjs +2 -2
  8. package/dist/{client-bootstrap-CGezi85O.mjs → client-bootstrap-4UoeVIHE.mjs} +2407 -1830
  9. package/dist/client-runtime-BHBlVUf5.mjs +1376 -0
  10. package/dist/{daemon-launcher-H_1r5Cqs.mjs → daemon-launcher-DxIgjBHW.mjs} +1551 -57
  11. package/dist/daemon-launcher.d.mts +85 -14
  12. package/dist/daemon-launcher.mjs +2 -2
  13. package/dist/diagnostics-Db5iVcuJ.mjs +123 -0
  14. package/dist/{entry-control-jBfKn1qO.mjs → entry-control-BDLZgg4m.mjs} +1 -1
  15. package/dist/{extensions-6a5vvJUT.mjs → extensions-Dx7ncPNA.mjs} +1 -4
  16. package/dist/extensions.mjs +1 -1
  17. package/dist/handoff-BjoEy3f8.mjs +106 -0
  18. package/dist/history-search-limits-Cx2UvRC2.mjs +16 -0
  19. package/dist/history-search-remote-BHuoellG.mjs +113 -0
  20. package/dist/history-search-remote-BzXdvrxk.mjs +26 -0
  21. package/dist/history-search-seat-BcHJTpeB.mjs +639 -0
  22. package/dist/history-search-seat-rZcq0XV6.mjs +639 -0
  23. package/dist/{host-bootstrap-MVxks641.mjs → host-bootstrap-BfnufpnW.mjs} +37 -72
  24. package/dist/{host-foundation-probe-DK7n5jDu.mjs → host-foundation-probe-DlD8-N_Q.mjs} +2 -2
  25. package/dist/host-runtime.mjs +5611 -290
  26. package/dist/index.d.mts +13 -6
  27. package/dist/index.mjs +22766 -6893
  28. package/dist/installed-dsh-BjUiJSwR.mjs +142 -0
  29. package/dist/interaction-port-D1Yv9zgu.mjs +45 -0
  30. package/dist/local-acp-control-CC5z4Xbq.mjs +304 -0
  31. package/dist/local-acp-endpoint-D1jYdJdv.mjs +41 -0
  32. package/dist/local-acp-listener-Cmgb5M0H.mjs +9493 -0
  33. package/dist/local-acp-status-B_25Q6kU.mjs +101 -0
  34. package/dist/local-client.mjs +719 -93
  35. package/dist/local-daemon-control-BFJAC8Kg.mjs +2199 -0
  36. package/dist/local-daemon-control-Bm3imctD.mjs +2101 -0
  37. package/dist/{local-discovery-BPZw1wEd.mjs → local-discovery-BMhaGIiJ.mjs} +254 -544
  38. package/dist/{local-discovery-BMoNXZjJ.mjs → local-discovery-Ba7_-NNC.mjs} +1 -1
  39. package/dist/{local-discovery-Bq3jLAn1.mjs → local-discovery-QSbFpjK2.mjs} +301 -544
  40. package/dist/local-host.mjs +970 -501
  41. package/dist/local-profile-daemon-admin-otpm69R6.mjs +469 -0
  42. package/dist/{local-scope-DEuGAy8l.mjs → local-scope-5DEKA_lW.mjs} +1075 -31
  43. package/dist/{local-transport-X4ZCe2uE.mjs → local-transport-DeWmdZ5E.mjs} +14 -3
  44. package/dist/{local-web-control-DKWtXIkr.mjs → local-web-control-Dny93N-r.mjs} +10 -7
  45. package/dist/{local-workspace-object-D06GL0UO.mjs → local-workspace-object-D0RVQt8U.mjs} +33 -9
  46. package/dist/model-selection-CYlqg2DV.mjs +83 -0
  47. package/dist/native-client-domains-Dg4srzYt.mjs +2 -0
  48. package/dist/native-client.d.mts +735 -0
  49. package/dist/native-client.mjs +3534 -0
  50. package/dist/{open-CmOBxSjN.mjs → open-QQva8-ar.mjs} +24 -20
  51. package/dist/{pi-tui-remote-contribution-Do8ECrUy.mjs → pi-tui-remote-contribution-565wiLWp.mjs} +741 -150
  52. package/dist/preferences.mjs +1 -1
  53. package/dist/{profile-preferences-migration-CThz4rHH.mjs → profile-preferences-migration-CNOWIdnr.mjs} +1 -1
  54. package/dist/{profile-preferences-migration-BfUGdPZx.mjs → profile-preferences-migration-IrnXcJWK.mjs} +10 -8
  55. package/dist/{prompt-sections-DXmjB58H.mjs → prompt-sections-Bi-9_Gr_.mjs} +28 -10
  56. package/dist/{prompt-sections-DUKmWb8g.mjs → prompt-sections-DFS1dqsY.mjs} +342 -56
  57. package/dist/{dist-BFgC-5tL.mjs → recall-scope-9Nuoto_i.mjs} +353 -1
  58. package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
  59. package/dist/schema-CCLvDa7Q.mjs +177 -0
  60. package/dist/{schema-qE_P09zJ.mjs → schema-t97l3aK8.mjs} +56 -3
  61. package/dist/{session-DC0XQr5O.mjs → session-Cs8iLCEx.mjs} +784 -342
  62. package/dist/{session-Cihe8PPS.mjs → session-EBRZF6Ow.mjs} +783 -341
  63. package/dist/session-create-facts-CkfG5DpQ.mjs +20 -0
  64. package/dist/{startup-CarQxWwi.d.mts → startup-Dti3Udne.d.mts} +30 -3
  65. package/dist/{startup-CARqn3kV.mjs → startup-UtFQSDe_.mjs} +90 -15
  66. package/dist/startup.d.mts +2 -2
  67. package/dist/startup.mjs +1 -1
  68. package/dist/task-read-remote-DRtkXDrZ.mjs +1083 -0
  69. package/dist/{terminal-progress-source-D4DHyXDo.mjs → terminal-progress-source-VsczdXA-.mjs} +610 -335
  70. package/dist/{transcript-view-a7cROAaI.mjs → transcript-view-B6vCnukn.mjs} +2284 -1166
  71. package/dist/{transcript-view-hvNVkPtv.mjs → transcript-view-DSSdE2vK.mjs} +2191 -765
  72. package/dist/write-failure-xNKczXH7.mjs +189 -0
  73. package/package.json +25 -8
  74. package/dist/local-acp-listener-CNkguN5-.mjs +0 -2566
  75. package/dist/local-daemon-control-Bg9s2aYi.mjs +0 -1424
  76. package/dist/local-daemon-control-Cu_4FIdd.mjs +0 -1585
  77. package/dist/local-profile-daemon-admin-AXgVH-6y.mjs +0 -91
  78. package/dist/preset-BcWqOtY7.mjs +0 -46
@@ -1,8 +1,9 @@
1
- import { H as cancellationError } from "./prompt-sections-DUKmWb8g.mjs";
2
- import { $ as effectiveWorkflowRunOpen, $r as customItemName, Ar as FILE_ARGUMENT_COMMANDS, At as isTaskItemActive, Bn as createBuiltinFooterRegistry, Dn as workspaceKey, E as FocusTimingStore, Et as buildSessionWorkspaceView, Fn as pickWelcomeWhaleVariant, Fr as attachmentCountLabel, Hn as tasksItem, Jn as QUEUE_CHORDS, Kn as HISTORY_CHORDS, Kr as TSP_FOOTER_NOTICES, L as projectTranscriptStructure, Ln as welcomeWhaleGradientColors, M as consecutiveTurnGroup, N as focusProjectionTurnOf, Nn as shortSessionId, Ot as visibleWorkspaceBrowserRows, P as projectFocus, Q as effectiveWorkflowPhaseOpen, Qn as TSP_CONTINUED_INSPECTION_LABEL, Rn as welcomeWhalePlainLines, S as pastedBodySpan, Tn as sanitizeTerminalText, Tt as SESSION_SOURCE_LABEL, Z as advanceWorkflowDisclosureState, _ as VISUAL_COPY_ROLE, a as dockDraftImageNodes, ar as formatKeyId, b as publishedVisualTitle, br as sanitizeDisplayText, bt as assistantVisualPresentation, c as imageRefProblem, ct as stripAtQuotes, d as visibleTranscriptMembers, dr as PROVIDER_DEFAULT, dt as splitTokenRemainder, er as TSP_SEARCH_CHORD_LABEL, fr as effortChoicesOf, ft as extractInlineSkillPrefix, gr as sanitizedPhysicalLine, hr as projectModelDirectory, i as describeTranscriptMainBlocksForPreset, jn as sanitizeSessionSearchInput, kt as workspaceRowStatusLabel, l as toolRowImageBlocks, lr as isBuiltInPresetRow, lt as isOpenQuotedToken, m as transcriptCopyPayload, n as TranscriptNodeKeys, nr as TSP_VISUAL_COPY_LABEL, o as imageDisplayName, ot as createInstalledAutocompleteProvider, p as TRANSCRIPT_COPY_ACTION, pr as initialEffortOf, r as describeTranscriptMainBlocks, rr as TSP_VISUAL_SELECT_LABEL, rt as workflowRunViewAllVisible, sr as matchesKeyId, st as classifyFileCompletionContext, tr as TSP_VISUAL_CHORDS, tt as workflowPhasePresentations, ur as presetDisplayText, ut as splitQueryRemainder, v as VISUAL_FIGURE_KEY_PREFIX, vt as createHistoryRecallScope, wi as isSurfacedInteractionTool, wn as formatSessionAge, wt as SESSION_PENDING_LABEL, x as PasteRangeTracker, y as VISUAL_FIGURE_ROLE, yn as imageProtocolPreference, yr as sanitizeDisplaySegment, zn as FooterCustomItemCatalog } from "./transcript-view-hvNVkPtv.mjs";
1
+ import { W as cancellationError } from "./prompt-sections-DFS1dqsY.mjs";
2
+ import { $ as advanceWorkflowDisclosureState, $n as TSP_VISUAL_COPY_LABEL, At as workspaceRowStatusLabel, Dr as sanitizeDisplaySegment, Dt as buildSessionWorkspaceView, E as FocusTimingStore, En as sanitizeTerminalText, Et as buildSessionInspectorView, F as focusProjectionTurnOf, Fn as FooterCustomItemCatalog, Gn as QUEUE_CHORDS, Gr as TSP_FOOTER_NOTICES, Hn as HISTORY_CHORDS, I as projectFocus, In as createBuiltinFooterRegistry, Kn as SESSION_WORKSPACE_CHORDS, Nn as welcomeWhaleGradientColors, On as workspaceKey, Or as sanitizeDisplayText, P as focusMaterializedMessages, Pn as welcomeWhalePlainLines, Pr as attachmentCountLabel, Qn as TSP_VISUAL_CHORDS, Qr as customItemName, R as projectTranscriptStructure, Rn as tasksItem, S as pastedBodySpan, Si as isPtcImageContext, St as assistantVisualPresentation, Ti as transcriptTurnOf, Tn as formatSessionAge, Yn as TSP_CONTINUED_INSPECTION_LABEL, Zn as TSP_SEARCH_CHORD_LABEL, _ as VISUAL_COPY_ROLE, a as dockDraftImageNodes, at as workflowRunViewAllVisible, b as publishedVisualTitle, bn as imageProtocolPreference, bt as createHistoryRecallScope, c as imageRefProblem, cr as builtInGuide, ct as createInstalledAutocompleteProvider, d as visibleTranscriptMembers, dr as initialEffortOf, dt as isOpenQuotedToken, er as TSP_VISUAL_SELECT_LABEL, et as effectiveWorkflowPhaseOpen, ft as splitQueryRemainder, i as describeTranscriptMainBlocksForPreset, ir as matchesKeyId, jn as pickWelcomeWhaleVariant, jt as isTaskItemActive, kn as classifySessionBrowserRow, kr as FILE_ARGUMENT_COMMANDS, kt as visibleWorkspaceBrowserRows, l as toolRowImageBlocks, lr as PROVIDER_DEFAULT, lt as classifyFileCompletionContext, m as transcriptCopyPayload, mt as extractInlineSkillPrefix, n as TranscriptNodeKeys, nr as formatKeyId, o as imageDisplayName, or as isBuiltInPresetRow, p as TRANSCRIPT_COPY_ACTION, pr as projectModelDirectory, pt as splitTokenRemainder, r as describeTranscriptMainBlocks, rt as workflowPhasePresentations, sr as presetDisplayText, tt as effectiveWorkflowRunOpen, ur as effortChoicesOf, ut as stripAtQuotes, v as VISUAL_FIGURE_KEY_PREFIX, wi as isSurfacedInteractionTool, wr as sanitizedPhysicalLine, x as PasteRangeTracker, y as VISUAL_FIGURE_ROLE } from "./transcript-view-DSSdE2vK.mjs";
3
3
  import { D as admitSvg, _ as svgDigest, p as authorizeSvg, s as visualFactLine, u as visualPartsFromText } from "./runtime-status-v-FTnWcD.mjs";
4
4
  import { t as runSyncDisposalSteps } from "./disposal-BYBbEpVY.mjs";
5
- import { Ct as hideFooterRefInTsp } from "./extensions-6a5vvJUT.mjs";
5
+ import { Ct as hideFooterRefInTsp } from "./extensions-Dx7ncPNA.mjs";
6
+ import { Q as shortSessionId, X as sanitizeSessionSearchInput } from "./daemon-launcher-DxIgjBHW.mjs";
6
7
  import { View, connect, html, rising, span, ui } from "@stencil-hq/tern";
7
8
  //#region src/tui/tsp/editor.ts
8
9
  /** The grapheme segmenter (`Intl.Segmenter` on Node 24; one shared instance). */
@@ -942,6 +943,18 @@ const HISTORY_SEARCH_FAILURE = "Could not search input history.";
942
943
  * native scroll container grants the real height, so this is a paging step and
943
944
  * never a claim about how many rows the pane shows. */
944
945
  const HISTORY_SEARCH_PAGE_ROWS = 6;
946
+ /** The Remote states whose own control is Retry. A `Down` at any of them (and
947
+ * the visible Retry button) restarts the query from its first page; the seat
948
+ * never continues the stale cursor. A too-long query is edit-only and never
949
+ * starts a retry RPC. */
950
+ const REMOTE_RETRY_STATUSES = /* @__PURE__ */ new Set([
951
+ "loading-host",
952
+ "failed",
953
+ "stale",
954
+ "incomplete",
955
+ "unavailable",
956
+ "denied"
957
+ ]);
945
958
  /** The Scope ring in the frozen `Session → Directory → All → Session` order. A
946
959
  * card opened with no live Session identity never offers `Session` — a Session
947
960
  * Scope without an identity is always empty, so advertising it would lie. */
@@ -1086,22 +1099,24 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1086
1099
  * the SDK dispatches an event by the id of the view it LAST rendered, so an
1087
1100
  * id of an older frame is simply not in the current view. No raw source file
1088
1101
  * path and no result identity ever reaches an HTML key. */
1089
- const actionKeyOf = (owner, token) => `h${owner.openSerial}-r${owner.queryRevision}-${token}`;
1090
- /** An action cell whose meaning depends on WHICH row is highlighted: the
1091
- * selected row's position joins the key, so a repaint that moved the
1092
- * selection retires the old cell's identity along with it. */
1102
+ const actionKeyOf = (owner, token) => `h${owner.openSerial}-r${owner.queryRevision}-p${owner.remoteView?.pageRevision ?? 0}-${token}`;
1103
+ /** An action cell whose meaning depends on WHICH row is highlighted. Both the
1104
+ * selected position and the MATERIAL page identity join the key, so a stale
1105
+ * press cannot resolve to the current handler after a refresh replaced the
1106
+ * row at the same index (even when the query revision did not move). */
1093
1107
  const selectionActionKeyOf = (owner, token) => {
1094
- const index = owner.rows.findIndex((row) => row.id === owner.selectedId);
1095
- return `h${owner.openSerial}-r${owner.queryRevision}-s${index}-${token}`;
1108
+ const index = (owner.remoteView?.rows ?? owner.rows).findIndex((row) => row.id === owner.selectedId);
1109
+ return `h${owner.openSerial}-r${owner.queryRevision}-p${owner.remoteView?.pageRevision ?? 0}-s${index}-${token}`;
1096
1110
  };
1097
1111
  /** The state half of every ACTING entry: this exact card, open, admitted by
1098
1112
  * the mount, and still on the Session scope captured at open. A parked card
1099
1113
  * answers `false`, so a Modal always owns the keys meanwhile. */
1114
+ const remoteScopeCurrent = (owner) => owner.remote === void 0 || owner.scopeCapture.remote?.isCurrent() !== false;
1100
1115
  const operable = (owner) => {
1101
1116
  if (state !== owner || owner.retired) return false;
1102
1117
  if (owner.phase !== "open") return false;
1103
1118
  if (!ports.admitted()) return false;
1104
- return owner.scopeCapture.isCurrent();
1119
+ return owner.scopeCapture.isCurrent() && remoteScopeCurrent(owner);
1105
1120
  };
1106
1121
  const clearTimer = (owner) => {
1107
1122
  if (owner.timer !== void 0) clearTimeout(owner.timer);
@@ -1120,13 +1135,18 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1120
1135
  if (state !== owner || owner.retired || owner.phase !== "open") return;
1121
1136
  ports.requestRender();
1122
1137
  };
1123
- const retire = () => {
1138
+ const retire = (options) => {
1124
1139
  const owner = state;
1125
1140
  if (owner === void 0) return;
1126
1141
  state = void 0;
1127
1142
  owner.retired = true;
1128
1143
  clearTimer(owner);
1129
1144
  abandonPending();
1145
+ owner.remoteUnsubscribe?.();
1146
+ owner.remoteUnsubscribe = void 0;
1147
+ owner.remote?.close(options);
1148
+ owner.remote = void 0;
1149
+ owner.remoteView = void 0;
1130
1150
  frameIds = /* @__PURE__ */ new Map();
1131
1151
  };
1132
1152
  /**
@@ -1141,6 +1161,103 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1141
1161
  retire();
1142
1162
  ports.requestRender();
1143
1163
  };
1164
+ /** The Remote owner's typed state, projected onto this seat's own status. */
1165
+ const projectRemoteStatus = (status) => status === "idle" ? "searching" : status;
1166
+ /** More is an explicit user read: ready page with an older page remaining and
1167
+ * no append in flight. Every other state is a real disabled state. */
1168
+ const remoteMoreEnabled = (view) => view.status === "ready" && view.hasMore && !view.moreLoading;
1169
+ /** Retry is the honest recovery for a failed/stale/incomplete/unavailable/
1170
+ * denied search, and for a selected row whose exact body read failed. */
1171
+ const remoteRetryEnabled = (view) => !view.moreLoading && (REMOTE_RETRY_STATUSES.has(view.status) || (view.status === "ready" || view.status === "partial") && view.body.kind === "failed");
1172
+ /** The one exact body this card may copy or restore: committed, ready and
1173
+ * still the row the painted action belongs to. */
1174
+ const remoteBodyReady = (owner) => {
1175
+ const view = owner.remoteView;
1176
+ if (view === void 0 || view.status !== "ready" && view.status !== "partial" || view.moreLoading) return void 0;
1177
+ const body = view.body;
1178
+ if (body.kind !== "ready") return void 0;
1179
+ if (body.row.id !== view.selectedId) return void 0;
1180
+ return body;
1181
+ };
1182
+ /**
1183
+ * Commit the shared owner's already-decided view into this seat's local
1184
+ * presentation facts. It owns no query/page/body truth of its own: it mirrors
1185
+ * the seat's query revision (so old painted action keys retire), the scope it
1186
+ * decided, the selected row and the row/body/status the view already carries.
1187
+ */
1188
+ const syncRemoteView = (owner) => {
1189
+ const remote = owner.remote;
1190
+ if (state !== owner || owner.retired || remote === void 0) return;
1191
+ const view = remote.view();
1192
+ const previous = owner.remoteView;
1193
+ owner.remoteView = view;
1194
+ owner.scope = view.scope;
1195
+ owner.query = view.query;
1196
+ owner.queryRevision = view.queryRevision;
1197
+ owner.selectedId = view.selectedId;
1198
+ owner.status = projectRemoteStatus(view.status);
1199
+ const selectedBefore = previous?.rows.find((row) => row.id === previous.selectedId);
1200
+ const selectedAfter = view.rows.find((row) => row.id === view.selectedId);
1201
+ const selectedIndexBefore = previous?.rows.findIndex((row) => row.id === view.selectedId) ?? -1;
1202
+ const selectedIndexAfter = view.rows.findIndex((row) => row.id === view.selectedId);
1203
+ const materialChanged = selectedBefore !== void 0 && selectedAfter !== void 0 && (selectedBefore.preview !== selectedAfter.preview || selectedBefore.contentLength !== selectedAfter.contentLength || selectedBefore.contentSha256 !== selectedAfter.contentSha256 || selectedBefore.hasNonText !== selectedAfter.hasNonText);
1204
+ if (view.selectedId !== previous?.selectedId || materialChanged) {
1205
+ owner.previewResetPending = true;
1206
+ owner.revealPending = true;
1207
+ } else if (selectedIndexAfter >= 0 && selectedIndexAfter !== selectedIndexBefore) owner.revealPending = true;
1208
+ change(owner);
1209
+ };
1210
+ /** The Remote seat retired itself because its captured Host scope died. The
1211
+ * mount's existing retire path owns the visible removal and the composer's
1212
+ * caret return; nothing here touches the draft. */
1213
+ const retireFromRemote = (owner) => {
1214
+ if (state !== owner || owner.retired) return;
1215
+ retire();
1216
+ try {
1217
+ ports.requestRender();
1218
+ } catch (error) {
1219
+ try {
1220
+ ports.reportFatal(error);
1221
+ } catch (secondary) {
1222
+ ports.reportSecondaryFailure(error, secondary);
1223
+ }
1224
+ }
1225
+ };
1226
+ const remoteMore = (owner) => {
1227
+ const view = owner.remoteView;
1228
+ if (view === void 0 || !remoteMoreEnabled(view)) return;
1229
+ owner.remote?.more();
1230
+ };
1231
+ const remoteRetry = (owner) => {
1232
+ const view = owner.remoteView;
1233
+ if (view === void 0 || !remoteRetryEnabled(view)) return;
1234
+ owner.remote?.retry();
1235
+ };
1236
+ /** The Remote browse route: an ordinary selection move, the frozen
1237
+ * Down-at-the-tail More, and Down-as-Retry in a failed/stale state. PageUp
1238
+ * and PageDown stay ordinary selection steps and claim no More action. */
1239
+ const remoteBrowse = (owner, step) => {
1240
+ const remote = owner.remote;
1241
+ const view = owner.remoteView;
1242
+ if (remote === void 0 || view === void 0) return;
1243
+ if (step === "down" && (REMOTE_RETRY_STATUSES.has(view.status) || view.body.kind === "failed")) {
1244
+ remoteRetry(owner);
1245
+ return;
1246
+ }
1247
+ if (view.status !== "ready" && view.status !== "partial") return;
1248
+ const rows = view.rows;
1249
+ if (step === "down" && view.selectedId === rows.at(-1)?.id) {
1250
+ if (view.status === "ready") remoteMore(owner);
1251
+ return;
1252
+ }
1253
+ if (rows.length === 0) return;
1254
+ const at = Math.max(0, rows.findIndex((row) => row.id === view.selectedId));
1255
+ const size = step === "page-up" || step === "page-down" ? HISTORY_SEARCH_PAGE_ROWS : 1;
1256
+ const delta = step === "up" || step === "page-up" ? -size : size;
1257
+ const target = rows[Math.min(rows.length - 1, Math.max(0, at + delta))];
1258
+ if (target === void 0 || target.id === view.selectedId) return;
1259
+ remote.select(target.id);
1260
+ };
1144
1261
  const runSearch = (owner, request) => {
1145
1262
  const source = binding?.source;
1146
1263
  if (source === void 0) return;
@@ -1158,7 +1275,7 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1158
1275
  if (state !== owner || owner.retired || pending !== request) return;
1159
1276
  if (request.serial !== owner.openSerial || request.revision !== owner.queryRevision) return;
1160
1277
  try {
1161
- if (owner.scopeCapture.isCurrent() === false) {
1278
+ if (owner.scopeCapture.isCurrent() === false || !remoteScopeCurrent(owner)) {
1162
1279
  retireDiscovered();
1163
1280
  return;
1164
1281
  }
@@ -1185,7 +1302,7 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1185
1302
  if (state !== owner || owner.retired || pending !== request) return;
1186
1303
  if (request.serial !== owner.openSerial || request.revision !== owner.queryRevision) return;
1187
1304
  try {
1188
- if (owner.scopeCapture.isCurrent() === false) {
1305
+ if (owner.scopeCapture.isCurrent() === false || !remoteScopeCurrent(owner)) {
1189
1306
  retireDiscovered();
1190
1307
  return;
1191
1308
  }
@@ -1229,7 +1346,10 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1229
1346
  change(owner);
1230
1347
  };
1231
1348
  /** The Scope ring THIS card offers. */
1232
- const scopeRing = (owner) => SCOPE_RING.filter((entry) => owner.scopeAvailable || entry.scope !== "session").map((entry) => entry.scope);
1349
+ const scopeRing = (owner) => {
1350
+ const directoryAvailable = owner.remote === void 0 ? true : owner.remoteView?.directory.available === true;
1351
+ return SCOPE_RING.filter((entry) => (entry.scope !== "session" || owner.scopeAvailable) && (entry.scope !== "current" || directoryAvailable)).map((entry) => entry.scope);
1352
+ };
1233
1353
  const browse = (owner, step) => {
1234
1354
  if (owner.status !== "ready") return;
1235
1355
  const rows = owner.rows;
@@ -1267,6 +1387,7 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1267
1387
  const owner = state;
1268
1388
  if (owner === void 0 || owner.retired) return;
1269
1389
  if (intent.serial !== owner.openSerial || intent.revision !== owner.queryRevision) return;
1390
+ if (intent.pageRevision !== void 0 && intent.pageRevision !== (owner.remoteView?.pageRevision ?? 0)) return;
1270
1391
  if (!operable(owner)) return;
1271
1392
  switch (intent.kind) {
1272
1393
  case "focus-query":
@@ -1275,15 +1396,30 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1275
1396
  case "query":
1276
1397
  owner.query = intent.query;
1277
1398
  owner.queryCursor = intent.cursor;
1399
+ if (owner.remote !== void 0) {
1400
+ owner.remote.setQuery(intent.query);
1401
+ return;
1402
+ }
1278
1403
  schedule(owner, false);
1279
1404
  return;
1280
1405
  case "scope": {
1281
1406
  const ring = scopeRing(owner);
1282
1407
  owner.scope = ring[(Math.max(0, ring.indexOf(owner.scope)) + intent.delta + ring.length) % ring.length];
1408
+ if (owner.remote !== void 0) {
1409
+ owner.remote.setScope(owner.scope);
1410
+ return;
1411
+ }
1283
1412
  schedule(owner, false);
1284
1413
  return;
1285
1414
  }
1286
1415
  case "select": {
1416
+ if (owner.remote !== void 0) {
1417
+ const view = owner.remoteView;
1418
+ if (view === void 0 || view.status !== "ready" && view.status !== "partial") return;
1419
+ if (!view.rows.some((row) => row.id === intent.rowId)) return;
1420
+ owner.remote.select(intent.rowId);
1421
+ return;
1422
+ }
1287
1423
  if (owner.status !== "ready") return;
1288
1424
  const row = owner.rows.find((candidate) => candidate.id === intent.rowId);
1289
1425
  if (row === void 0 || row.id === owner.selectedId) return;
@@ -1293,8 +1429,19 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1293
1429
  return;
1294
1430
  }
1295
1431
  case "browse":
1432
+ if (owner.remote !== void 0) {
1433
+ remoteBrowse(owner, intent.step);
1434
+ return;
1435
+ }
1296
1436
  browse(owner, intent.step);
1297
1437
  return;
1438
+ case "more": {
1439
+ if (owner.remote === void 0) return;
1440
+ const view = owner.remoteView;
1441
+ if (view === void 0 || intent.page !== view.rows.length) return;
1442
+ remoteMore(owner);
1443
+ return;
1444
+ }
1298
1445
  case "preview-scroll": {
1299
1446
  const id = frameIds.get(containerKeyOf(owner.openSerial, "preview-scroll"));
1300
1447
  if (id !== void 0) ports.scroll(id, intent.to);
@@ -1305,11 +1452,31 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1305
1452
  change(owner);
1306
1453
  return;
1307
1454
  case "retry":
1455
+ if (owner.remote !== void 0) {
1456
+ remoteRetry(owner);
1457
+ return;
1458
+ }
1308
1459
  if (owner.status !== "failed") return;
1309
1460
  schedule(owner, true);
1310
1461
  return;
1311
1462
  case "copy": {
1312
1463
  if (!selectionStillPainted(owner, intent)) return;
1464
+ if (owner.remote !== void 0) {
1465
+ const body = remoteBodyReady(owner);
1466
+ if (body === void 0 || body.row.id !== intent.selectedId || body.text === "") return;
1467
+ const raw = body.text;
1468
+ const rowId = body.row.id;
1469
+ const serial = owner.openSerial;
1470
+ const revision = owner.queryRevision;
1471
+ ports.copyRaw(raw, () => {
1472
+ const live = state;
1473
+ if (live === void 0 || live.retired || live.remote === void 0) return false;
1474
+ if (live.phase !== "open" && live.phase !== "parked" || live.openSerial !== serial || live.queryRevision !== revision || live.selectedId !== rowId || !live.scopeCapture.isCurrent() || !remoteScopeCurrent(live)) return false;
1475
+ const current = remoteBodyReady(live);
1476
+ return current !== void 0 && current.row.id === rowId && current.text === raw;
1477
+ });
1478
+ return;
1479
+ }
1313
1480
  const row = settledSelected(owner);
1314
1481
  if (row === void 0) return;
1315
1482
  const raw = row.content;
@@ -1324,6 +1491,22 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1324
1491
  }
1325
1492
  case "restore": {
1326
1493
  if (!selectionStillPainted(owner, intent)) return;
1494
+ if (owner.remote !== void 0) {
1495
+ const body = remoteBodyReady(owner);
1496
+ if (body === void 0 || body.row.id !== intent.selectedId || body.text === "") return;
1497
+ const raw = body.text;
1498
+ if (!ports.composerWritable()) return;
1499
+ if (!owner.scopeCapture.isCurrent()) return;
1500
+ const remoteScope = owner.scopeCapture.remote;
1501
+ try {
1502
+ retire({ preserveScope: true });
1503
+ if (remoteScope?.isCurrent() !== true) return;
1504
+ ports.restoreToComposer(raw);
1505
+ } finally {
1506
+ remoteScope?.dispose();
1507
+ }
1508
+ return;
1509
+ }
1327
1510
  const row = settledSelected(owner);
1328
1511
  if (row === void 0) return;
1329
1512
  const raw = row.content;
@@ -1346,7 +1529,7 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1346
1529
  const handleKey = (key) => {
1347
1530
  const owner = state;
1348
1531
  if (owner === void 0 || owner.retired || owner.phase !== "open") return false;
1349
- if (!ports.admitted() || !owner.scopeCapture.isCurrent()) {
1532
+ if (!ports.admitted() || !owner.scopeCapture.isCurrent() || !remoteScopeCurrent(owner)) {
1350
1533
  retireDiscovered();
1351
1534
  return false;
1352
1535
  }
@@ -1357,34 +1540,40 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1357
1540
  const keyIntent = (owner, key) => {
1358
1541
  const serial = owner.openSerial;
1359
1542
  const revision = owner.queryRevision;
1543
+ const pageRevision = owner.remoteView?.pageRevision ?? 0;
1360
1544
  if (key.name === "escape") return {
1361
1545
  kind: "close",
1362
1546
  serial,
1363
- revision
1547
+ revision,
1548
+ pageRevision
1364
1549
  };
1365
1550
  if (key.ctrl === true && key.name === "c" && !key.alt && !key.meta && !key.shift) return {
1366
1551
  kind: "close",
1367
1552
  serial,
1368
- revision
1553
+ revision,
1554
+ pageRevision
1369
1555
  };
1370
1556
  if (key.ctrl === true && key.name === "r" && !key.alt && !key.meta) return {
1371
1557
  kind: "focus-query",
1372
1558
  serial,
1373
- revision
1559
+ revision,
1560
+ pageRevision
1374
1561
  };
1375
1562
  if (key.alt === true && key.ctrl !== true && key.meta !== true) {
1376
1563
  if (key.name === "c" && !key.shift) return {
1377
1564
  kind: "copy",
1378
1565
  selectedId: owner.selectedId,
1379
1566
  serial,
1380
- revision
1567
+ revision,
1568
+ pageRevision
1381
1569
  };
1382
1570
  const previewStep = key.name === "up" ? "line-up" : key.name === "down" ? "line-down" : key.name === "page_up" ? "page-up" : key.name === "page_down" ? "page-down" : key.name === "home" ? "start" : key.name === "end" ? "end" : void 0;
1383
1571
  if (previewStep !== void 0) return {
1384
1572
  kind: "preview-scroll",
1385
1573
  to: previewStep,
1386
1574
  serial,
1387
- revision
1575
+ revision,
1576
+ pageRevision
1388
1577
  };
1389
1578
  return;
1390
1579
  }
@@ -1393,42 +1582,49 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1393
1582
  kind: "scope",
1394
1583
  delta: key.shift === true ? -1 : 1,
1395
1584
  serial,
1396
- revision
1585
+ revision,
1586
+ pageRevision
1397
1587
  };
1398
1588
  if (key.name === "f2") return {
1399
1589
  kind: "expand",
1400
1590
  serial,
1401
- revision
1591
+ revision,
1592
+ pageRevision
1402
1593
  };
1403
1594
  if (key.name === "enter") return {
1404
1595
  kind: "restore",
1405
1596
  selectedId: owner.selectedId,
1406
1597
  serial,
1407
- revision
1598
+ revision,
1599
+ pageRevision
1408
1600
  };
1409
1601
  if (key.name === "up") return {
1410
1602
  kind: "browse",
1411
1603
  step: "up",
1412
1604
  serial,
1413
- revision
1605
+ revision,
1606
+ pageRevision
1414
1607
  };
1415
1608
  if (key.name === "down") return {
1416
1609
  kind: "browse",
1417
1610
  step: "down",
1418
1611
  serial,
1419
- revision
1612
+ revision,
1613
+ pageRevision
1420
1614
  };
1421
1615
  if (key.name === "page_up") return {
1422
1616
  kind: "browse",
1423
1617
  step: "page-up",
1424
1618
  serial,
1425
- revision
1619
+ revision,
1620
+ pageRevision
1426
1621
  };
1427
1622
  if (key.name === "page_down") return {
1428
1623
  kind: "browse",
1429
1624
  step: "page-down",
1430
1625
  serial,
1431
- revision
1626
+ revision,
1627
+ pageRevision
1432
1628
  };
1433
1629
  if (key.shift === true) return void 0;
1434
1630
  const edited = editQuery$4(owner.query, owner.queryCursor, key);
@@ -1437,13 +1633,91 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1437
1633
  query: edited.query,
1438
1634
  cursor: edited.cursor,
1439
1635
  serial,
1440
- revision
1636
+ revision,
1637
+ pageRevision
1638
+ };
1639
+ };
1640
+ /** The Preview of the shared Remote owner's selected row: the bounded preview
1641
+ * until the exact body is verified, then the exact text. Copy/Restore read
1642
+ * the raw body, never this sanitized projection. */
1643
+ const remotePreview = (body, row) => {
1644
+ const text = body.kind === "ready" ? body.text : body.kind === "failed" ? body.preview : body.kind === "loading" ? body.preview : row.preview;
1645
+ const notice = body.kind === "failed" ? body.message : body.kind === "ready" ? body.text === "" ? "No text to restore" : body.hasNonText ? "Text only · attachments not restored" : void 0 : void 0;
1646
+ return {
1647
+ text: sanitizeDisplayText(text),
1648
+ directory: `Directory: ${row.effectiveCwd === null ? "unknown" : sanitizedPhysicalLine(row.effectiveCwd)}`,
1649
+ time: `Time: ${previewTime(row.acceptedAt)}`,
1650
+ session: `Session: ${sanitizedPhysicalLine(row.sessionId)}`,
1651
+ ...notice === void 0 ? {} : { notice: sanitizedPhysicalLine(notice) }
1652
+ };
1653
+ };
1654
+ const remoteRenderState = (owner) => {
1655
+ const view = owner.remoteView;
1656
+ if (view === void 0) return void 0;
1657
+ const now = Date.now();
1658
+ const painted = view.rows.map((row, index) => ({
1659
+ id: row.id,
1660
+ key: actionKeyOf(owner, `o${index}`),
1661
+ summary: rowSummary(row.preview),
1662
+ time: shortTime(row.acceptedAt, now),
1663
+ directory: row.effectiveCwd === null ? "" : shortCwd(row.effectiveCwd),
1664
+ selected: row.id === view.selectedId
1665
+ }));
1666
+ const exact = remoteBodyReady(owner);
1667
+ const selectedRow = view.rows.find((row) => row.id === view.selectedId);
1668
+ const preview = selectedRow === void 0 ? void 0 : remotePreview(view.body, selectedRow);
1669
+ const status = projectRemoteStatus(view.status);
1670
+ const header = view.status === "ready" ? view.moreLoading ? `Results · ${String(view.rows.length)} shown · Loading more…` : sanitizedPhysicalLine(view.message === "" ? `Results · ${String(view.rows.length)} shown` : view.message) : sanitizedPhysicalLine(view.message === "" ? "Searching…" : view.message);
1671
+ const headerCompact = view.status === "partial" && view.progress !== void 0 ? (() => {
1672
+ const { settled, total } = view.progress;
1673
+ const percent = total === 0 ? 0 : Math.floor(settled * 100 / total);
1674
+ return view.rows.length === 0 ? "No matches yet — indexing…" : `Indexing ${String(settled)}/${String(total)} (${String(percent)}%)`;
1675
+ })() : header;
1676
+ return {
1677
+ serial: owner.openSerial,
1678
+ revision: owner.queryRevision,
1679
+ pageRevision: view.pageRevision,
1680
+ scope: SCOPE_LABELS[view.scope],
1681
+ scopeKey: actionKeyOf(owner, "scope"),
1682
+ expandKey: actionKeyOf(owner, "expand"),
1683
+ closeKey: actionKeyOf(owner, "close"),
1684
+ queryKey: queryKeyOf(owner.openSerial),
1685
+ query: owner.query,
1686
+ queryCursor: owner.queryCursor,
1687
+ status,
1688
+ expanded: owner.expanded,
1689
+ selectedId: view.selectedId,
1690
+ resultsKey: containerKeyOf(owner.openSerial, "results-scroll"),
1691
+ previewKey: containerKeyOf(owner.openSerial, "preview-scroll"),
1692
+ header,
1693
+ headerCompact,
1694
+ rows: painted,
1695
+ empty: void 0,
1696
+ failure: void 0,
1697
+ preview,
1698
+ previewHeading: view.body.kind === "ready" ? "Preview" : view.body.kind === "failed" ? "Preview · exact text unavailable" : "Preview · Loading full text…",
1699
+ hint: `${HISTORY_CHORDS.scope.label} scope · ${HISTORY_CHORDS.results.label} select · ${HISTORY_CHORDS.preview.label} preview · ${HISTORY_CHORDS.copy.label} copy · ${HISTORY_CHORDS.expand.label} ${owner.expanded ? "collapse" : "expand"} · ${HISTORY_CHORDS.accept.label} restore · ${HISTORY_CHORDS.cancel.label} cancel`,
1700
+ copyLabel: `Copy all · ${HISTORY_CHORDS.copy.label}`,
1701
+ copyKey: selectionActionKeyOf(owner, "copy"),
1702
+ restoreLabel: `Restore to draft · ${HISTORY_CHORDS.accept.label}`,
1703
+ restoreKey: selectionActionKeyOf(owner, "restore"),
1704
+ retryLabel: "Retry · ↓",
1705
+ retryKey: actionKeyOf(owner, `retry-${view.status}-${view.body.kind}`),
1706
+ retryEnabled: remoteRetryEnabled(view),
1707
+ actionsEnabled: exact !== void 0 && exact.text !== "",
1708
+ remote: true,
1709
+ moreLabel: "More · ↓",
1710
+ moreKey: actionKeyOf(owner, `more-${String(view.rows.length)}-${view.moreLoading ? "loading" : "idle"}-${view.hasMore ? "more" : "end"}`),
1711
+ moreEnabled: remoteMoreEnabled(view),
1712
+ moreLoading: view.moreLoading,
1713
+ page: view.rows.length
1441
1714
  };
1442
1715
  };
1443
1716
  const renderState = () => {
1444
1717
  const owner = state;
1445
1718
  if (owner === void 0 || owner.retired) return void 0;
1446
- if (owner.phase !== "open" || !ports.admitted() || !owner.scopeCapture.isCurrent()) return void 0;
1719
+ if (owner.phase !== "open" || !ports.admitted() || !owner.scopeCapture.isCurrent() || !remoteScopeCurrent(owner)) return void 0;
1720
+ if (owner.remote !== void 0) return remoteRenderState(owner);
1447
1721
  const rows = owner.rows;
1448
1722
  const now = Date.now();
1449
1723
  const painted = rows.map((row, index) => ({
@@ -1466,6 +1740,7 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1466
1740
  return {
1467
1741
  serial: owner.openSerial,
1468
1742
  revision: owner.queryRevision,
1743
+ pageRevision: 0,
1469
1744
  scope: SCOPE_LABELS[owner.scope],
1470
1745
  scopeKey: actionKeyOf(owner, "scope"),
1471
1746
  expandKey: actionKeyOf(owner, "expand"),
@@ -1479,10 +1754,12 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1479
1754
  resultsKey: containerKeyOf(owner.openSerial, "results-scroll"),
1480
1755
  previewKey: containerKeyOf(owner.openSerial, "preview-scroll"),
1481
1756
  header,
1757
+ headerCompact: header,
1482
1758
  rows: painted,
1483
1759
  empty,
1484
1760
  failure: owner.status === "failed" ? HISTORY_SEARCH_FAILURE : void 0,
1485
1761
  preview,
1762
+ previewHeading: "Preview",
1486
1763
  hint: `${HISTORY_CHORDS.scope.label} scope · ${HISTORY_CHORDS.results.label} select · ${HISTORY_CHORDS.preview.label} preview · ${HISTORY_CHORDS.copy.label} copy · ${HISTORY_CHORDS.expand.label} ${owner.expanded ? "collapse" : "expand"} · ${HISTORY_CHORDS.accept.label} restore · ${HISTORY_CHORDS.cancel.label} cancel`,
1487
1764
  copyLabel: `Copy all · ${HISTORY_CHORDS.copy.label}`,
1488
1765
  copyKey: selectionActionKeyOf(owner, "copy"),
@@ -1490,7 +1767,14 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1490
1767
  restoreKey: selectionActionKeyOf(owner, "restore"),
1491
1768
  retryLabel: "Retry",
1492
1769
  retryKey: actionKeyOf(owner, "retry"),
1493
- actionsEnabled: selected !== void 0
1770
+ retryEnabled: owner.status === "failed",
1771
+ actionsEnabled: selected !== void 0,
1772
+ remote: false,
1773
+ moreLabel: "",
1774
+ moreKey: "",
1775
+ moreEnabled: false,
1776
+ moreLoading: false,
1777
+ page: 0
1494
1778
  };
1495
1779
  };
1496
1780
  const indexFrame = (dockRoot) => {
@@ -1504,7 +1788,8 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1504
1788
  containerKeyOf(owner.openSerial, "results-scroll"),
1505
1789
  containerKeyOf(owner.openSerial, "preview-scroll")
1506
1790
  ]);
1507
- owner.rows.forEach((_, index) => wanted.add(actionKeyOf(owner, `o${index}`)));
1791
+ const rowCount = owner.remoteView?.rows.length ?? owner.rows.length;
1792
+ for (let index = 0; index < rowCount; index += 1) wanted.add(actionKeyOf(owner, `o${index}`));
1508
1793
  const visit = (tree) => {
1509
1794
  const key = tree.props["key"];
1510
1795
  if (typeof key === "string" && wanted.has(key)) frameIds.set(key, tree.id);
@@ -1513,7 +1798,7 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1513
1798
  visit(root);
1514
1799
  if (owner.revealPending) {
1515
1800
  owner.revealPending = false;
1516
- const at = owner.rows.findIndex((row) => row.id === owner.selectedId);
1801
+ const at = (owner.remoteView?.rows ?? owner.rows).findIndex((row) => row.id === owner.selectedId);
1517
1802
  const id = at < 0 ? void 0 : frameIds.get(actionKeyOf(owner, `o${at}`));
1518
1803
  if (id !== void 0) ports.reveal(id);
1519
1804
  }
@@ -1527,12 +1812,12 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1527
1812
  isOpen: () => {
1528
1813
  const owner = state;
1529
1814
  if (owner === void 0 || owner.retired || owner.phase !== "open") return false;
1530
- if (!owner.scopeCapture.isCurrent()) return false;
1815
+ if (!owner.scopeCapture.isCurrent() || !remoteScopeCurrent(owner)) return false;
1531
1816
  return ports.admitted();
1532
1817
  },
1533
1818
  holdsSeat: () => {
1534
1819
  const owner = state;
1535
- return owner !== void 0 && !owner.retired && (owner.phase === "open" || owner.phase === "parked") && owner.scopeCapture.isCurrent();
1820
+ return owner !== void 0 && !owner.retired && (owner.phase === "open" || owner.phase === "parked") && owner.scopeCapture.isCurrent() && remoteScopeCurrent(owner);
1536
1821
  },
1537
1822
  supported: () => binding !== void 0 && nativeSupported(),
1538
1823
  handleKey,
@@ -1544,7 +1829,10 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1544
1829
  if (bundle === void 0) return;
1545
1830
  retire();
1546
1831
  const scopeCapture = bundle.captureScope();
1547
- const scope = scopeCapture.sessionId === void 0 ? "current" : "session";
1832
+ const remoteScope = scopeCapture.remote;
1833
+ const read = bundle.read;
1834
+ const diag = bundle.diag;
1835
+ const scope = remoteScope === void 0 ? scopeCapture.sessionId === void 0 ? "current" : "session" : scopeCapture.sessionId === void 0 ? "all" : "session";
1548
1836
  const owner = {
1549
1837
  phase: "open",
1550
1838
  openSerial: ++openSerial,
@@ -1563,10 +1851,34 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1563
1851
  timer: void 0,
1564
1852
  revealPending: false,
1565
1853
  previewResetPending: false,
1854
+ remote: void 0,
1855
+ remoteView: void 0,
1856
+ remoteUnsubscribe: void 0,
1566
1857
  retired: false
1567
1858
  };
1568
1859
  state = owner;
1569
- schedule(owner, true);
1860
+ if (remoteScope !== void 0) {
1861
+ if (read !== void 0 && diag !== void 0) {
1862
+ const createRemoteSeat = binding?.createRemoteSeat;
1863
+ if (createRemoteSeat === void 0) throw new Error("the Remote History seat factory is unavailable");
1864
+ const remote = createRemoteSeat({
1865
+ read,
1866
+ diag,
1867
+ sessionId: scopeCapture.sessionId,
1868
+ scope: remoteScope,
1869
+ onRetire: () => {
1870
+ retireFromRemote(owner);
1871
+ }
1872
+ });
1873
+ owner.remote = remote;
1874
+ owner.remoteView = remote.view();
1875
+ owner.remoteUnsubscribe = remote.subscribe(() => {
1876
+ syncRemoteView(owner);
1877
+ });
1878
+ remote.open(scope, owner.query);
1879
+ syncRemoteView(owner);
1880
+ }
1881
+ } else schedule(owner, true);
1570
1882
  ports.setFocus();
1571
1883
  },
1572
1884
  syncBlocker: (blocked) => {
@@ -1581,7 +1893,7 @@ function createTspHistorySearch(ports, binding, nativeSupported) {
1581
1893
  return false;
1582
1894
  }
1583
1895
  if (owner.phase !== "parked") return false;
1584
- if (!owner.scopeCapture.isCurrent()) {
1896
+ if (!owner.scopeCapture.isCurrent() || !remoteScopeCurrent(owner)) {
1585
1897
  retire();
1586
1898
  return false;
1587
1899
  }
@@ -1641,11 +1953,16 @@ const HISTORY_SEARCH_ROLES = {
1641
1953
  body: "dsh.history.body",
1642
1954
  results: "dsh.history.results",
1643
1955
  resultsHead: "dsh.history.results-head",
1956
+ /** The same heading row while a first-cold partial page is painted. It is not
1957
+ * hidden by the short-pane compression, so the indexing fact stays visible. */
1958
+ resultsHeadProgress: "dsh.history.results-head-progress",
1644
1959
  resultsScroll: "dsh.history.results-scroll",
1645
1960
  row: "dsh.history.row",
1646
1961
  rowText: "dsh.history.row-text",
1647
1962
  rowMeta: "dsh.history.row-meta",
1648
1963
  status: "dsh.history.status",
1964
+ pageActions: "dsh.history.page-actions",
1965
+ more: "dsh.history.more",
1649
1966
  preview: "dsh.history.preview",
1650
1967
  previewHead: "dsh.history.preview-head",
1651
1968
  previewScroll: "dsh.history.preview-scroll",
@@ -1661,7 +1978,7 @@ const HISTORY_SEARCH_ROLES = {
1661
1978
  /** One results row: a real button, so a click is a client-recognized control
1662
1979
  * and never blue text pretending to be one. A row click SELECTS; only the
1663
1980
  * explicit `Restore to draft` cell writes the Composer. */
1664
- function resultRow(row, onIntent, revision, serial) {
1981
+ function resultRow(row, onIntent, revision, serial, pageRevision) {
1665
1982
  const marks = [row.time, row.directory].filter((mark) => mark !== "");
1666
1983
  const title = marks.length === 0 ? row.summary : `${row.summary} · ${marks.join(" · ")}`;
1667
1984
  return html.button({
@@ -1674,7 +1991,8 @@ function resultRow(row, onIntent, revision, serial) {
1674
1991
  kind: "select",
1675
1992
  rowId: row.id,
1676
1993
  serial,
1677
- revision
1994
+ revision,
1995
+ pageRevision
1678
1996
  })
1679
1997
  }, html.span({ role: HISTORY_SEARCH_ROLES.rowText }, `${row.selected ? "›" : " "}${row.summary}`), ...marks.length === 0 ? [] : [html.span({ role: HISTORY_SEARCH_ROLES.rowMeta }, marks.join(" · "))]);
1680
1998
  }
@@ -1696,29 +2014,50 @@ function historySearchView(input) {
1696
2014
  const { state, onIntent } = input;
1697
2015
  const revision = state.revision;
1698
2016
  const serial = state.serial;
2017
+ const pageRevision = state.pageRevision;
1699
2018
  const resultsBody = [];
1700
- for (const row of state.rows) resultsBody.push(resultRow(row, onIntent, revision, serial));
2019
+ for (const row of state.rows) resultsBody.push(resultRow(row, onIntent, revision, serial, pageRevision));
1701
2020
  if (state.empty !== void 0) resultsBody.push(ui.text({
1702
2021
  key: `h${serial}-empty`,
1703
2022
  role: HISTORY_SEARCH_ROLES.status,
1704
2023
  wrap: "none",
1705
2024
  text: state.empty
1706
2025
  }));
2026
+ const pageButtons = [];
2027
+ if (state.remote && (state.moreEnabled || state.moreLoading)) pageButtons.push(chromeButton$1(state.moreKey, HISTORY_SEARCH_ROLES.more, state.moreLabel, state.moreEnabled ? "Load the next page of history" : "Loading the next page of history", state.moreEnabled, () => onIntent({
2028
+ kind: "more",
2029
+ page: state.page,
2030
+ serial,
2031
+ revision,
2032
+ pageRevision
2033
+ })));
2034
+ if (state.remote && state.retryEnabled) pageButtons.push(chromeButton$1(state.retryKey, HISTORY_SEARCH_ROLES.retry, state.retryLabel, "Search this scope and query again", true, () => onIntent({
2035
+ kind: "retry",
2036
+ serial,
2037
+ revision,
2038
+ pageRevision
2039
+ })));
2040
+ const pageActions = pageButtons.length === 0 ? void 0 : ui.row({
2041
+ key: `h${serial}-page-actions`,
2042
+ role: HISTORY_SEARCH_ROLES.pageActions,
2043
+ gap: "sm",
2044
+ align: "center"
2045
+ }, ...pageButtons);
1707
2046
  const results = ui.col({
1708
2047
  key: `h${serial}-results`,
1709
2048
  role: HISTORY_SEARCH_ROLES.results,
1710
2049
  gap: "none"
1711
2050
  }, ui.text({
1712
2051
  key: `h${serial}-results-head`,
1713
- role: HISTORY_SEARCH_ROLES.resultsHead,
2052
+ role: state.status === "partial" ? HISTORY_SEARCH_ROLES.resultsHeadProgress : HISTORY_SEARCH_ROLES.resultsHead,
1714
2053
  wrap: "none",
1715
- text: state.header
2054
+ text: input.wide ? state.header : state.headerCompact
1716
2055
  }), ui.scroll({
1717
2056
  key: state.resultsKey,
1718
2057
  role: HISTORY_SEARCH_ROLES.resultsScroll,
1719
2058
  variant: "bar",
1720
2059
  gap: "none"
1721
- }, ...resultsBody));
2060
+ }, ...resultsBody), ...pageActions === void 0 ? [] : [pageActions]);
1722
2061
  const previewBody = [];
1723
2062
  if (state.preview !== void 0) {
1724
2063
  previewBody.push(ui.text({
@@ -1745,6 +2084,12 @@ function historySearchView(input) {
1745
2084
  wrap: "none",
1746
2085
  text: state.preview.session
1747
2086
  }));
2087
+ if (state.preview.notice !== void 0) previewBody.push(ui.text({
2088
+ key: `h${serial}-preview-notice`,
2089
+ role: HISTORY_SEARCH_ROLES.previewMeta,
2090
+ wrap: "none",
2091
+ text: state.preview.notice
2092
+ }));
1748
2093
  } else previewBody.push(ui.text({
1749
2094
  key: `h${serial}-preview-none`,
1750
2095
  role: HISTORY_SEARCH_ROLES.previewMeta,
@@ -1759,7 +2104,7 @@ function historySearchView(input) {
1759
2104
  key: `h${serial}-preview-head`,
1760
2105
  role: HISTORY_SEARCH_ROLES.previewHead,
1761
2106
  wrap: "none",
1762
- text: "Preview"
2107
+ text: state.previewHeading
1763
2108
  }), ui.scroll({
1764
2109
  key: state.previewKey,
1765
2110
  role: HISTORY_SEARCH_ROLES.previewScroll,
@@ -1806,15 +2151,18 @@ function historySearchView(input) {
1806
2151
  kind: "scope",
1807
2152
  delta: 1,
1808
2153
  serial,
1809
- revision
2154
+ revision,
2155
+ pageRevision
1810
2156
  })), chromeButton$1(state.expandKey, HISTORY_SEARCH_ROLES.expand, state.expanded ? "Collapse" : "Expand", state.expanded ? "Collapse the history card" : "Expand the history card", true, () => onIntent({
1811
2157
  kind: "expand",
1812
2158
  serial,
1813
- revision
2159
+ revision,
2160
+ pageRevision
1814
2161
  })), chromeButton$1(state.closeKey, HISTORY_SEARCH_ROLES.close, "×", "Close history search", true, () => onIntent({
1815
2162
  kind: "close",
1816
2163
  serial,
1817
- revision
2164
+ revision,
2165
+ pageRevision
1818
2166
  })))), ui.input({
1819
2167
  key: state.queryKey,
1820
2168
  role: HISTORY_SEARCH_ROLES.query,
@@ -1825,7 +2173,8 @@ function historySearchView(input) {
1825
2173
  onFocus: () => onIntent({
1826
2174
  kind: "focus-query",
1827
2175
  serial,
1828
- revision
2176
+ revision,
2177
+ pageRevision
1829
2178
  })
1830
2179
  }), body, ui.row({
1831
2180
  key: `h${serial}-actions`,
@@ -1840,7 +2189,8 @@ function historySearchView(input) {
1840
2189
  }), ...state.failure === void 0 ? [] : [chromeButton$1(state.retryKey, HISTORY_SEARCH_ROLES.retry, state.retryLabel, "Search this scope and query again", true, () => onIntent({
1841
2190
  kind: "retry",
1842
2191
  serial,
1843
- revision
2192
+ revision,
2193
+ pageRevision
1844
2194
  }))], ui.row({
1845
2195
  key: `h${serial}-actions-end`,
1846
2196
  role: HISTORY_SEARCH_ROLES.actionsEnd,
@@ -1850,12 +2200,14 @@ function historySearchView(input) {
1850
2200
  kind: "copy",
1851
2201
  selectedId: state.selectedId,
1852
2202
  serial,
1853
- revision
2203
+ revision,
2204
+ pageRevision
1854
2205
  })), chromeButton$1(state.restoreKey, HISTORY_SEARCH_ROLES.restore, state.restoreLabel, state.actionsEnabled ? "Restore the selected entry into the composer; it never sends it" : "Select a settled history entry to restore it", state.actionsEnabled, () => onIntent({
1855
2206
  kind: "restore",
1856
2207
  selectedId: state.selectedId,
1857
2208
  serial,
1858
- revision
2209
+ revision,
2210
+ pageRevision
1859
2211
  })))));
1860
2212
  }
1861
2213
  /** The ONE scoped sheet. Layout budgets are the v3 Polish candidate figures
@@ -1912,7 +2264,8 @@ const HISTORY_SEARCH_STYLES = `
1912
2264
  [data-role='dsh.history.close'],
1913
2265
  [data-role='dsh.history.copy'],
1914
2266
  [data-role='dsh.history.restore'],
1915
- [data-role='dsh.history.retry'] {
2267
+ [data-role='dsh.history.retry'],
2268
+ [data-role='dsh.history.more'] {
1916
2269
  display: inline-flex;
1917
2270
  align-items: center;
1918
2271
  gap: 4px;
@@ -1930,17 +2283,30 @@ const HISTORY_SEARCH_STYLES = `
1930
2283
  [data-role='dsh.history.scope']:hover,
1931
2284
  [data-role='dsh.history.expand']:hover,
1932
2285
  [data-role='dsh.history.close']:hover,
1933
- [data-role='dsh.history.retry']:hover {
2286
+ [data-role='dsh.history.retry']:hover,
2287
+ [data-role='dsh.history.more']:hover {
1934
2288
  background: var(--l1);
1935
2289
  color: var(--t1);
1936
2290
  }
1937
2291
  [data-role='dsh.history.scope'][aria-disabled='true'],
1938
2292
  [data-role='dsh.history.copy'][aria-disabled='true'],
1939
- [data-role='dsh.history.restore'][aria-disabled='true'] {
2293
+ [data-role='dsh.history.restore'][aria-disabled='true'],
2294
+ [data-role='dsh.history.retry'][aria-disabled='true'],
2295
+ [data-role='dsh.history.more'][aria-disabled='true'] {
1940
2296
  color: var(--t4);
1941
2297
  border-color: var(--l1);
1942
2298
  cursor: not-allowed;
1943
2299
  }
2300
+ /* The Remote paging row is a fixed non-shrinking row inside the results
2301
+ region, exactly like the region heading; the scroll area above it owns the
2302
+ only flexible space. */
2303
+ [data-role='dsh.history.page-actions'] {
2304
+ display: flex;
2305
+ align-items: center;
2306
+ gap: 8px;
2307
+ flex-shrink: 0;
2308
+ padding-top: 2px;
2309
+ }
1944
2310
  /* The primary verb is the filled one, and it is never called Send or Run. */
1945
2311
  [data-role='dsh.history.restore'] {
1946
2312
  border-color: var(--accent);
@@ -1992,10 +2358,12 @@ const HISTORY_SEARCH_STYLES = `
1992
2358
  flex: 1 1 0;
1993
2359
  }
1994
2360
  [data-role='dsh.history.results-head'],
2361
+ [data-role='dsh.history.results-head-progress'],
1995
2362
  [data-role='dsh.history.preview-head'] {
1996
2363
  flex-shrink: 0;
1997
2364
  }
1998
2365
  [data-role='dsh.history.results-head'],
2366
+ [data-role='dsh.history.results-head-progress'],
1999
2367
  [data-role='dsh.history.preview-head'] {
2000
2368
  color: var(--t3);
2001
2369
  font-family: var(--sans);
@@ -2103,6 +2471,7 @@ const HISTORY_SEARCH_STYLES = `
2103
2471
  [data-role='dsh.history.hint'] { display: none; }
2104
2472
  [data-role='dsh.history.results-head'],
2105
2473
  [data-role='dsh.history.preview-head'] { display: none; }
2474
+ [data-role='dsh.history.results-head-progress'] { display: block; padding: 0; font-size: 10px; }
2106
2475
  /* At a short pane the expansion may only take what the pane can spare:
2107
2476
  measured on the real client at 900x360, a 62vh budget grew the card by
2108
2477
  50px and left 12.8px of the 33px composer visible. The dock keeps the
@@ -7413,139 +7782,6 @@ var TspModelQuickMenu = class {
7413
7782
  }
7414
7783
  };
7415
7784
  //#endregion
7416
- //#region src/tui/tsp/preset-guide-content.ts
7417
- /** The official English Mode Guides of the four SHIPPED presets.
7418
- *
7419
- * The copy is a verbatim transcription of the official Web surface's curated
7420
- * help, pinned to
7421
- * `deepseek-ai/deepseek-harness@d743267388641bc76f17c45ce8b4c231aed1d32c`
7422
- * `packages/client/ui-agent-preset/src/client/guide-locales.ts` (the `guideEn`
7423
- * seat): the intro, the mode explanation and the usage examples, unchanged.
7424
- * Refreshing the official wording means refreshing that pin — this module never
7425
- * translates, rewrites or generates guide text of its own.
7426
- *
7427
- * Source license: the upstream repository is MIT (`Copyright (c) 2026
7428
- * DeepSeek`); this transcription keeps the upstream wording and attributes the
7429
- * source in this header rather than duplicating a license file, per the
7430
- * repository's vendoring-attribution practice for small quoted excerpts.
7431
- *
7432
- * The Guide is READ-ONLY static content: it is not part of the live roster and
7433
- * carries no business authority. A Custom declaration that reuses a shipped id
7434
- * must never borrow an official Guide, so the lookup requires the caller's
7435
- * ALREADY-DERIVED shipped classification instead of trusting the id alone.
7436
- * @module tui/tsp/preset-guide-content
7437
- */
7438
- /** The two Markdown sections the official Web dialog renders, in order. */
7439
- const GUIDE_SECTION_HEADS = {
7440
- modeDetails: "Mode details",
7441
- howToUse: "How to use"
7442
- };
7443
- /** The four shipped presets' pinned official copy, keyed by shipped id. */
7444
- const BUILT_IN_GUIDES = {
7445
- standard: {
7446
- intro: "Choose Standard mode when starting a new task. Describe what you want to accomplish, point to the relevant files, and explain how to check the result.",
7447
- explanation: [
7448
- "### How it works",
7449
- "The agent calls tools directly to read and edit files, search, and run terminal commands. It includes Skills, planning, goals, subagents, workflows, and context compaction.",
7450
- "### When to choose it",
7451
- "Start here for everyday coding, file work, and research. Standard mode can also write scripts and process files in batches. PTC changes how tool calls are organized; it is not required for batch tasks."
7452
- ].join("\n\n"),
7453
- usage: [
7454
- "### Fix a bug",
7455
- "> Find out why submitting the search form twice makes the results disappear. Fix it and run the relevant tests. Explain the cause and what changed.",
7456
- "Expected output: a code change, the relevant test results, and an explanation of the cause.",
7457
- "### Organize project notes",
7458
- "> Read the Markdown notes in this project. Summarize the agreed decisions and open questions, with links to the source files.",
7459
- "Expected output: a summary with references that you can check against the original notes."
7460
- ].join("\n\n")
7461
- },
7462
- ptc: {
7463
- intro: "Choose PTC mode when starting a new task. Specify the input files, processing rules, and output format. The agent writes the code.",
7464
- explanation: [
7465
- "### How tools are called",
7466
- "PTC means Programmatic Tool Calling. In this built-in preset, the agent uses run_code to write a TypeScript program that calls tools through a generated SDK. The program can use loops, conditions, error handling, and concurrent calls where appropriate.",
7467
- "### What reaches the model",
7468
- "Tool results first reach the program, which can filter and combine them. The model receives what the program prints or returns; image results are attached separately. Nested tool calls are still recorded and remain subject to tool permissions.",
7469
- "### Compared with Standard mode",
7470
- "Both modes can handle coding and batch tasks. Standard mode exposes individual tools directly; PTC organizes tool calls in code. The current PTC preset leaves the workflow tool disabled. Speed and token use depend on the task and how the program handles its results."
7471
- ].join("\n\n"),
7472
- usage: [
7473
- "### Check a set of configuration files",
7474
- "> Check all JSON files in configs/. List missing required fields and invalid values against schema.json. Save a CSV with one row per issue. Include unreadable files in the report and keep checking the rest. Leave the original files unchanged.",
7475
- "Expected output: an issue summary and a CSV report. The program can repeat the same checks, handle individual failures, and collect the results.",
7476
- "### Summarize error logs",
7477
- "> Analyze the log files in logs/. Group errors by service and error type. Show the ten most frequent groups and one example from each. Save the full counts to a CSV.",
7478
- "Expected output: the top error groups and a complete count table. Intermediate data can be aggregated in the program before the summary reaches the model."
7479
- ].join("\n\n")
7480
- },
7481
- minimal: {
7482
- intro: "Choose Minimal mode for a new task. For a comparison, hold the model, permissions, input, and starting workspace state constant across runs.",
7483
- explanation: [
7484
- "### What is included",
7485
- "One persistent shell tool and a fixed system prompt. The built-in preset does not load Skills, planning, context compaction, or the standard runtime context.",
7486
- "### When to choose it",
7487
- "Use it as a baseline for experiments and comparisons. It can still read files and execute scripts through shell commands, but offers fewer built-in ways to manage a long task. Fewer tools does not necessarily make it easier for a beginner."
7488
- ].join("\n\n"),
7489
- usage: [
7490
- "### Compare performance on a small bug fix",
7491
- "> Run the tests for this project, find the cause of the failure, and make the smallest fix. Run the relevant tests again and report the result.",
7492
- "Run the same task separately in Standard and Minimal modes from the same starting state. Compare task completion, tool calls, and the resulting changes. Minimal mode performs the work through terminal commands."
7493
- ].join("\n\n")
7494
- },
7495
- cordis: {
7496
- intro: "Choose Creator mode for a new task. Describe the capability you want, where it should appear, and how you will verify it.",
7497
- explanation: [
7498
- "### What you can create",
7499
- "Creator mode includes the standard task tools plus runtime inspection, persistent plugin management, and guidance for authoring Cordis plugins and agent presets. It can create a plugin that adds a capability or UI, or a preset that combines tools and prompts for a particular job.",
7500
- "### Plugins and modes",
7501
- "A plugin adds capabilities to DSH, such as a tool, a service connection, or a UI entry. A mode is an agent preset that selects tools and defines how the agent works in a task. A plugin can be included in a custom preset.",
7502
- "### How the result takes effect",
7503
- "Ask the agent to install and verify the result, not just generate source code. A plugin may load immediately or require a restart, depending on what it changes. A newly created preset is selected when starting a new task."
7504
- ].join("\n\n"),
7505
- usage: [
7506
- "### Add a UI",
7507
- "> Create a DSH plugin that adds a project notes entry to the sidebar. Let me browse the Markdown files in this workspace and preview a selected note. Install it and verify that the page opens.",
7508
- "Expected output: an installed plugin with a working entry and preview page, plus any remaining activation steps.",
7509
- "### Add a tool",
7510
- "> Create a plugin with a tool that reads this project’s test report and summarizes the failed tests. Register it and verify it with a sample report.",
7511
- "Expected output: a plugin with a callable tool and a verified sample call.",
7512
- "### Create my own mode",
7513
- "> Create a “Code review” mode based on Standard mode. Have it prioritize potential bugs and test gaps, cite file paths and lines, and ask before modifying files. Save it as a selectable preset.",
7514
- "Expected output: a custom preset for new tasks. These review instructions guide the agent; permission settings determine which actions it can execute."
7515
- ].join("\n\n")
7516
- }
7517
- };
7518
- /**
7519
- * The complete read-only Markdown body of one shipped preset's Mode guide: the
7520
- * two official sections the Web dialog shows, rendered as ONE continuous
7521
- * scrolling body instead of behind a second layer of tabs or a modal.
7522
- */
7523
- function copyMarkdown(copy) {
7524
- return [
7525
- `## ${GUIDE_SECTION_HEADS.modeDetails}`,
7526
- copy.intro,
7527
- copy.explanation,
7528
- `## ${GUIDE_SECTION_HEADS.howToUse}`,
7529
- copy.usage
7530
- ].join("\n\n");
7531
- }
7532
- /**
7533
- * The official Mode guide of one row, or `undefined` when the row must not have
7534
- * one.
7535
- *
7536
- * `builtIn` is the row's ALREADY-DERIVED shipped classification — the value
7537
- * `isBuiltInPresetRow` produced from the raw roster DTO. It is checked FIRST and
7538
- * on its own: the shipped-id table is consulted only for a row the official
7539
- * classification really calls shipped, so a user declaration that happens to
7540
- * reuse `standard`/`ptc`/`minimal`/`cordis` (and therefore publishes its own
7541
- * `name`) keeps its own copy and never inherits an official Guide.
7542
- */
7543
- function builtInGuide(row) {
7544
- if (!row.builtIn) return void 0;
7545
- const copy = BUILT_IN_GUIDES[row.id];
7546
- return copy === void 0 ? void 0 : copyMarkdown(copy);
7547
- }
7548
- //#endregion
7549
7785
  //#region src/tui/tsp/preset-picker-state.ts
7550
7786
  const ROW_PREFIX = "preset:";
7551
7787
  /**
@@ -9427,7 +9663,7 @@ function acpAccessStatusDetail(outcome) {
9427
9663
  if (outcome.kind === "unavailable") return `The Host ACP status could not be read: ${outcome.message}`;
9428
9664
  switch (outcome.status.state) {
9429
9665
  case "disabled": return "The local ACP v1 listener is not bound on this Host.";
9430
- case "enabled": return "The local ACP v1 listener is bound on this Host's Unix socket.";
9666
+ case "enabled": return "The local ACP v1 listener is enabled on this Host.";
9431
9667
  case "changing": return "An ACP enable/disable request is still running; wait for it to settle.";
9432
9668
  case "unavailable": return `The Host cannot report a healthy ACP listener: ${outcome.status.reason}`;
9433
9669
  }
@@ -9906,6 +10142,7 @@ function workspaceModel(panel) {
9906
10142
  rows: panel.snapshot.rows,
9907
10143
  activity: snapshot.activity,
9908
10144
  answerEligibility: snapshot.answerEligibility,
10145
+ status: panel.snapshot.status?.rows,
9909
10146
  workspaces: snapshot.facts,
9910
10147
  workspaceBaselineProven: snapshot.baselineProven,
9911
10148
  scope: { kind: "all" },
@@ -9913,17 +10150,28 @@ function workspaceModel(panel) {
9913
10150
  ...panel.request.subject.currentSessionId === void 0 && panel.nextCreateWorkspaceId !== void 0 ? { nextCreateWorkspaceId: panel.nextCreateWorkspaceId } : {}
9914
10151
  });
9915
10152
  }
10153
+ function eligibleBrowseRows(panel) {
10154
+ const snapshot = panel.snapshot;
10155
+ const activity = snapshot.workspace?.activityRosterRevision === snapshot.listRevision ? snapshot.workspace.activity : void 0;
10156
+ const activityById = new Map((activity ?? []).map((fact) => [fact.sessionId, fact]));
10157
+ return snapshot.rows.filter((row) => classifySessionBrowserRow(row, activityById.get(row.id), snapshot.workspace?.answerEligibility, snapshot.status?.rows.get(row.id)).browseEligible);
10158
+ }
9916
10159
  function priorityWorkspaceId(panel) {
9917
10160
  const model = workspaceModel(panel);
9918
10161
  return model?.nextCreateWorkspaceId ?? model?.currentWorkspaceId;
9919
10162
  }
10163
+ function defaultWorkspaceExpanded(panel, workspaceId) {
10164
+ if (workspaceId === priorityWorkspaceId(panel)) return true;
10165
+ const group = workspaceGroups(panel).find((candidate) => candidate.workspaceId === workspaceId);
10166
+ return (group?.needs ?? 0) + (group?.working ?? 0) + (group?.unread ?? 0) > 0;
10167
+ }
9920
10168
  function browseRows(panel) {
9921
- if (panel.snapshot.workspace === void 0) return panel.snapshot.rows.map((row) => ({
10169
+ if (panel.snapshot.workspace === void 0) return eligibleBrowseRows(panel).map((row) => ({
9922
10170
  row,
9923
10171
  depth: 0
9924
10172
  }));
9925
10173
  const model = workspaceModel(panel);
9926
- if (model === void 0 || !model.workspaceBaselineProven) return panel.snapshot.rows.map((row) => ({
10174
+ if (model === void 0 || !model.workspaceBaselineProven) return eligibleBrowseRows(panel).map((row) => ({
9927
10175
  row,
9928
10176
  depth: 0
9929
10177
  }));
@@ -9953,7 +10201,8 @@ function workspaceGroups(panel) {
9953
10201
  path: group.path,
9954
10202
  rows,
9955
10203
  needs: group.ids.filter((id) => model.rowsById.get(id)?.priority === "needs").length,
9956
- working: group.ids.filter((id) => model.rowsById.get(id)?.priority === "working").length
10204
+ working: group.ids.filter((id) => model.rowsById.get(id)?.priority === "working").length,
10205
+ unread: group.ids.filter((id) => model.rowsById.get(id)?.priority === "unread").length
9957
10206
  };
9958
10207
  });
9959
10208
  }
@@ -9966,11 +10215,6 @@ function visibleRows$1(panel) {
9966
10215
  function rowFor(panel, id) {
9967
10216
  return id === void 0 ? void 0 : visibleRows$1(panel).find((row) => row.id === id);
9968
10217
  }
9969
- function firstBrowseId(panel) {
9970
- const current = panel.request.subject.currentSessionId;
9971
- const rows = visibleRows$1(panel);
9972
- return rows.some((row) => row.id === current) ? current : rows[0]?.id;
9973
- }
9974
10218
  /** The selected Folder is an OFFICIAL Host Workspace, not the synthetic
9975
10219
  * Unassigned/Membership-ambiguous projection group. */
9976
10220
  function officialWorkspaceSelected(panel) {
@@ -9987,6 +10231,65 @@ function selectedSessionRow(panel) {
9987
10231
  if (panel.selectedItem !== void 0 && panel.selectedItem !== `session:${panel.selected}`) return void 0;
9988
10232
  return rowFor(panel, panel.selected);
9989
10233
  }
10234
+ /** The SAME shared Inspector display projection the PiTUI presenter consumes.
10235
+ * It is built from the already-admitted typed selection, the matching cut and
10236
+ * the accepted Search excerpt only; it never reads, retains or writes. */
10237
+ function inspectorView(panel) {
10238
+ const row = selectedSessionRow(panel);
10239
+ if (row === void 0) return void 0;
10240
+ const result = queryMode(panel) ? panel.snapshot.searchResults.find((candidate) => candidate.row.id === row.id) : void 0;
10241
+ return buildSessionInspectorView({
10242
+ row,
10243
+ fact: workspaceModel(panel)?.rowsById.get(row.id),
10244
+ inspector: panel.snapshot.inspector?.sessionId === row.id ? panel.snapshot.inspector : void 0,
10245
+ workspaces: panel.snapshot.workspace?.facts ?? [],
10246
+ workspaceBaselineProven: panel.snapshot.workspace?.baselineProven === true,
10247
+ currentSessionId: panel.request.subject.currentSessionId,
10248
+ ...result === void 0 ? {} : { excerpt: {
10249
+ source: result.source,
10250
+ ...result.snippet === void 0 ? {} : { snippet: result.snippet }
10251
+ } }
10252
+ });
10253
+ }
10254
+ /** The selected preview's compact GROUPS (identity/status stay text lines).
10255
+ * Every group key is panel+group scoped so two groups never collide. */
10256
+ function previewGroupNodes(panel, groups, nativeKv) {
10257
+ const nodes = [];
10258
+ for (const group of groups) {
10259
+ nodes.push(ui.text(span(sanitizeTerminalText(group.head), "muted")));
10260
+ if (group.facts.length === 0) continue;
10261
+ if (nativeKv && group.prose !== true) {
10262
+ nodes.push(ui.kv({
10263
+ key: `session-browser-preview-kv-${panel.serial}-${group.id}`,
10264
+ layout: "grid",
10265
+ items: group.facts.map((fact) => ({
10266
+ k: sanitizeTerminalText(fact.label),
10267
+ v: sanitizeTerminalText(fact.value)
10268
+ }))
10269
+ }));
10270
+ continue;
10271
+ }
10272
+ for (const fact of group.facts) {
10273
+ nodes.push(ui.text(span(sanitizeTerminalText(fact.label), "muted")));
10274
+ nodes.push(ui.text(group.prose === true ? {
10275
+ wrap: "word",
10276
+ lines: 3
10277
+ } : { wrap: "word" }, sanitizeTerminalText(fact.value)));
10278
+ }
10279
+ }
10280
+ return nodes;
10281
+ }
10282
+ /** The selected Session's quiet native side preview: a short read summary, not
10283
+ * a second reading page. It is a picker CHILD subtree (never an item payload)
10284
+ * and exists only while one admitted typed Session row is selected. */
10285
+ function previewLayer(panel, nativeKv) {
10286
+ const view = inspectorView(panel);
10287
+ if (view === void 0) return ui.col({ key: `session-browser-preview-empty-${panel.serial}` }, ui.text(span("No session selected", "muted")));
10288
+ return ui.col({
10289
+ key: `session-browser-preview-${panel.serial}`,
10290
+ gap: "xs"
10291
+ }, ui.text(sanitizeTerminalText(view.title)), ui.text(span(sanitizeTerminalText(`${view.shortId} · ${view.stateLabel}`), "muted")), ui.text(span(sanitizeTerminalText(view.freshness), "muted")), ...view.notice === "" ? [] : [ui.text(span(sanitizeTerminalText(view.notice), view.state === "error" ? "error" : "muted"))], ...previewGroupNodes(panel, view.summaryGroups, nativeKv));
10292
+ }
9990
10293
  function actionDisabledReason(panel, base) {
9991
10294
  if (base === "confirm-directory") {
9992
10295
  if (panel.directorySubmitting) return "Directory verification is in progress.";
@@ -9996,7 +10299,10 @@ function actionDisabledReason(panel, base) {
9996
10299
  }
9997
10300
  if (base === "close" && panel.directoryEntry && panel.directorySubmitting) return "Wait for directory verification to finish.";
9998
10301
  if (base === "use-directory") return panel.request.subject.currentSessionId === void 0 && officialWorkspaceSelected(panel) ? void 0 : "Select an official Workspace while sessionless.";
9999
- if (base === "new-session") return officialWorkspaceSelected(panel) ? void 0 : "Select an official Workspace folder first.";
10302
+ if (base === "new-session") {
10303
+ if (panel.request.onNewSession === void 0) return "Session creation is unavailable.";
10304
+ return officialWorkspaceSelected(panel) ? void 0 : "Select an official Workspace folder first.";
10305
+ }
10000
10306
  if (base === "add-directory") return panel.request.onAddDirectory === void 0 ? "Directory entry is unavailable." : void 0;
10001
10307
  if (base === "details" && selectedSessionRow(panel) === void 0) return "Select a session to read its details.";
10002
10308
  if (base === "resume") {
@@ -10022,17 +10328,42 @@ function stepActionFocus(panel, delta) {
10022
10328
  if (enabled.length === 0) return panel.actionFocus;
10023
10329
  return enabled[(enabled.indexOf(focusedAction(panel)) + delta + enabled.length) % enabled.length];
10024
10330
  }
10331
+ /** Re-anchor the ONE typed selection after an accepted state change. The
10332
+ * session id and its picker item identity are committed TOGETHER: a stale
10333
+ * `session:<old>` item beside a new `selected` id would make Enter/Footer act
10334
+ * on a row the frame never selected. */
10335
+ function selectFirstVisibleSession(panel) {
10336
+ const current = panel.request.subject.currentSessionId;
10337
+ const rows = visibleRows$1(panel);
10338
+ if (rows.some((row) => row.id === current)) {
10339
+ panel.selected = current;
10340
+ panel.selectedItem = `session:${current}`;
10341
+ return;
10342
+ }
10343
+ if (!queryMode(panel)) {
10344
+ const model = workspaceModel(panel);
10345
+ const hiddenCurrentFolder = model?.workspaceBaselineProven === true ? model.currentQuietBlankWorkspaceId : void 0;
10346
+ if (hiddenCurrentFolder !== void 0) {
10347
+ panel.selected = void 0;
10348
+ panel.selectedItem = `workspace:${hiddenCurrentFolder}`;
10349
+ return;
10350
+ }
10351
+ }
10352
+ const next = rows[0]?.id;
10353
+ panel.selected = next;
10354
+ panel.selectedItem = next === void 0 ? void 0 : `session:${next}`;
10355
+ }
10025
10356
  function normalize(panel) {
10026
10357
  if (panel.page === "details") {
10027
10358
  if (rowFor(panel, panel.selected) === void 0) {
10028
10359
  panel.page = "browse";
10029
10360
  panel.readerEpoch++;
10030
10361
  panel.zone = "list";
10031
- panel.selected = firstBrowseId(panel);
10362
+ selectFirstVisibleSession(panel);
10032
10363
  } else return;
10033
10364
  }
10034
10365
  if (panel.selectedItem?.startsWith("workspace:") === true || panel.selectedItem?.startsWith("more:") === true) panel.selected = void 0;
10035
- else if (panel.selected === void 0 || rowFor(panel, panel.selected) === void 0) panel.selected = firstBrowseId(panel);
10366
+ else if (panel.selected === void 0 || rowFor(panel, panel.selected) === void 0) selectFirstVisibleSession(panel);
10036
10367
  if (panel.zone === "actions") panel.actionFocus = focusedAction(panel);
10037
10368
  }
10038
10369
  function actionId(panel, action) {
@@ -10052,32 +10383,65 @@ function actionLabel(action) {
10052
10383
  function actionList(panel) {
10053
10384
  const focus = panel.zone === "actions" ? focusedAction(panel) : void 0;
10054
10385
  const folderSelected = !queryMode(panel) && panel.selectedItem?.startsWith("workspace:") === true;
10386
+ const currentBlankWorkspaceId = folderSelected ? workspaceModel(panel)?.currentQuietBlankWorkspaceId : void 0;
10055
10387
  return browseActions(panel).filter((base) => {
10056
10388
  if (base === "use-directory") return panel.request.subject.currentSessionId === void 0 && folderSelected;
10057
10389
  if (base === "new-session") return folderSelected;
10390
+ if (folderSelected && (base === "details" || base === "resume")) return false;
10058
10391
  return true;
10059
10392
  }).map((base) => {
10060
10393
  const disabled = actionDisabledReason(panel, base);
10061
10394
  const focused = base === focus;
10395
+ const currentMarker = base === "new-session" && disabled === void 0 && currentBlankWorkspaceId !== void 0 && panel.selectedItem === `workspace:${currentBlankWorkspaceId}` ? " · Current" : "";
10396
+ const chord = base === "details" && disabled === void 0 ? " [F2]" : "";
10062
10397
  return {
10063
10398
  id: base === "close" ? base : actionId(panel, base),
10064
- label: `${panel.directoryEntry && base === "close" ? "Cancel" : actionLabel(base)}${focused ? " [Enter]" : ""}`,
10399
+ label: `${panel.directoryEntry && base === "close" ? "Cancel" : actionLabel(base)}${chord}${currentMarker}${focused ? " [Enter]" : ""}`,
10065
10400
  ...base === "resume" ? { primary: true } : {},
10066
10401
  ...disabled === void 0 ? {} : { disabled }
10067
10402
  };
10068
10403
  });
10069
10404
  }
10070
- function rowItem(row, depth, result, fact) {
10071
- const title = row.title === void 0 || row.title.trim() === "" ? shortSessionId(row.id) : row.title;
10405
+ /** The visible title identity of one row: the sanitized title, or the canonical
10406
+ * short id when the title has no usable content. */
10407
+ function titleIdentity(row) {
10408
+ const sanitized = row.title === void 0 ? void 0 : sanitizeTerminalText(row.title);
10409
+ return sanitized === void 0 || sanitized.trim() === "" ? shortSessionId(row.id) : sanitized;
10410
+ }
10411
+ /** Exact same-title collisions in the actual listed corpus. Native clipping is
10412
+ * client-owned, so only a KNOWN same-title conflict forces the short id into
10413
+ * the label; every other row stays title-first and its full ID remains in the
10414
+ * row detail / Details reader. */
10415
+ function duplicateTitleIds(rows) {
10416
+ const groups = /* @__PURE__ */ new Map();
10417
+ for (const row of rows) {
10418
+ const title = titleIdentity(row);
10419
+ const group = groups.get(title) ?? [];
10420
+ group.push(row.id);
10421
+ groups.set(title, group);
10422
+ }
10423
+ const duplicates = /* @__PURE__ */ new Set();
10424
+ for (const ids of groups.values()) {
10425
+ if (ids.length < 2) continue;
10426
+ for (const id of ids) duplicates.add(id);
10427
+ }
10428
+ return duplicates;
10429
+ }
10430
+ function rowItem(row, depth, result, fact, grouped, showId) {
10431
+ const title = titleIdentity(row);
10432
+ const shortId = sanitizeTerminalText(shortSessionId(row.id));
10433
+ const label = showId ? `${title} · ${shortId}` : title;
10072
10434
  const migration = row.formatStatus === "migration-required" ? "Migration required" : void 0;
10435
+ const workspaceText = grouped ? void 0 : row.workspace === void 0 ? workspaceKey(row.cwd) : `${sanitizeTerminalText(row.workspace.title)} · ${sanitizeTerminalText(row.workspace.path)}`;
10436
+ const status = fact === void 0 ? void 0 : workspaceRowStatusLabel(fact);
10073
10437
  const detail = [
10074
- row.workspace === void 0 ? workspaceKey(row.cwd) : `${row.workspace.title} · ${row.workspace.path}`,
10075
- fact === void 0 ? void 0 : workspaceRowStatusLabel(fact),
10438
+ workspaceText,
10439
+ status,
10076
10440
  `Updated ${formatSessionAge(row.updatedAt)}`,
10077
10441
  migration,
10078
- row.preset === void 0 ? void 0 : `Preset ${row.preset}`,
10442
+ row.preset === void 0 ? void 0 : `Preset ${sanitizeTerminalText(row.preset)}`,
10079
10443
  row.live ? "Live" : "Persisted",
10080
- shortSessionId(row.id)
10444
+ shortId
10081
10445
  ].filter((part) => part !== void 0).map(sanitizeTerminalText).join(" · ");
10082
10446
  const badges = [];
10083
10447
  if (row.parentSession !== void 0) badges.push({
@@ -10090,9 +10454,10 @@ function rowItem(row, depth, result, fact) {
10090
10454
  });
10091
10455
  return {
10092
10456
  id: `session:${row.id}`,
10093
- label: sanitizeTerminalText(title),
10457
+ label: sanitizeTerminalText(label),
10094
10458
  detail: result?.snippet === void 0 ? detail : [
10095
- `${row.workspace?.title ?? workspaceKey(row.cwd)} · ${row.workspace?.path ?? ""}`,
10459
+ grouped ? void 0 : `${row.workspace?.title ?? workspaceKey(row.cwd)} · ${row.workspace?.path ?? ""}`,
10460
+ status,
10096
10461
  `Updated ${formatSessionAge(row.updatedAt)}`,
10097
10462
  migration,
10098
10463
  sanitizeTerminalText(result.snippet)
@@ -10129,7 +10494,7 @@ function emptyText(panel) {
10129
10494
  if (snapshot.listState === "loading") return "Loading persisted sessions…";
10130
10495
  if (snapshot.listState === "unavailable") return "No session listing capability is available.";
10131
10496
  if (snapshot.listState === "error") return "The session list could not be loaded.";
10132
- if (!queryMode(panel)) return snapshot.listState === "empty" ? "No persisted sessions are available." : "No sessions are available.";
10497
+ if (!queryMode(panel)) return snapshot.listState === "empty" ? "No persisted sessions are available." : eligibleBrowseRows(panel).length === 0 ? "No visible sessions" : "No sessions are available.";
10133
10498
  if (snapshot.searchState === "loading") return "Searching…";
10134
10499
  if (snapshot.searchState === "unavailable") return "No metadata matches; content search is unavailable.";
10135
10500
  if (snapshot.searchState === "error") return "No metadata matches; content search failed.";
@@ -10141,7 +10506,7 @@ function pickerSubtitle(panel) {
10141
10506
  return queryMode(panel) ? `${panel.snapshot.searchResults.length} global matches · ${current}` : `All workspaces · ${current}`;
10142
10507
  }
10143
10508
  function workspaceItem(group) {
10144
- const activity = (group.needs ?? 0) + (group.working ?? 0) > 0 ? ` · ${group.needs ?? 0} Needs · ${group.working ?? 0} Working` : "";
10509
+ const activity = (group.needs ?? 0) + (group.working ?? 0) + (group.unread ?? 0) > 0 ? ` · ${group.needs ?? 0} Needs · ${group.working ?? 0} Working · ${group.unread ?? 0} Unread` : "";
10145
10510
  return {
10146
10511
  id: group.id,
10147
10512
  label: `${group.current ? "Current · " : group.next ? "Next · " : ""}${sanitizeTerminalText(group.title)}`,
@@ -10162,12 +10527,23 @@ function showMoreItem(group) {
10162
10527
  }
10163
10528
  function visibleBrowseItems(panel) {
10164
10529
  const model = workspaceModel(panel);
10165
- if (model === void 0 || !model.workspaceBaselineProven) return panel.snapshot.rows.map((row) => rowItem(row, 0));
10530
+ if (model === void 0 || !model.workspaceBaselineProven) {
10531
+ const rows = eligibleBrowseRows(panel);
10532
+ const duplicates = duplicateTitleIds(rows);
10533
+ return rows.map((row) => rowItem(row, 0, void 0, model?.rowsById.get(row.id), false, duplicates.has(row.id)));
10534
+ }
10166
10535
  const display = {
10167
10536
  expanded: new Map([...panel.expandedWorkspaces].map(([id, value]) => [id, value])),
10168
10537
  historyLimit: panel.historyLimits
10169
10538
  };
10170
- return visibleWorkspaceBrowserRows(model, display, panel.selected, panel.request.subject.currentSessionId).flatMap((row) => {
10539
+ const projected = visibleWorkspaceBrowserRows(model, display, panel.selected, panel.request.subject.currentSessionId);
10540
+ const duplicates = duplicateTitleIds(projected.flatMap((row) => {
10541
+ if (row.kind !== "session") return [];
10542
+ const session = panel.snapshot.rows.find((candidate) => candidate.id === row.sessionId);
10543
+ return session === void 0 ? [] : [session];
10544
+ }));
10545
+ const officialWorkspaceIds = new Set(model.groups.filter((group) => group.kind === void 0 && group.path !== "").map((group) => group.workspaceId));
10546
+ return projected.flatMap((row) => {
10171
10547
  if (row.kind === "folder") return [workspaceItem({
10172
10548
  id: row.id,
10173
10549
  workspaceId: row.workspaceId,
@@ -10177,6 +10553,7 @@ function visibleBrowseItems(panel) {
10177
10553
  total: row.total,
10178
10554
  needs: row.needs,
10179
10555
  working: row.working,
10556
+ unread: row.unread,
10180
10557
  expanded: row.expanded,
10181
10558
  current: row.current,
10182
10559
  next: row.next
@@ -10187,20 +10564,26 @@ function visibleBrowseItems(panel) {
10187
10564
  })];
10188
10565
  if (row.kind === "session") {
10189
10566
  const session = panel.snapshot.rows.find((candidate) => candidate.id === row.sessionId);
10190
- return session === void 0 ? [] : [rowItem(session, 1, void 0, model.rowsById.get(row.sessionId))];
10567
+ const grouped = officialWorkspaceIds.has(row.workspaceId);
10568
+ return session === void 0 ? [] : [rowItem(session, 1, void 0, model.rowsById.get(row.sessionId), grouped, duplicates.has(row.sessionId))];
10191
10569
  }
10192
10570
  return [];
10193
10571
  });
10194
10572
  }
10195
10573
  function pickerLayerItems(panel) {
10196
10574
  if (panel.snapshot.workspace?.baselineProven === true) return visibleBrowseItems(panel);
10197
- return panel.snapshot.rows.map((row) => rowItem(row, 0));
10575
+ const rows = eligibleBrowseRows(panel);
10576
+ const duplicates = duplicateTitleIds(rows);
10577
+ const statusById = workspaceModel(panel)?.rowsById;
10578
+ return rows.map((row) => rowItem(row, 0, void 0, statusById?.get(row.id), false, duplicates.has(row.id)));
10198
10579
  }
10199
- function pickerLayer(panel) {
10580
+ function pickerLayer(panel, nativeKv) {
10200
10581
  const pathEntry = panel.directoryEntry;
10201
10582
  const searching = !pathEntry && queryMode(panel);
10202
10583
  const searchResults = searching ? visibleSearchResults(panel) : [];
10203
- const rows = pathEntry ? [] : searching ? searchResults.map((result) => rowItem(result.row, void 0, result)) : pickerLayerItems(panel);
10584
+ const searchStatus = searching ? workspaceModel(panel)?.rowsById : void 0;
10585
+ const searchDuplicates = duplicateTitleIds(searchResults.map((result) => result.row));
10586
+ const rows = pathEntry ? [] : searching ? searchResults.map((result) => rowItem(result.row, void 0, result, searchStatus?.get(result.row.id), false, searchDuplicates.has(result.row.id))) : pickerLayerItems(panel);
10204
10587
  const selected = pathEntry ? void 0 : panel.selectedItem ?? (panel.selected === void 0 ? void 0 : `session:${panel.selected}`);
10205
10588
  const currentId = panel.request.subject.currentSessionId;
10206
10589
  const currentItem = currentId === void 0 ? void 0 : `session:${currentId}`;
@@ -10214,7 +10597,7 @@ function pickerLayer(panel) {
10214
10597
  subtitle: pathEntry ? "Host absolute path · Enter validate · Esc cancel" : pickerSubtitle(panel),
10215
10598
  layout: searching ? "cards" : "tree",
10216
10599
  size: "lg",
10217
- preview: "none",
10600
+ preview: pathEntry ? "none" : "side",
10218
10601
  query: pathEntry ? panel.directoryPath : panel.query,
10219
10602
  cursor: pathEntry ? panel.directoryCursor : panel.cursor,
10220
10603
  placeholder: pathEntry ? "/path/to/project" : "Search sessions and messages…",
@@ -10230,81 +10613,41 @@ function pickerLayer(panel) {
10230
10613
  current,
10231
10614
  actions
10232
10615
  };
10233
- return ui.col({ key: `session-browser-layer-${panel.serial}` }, ui.picker(props));
10234
- }
10235
- function detailResult(panel, row) {
10236
- return panel.snapshot.searchResults.find((result) => result.row.id === row.id);
10237
- }
10238
- /** The existing Identity `State` value, extended with the Host-authoritative
10239
- * on-disk format state when the Client reported one. `current` and absent add
10240
- * nothing; no new fact group or control is introduced. */
10241
- function rowStateText(panel, row) {
10242
- const base = row.id === panel.request.subject.currentSessionId ? "Current session" : row.live ? "Live session" : "Persisted session";
10243
- return row.formatStatus === "migration-required" ? `${base} · Migration required` : base;
10616
+ return ui.col({ key: `session-browser-layer-${panel.serial}` }, pathEntry ? ui.picker(props) : ui.picker(props, previewLayer(panel, nativeKv)));
10244
10617
  }
10245
- /** The excerpt group's id: the ONE group whose body is Host content the user reads
10246
- * as prose, so it is never a grid row (see `detailReader`). */
10247
- const EXCERPT_GROUP_ID = "excerpt";
10248
10618
  /**
10249
- * The read-only Session Details Reader.
10619
+ * The read-only Session Details Reader, built from the SAME shared display
10620
+ * groups as the PiTUI Inspector. Identity stays its own first group; every
10621
+ * short-fact group paints as ONE native `kv` grid when the pane negotiated it,
10622
+ * and the complete per-fact text rows otherwise (the client owns value wrapping,
10623
+ * so an unbroken ID or long cwd stays whole). The Host Search excerpt is Host
10624
+ * content read as prose and therefore always keeps a complete wrapped `ui.text`.
10250
10625
  *
10251
- * The four fact groups (Identity / Activity / Lineage / Configuration) are labelled
10252
- * short facts, so on a pane that negotiated `kv` each paints as ONE native grid: the
10253
- * client aligns every label with its value instead of paying a separate line per
10254
- * label, which is what lets a narrow pane show more of the same facts at once. The
10255
- * values are the SAME complete strings the text branch sends and the client owns any
10256
- * wrapping (`KvItem` has no `wrap`), so an unbroken ID or a long cwd stays whole.
10257
- *
10258
- * The Host search excerpt is a different shape: its value is matched CONTENT read as
10259
- * prose, so it keeps its own `Matching content` label plus one complete wrapped
10260
- * `ui.text` at EVERY capability. A pane without `kv` keeps the original per-fact text
10261
- * rows verbatim, in the same order, with the same scroll body and the same Back row.
10626
+ * Same-id Inspector data updates the SAME reading identity (same overlay/body/
10627
+ * scroll key); only a real page/selection change opens a new reading.
10262
10628
  */
10263
10629
  function detailReader(panel, bind, nativeKv) {
10264
- const row = rowFor(panel, panel.selected);
10630
+ const view = inspectorView(panel);
10265
10631
  const scope = `${panel.serial}-${panel.readerEpoch}`;
10266
10632
  const bodyKey = `${DETAILS_BODY_KEY_PREFIX}${scope}`;
10267
- const title = row?.title === void 0 || row.title.trim() === "" ? row === void 0 ? "Session details" : shortSessionId(row.id) : row.title;
10268
- const result = row === void 0 ? void 0 : detailResult(panel, row);
10269
- const activity = row === void 0 ? void 0 : workspaceModel(panel)?.rowsById.get(row.id);
10270
- const groups = row === void 0 ? [] : [
10271
- {
10272
- id: "identity",
10273
- head: "Identity",
10274
- facts: [
10275
- ["Session ID", row.id],
10276
- ["Title", title],
10277
- ["State", rowStateText(panel, row)],
10278
- ["Created in", row.cwd === void 0 ? "Unknown" : row.cwd]
10279
- ]
10280
- },
10281
- {
10282
- id: "activity",
10283
- head: "Activity",
10284
- facts: [
10285
- ["Created", row.createdAt === void 0 ? "Unknown" : new Date(row.createdAt).toISOString()],
10286
- ["Updated", new Date(row.updatedAt).toISOString()],
10287
- ["Running", activity?.running === true ? "Yes" : activity?.running === false ? "No" : "Unknown"],
10288
- ["Pending", activity === void 0 ? "Unknown" : SESSION_PENDING_LABEL[activity.pending]],
10289
- ["Source", activity === void 0 ? "unknown" : SESSION_SOURCE_LABEL[activity.source]]
10290
- ]
10291
- },
10292
- {
10293
- id: "relationship",
10294
- head: "Lineage",
10295
- facts: [["Parent session", row.parentSession ?? "No parent session"]]
10296
- },
10297
- {
10298
- id: "configuration",
10299
- head: "Configuration",
10300
- facts: [["Agent preset", row.preset ?? "Unknown preset"]]
10301
- },
10302
- ...result?.snippet === void 0 ? [] : [{
10303
- id: EXCERPT_GROUP_ID,
10304
- head: `Host search excerpt · ${result.source}`,
10305
- facts: [["Matching content", result.snippet]]
10306
- }]
10307
- ];
10633
+ const groups = view === void 0 ? [] : [{
10634
+ id: "identity",
10635
+ head: "Identity",
10636
+ facts: [
10637
+ {
10638
+ label: "Session ID",
10639
+ value: view.fullId
10640
+ },
10641
+ {
10642
+ label: "Title",
10643
+ value: view.title
10644
+ },
10645
+ {
10646
+ label: "State",
10647
+ value: view.identityState
10648
+ }
10649
+ ]
10650
+ }, ...view.groups];
10308
10651
  return ui.col({ key: `session-browser-reader-layer-${panel.serial}` }, ui.overlay({
10309
10652
  key: `session-browser-reader-${scope}`,
10310
10653
  head: "Session details",
@@ -10316,20 +10659,25 @@ function detailReader(panel, bind, nativeKv) {
10316
10659
  }, ui.text(span("← Back to sessions · Esc", "accent"))), ui.col({
10317
10660
  key: bodyKey,
10318
10661
  gap: "xs"
10319
- }, ...row === void 0 ? [ui.text(span("The selected session is no longer available.", "muted"))] : groups.map((group) => ui.col({
10320
- key: `session-browser-group-${group.id}`,
10321
- gap: "xs"
10322
- }, ui.text(span(sanitizeTerminalText(group.head), "muted")), ...nativeKv && group.id !== EXCERPT_GROUP_ID ? [ui.kv({
10323
- key: `session-browser-kv-${group.id}`,
10324
- layout: "grid",
10325
- items: group.facts.map(([label, value]) => ({
10326
- k: sanitizeTerminalText(label),
10327
- v: sanitizeTerminalText(value)
10328
- }))
10329
- })] : group.facts.flatMap(([label, value]) => [ui.text(span(label, "muted")), ui.text({ wrap: "word" }, sanitizeTerminalText(value))]))))));
10662
+ }, ...view === void 0 ? [ui.text(span("The selected session is no longer available.", "muted"))] : [
10663
+ ui.text(sanitizeTerminalText(view.title)),
10664
+ ui.text(span(sanitizeTerminalText(view.stateLabel), "muted")),
10665
+ ...view.notice === "" ? [] : [ui.text(span(sanitizeTerminalText(view.notice), view.state === "error" ? "error" : "muted"))],
10666
+ ...groups.map((group) => ui.col({
10667
+ key: `session-browser-group-${group.id}`,
10668
+ gap: "xs"
10669
+ }, ui.text(span(sanitizeTerminalText(group.head), "muted")), ...nativeKv && group.prose !== true ? [ui.kv({
10670
+ key: `session-browser-kv-${group.id}`,
10671
+ layout: "grid",
10672
+ items: group.facts.map((fact) => ({
10673
+ k: sanitizeTerminalText(fact.label),
10674
+ v: sanitizeTerminalText(fact.value)
10675
+ }))
10676
+ })] : group.facts.flatMap((fact) => [ui.text(span(sanitizeTerminalText(fact.label), "muted")), ui.text({ wrap: "word" }, sanitizeTerminalText(fact.value))])))
10677
+ ])));
10330
10678
  }
10331
10679
  function layer(panel, bind, nativeKv) {
10332
- return panel.page === "details" ? detailReader(panel, bind, nativeKv) : pickerLayer(panel);
10680
+ return panel.page === "details" ? detailReader(panel, bind, nativeKv) : pickerLayer(panel, nativeKv);
10333
10681
  }
10334
10682
  var TspSessionBrowser = class {
10335
10683
  surfaceId;
@@ -10402,6 +10750,11 @@ var TspSessionBrowser = class {
10402
10750
  isDisposed: () => panel.disposed,
10403
10751
  setSnapshot: (snapshot, options) => {
10404
10752
  if (this.current() !== panel) return;
10753
+ if (options?.inspectorOnly === true) {
10754
+ panel.snapshot = snapshot;
10755
+ if (!this.suspended && (panel.page === "details" || selectedSessionRow(panel) !== void 0)) this.render();
10756
+ return;
10757
+ }
10405
10758
  if (options?.initialQuery !== void 0 && !panel.initialQueryApplied) {
10406
10759
  panel.initialQueryApplied = true;
10407
10760
  if (!panel.queryEdited) {
@@ -10447,6 +10800,8 @@ var TspSessionBrowser = class {
10447
10800
  if (this.panel !== void 0) this.panel.revision++;
10448
10801
  this.targets.clear();
10449
10802
  this.readerBodyId = void 0;
10803
+ const panel = this.panel;
10804
+ if (panel !== void 0 && !panel.disposed) panel.request.onInspectorSelection?.(void 0);
10450
10805
  }
10451
10806
  }
10452
10807
  desiredFocusId() {
@@ -10496,11 +10851,14 @@ var TspSessionBrowser = class {
10496
10851
  };
10497
10852
  if (base === "new-session" && actionDisabledReason(panel, base) === void 0) return { kind: "new-session" };
10498
10853
  if (base === "details" && selectedSessionRow(panel) !== void 0) return { kind: "details" };
10499
- if (base === "resume" && actionDisabledReason(panel, "resume") === void 0 && panel.selected !== void 0) return {
10500
- kind: "resume",
10501
- sessionId: panel.selected,
10502
- source: "footer"
10503
- };
10854
+ if (base === "resume" && actionDisabledReason(panel, "resume") === void 0) {
10855
+ const session = selectedSessionRow(panel);
10856
+ return session === void 0 ? void 0 : {
10857
+ kind: "resume",
10858
+ sessionId: session.id,
10859
+ source: "footer"
10860
+ };
10861
+ }
10504
10862
  }
10505
10863
  act(panel, revision, intent) {
10506
10864
  if (!this.canInteract() || this.current() !== panel || panel.revision !== revision) return;
@@ -10521,7 +10879,7 @@ var TspSessionBrowser = class {
10521
10879
  panel.selectedItem = `workspace:${intent.workspaceId}`;
10522
10880
  panel.selected = void 0;
10523
10881
  if (intent.toggle) {
10524
- if (!(panel.expandedWorkspaces.get(intent.workspaceId) ?? (intent.workspaceId === priorityWorkspaceId(panel) || (workspaceGroups(panel).find((group) => group.workspaceId === intent.workspaceId)?.needs ?? 0) > 0 || (workspaceGroups(panel).find((group) => group.workspaceId === intent.workspaceId)?.working ?? 0) > 0))) {
10882
+ if (!(panel.expandedWorkspaces.get(intent.workspaceId) ?? defaultWorkspaceExpanded(panel, intent.workspaceId))) {
10525
10883
  if (!panel.historyLimits.has(intent.workspaceId)) panel.historyLimits.set(intent.workspaceId, intent.workspaceId === priorityWorkspaceId(panel) ? 8 : 5);
10526
10884
  panel.expandedWorkspaces.set(intent.workspaceId, true);
10527
10885
  } else panel.expandedWorkspaces.set(intent.workspaceId, false);
@@ -10532,7 +10890,7 @@ var TspSessionBrowser = class {
10532
10890
  panel.selectedItem = `more:${intent.workspaceId}`;
10533
10891
  panel.selected = void 0;
10534
10892
  if (intent.reveal) {
10535
- if (panel.expandedWorkspaces.get(intent.workspaceId) ?? (intent.workspaceId === priorityWorkspaceId(panel) || (workspaceGroups(panel).find((group) => group.workspaceId === intent.workspaceId)?.needs ?? 0) > 0 || (workspaceGroups(panel).find((group) => group.workspaceId === intent.workspaceId)?.working ?? 0) > 0)) {
10893
+ if (panel.expandedWorkspaces.get(intent.workspaceId) ?? defaultWorkspaceExpanded(panel, intent.workspaceId)) {
10536
10894
  const current = panel.historyLimits.get(intent.workspaceId) ?? (intent.workspaceId === priorityWorkspaceId(panel) ? 8 : 0);
10537
10895
  panel.historyLimits.set(intent.workspaceId, current + 5);
10538
10896
  } else panel.historyLimits.set(intent.workspaceId, 5);
@@ -10725,6 +11083,7 @@ var TspSessionBrowser = class {
10725
11083
  step: scroll
10726
11084
  };
10727
11085
  }
11086
+ if (matchesKeyId(key, SESSION_WORKSPACE_CHORDS.inspect.keys[0])) return this.visibleActionIntent(panel, "details");
10728
11087
  if (key.name === "escape") {
10729
11088
  if (panel.query !== "") return {
10730
11089
  kind: "query",
@@ -10780,9 +11139,10 @@ var TspSessionBrowser = class {
10780
11139
  workspaceId: selectedId.slice(5),
10781
11140
  reveal: true
10782
11141
  };
10783
- return panel.selected === void 0 ? void 0 : {
11142
+ const session = selectedSessionRow(panel);
11143
+ return session === void 0 ? void 0 : {
10784
11144
  kind: "resume",
10785
- sessionId: panel.selected,
11145
+ sessionId: session.id,
10786
11146
  source: "enter"
10787
11147
  };
10788
11148
  }
@@ -10926,8 +11286,22 @@ var TspSessionBrowser = class {
10926
11286
  };
10927
11287
  visit(root);
10928
11288
  }
11289
+ this.reportInspectorSelection(panel);
10929
11290
  return node;
10930
11291
  }
11292
+ /** The ONE selected-Session report of a committed native layer. It uses the
11293
+ * SAME typed selection the Resume/Details actions use; a browse cursor
11294
+ * anchored on a Folder is never guessed into a Session. The Details reading
11295
+ * keeps the SAME admitted id/origin alive (its page paints that identity), so
11296
+ * entering Details neither clears nor reopens the exact read. */
11297
+ reportInspectorSelection(panel) {
11298
+ if (panel.disposed || this.panel !== panel) return;
11299
+ const selected = panel.directoryEntry ? void 0 : selectedSessionRow(panel);
11300
+ panel.request.onInspectorSelection?.(selected === void 0 ? void 0 : {
11301
+ sessionId: selected.id,
11302
+ origin: queryMode(panel) ? "search" : "browse"
11303
+ });
11304
+ }
10931
11305
  };
10932
11306
  //#endregion
10933
11307
  //#region src/tui/tsp/statusline-view.ts
@@ -13907,8 +14281,18 @@ function mountTspRenderer(session, options) {
13907
14281
  * through the existing display seam. I-A added no visible recall surface;
13908
14282
  * TSP I-B made the composer's ↑/↓ read exactly this projection — the composer
13909
14283
  * owns only the short-lived browse position and the draft it replaced.
14284
+ * Feature History PR2-A: absent when the Split Client injected its process
14285
+ * memory — that backend has no leased occurrences, settlements or reseeds to
14286
+ * reconcile, so it owns no kernel at all.
14287
+ */
14288
+ const historyRecall = options.inputRecall === void 0 ? createHistoryRecallScope() : void 0;
14289
+ /**
14290
+ * Feature History PR2-A: the SELECTED recall authority's newest-first
14291
+ * projection. The Split Client's process memory is the owner across mounts
14292
+ * (a same-PID HMR replacement reads the SAME object); Direct keeps this
14293
+ * mount's kernel. Exactly one of the two exists.
13910
14294
  */
13911
- const historyRecall = createHistoryRecallScope();
14295
+ const recallSnapshot = () => options.inputRecall?.snapshot() ?? historyRecall.snapshot();
13912
14296
  /**
13913
14297
  * PR2: the live submission attempt freezing the composer, or undefined.
13914
14298
  * Set ONLY by the application's `holdSubmission` (through the composer
@@ -13934,7 +14318,7 @@ function mountTspRenderer(session, options) {
13934
14318
  },
13935
14319
  notify: (text, kind) => display.notify(text, kind)
13936
14320
  }, {
13937
- entries: () => historyRecall.snapshot(),
14321
+ entries: () => recallSnapshot(),
13938
14322
  admitDraft: (text) => {
13939
14323
  const handlers = boundHandlers;
13940
14324
  if (handlers === void 0) throw new Error("the TSP composer recalled before the input was bound");
@@ -14324,6 +14708,18 @@ function mountTspRenderer(session, options) {
14324
14708
  * close times only; no mirror stats authority or second window owner. */
14325
14709
  let lastWindowState;
14326
14710
  let lastTurnActivities;
14711
+ /**
14712
+ * The ONE derived collapsed-Focus visibility index of the CURRENT committed
14713
+ * transcript publication. It is a disposable memo over the shared
14714
+ * `projectFocus` result for search ancestry, never a second disclosure
14715
+ * authority: it is rebuilt when the publication epoch or the authoritative
14716
+ * activity map changes, so a row that mutates in place (or a late
14717
+ * continuation that reflows a command) can never keep a stale verdict.
14718
+ */
14719
+ let collapsedFocusVisible;
14720
+ /** Increments on every committed transcript publication (a dropped stale
14721
+ * frame does not count). The visibility memo above is keyed by it. */
14722
+ let transcriptPublicationEpoch = 0;
14327
14723
  /** The ONE renderer-local Focus Turn disclosure owner set. Separate
14328
14724
  * occurrence node keys are derived from the projected owner object; the
14329
14725
  * semantic open decision remains the turn number. */
@@ -14966,6 +15362,10 @@ function mountTspRenderer(session, options) {
14966
15362
  if (message.content !== void 0) pushBodyImages(message.content);
14967
15363
  return;
14968
15364
  }
15365
+ if (message.kind === "system") {
15366
+ if (isPtcImageContext(message)) pushBodyImages(message.content);
15367
+ return;
15368
+ }
14969
15369
  if (message.kind !== "tool") return;
14970
15370
  for (const block of toolRowImageBlocks(message)) push(block.attachment);
14971
15371
  for (const child of message.subCalls ?? []) if (visibleMembers.has(child)) visit(child);
@@ -15598,11 +15998,19 @@ function mountTspRenderer(session, options) {
15598
15998
  const toolKeys = /* @__PURE__ */ new Set();
15599
15999
  const workflowRuns = /* @__PURE__ */ new Set();
15600
16000
  const workflowPhases = /* @__PURE__ */ new Map();
15601
- if ("turn" in message && focusRootHides(message)) focusTurns.add(message.turn);
16001
+ const turn = transcriptTurnOf(message);
16002
+ if (turn !== void 0 && focusRootHides(message)) focusTurns.add(turn);
15602
16003
  const structure = projectTranscriptStructure(lastMessages);
16004
+ const focusMaterializedWorkOwners = options.displayState?.preset === "focus" && lastTurnActivities !== void 0 ? /* @__PURE__ */ new Set() : void 0;
16005
+ if (focusMaterializedWorkOwners !== void 0 && lastTurnActivities !== void 0) {
16006
+ const focusScope = new Set(expandedFocusTurns);
16007
+ for (const grantedTurn of focusTurns) focusScope.add(grantedTurn);
16008
+ for (const block of projectFocus(lastMessages, lastTurnActivities, focusScope, true)) if (block.kind === "work") focusMaterializedWorkOwners.add(block.span.owner);
16009
+ }
15603
16010
  for (const block of structure) {
15604
16011
  if (block.kind === "work") {
15605
16012
  if (!workSpanContains(block.span, message)) continue;
16013
+ if (focusMaterializedWorkOwners !== void 0 && !focusMaterializedWorkOwners.has(block.span.owner)) continue;
15606
16014
  workOwners.add(block.span.owner);
15607
16015
  continue;
15608
16016
  }
@@ -15659,19 +16067,21 @@ function mountTspRenderer(session, options) {
15659
16067
  if (options.displayState?.preset !== "focus") return false;
15660
16068
  const activities = lastTurnActivities;
15661
16069
  if (activities === void 0) return false;
15662
- const turn = focusProjectionTurnOf(message);
15663
- if (turn === void 0) return false;
15664
- const start = lastMessages.indexOf(message);
15665
- if (start < 0) return false;
15666
- let groupStart = start;
15667
- while (groupStart > 0 && focusProjectionTurnOf(lastMessages[groupStart - 1]) === turn) groupStart -= 1;
15668
- const group = consecutiveTurnGroup(lastMessages, groupStart, turn);
15669
- const visible = /* @__PURE__ */ new Set();
15670
- for (const block of projectFocus(group, activities, EMPTY_PROBE_TURNS, true)) if (block.kind === "message") visible.add(block.message);
15671
- else if (block.kind === "work") {
15672
- for (const part of block.span.parts) if (part.kind === "message") visible.add(part.message);
16070
+ if (focusProjectionTurnOf(message) === void 0) return false;
16071
+ let visibleIndex = collapsedFocusVisible;
16072
+ if (visibleIndex === void 0 || visibleIndex.publication !== transcriptPublicationEpoch || visibleIndex.activities !== activities) {
16073
+ const visible = /* @__PURE__ */ new Set();
16074
+ for (const block of projectFocus(lastMessages, activities, EMPTY_PROBE_TURNS, true)) if (block.kind === "message") visible.add(block.message);
16075
+ const materialized = focusMaterializedMessages(lastMessages, activities);
16076
+ visibleIndex = {
16077
+ publication: transcriptPublicationEpoch,
16078
+ activities,
16079
+ visible,
16080
+ materialized
16081
+ };
16082
+ collapsedFocusVisible = visibleIndex;
15673
16083
  }
15674
- return !visible.has(message);
16084
+ return !visibleIndex.visible.has(message) && visibleIndex.materialized.has(message);
15675
16085
  };
15676
16086
  const EMPTY_PROBE_TURNS = /* @__PURE__ */ new Set();
15677
16087
  /**
@@ -15966,7 +16376,7 @@ function mountTspRenderer(session, options) {
15966
16376
  if (block.kind === "message") {
15967
16377
  const rootOwner = block.focusPresentationOwner;
15968
16378
  const turn = rootOwner === void 0 ? void 0 : focusRootTurnByOwner.get(rootOwner);
15969
- if (turn !== void 0) collectFocusInnerMessage(block.message, turn);
16379
+ if (turn !== void 0 && block.containerPath !== void 0) collectFocusInnerMessage(block.message, turn);
15970
16380
  continue;
15971
16381
  }
15972
16382
  const key = `${scopePrefix}work-${scopeKeys.keyFor(block.span.owner)}`;
@@ -16314,6 +16724,7 @@ function mountTspRenderer(session, options) {
16314
16724
  const setTranscript = (messages, activities, window, streamingToolPreviews, _searchPresentation, source, welcomeEligibilityCommit) => {
16315
16725
  if (disposed) return;
16316
16726
  if (retiredSource !== void 0 && source === retiredSource) return;
16727
+ transcriptPublicationEpoch += 1;
16317
16728
  if (welcomeEligibilityCommit !== void 0) welcomeEligibility = welcomeEligibilityCommit;
16318
16729
  lastProjectionEmpty = messages.length === 0;
16319
16730
  if (source !== void 0 && source !== projectionScope) {
@@ -16476,6 +16887,9 @@ function mountTspRenderer(session, options) {
16476
16887
  retiredSource = projectionScope;
16477
16888
  welcomeEligibility = "hidden";
16478
16889
  presentedStatus = void 0;
16890
+ statusFacts.sessionTitle = void 0;
16891
+ statusFacts.todos = void 0;
16892
+ statusFacts.compactionPhase = void 0;
16479
16893
  busyEpoch = 0;
16480
16894
  releaseImageSubscriptions();
16481
16895
  clearVisualFrameState();
@@ -16496,19 +16910,28 @@ function mountTspRenderer(session, options) {
16496
16910
  },
16497
16911
  resetInputHistory(entries, owner, writeIds) {
16498
16912
  if (disposed) return;
16913
+ if (historyRecall === void 0) return;
16499
16914
  composer.reseatRecallAfterReseed();
16500
16915
  historyRecall.reset(entries, owner, writeIds);
16501
16916
  },
16917
+ reseedInputRecall() {
16918
+ if (disposed) return;
16919
+ if (historyRecall === void 0) composer.reseatRecallAfterReseed();
16920
+ },
16921
+ resetInputRecallScope() {
16922
+ if (disposed) return;
16923
+ composer.invalidateRecallNavigation();
16924
+ },
16502
16925
  beginInputHistoryScope(owner) {
16503
16926
  if (disposed) return;
16504
16927
  composer.invalidateRecallNavigation();
16505
16928
  completion.retire();
16506
16929
  historySearch?.retire();
16507
- historyRecall.begin(owner);
16930
+ historyRecall?.begin(owner);
16508
16931
  },
16509
16932
  settleScopeInput(settlement) {
16510
16933
  if (disposed) return;
16511
- historyRecall.settle(settlement);
16934
+ historyRecall?.settle(settlement);
16512
16935
  },
16513
16936
  setSearchResult() {},
16514
16937
  notify(text, kind = "info") {
@@ -16576,12 +16999,12 @@ function mountTspRenderer(session, options) {
16576
16999
  let heldOverflowed = false;
16577
17000
  /**
16578
17001
  * M6 UX PR1: the ONE armed raw exit key (Ctrl+C while idle / Ctrl+D on an
16579
- * empty draft). Only the SAME key inside the 1.5 s window confirms; any
17002
+ * empty draft). Only the SAME key inside the 3 s window confirms; any
16580
17003
  * other key disarms, and an expired arm is simply replaced.
16581
17004
  */
16582
17005
  let lastExitKey;
16583
17006
  /** M6 UX PR1: the raw exit-key confirmation window (same as PiTui's). */
16584
- const RAW_EXIT_CONFIRM_WINDOW_MS = 1500;
17007
+ const RAW_EXIT_CONFIRM_WINDOW_MS = 3e3;
16585
17008
  let inputBound = false;
16586
17009
  /** The bound application input handlers (B1: editor-local + lifecycle). */
16587
17010
  let boundHandlers;
@@ -16796,7 +17219,12 @@ function mountTspRenderer(session, options) {
16796
17219
  render();
16797
17220
  return;
16798
17221
  }
16799
- const scopeToken = serializedDraft.startsWith("!") || !handlers.shouldRememberInput(serializedDraft) ? void 0 : historyRecall.rememberAccepted(serializedDraft);
17222
+ const eligible = !serializedDraft.startsWith("!") && handlers.shouldRememberInput(serializedDraft);
17223
+ let scopeToken;
17224
+ if (eligible) {
17225
+ if (options.inputRecall === void 0) scopeToken = historyRecall.rememberAccepted(serializedDraft);
17226
+ else options.inputRecall.remember(serializedDraft);
17227
+ }
16800
17228
  composer.setDraft("");
16801
17229
  handlers.submit(serializedDraft, gesture, scopeToken);
16802
17230
  };
@@ -16825,8 +17253,8 @@ function mountTspRenderer(session, options) {
16825
17253
  submitComposerDraft(handlers, "enter");
16826
17254
  };
16827
17255
  /**
16828
- * PR-C (TSP-7): the Stop click — the EXISTING cancel intent, exactly like
16829
- * Ctrl+C. It re-checks the busy fact at click time (a one-frame-old painted
17256
+ * PR-C (TSP-7): the Stop click — the EXISTING cancel intent, like Escape.
17257
+ * It re-checks the busy fact at click time (a one-frame-old painted
16830
17258
  * button must never cancel a NEW session's run) and never reads or writes
16831
17259
  * the draft.
16832
17260
  */
@@ -17469,8 +17897,10 @@ function mountTspRenderer(session, options) {
17469
17897
  historySearch.handleKey(key);
17470
17898
  return false;
17471
17899
  }
17900
+ let forwardedSearchCancel = false;
17472
17901
  if (transcriptSearch?.isOpen() === true) {
17473
17902
  if (transcriptSearch.handleKey(key)) return false;
17903
+ forwardedSearchCancel = true;
17474
17904
  }
17475
17905
  if (!fencedOut(key) && key.alt === true && key.ctrl !== true && key.meta !== true && key.shift !== true && key.name === "q") {
17476
17906
  retireQuickMenu();
@@ -17478,10 +17908,20 @@ function mountTspRenderer(session, options) {
17478
17908
  return false;
17479
17909
  }
17480
17910
  if (key.ctrl === true && key.name === "c") {
17911
+ const menuOwnedKey = modelQuick?.isOpen() === true || permissionMenuOpen;
17481
17912
  if (closePermissionMenu()) render();
17482
17913
  retireQuickMenu();
17483
17914
  if (completion.retire()) render();
17484
17915
  const activity = handlers.sessionActivity?.();
17916
+ if (activity !== void 0 && !forwardedSearchCancel && !menuOwnedKey && composerActionsAdmitted() && !historyHoldsComposerSeat() && webPicker?.isOpen() !== true && acpPicker?.isOpen() !== true && !composerHeld() && composer.state().text !== "") {
17917
+ composer.clearDraftStateOnly();
17918
+ lastExitKey = activity === "idle" ? {
17919
+ identity: "interrupt",
17920
+ at
17921
+ } : void 0;
17922
+ render();
17923
+ return false;
17924
+ }
17485
17925
  if (activity === "working" || activity === void 0) {
17486
17926
  lastExitKey = void 0;
17487
17927
  handlers.cancel();
@@ -17492,15 +17932,6 @@ function mountTspRenderer(session, options) {
17492
17932
  display.notify("The current session's running state cannot be verified.", "error");
17493
17933
  return false;
17494
17934
  }
17495
- if (composer.state().text !== "") {
17496
- composer.clearDraftStateOnly();
17497
- render();
17498
- lastExitKey = {
17499
- identity: "interrupt",
17500
- at
17501
- };
17502
- return false;
17503
- }
17504
17935
  if (armOrConfirmRawExit("interrupt", at)) {
17505
17936
  handlers.exit();
17506
17937
  return false;
@@ -17643,6 +18074,7 @@ function mountTspRenderer(session, options) {
17643
18074
  for (const owner of focusThinkingOwnersByTurn.get(turn) ?? []) expandedThinkingOwners.delete(owner);
17644
18075
  for (const rootKey of focusToolRootsByTurn.get(turn) ?? []) expandedToolKeys.delete(rootKey);
17645
18076
  }
18077
+ if (searchGrants !== void 0 && searchGrantSuppressedEpoch !== searchNavigationEpoch) searchGrants = deriveSearchGrants();
17646
18078
  if (rebuildLastMain()) render();
17647
18079
  }
17648
18080
  return false;
@@ -17906,12 +18338,16 @@ function mountTspRenderer(session, options) {
17906
18338
  };
17907
18339
  render();
17908
18340
  },
17909
- settleSubmission: (attemptId, result) => {
18341
+ settleSubmission: (attemptId, result, officialRequestId, hostAccepted = true) => {
17910
18342
  const hold = heldSubmission;
17911
18343
  if (hold === void 0 || hold.attemptId !== attemptId) return;
17912
18344
  heldSubmission = void 0;
17913
18345
  if (result === "accepted") {
17914
- if (hold.remember) historyRecall.rememberAccepted(hold.text);
18346
+ if (hostAccepted) options.inputRecall?.revokeDirectory();
18347
+ if (hold.remember) {
18348
+ if (options.inputRecall === void 0) historyRecall.rememberAccepted(hold.text);
18349
+ else options.inputRecall.remember(hold.text, officialRequestId);
18350
+ } else if (hostAccepted && options.inputRecall !== void 0) composer.reseatRecallAfterReseed();
17915
18351
  composer.setDraft("");
17916
18352
  }
17917
18353
  render();
@@ -17960,8 +18396,14 @@ function mountTspRenderer(session, options) {
17960
18396
  render();
17961
18397
  }
17962
18398
  },
17963
- scopeFactCountForTest: () => historyRecall.scopeFactCountForTest(),
17964
- reconcileStepsForTest: () => historyRecall.reconcileStepsForTest(),
18399
+ scopeFactCountForTest: () => {
18400
+ if (historyRecall === void 0) throw new Error("the Split Client recall memory has no Direct scope facts to report");
18401
+ return historyRecall.scopeFactCountForTest();
18402
+ },
18403
+ reconcileStepsForTest: () => {
18404
+ if (historyRecall === void 0) throw new Error("the Split Client recall memory has no Direct scope reconcile to report");
18405
+ return historyRecall.reconcileStepsForTest();
18406
+ },
17965
18407
  installCommandCompletions: (installation) => {
17966
18408
  if (disposed) return;
17967
18409
  const { provider } = createInstalledAutocompleteProvider({