@xmoon76/dsh-pi-tui 0.5.8 → 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.
- package/README.en.md +61 -25
- package/README.md +61 -25
- package/cordis.patch.yml +13 -0
- package/dist/acp-stdio.mjs +151 -0
- package/dist/{bootstrap-CMIjGyuk.mjs → bootstrap-CVyHGQDX.mjs} +21901 -6575
- package/dist/browser-CDUSHIIr.mjs +76 -0
- package/dist/builtins.mjs +2 -2
- package/dist/{client-bootstrap-BjGPc-DM.mjs → client-bootstrap-4UoeVIHE.mjs} +2488 -2734
- package/dist/client-runtime-BHBlVUf5.mjs +1376 -0
- package/dist/{daemon-launcher-Dult7Jxv.mjs → daemon-launcher-DxIgjBHW.mjs} +1549 -172
- package/dist/daemon-launcher.d.mts +85 -14
- package/dist/daemon-launcher.mjs +2 -2
- package/dist/{local-profile-daemon-admin-BmQSdzT0.mjs → diagnostics-Db5iVcuJ.mjs} +3 -90
- package/dist/{entry-control-DjNsE3I0.mjs → entry-control-BDLZgg4m.mjs} +1 -1
- package/dist/{extensions-B4uLpSTv.mjs → extensions-Dx7ncPNA.mjs} +1 -1
- package/dist/extensions.mjs +1 -1
- package/dist/handoff-BjoEy3f8.mjs +106 -0
- package/dist/history-search-limits-Cx2UvRC2.mjs +16 -0
- package/dist/history-search-remote-BHuoellG.mjs +113 -0
- package/dist/history-search-remote-BzXdvrxk.mjs +26 -0
- package/dist/history-search-seat-BcHJTpeB.mjs +639 -0
- package/dist/history-search-seat-rZcq0XV6.mjs +639 -0
- package/dist/{host-bootstrap-MVxks641.mjs → host-bootstrap-BfnufpnW.mjs} +37 -72
- package/dist/{host-foundation-probe-DMNTmNrH.mjs → host-foundation-probe-DlD8-N_Q.mjs} +2 -2
- package/dist/host-runtime.mjs +5611 -290
- package/dist/index.d.mts +13 -6
- package/dist/index.mjs +22334 -6695
- package/dist/installed-dsh-BjUiJSwR.mjs +142 -0
- package/dist/interaction-port-D1Yv9zgu.mjs +45 -0
- package/dist/local-acp-control-CC5z4Xbq.mjs +304 -0
- package/dist/local-acp-endpoint-D1jYdJdv.mjs +41 -0
- package/dist/local-acp-listener-Cmgb5M0H.mjs +9493 -0
- package/dist/local-acp-status-B_25Q6kU.mjs +101 -0
- package/dist/local-client.mjs +292 -63
- package/dist/local-daemon-control-BFJAC8Kg.mjs +2199 -0
- package/dist/local-daemon-control-Bm3imctD.mjs +2101 -0
- package/dist/{local-discovery-uOBfFq5j.mjs → local-discovery-BMhaGIiJ.mjs} +254 -544
- package/dist/{local-discovery-egN4_gsQ.mjs → local-discovery-Ba7_-NNC.mjs} +1 -1
- package/dist/{local-discovery-DOSsCh9q.mjs → local-discovery-QSbFpjK2.mjs} +301 -544
- package/dist/local-host.mjs +952 -501
- package/dist/local-profile-daemon-admin-otpm69R6.mjs +469 -0
- package/dist/{local-scope-DamiMqPd.mjs → local-scope-5DEKA_lW.mjs} +1023 -96
- package/dist/{local-transport-Iwo0mtu3.mjs → local-transport-DeWmdZ5E.mjs} +14 -3
- package/dist/{local-web-control-DMrjwCkl.mjs → local-web-control-Dny93N-r.mjs} +10 -7
- package/dist/{local-workspace-object-D06GL0UO.mjs → local-workspace-object-D0RVQt8U.mjs} +33 -9
- package/dist/model-selection-CYlqg2DV.mjs +83 -0
- package/dist/native-client-domains-Dg4srzYt.mjs +2 -0
- package/dist/native-client.d.mts +735 -0
- package/dist/native-client.mjs +3534 -0
- package/dist/{open-CmOBxSjN.mjs → open-QQva8-ar.mjs} +24 -20
- package/dist/{pi-tui-remote-contribution-Do8ECrUy.mjs → pi-tui-remote-contribution-565wiLWp.mjs} +741 -150
- package/dist/preferences.mjs +1 -1
- package/dist/{profile-preferences-migration-CThz4rHH.mjs → profile-preferences-migration-CNOWIdnr.mjs} +1 -1
- package/dist/{profile-preferences-migration-BfUGdPZx.mjs → profile-preferences-migration-IrnXcJWK.mjs} +10 -8
- package/dist/{prompt-sections-DXmjB58H.mjs → prompt-sections-Bi-9_Gr_.mjs} +28 -10
- package/dist/{prompt-sections-DUKmWb8g.mjs → prompt-sections-DFS1dqsY.mjs} +342 -56
- package/dist/{dist-BFgC-5tL.mjs → recall-scope-9Nuoto_i.mjs} +353 -1
- package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
- package/dist/schema-CCLvDa7Q.mjs +177 -0
- package/dist/{schema-qE_P09zJ.mjs → schema-t97l3aK8.mjs} +56 -3
- package/dist/{session-C6tSs86s.mjs → session-Cs8iLCEx.mjs} +784 -342
- package/dist/{session-CstInGIA.mjs → session-EBRZF6Ow.mjs} +783 -341
- package/dist/session-create-facts-CkfG5DpQ.mjs +20 -0
- package/dist/{startup-CarQxWwi.d.mts → startup-Dti3Udne.d.mts} +30 -3
- package/dist/{startup-EG5UqIcd.mjs → startup-UtFQSDe_.mjs} +90 -15
- package/dist/startup.d.mts +2 -2
- package/dist/startup.mjs +1 -1
- package/dist/task-read-remote-DRtkXDrZ.mjs +1083 -0
- package/dist/{terminal-progress-source-CpfpQO_h.mjs → terminal-progress-source-VsczdXA-.mjs} +610 -332
- package/dist/{transcript-view-CuJYWkhp.mjs → transcript-view-B6vCnukn.mjs} +2096 -977
- package/dist/{transcript-view-C1YtJ49Y.mjs → transcript-view-DSSdE2vK.mjs} +2078 -651
- package/dist/write-failure-xNKczXH7.mjs +189 -0
- package/package.json +20 -3
- package/dist/local-acp-listener-B65J0Bx4.mjs +0 -3115
- package/dist/local-daemon-control-C14q9KnD.mjs +0 -1588
- package/dist/local-daemon-control-TCnERL7n.mjs +0 -1424
- package/dist/preset-BcWqOtY7.mjs +0 -46
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as rankPathCandidates, I as reattachDisplayBase, L as resolvePathQuery, M as discoverForQuery, N as escapeFinderRegex, P as createBoundedFinderCandidateCollector, R as separatorOfRaw, j as createFinderRecordStream } from "./prompt-sections-DFS1dqsY.mjs";
|
|
2
2
|
import { i as StepUsageAccumulator, s as totalTokens } from "./performance-view-CfGvLZyD.mjs";
|
|
3
3
|
import { C as chartHumanText, E as chartValueRows, I as humanFacingVisualResult, L as isVisualToolName, M as CHART_TOOL_NAME, N as PRESENT_VISUAL_TOOL_NAME, P as SVG_TOOL_NAME, c as visualParts, g as svgDetailRows, u as visualPartsFromText, w as chartProjection, x as chartDisplayTitle } from "./runtime-status-v-FTnWcD.mjs";
|
|
4
|
-
import { Et as resolveCommandFooterFallback, I as CombinedAutocompleteProvider, Tt as parseFooterLayout, _t as sliceByColumn, bt as visibleWidth, rt as fuzzyFilter, wt as isFooterLayout, xt as wrapTextWithAnsi, yt as truncateToWidth } from "./extensions-
|
|
4
|
+
import { Et as resolveCommandFooterFallback, I as CombinedAutocompleteProvider, Tt as parseFooterLayout, _t as sliceByColumn, bt as visibleWidth, rt as fuzzyFilter, wt as isFooterLayout, xt as wrapTextWithAnsi, yt as truncateToWidth } from "./extensions-Dx7ncPNA.mjs";
|
|
5
|
+
import { Q as shortSessionId } from "./daemon-launcher-DxIgjBHW.mjs";
|
|
5
6
|
import { accessSync, appendFileSync, constants, existsSync, mkdirSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
6
7
|
import { homedir } from "node:os";
|
|
7
8
|
import { delimiter, dirname, join } from "node:path";
|
|
@@ -340,6 +341,25 @@ function classifyTranscriptMessage(message) {
|
|
|
340
341
|
}
|
|
341
342
|
}
|
|
342
343
|
/**
|
|
344
|
+
* The ONE internal numeric model-turn reader shared by transcript consumers:
|
|
345
|
+
* the row's admitted semantic-turn ownership, or `undefined` when the row
|
|
346
|
+
* owns none (a command, a window summary, or a compaction that never proved a
|
|
347
|
+
* numeric owner). A standalone compaction is a real transcript row that
|
|
348
|
+
* belongs to NO model turn — never `0`, never a placement anchor. This is
|
|
349
|
+
* SEMANTIC ownership; the fold's presentation placement (`TranscriptFolder`
|
|
350
|
+
* `placementAnchorOf`) is a separate fact and must never be promoted here.
|
|
351
|
+
*
|
|
352
|
+
* Already-narrowed accesses on tool/system/assistant/user rows keep their
|
|
353
|
+
* definite `turn`; this helper exists for the generic row readers (window,
|
|
354
|
+
* grouping, Focus projection, search navigation) whose union includes the
|
|
355
|
+
* optional-turn compaction row.
|
|
356
|
+
*/
|
|
357
|
+
function transcriptTurnOf(message) {
|
|
358
|
+
if (!("turn" in message)) return void 0;
|
|
359
|
+
const turn = message.turn;
|
|
360
|
+
return typeof turn === "number" ? turn : void 0;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
343
363
|
* Whether a system row is an injected context boundary that Focus keeps
|
|
344
364
|
* visible when its Thought is collapsed. The fold's authoritative `context`
|
|
345
365
|
* marker intentionally covers unknown/future injection producers too.
|
|
@@ -493,7 +513,9 @@ function isTranscriptContextForm(value) {
|
|
|
493
513
|
* relay/notice sender, and the inject/recall role. This is the SINGLE
|
|
494
514
|
* parser of raw context sources; the fold and every projection consume its
|
|
495
515
|
* result. An absent/unknown form stays undefined — the caller must present
|
|
496
|
-
* the row as standalone generic Context.
|
|
516
|
+
* the row as standalone generic Context. `formDeclared` preserves the raw
|
|
517
|
+
* PRESENCE of the member (even an unknown or non-string value) so eligibility
|
|
518
|
+
* can distinguish "no form declared" from "declared but not understood".
|
|
497
519
|
* @param source - the logged user/message source, exactly as recorded.
|
|
498
520
|
*/
|
|
499
521
|
function contextPresentation(source) {
|
|
@@ -502,11 +524,19 @@ function contextPresentation(source) {
|
|
|
502
524
|
if (record === null) return { role };
|
|
503
525
|
const kind = readString(record, "kind");
|
|
504
526
|
const form = record["form"];
|
|
527
|
+
const formDeclared = Object.hasOwn(record, "form");
|
|
505
528
|
const senderSessionId = readString(record, "senderSessionId");
|
|
529
|
+
const entries = record["entries"];
|
|
530
|
+
const completeCatalogUpdate = kind === "skill-catalog" && form === "catalog" && record["update"] === true && !Object.hasOwn(record, "incomplete") && Array.isArray(entries) && entries.every((entry) => {
|
|
531
|
+
const item = asRecord(entry);
|
|
532
|
+
return item !== null && readString(item, "name") !== null && typeof item["description"] === "string";
|
|
533
|
+
});
|
|
506
534
|
return {
|
|
507
535
|
...isTranscriptContextForm(form) ? { form } : {},
|
|
536
|
+
...formDeclared ? { formDeclared: true } : {},
|
|
508
537
|
...kind === null ? {} : { sourceKind: kind },
|
|
509
538
|
...senderSessionId === null ? {} : { senderSessionId },
|
|
539
|
+
...completeCatalogUpdate ? { completeCatalogUpdate: true } : {},
|
|
510
540
|
role
|
|
511
541
|
};
|
|
512
542
|
}
|
|
@@ -530,6 +560,22 @@ function isAmbientContext(message) {
|
|
|
530
560
|
return isSurfacedContext(message) && form !== void 0 && AMBIENT_CONTEXT_FORMS.includes(form);
|
|
531
561
|
}
|
|
532
562
|
/**
|
|
563
|
+
* Whether one row is an image-bearing `ptc-mode` injected Context row.
|
|
564
|
+
*
|
|
565
|
+
* This is a STRUCTURED MEDIA question only: surfaced Context + the exact
|
|
566
|
+
* producer source kind `ptc-mode` + at least one real `image` ContentBlock.
|
|
567
|
+
* It deliberately says nothing about same-turn delivery/carriage (that is the
|
|
568
|
+
* separate `sameTurnNextStep` presentation flag), nothing about producer
|
|
569
|
+
* intent subtypes (none exist yet) and never parses the flat text. The
|
|
570
|
+
* producer's text-only Spill Context and its environment-reset Context are
|
|
571
|
+
* therefore never image-bearing rows.
|
|
572
|
+
*/
|
|
573
|
+
function isPtcImageContext(message) {
|
|
574
|
+
if (!isSurfacedContext(message)) return false;
|
|
575
|
+
if (message.contextPresentation?.sourceKind !== "ptc-mode") return false;
|
|
576
|
+
return message.content !== void 0 && message.content.some((block) => block.type === "image");
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
533
579
|
* The card-header icon SEMANTIC for one context injection, keyed by source
|
|
534
580
|
* kind so a reader can tell an instruction file from a skill catalog or a
|
|
535
581
|
* recalled session at a glance (the Web renders one browse icon for all of
|
|
@@ -583,8 +629,9 @@ function recentTurnThreshold(messages, recentTurns, kinds) {
|
|
|
583
629
|
if (recentTurns <= 0) return Number.POSITIVE_INFINITY;
|
|
584
630
|
const turns = /* @__PURE__ */ new Set();
|
|
585
631
|
for (const message of messages) {
|
|
586
|
-
|
|
587
|
-
if (
|
|
632
|
+
const turn = transcriptTurnOf(message);
|
|
633
|
+
if (turn === void 0) continue;
|
|
634
|
+
if (kinds === void 0 || kinds.includes(message.kind)) turns.add(turn);
|
|
588
635
|
}
|
|
589
636
|
const sorted = [...turns].sort((a, b) => b - a);
|
|
590
637
|
if (sorted.length <= recentTurns) return 0;
|
|
@@ -1293,12 +1340,18 @@ function windowMessages(messages, maxTurns, endTurn) {
|
|
|
1293
1340
|
if (maxTurns <= 0) return [...messages];
|
|
1294
1341
|
if (endTurn !== void 0) {
|
|
1295
1342
|
const turns = /* @__PURE__ */ new Set();
|
|
1296
|
-
for (const message of messages)
|
|
1343
|
+
for (const message of messages) {
|
|
1344
|
+
const turn = transcriptTurnOf(message);
|
|
1345
|
+
if (turn !== void 0) turns.add(turn);
|
|
1346
|
+
}
|
|
1297
1347
|
const sorted = [...turns].sort((a, b) => b - a);
|
|
1298
1348
|
const anchor = sorted.indexOf(endTurn);
|
|
1299
1349
|
if (anchor === -1) return windowMessages(messages, maxTurns);
|
|
1300
1350
|
const windowTurns = new Set(sorted.slice(anchor, anchor + maxTurns));
|
|
1301
|
-
const kept = messages.filter((message) =>
|
|
1351
|
+
const kept = messages.filter((message) => {
|
|
1352
|
+
const turn = transcriptTurnOf(message);
|
|
1353
|
+
return turn === void 0 || windowTurns.has(turn);
|
|
1354
|
+
});
|
|
1302
1355
|
const newerTurns = new Set(sorted.slice(0, anchor));
|
|
1303
1356
|
const oldTurns = new Set(sorted.slice(anchor + maxTurns));
|
|
1304
1357
|
if (newerTurns.size === 0 && oldTurns.size === 0) return kept;
|
|
@@ -1318,10 +1371,11 @@ function windowMessages(messages, maxTurns, endTurn) {
|
|
|
1318
1371
|
let oldTools = 0;
|
|
1319
1372
|
let oldCount = 0;
|
|
1320
1373
|
for (const message of messages) {
|
|
1321
|
-
|
|
1374
|
+
const turn = transcriptTurnOf(message);
|
|
1375
|
+
if (turn !== void 0 && turn < boundary) {
|
|
1322
1376
|
oldCount += 1;
|
|
1323
1377
|
if (message.kind === "tool") oldTools += 1;
|
|
1324
|
-
oldTurns.add(
|
|
1378
|
+
oldTurns.add(turn);
|
|
1325
1379
|
continue;
|
|
1326
1380
|
}
|
|
1327
1381
|
kept.push(message);
|
|
@@ -1447,6 +1501,16 @@ function assistantLatestStepOf(activity) {
|
|
|
1447
1501
|
}
|
|
1448
1502
|
/** Whether an Assistant crossed an admitted human-steer boundary and is
|
|
1449
1503
|
* therefore a persistent conversation answer rather than Focus process. */
|
|
1504
|
+
/** Whether the exact Assistant row's step has authoritative continuation
|
|
1505
|
+
* evidence in the Fold: a real tool/call or step boundary after its
|
|
1506
|
+
* settlement, or a later output that confirmed its streaming candidate. The
|
|
1507
|
+
* Focus projection holds a latest-step settled Assistant back as the pending
|
|
1508
|
+
* final ONLY when this fact is absent; presentation row kind/order never
|
|
1509
|
+
* answers that question. */
|
|
1510
|
+
function assistantStepIntermediateOf(activity, message) {
|
|
1511
|
+
const step = assistantStepOf(message);
|
|
1512
|
+
return step !== void 0 && activity.intermediateAssistantSteps.has(step);
|
|
1513
|
+
}
|
|
1450
1514
|
function assistantCommittedBeforeSteer(activity, message) {
|
|
1451
1515
|
if (message.kind !== "assistant") return false;
|
|
1452
1516
|
const step = assistantStepOf(message);
|
|
@@ -1829,9 +1893,15 @@ function assistantEntryHasInterruptionEvidence(entry) {
|
|
|
1829
1893
|
* the shared {@link WorkflowProjection} owns the projection itself. */
|
|
1830
1894
|
var TranscriptFolder = class TranscriptFolder {
|
|
1831
1895
|
items = [];
|
|
1832
|
-
/**
|
|
1896
|
+
/** The observed valid positional prefix of the durable next-step queue,
|
|
1897
|
+
* awaiting a claim, cancellation or replacement. A fragment that cannot
|
|
1898
|
+
* address this prefix exactly discards it (fail open); JS splice clamping is
|
|
1899
|
+
* never positional evidence. */
|
|
1833
1900
|
pendingNextSteps = [];
|
|
1834
|
-
/**
|
|
1901
|
+
/** Unconsumed positive claim candidates: removed from next-step by an
|
|
1902
|
+
* official full-drain claim in this same open turn, awaiting the actual
|
|
1903
|
+
* `user/message` append. Retired at the owning turn's step/turn end and when
|
|
1904
|
+
* a newer open turn is accepted. */
|
|
1835
1905
|
claimedNextStepTurns = /* @__PURE__ */ new Map();
|
|
1836
1906
|
/** The assistant message object per (turn, step); streaming text lands in place. */
|
|
1837
1907
|
assistantEntries = /* @__PURE__ */ new Map();
|
|
@@ -1964,21 +2034,15 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
1964
2034
|
* turn 0 itself is a perfectly legal first turn (an in-turn-0 command
|
|
1965
2035
|
* anchored to 0 must NOT be re-anchored away by turn 1). */
|
|
1966
2036
|
seenAcceptedTurnStart = false;
|
|
1967
|
-
/** The placement-anchor AUTHORITY for
|
|
1968
|
-
*
|
|
1969
|
-
*
|
|
1970
|
-
*
|
|
1971
|
-
*
|
|
1972
|
-
*
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
* `/compact` is the compaction card, so its window/search placement must
|
|
1977
|
-
* inherit the command's anchor (a pre-turn or replayed manual compaction
|
|
1978
|
-
* would otherwise keep the legacy `currentTurn` and anchor the wrong
|
|
1979
|
-
* bounded window). Written at fuse time; re-anchored with the leading
|
|
1980
|
-
* prefix exactly like the command sidecar. */
|
|
1981
|
-
manualCompactionPlacementTurns = /* @__PURE__ */ new WeakMap();
|
|
2037
|
+
/** The placement-anchor AUTHORITY for standalone rows (plan §4.3): one
|
|
2038
|
+
* anchor per command object, per compaction WITHOUT an admitted numeric
|
|
2039
|
+
* model-turn owner, and per successfully fused compaction representative.
|
|
2040
|
+
* Written at append time and re-anchored with the leading prefix. Search
|
|
2041
|
+
* navigation, the fast indexed window's physical ranges and the
|
|
2042
|
+
* non-monotonic defensive window all derive placement from this ONE sidecar
|
|
2043
|
+
* — never a semantic `turn` on the row, never a second dedicated map, and
|
|
2044
|
+
* never the reverse (an anchor is not ownership). */
|
|
2045
|
+
standalonePlacementTurns = /* @__PURE__ */ new WeakMap();
|
|
1982
2046
|
/** Manual-compaction correlation legs (post-PR166 plan §7): bounded direct
|
|
1983
2047
|
* lookups so `command/done.sourceEventSeq` and compaction
|
|
1984
2048
|
* `sourceCommandId` never scan history. */
|
|
@@ -2156,6 +2220,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2156
2220
|
tools: /* @__PURE__ */ new Map(),
|
|
2157
2221
|
thinkingTail: "",
|
|
2158
2222
|
confirmedSteps: /* @__PURE__ */ new Set(),
|
|
2223
|
+
intermediateAssistantSteps: /* @__PURE__ */ new Set(),
|
|
2159
2224
|
settledSteps: /* @__PURE__ */ new Set(),
|
|
2160
2225
|
firstVisibleAssistantTimes: /* @__PURE__ */ new Map(),
|
|
2161
2226
|
committedAnswerSteps: /* @__PURE__ */ new Set(),
|
|
@@ -2391,6 +2456,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2391
2456
|
activity.messageConfirmed = text === "" ? void 0 : text.slice(-TranscriptFolder.MESSAGE_TAIL_CAP);
|
|
2392
2457
|
activity.messageConfirmedStep = candidate.step;
|
|
2393
2458
|
activity.confirmedSteps.add(candidate.step);
|
|
2459
|
+
activity.intermediateAssistantSteps.add(candidate.step);
|
|
2394
2460
|
activity.messageCandidate = void 0;
|
|
2395
2461
|
}
|
|
2396
2462
|
/** Commit the exact previous text-only answer once its next step admits a
|
|
@@ -2449,72 +2515,77 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2449
2515
|
this.turnValueSet.add(turn);
|
|
2450
2516
|
}
|
|
2451
2517
|
/** The FIRST REAL model turn (turn/start) adopts the leading standalone
|
|
2452
|
-
* prefix (pre-turn commands
|
|
2453
|
-
* the first turn value, so an
|
|
2454
|
-
* first turn reveals them (the raw
|
|
2455
|
-
*
|
|
2456
|
-
*
|
|
2457
|
-
*
|
|
2518
|
+
* prefix (pre-turn commands AND pre-turn standalone compactions): their
|
|
2519
|
+
* anchors — 0 until now — re-anchor to the first accepted turn value, so an
|
|
2520
|
+
* anchored search window that contains the first turn reveals them (the raw
|
|
2521
|
+
* prefix itself renders from index 0). Only a REAL turn/start adopts the
|
|
2522
|
+
* prefix. A fused representative is skipped: its command was already
|
|
2523
|
+
* re-anchored through the ONE hand-over path, so the command stays the only
|
|
2524
|
+
* independent anchor authority regardless of fusion order. */
|
|
2458
2525
|
adoptLeadingAnchors(turn) {
|
|
2459
2526
|
if (this.seenAcceptedTurnStart) return;
|
|
2460
2527
|
this.seenAcceptedTurnStart = true;
|
|
2461
2528
|
if (this.pendingAnchorEntries.length === 0) return;
|
|
2462
2529
|
for (const index of this.pendingAnchorEntries) {
|
|
2463
2530
|
const item = this.items[index];
|
|
2464
|
-
if (item
|
|
2531
|
+
if (item === void 0) continue;
|
|
2532
|
+
if (item.kind === "compaction" && item.sourceCommand !== void 0) continue;
|
|
2533
|
+
if (item.kind === "command" || item.kind === "compaction") this.setPlacementAnchor(item, index, turn);
|
|
2465
2534
|
}
|
|
2466
2535
|
this.pendingAnchorEntries.length = 0;
|
|
2467
2536
|
}
|
|
2468
|
-
/** The PRESENTATION placement anchor of one
|
|
2469
|
-
*
|
|
2470
|
-
* still has no turn (re-anchored by {@link
|
|
2471
|
-
* drives window/search navigation ONLY — it is never stored on
|
|
2472
|
-
* a semantic `turn
|
|
2537
|
+
/** The PRESENTATION placement anchor of one standalone row: the turn
|
|
2538
|
+
* currently open, else the latest registered log-order turn, else 0 while
|
|
2539
|
+
* the log still has no turn (re-anchored by {@link adoptLeadingAnchors}).
|
|
2540
|
+
* This anchor drives window/search navigation ONLY — it is never stored on
|
|
2541
|
+
* the row as a semantic `turn`, and a numeric owner never consumes it. */
|
|
2473
2542
|
placementAnchorTurn() {
|
|
2474
2543
|
if (this.openTurn !== void 0) return this.openTurn;
|
|
2475
2544
|
return this.turnValues.length > 0 ? this.turnValues[this.turnValues.length - 1] : 0;
|
|
2476
2545
|
}
|
|
2477
|
-
/** Write one
|
|
2478
|
-
* fused manual-compaction
|
|
2479
|
-
* so its sidecar and search entry
|
|
2546
|
+
/** Write one standalone row's placement anchor and hand a COMMAND's anchor
|
|
2547
|
+
* over to an already fused manual-compaction representative: the card is
|
|
2548
|
+
* the VISIBLE owner, so its sidecar and search entry follow the same
|
|
2549
|
+
* anchor. This is the ONE write path — the anchor is never inferred back
|
|
2550
|
+
* into semantic ownership. */
|
|
2480
2551
|
setPlacementAnchor(message, index, turn) {
|
|
2481
|
-
this.
|
|
2552
|
+
this.standalonePlacementTurns.set(message, turn);
|
|
2482
2553
|
const entry = this.searchEntries[index];
|
|
2483
2554
|
if (entry !== void 0) entry.turn = turn;
|
|
2555
|
+
if (message.kind !== "command") return;
|
|
2484
2556
|
const owner = this.compactionOwnerByCommandId.get(message.commandId);
|
|
2485
2557
|
if (owner === void 0) return;
|
|
2486
2558
|
const compaction = this.items[owner];
|
|
2487
2559
|
if (compaction !== void 0 && compaction.kind === "compaction") {
|
|
2488
|
-
this.
|
|
2560
|
+
this.standalonePlacementTurns.set(compaction, turn);
|
|
2489
2561
|
const ownerEntry = this.searchEntries[owner];
|
|
2490
2562
|
if (ownerEntry !== void 0) ownerEntry.turn = turn;
|
|
2491
2563
|
}
|
|
2492
2564
|
}
|
|
2493
|
-
/** The placement anchor of one
|
|
2494
|
-
*
|
|
2495
|
-
*
|
|
2496
|
-
* anchor. */
|
|
2565
|
+
/** The placement anchor of one standalone row from the shared authority
|
|
2566
|
+
* sidecar (undefined for numeric-turn-owned rows): a plain command, a
|
|
2567
|
+
* compaction with no admitted numeric owner, or a fused representative
|
|
2568
|
+
* inheriting its command's anchor. Never semantic ownership. */
|
|
2497
2569
|
placementAnchorOf(message) {
|
|
2498
|
-
|
|
2499
|
-
if (message.kind === "compaction" && message.sourceCommand !== void 0) return this.manualCompactionPlacementTurns.get(message);
|
|
2570
|
+
return this.standalonePlacementTurns.get(message);
|
|
2500
2571
|
}
|
|
2501
2572
|
/** Append one folded message, maintaining the window projections. Returns
|
|
2502
2573
|
* the raw item index (the stable search identity). */
|
|
2503
2574
|
appendItem(message) {
|
|
2504
2575
|
this.items.push(message);
|
|
2505
2576
|
const index = this.items.length - 1;
|
|
2577
|
+
if (message.kind === "command") setTranscriptTiming(message, pointTiming(message.time));
|
|
2506
2578
|
const corpus = transcriptSearchCorpus(message);
|
|
2507
|
-
const
|
|
2508
|
-
const anchorTurn =
|
|
2509
|
-
if (!ownsTurn && message.kind === "command") this.commandPlacementTurns.set(message, anchorTurn);
|
|
2579
|
+
const turn = transcriptTurnOf(message);
|
|
2580
|
+
const anchorTurn = turn ?? this.placementAnchorTurn();
|
|
2510
2581
|
this.searchEntries.push({
|
|
2511
2582
|
turn: anchorTurn,
|
|
2512
2583
|
normalizedText: corpus.normalizedText,
|
|
2513
2584
|
spans: corpus.spans
|
|
2514
2585
|
});
|
|
2515
|
-
if (
|
|
2586
|
+
if (turn === void 0 && (message.kind === "command" || message.kind === "compaction")) this.setPlacementAnchor(message, index, anchorTurn);
|
|
2587
|
+
if (turn === void 0 && !this.seenAcceptedTurnStart) this.pendingAnchorEntries.push(index);
|
|
2516
2588
|
this.searchRevisionCounter += 1;
|
|
2517
|
-
const turn = ownsTurn ? message.turn : void 0;
|
|
2518
2589
|
if (turn !== void 0) {
|
|
2519
2590
|
if (this.turnValues.length === 0) this.appendTurnIndex(turn);
|
|
2520
2591
|
else if (this.turnsMonotonic) {
|
|
@@ -2569,7 +2640,8 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2569
2640
|
if (group !== void 0 && this.representativeOf(index) !== index) continue;
|
|
2570
2641
|
const card = group ?? this.items[index];
|
|
2571
2642
|
if (card === void 0) continue;
|
|
2572
|
-
|
|
2643
|
+
const cardTurn = transcriptTurnOf(card);
|
|
2644
|
+
if (cardTurn !== void 0 && !(card.kind === "compaction" && card.sourceCommand !== void 0)) entry.turn = cardTurn;
|
|
2573
2645
|
const corpus = transcriptSearchCorpus(card);
|
|
2574
2646
|
entry.normalizedText = corpus.normalizedText;
|
|
2575
2647
|
entry.spans = corpus.spans;
|
|
@@ -2726,7 +2798,8 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2726
2798
|
continue;
|
|
2727
2799
|
}
|
|
2728
2800
|
const item = this.items[index];
|
|
2729
|
-
|
|
2801
|
+
const turn = item === void 0 ? void 0 : transcriptTurnOf(item);
|
|
2802
|
+
if (item !== void 0 && turn !== void 0 && this.isVisible(item)) this.addGroupedTurn(turn);
|
|
2730
2803
|
}
|
|
2731
2804
|
this.groupedTurnIndexDirty = false;
|
|
2732
2805
|
}
|
|
@@ -2913,7 +2986,8 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2913
2986
|
flush();
|
|
2914
2987
|
runTurn = void 0;
|
|
2915
2988
|
if (item.kind === "tool" && absoluteCounts) this.groupedToolCount += 1;
|
|
2916
|
-
|
|
2989
|
+
const turn = transcriptTurnOf(item);
|
|
2990
|
+
if (turn !== void 0) this.addGroupedTurn(turn);
|
|
2917
2991
|
}
|
|
2918
2992
|
flush();
|
|
2919
2993
|
}
|
|
@@ -3054,7 +3128,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
3054
3128
|
/** The turn value of one raw row, when it carries one. */
|
|
3055
3129
|
turnOfRaw(index) {
|
|
3056
3130
|
const item = this.items[index];
|
|
3057
|
-
return item
|
|
3131
|
+
return item === void 0 ? void 0 : transcriptTurnOf(item);
|
|
3058
3132
|
}
|
|
3059
3133
|
/** Re-group one LOCAL span from the display order: detach its existing groups,
|
|
3060
3134
|
* then rebuild the runs over the final display order (bounded by the span). */
|
|
@@ -3306,7 +3380,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
3306
3380
|
if (members === void 0) return false;
|
|
3307
3381
|
const meta = this.groupMeta.get(previousGroup);
|
|
3308
3382
|
const firstMember = this.items[members[0]];
|
|
3309
|
-
const firstTurn = meta?.firstTurn ?? (firstMember
|
|
3383
|
+
const firstTurn = meta?.firstTurn ?? (firstMember === void 0 ? previous.turn : transcriptTurnOf(firstMember) ?? previous.turn);
|
|
3310
3384
|
const wasCross = meta?.spansTurns ?? this.crossTurn(members);
|
|
3311
3385
|
this.removeGroupedTurn(previousGroup.turn);
|
|
3312
3386
|
this.removeGroupedTurn(item.turn);
|
|
@@ -3370,10 +3444,10 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
3370
3444
|
crossTurn(members) {
|
|
3371
3445
|
if (members.length <= 1) return false;
|
|
3372
3446
|
const first = this.items[members[0]];
|
|
3373
|
-
const turn =
|
|
3447
|
+
const turn = transcriptTurnOf(first);
|
|
3374
3448
|
for (let i = 1; i < members.length; i += 1) {
|
|
3375
3449
|
const member = this.items[members[i]];
|
|
3376
|
-
if ((
|
|
3450
|
+
if (transcriptTurnOf(member) !== turn) return true;
|
|
3377
3451
|
}
|
|
3378
3452
|
return false;
|
|
3379
3453
|
}
|
|
@@ -4011,6 +4085,22 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4011
4085
|
isDeclaredToolCall(turn, step, callId) {
|
|
4012
4086
|
return this.declaredToolCallsByStep.get(stepKey(turn, step))?.has(callId) === true;
|
|
4013
4087
|
}
|
|
4088
|
+
/** Whether this step's durable evidence owns a same-step ACTUAL tool call
|
|
4089
|
+
* that the lane convergence places on the Assistant's FOLLOWING display side
|
|
4090
|
+
* (text-then-call). A cold fold can observe the call event BEFORE the
|
|
4091
|
+
* settlement; the existing lane relation is the display authority, and a
|
|
4092
|
+
* conformant raw row needs no relation. A call on the preceding side, a
|
|
4093
|
+
* requested-but-never-started call (no card) and an older-step call are not
|
|
4094
|
+
* continuation. */
|
|
4095
|
+
assistantStepHasFollowingActualCall(turn, step) {
|
|
4096
|
+
const declared = this.declaredToolCallsByStep.get(stepKey(turn, step));
|
|
4097
|
+
if (declared === void 0) return false;
|
|
4098
|
+
for (const callId of declared) {
|
|
4099
|
+
if (!this.toolCardIndexOf.has(toolCallKey(turn, step, callId))) continue;
|
|
4100
|
+
if (this.toolRowEvidence(turn, step, callId)?.position === "after") return true;
|
|
4101
|
+
}
|
|
4102
|
+
return false;
|
|
4103
|
+
}
|
|
4014
4104
|
/** Whether a proven Tool row already sits on the physical side its evidence
|
|
4015
4105
|
* asks for (so it keeps its own slot and needs no relation). */
|
|
4016
4106
|
toolRowIsConformant(evidence, anchorIndex) {
|
|
@@ -4597,7 +4687,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4597
4687
|
if (anchor !== void 0) anchoredRows.set(message, anchor);
|
|
4598
4688
|
else windowInput.push(message);
|
|
4599
4689
|
}
|
|
4600
|
-
const allTurns = [...new Set(windowInput.
|
|
4690
|
+
const allTurns = [...new Set(windowInput.map((message) => transcriptTurnOf(message)).filter((turn) => turn !== void 0))].sort((a, b) => a - b);
|
|
4601
4691
|
const windowed = windowMessages(windowInput, maxTurns, options.endTurn);
|
|
4602
4692
|
const sortedDesc = [...allTurns].sort((a, b) => b - a);
|
|
4603
4693
|
const anchorIndex = options.endTurn === void 0 ? -1 : sortedDesc.indexOf(options.endTurn);
|
|
@@ -4614,7 +4704,10 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4614
4704
|
if (windowedBody.has(message)) messages.push(message);
|
|
4615
4705
|
}
|
|
4616
4706
|
const visibleSet = /* @__PURE__ */ new Set();
|
|
4617
|
-
for (const message of messages)
|
|
4707
|
+
for (const message of messages) {
|
|
4708
|
+
const turn = transcriptTurnOf(message);
|
|
4709
|
+
if (turn !== void 0) visibleSet.add(turn);
|
|
4710
|
+
}
|
|
4618
4711
|
const visibleTurnValues = [...visibleSet].sort((a, b) => a - b);
|
|
4619
4712
|
const firstTurn = visibleTurnValues[0] ?? this.turnValues[range.start];
|
|
4620
4713
|
const lastTurn = visibleTurnValues[visibleTurnValues.length - 1] ?? this.turnValues[range.end];
|
|
@@ -4642,7 +4735,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4642
4735
|
}
|
|
4643
4736
|
if (leading.length > 0) projected.messages = [...leading, ...projected.messages];
|
|
4644
4737
|
}
|
|
4645
|
-
const visibleTurns = projected.messages.
|
|
4738
|
+
const visibleTurns = projected.messages.map((message) => transcriptTurnOf(message)).filter((turn) => turn !== void 0);
|
|
4646
4739
|
const firstTurn = visibleTurns[0] ?? this.turnValues[range.start];
|
|
4647
4740
|
const lastTurn = visibleTurns[visibleTurns.length - 1] ?? this.turnValues[range.end];
|
|
4648
4741
|
const facts = this.crossTurnGroups > 0 ? this.groupedTurnFacts(this.turnValues[range.start], this.turnValues[range.end]) : void 0;
|
|
@@ -4933,17 +5026,19 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4933
5026
|
const compactionId = typeof data.compactionId === "string" ? data.compactionId : void 0;
|
|
4934
5027
|
let index = compactionId === void 0 ? void 0 : this.compacting.get(compactionId);
|
|
4935
5028
|
if (index === void 0) {
|
|
5029
|
+
const ownerTurn = kind === "compaction/start" || kind === "compaction/end" ? compactionOwnerTurnOf(data.turn) : void 0;
|
|
4936
5030
|
const created = {
|
|
4937
5031
|
kind: "compaction",
|
|
4938
|
-
turn: this.currentTurn,
|
|
4939
5032
|
text: "",
|
|
4940
5033
|
items: 0,
|
|
4941
5034
|
tokens: 0,
|
|
4942
|
-
running: true
|
|
5035
|
+
running: true,
|
|
5036
|
+
...ownerTurn === void 0 ? {} : { turn: ownerTurn }
|
|
4943
5037
|
};
|
|
4944
5038
|
this.appendItem(created);
|
|
4945
5039
|
index = this.items.length - 1;
|
|
4946
5040
|
setTranscriptTiming(created, pointTiming(event.time));
|
|
5041
|
+
if (ownerTurn !== void 0 && this.activityByTurn.get(ownerTurn)?.completed === true) markPostTurnReplayEvidence(created);
|
|
4947
5042
|
if (compactionId !== void 0) this.compacting.set(compactionId, index);
|
|
4948
5043
|
}
|
|
4949
5044
|
const entry = this.items[index];
|
|
@@ -5026,15 +5121,12 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5026
5121
|
compaction.sourceCommand = message;
|
|
5027
5122
|
this.fusedCommands.add(message);
|
|
5028
5123
|
this.compactionOwnerByCommandId.set(message.commandId, target);
|
|
5029
|
-
const
|
|
5124
|
+
const compactionPoint = transcriptTimingOf(compaction)?.startedAt;
|
|
5125
|
+
const commandPoint = transcriptTimingOf(message)?.startedAt;
|
|
5126
|
+
const earliestPoint = compactionPoint === void 0 ? commandPoint : commandPoint === void 0 ? compactionPoint : Math.min(compactionPoint, commandPoint);
|
|
5127
|
+
if (earliestPoint !== void 0) setTranscriptTiming(compaction, pointTiming(earliestPoint));
|
|
5128
|
+
const anchor = this.placementAnchorOf(message);
|
|
5030
5129
|
if (anchor !== void 0) this.setPlacementAnchor(message, index, anchor);
|
|
5031
|
-
const ghostIndex = this.turnValues.indexOf(compaction.turn);
|
|
5032
|
-
if (ghostIndex >= 0 && this.turnStarts[ghostIndex] === target && this.activityByTurn.get(compaction.turn)?.startedAt === void 0 && (ghostIndex + 1 >= this.turnStarts.length || this.turnStarts[ghostIndex + 1] === target + 1)) {
|
|
5033
|
-
this.turnValues.splice(ghostIndex, 1);
|
|
5034
|
-
this.turnStarts.splice(ghostIndex, 1);
|
|
5035
|
-
this.turnValueSet.delete(compaction.turn);
|
|
5036
|
-
this.removeGroupedTurn(compaction.turn);
|
|
5037
|
-
}
|
|
5038
5130
|
this.markSearchEntryDirty(target);
|
|
5039
5131
|
this.markSearchEntryDirty(index);
|
|
5040
5132
|
}
|
|
@@ -5106,15 +5198,25 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5106
5198
|
}
|
|
5107
5199
|
if (kind === "agent/inbox/spliced") {
|
|
5108
5200
|
const data = event.data;
|
|
5109
|
-
const
|
|
5201
|
+
const insertedSource = data.inserted;
|
|
5202
|
+
const inserted = Array.isArray(insertedSource) ? insertedSource.map((message) => ({
|
|
5110
5203
|
id: message.id,
|
|
5111
5204
|
insertionTurn: this.openTurn,
|
|
5112
5205
|
insertionTime: event.time
|
|
5113
|
-
}));
|
|
5114
|
-
|
|
5115
|
-
if (
|
|
5116
|
-
|
|
5117
|
-
|
|
5206
|
+
})) : [];
|
|
5207
|
+
const validInserted = Array.isArray(insertedSource) && inserted.every((identity) => typeof identity.id === "string" && identity.id !== "");
|
|
5208
|
+
if (validInserted) for (const { id } of inserted) this.claimedNextStepTurns.delete(id);
|
|
5209
|
+
if (data.target !== "next-step") return;
|
|
5210
|
+
const removedCount = data.removedCount ?? 0;
|
|
5211
|
+
if (!(validInserted && Number.isSafeInteger(data.start) && data.start >= 0 && Number.isSafeInteger(removedCount) && removedCount >= 0 && data.start <= this.pendingNextSteps.length && data.start + removedCount <= this.pendingNextSteps.length)) {
|
|
5212
|
+
this.pendingNextSteps.length = 0;
|
|
5213
|
+
this.claimedNextStepTurns.clear();
|
|
5214
|
+
return;
|
|
5215
|
+
}
|
|
5216
|
+
const priorObservedLength = this.pendingNextSteps.length;
|
|
5217
|
+
const removed = this.pendingNextSteps.splice(data.start, removedCount, ...inserted);
|
|
5218
|
+
if (!(data.start === 0 && removedCount > 0 && removedCount === priorObservedLength && inserted.length === 0 && data.outcome === void 0)) return;
|
|
5219
|
+
for (const identity of removed) if (identity.insertionTurn !== void 0 && identity.insertionTurn === this.openTurn) this.claimedNextStepTurns.set(identity.id, identity);
|
|
5118
5220
|
return;
|
|
5119
5221
|
}
|
|
5120
5222
|
if (kind === "compaction/start" || kind === "compaction/summary" || kind === "compaction/end" || kind === "session/end-seed") {
|
|
@@ -5170,6 +5272,11 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5170
5272
|
}
|
|
5171
5273
|
}
|
|
5172
5274
|
this.usage.onStepStart(event.data.turn, event.data.step);
|
|
5275
|
+
const latestSettled = activity.lastAssistantStep;
|
|
5276
|
+
if (latestSettled !== void 0 && event.data.step > latestSettled && activity.settledSteps.has(latestSettled) && !activity.intermediateAssistantSteps.has(latestSettled)) {
|
|
5277
|
+
activity.intermediateAssistantSteps.add(latestSettled);
|
|
5278
|
+
activity.revision += 1;
|
|
5279
|
+
}
|
|
5173
5280
|
const candidate = activity.messageCandidate;
|
|
5174
5281
|
if (candidate !== void 0 && candidate.step < event.data.step) {
|
|
5175
5282
|
this.confirmMessageCandidate(activity);
|
|
@@ -5181,6 +5288,9 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5181
5288
|
case "step/end": {
|
|
5182
5289
|
const activity = this.activityFor(event.data.turn);
|
|
5183
5290
|
if (activity.completed) break;
|
|
5291
|
+
if (event.data.turn === this.openTurn) {
|
|
5292
|
+
for (const identity of this.claimedNextStepTurns.values()) if (identity.insertionTurn === this.openTurn) this.claimedNextStepTurns.delete(identity.id);
|
|
5293
|
+
}
|
|
5184
5294
|
this.markAttemptEvidenceInterrupted(event.data.turn, event.data.step);
|
|
5185
5295
|
this.clearPreparingStartsForStep(event.data.turn, event.data.step);
|
|
5186
5296
|
this.usage.onStepEnd(event.data.turn, event.data.step);
|
|
@@ -5196,18 +5306,22 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5196
5306
|
this.adoptLeadingAnchors(event.data.turn);
|
|
5197
5307
|
activity.completed = false;
|
|
5198
5308
|
activity.reason = void 0;
|
|
5199
|
-
if (event.data.turn === this.currentTurn)
|
|
5309
|
+
if (event.data.turn === this.currentTurn) {
|
|
5310
|
+
for (const identity of this.claimedNextStepTurns.values()) if (identity.insertionTurn !== event.data.turn) this.claimedNextStepTurns.delete(identity.id);
|
|
5311
|
+
this.openTurn = event.data.turn;
|
|
5312
|
+
}
|
|
5200
5313
|
activity.revision += 1;
|
|
5201
5314
|
break;
|
|
5202
5315
|
}
|
|
5203
5316
|
case "user/message": {
|
|
5204
5317
|
const claimedIdentity = this.claimedNextStepTurns.get(event.data.id);
|
|
5205
|
-
|
|
5206
|
-
const
|
|
5318
|
+
this.claimedNextStepTurns.delete(event.data.id);
|
|
5319
|
+
const openTurn = this.openTurn;
|
|
5320
|
+
const deliveredThisTurn = claimedIdentity !== void 0 && openTurn !== void 0 && claimedIdentity.insertionTurn === openTurn && this.currentTurn === openTurn;
|
|
5321
|
+
const isMidTurnSteer = deliveredThisTurn;
|
|
5207
5322
|
const blocks = event.data.content;
|
|
5208
5323
|
const text = textWithAttachmentMarkers(blocks);
|
|
5209
5324
|
const sourcePresentation = contextPresentation(event.data.source);
|
|
5210
|
-
const sameTurnNextStepDelivery = wasClaimedFromNextStep === true && claimedIdentity !== void 0 && claimedIdentity.insertionTurn === this.currentTurn && (sourcePresentation.sourceKind === "tool-jobs" && sourcePresentation.form === "notice" || sourcePresentation.sourceKind === "agent-message" && sourcePresentation.form === "relay" || sourcePresentation.sourceKind === "subagent-settled" && sourcePresentation.form === "notice");
|
|
5211
5325
|
if (sourcePresentation.sourceKind === "user") {
|
|
5212
5326
|
if (!userBlocksVisibleNow(blocks)) break;
|
|
5213
5327
|
const activity = this.activityFor(this.currentTurn);
|
|
@@ -5237,7 +5351,8 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5237
5351
|
...summary === null ? {} : { summary },
|
|
5238
5352
|
icon: contextIconSemantic(event.data.source),
|
|
5239
5353
|
context: true,
|
|
5240
|
-
|
|
5354
|
+
...sourcePresentation.sourceKind === "ptc-mode" && blocks.some((block) => block.type === "image") ? { content: blocks } : {},
|
|
5355
|
+
contextPresentation: deliveredThisTurn ? {
|
|
5241
5356
|
...sourcePresentation,
|
|
5242
5357
|
sameTurnNextStep: true
|
|
5243
5358
|
} : sourcePresentation
|
|
@@ -5308,8 +5423,10 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5308
5423
|
if (!alreadySettled) activity.assistantMessages += 1;
|
|
5309
5424
|
activity.settledSteps.add(event.data.step);
|
|
5310
5425
|
const staleForFocus = event.data.step < priorLast;
|
|
5426
|
+
if (!staleForFocus && this.assistantStepHasFollowingActualCall(event.data.turn, event.data.step)) activity.intermediateAssistantSteps.add(event.data.step);
|
|
5311
5427
|
if (!staleForFocus) activity.lastAssistantVisible = event.data.interrupted === true || assistantBlocksVisibleNow(messageBlocks);
|
|
5312
5428
|
activity.lastAssistantStep = Math.max(priorLast, event.data.step);
|
|
5429
|
+
if (priorLast !== void 0 && event.data.step > priorLast && activity.settledSteps.has(priorLast) && !activity.intermediateAssistantSteps.has(priorLast)) activity.intermediateAssistantSteps.add(priorLast);
|
|
5313
5430
|
if (staleForFocus) {
|
|
5314
5431
|
if (activity.messageConfirmedStep === event.data.step) activity.messageConfirmed = text === "" ? void 0 : text.slice(-TranscriptFolder.MESSAGE_TAIL_CAP);
|
|
5315
5432
|
} else {
|
|
@@ -5378,7 +5495,15 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5378
5495
|
status: "running"
|
|
5379
5496
|
};
|
|
5380
5497
|
}
|
|
5381
|
-
this.
|
|
5498
|
+
const provenPrecedingSameStepCall = (step) => event.data.step === step && this.toolRowEvidence(callTurn, event.data.step, key)?.position === "before";
|
|
5499
|
+
const candidate = activity.messageCandidate;
|
|
5500
|
+
if (candidate !== void 0) {
|
|
5501
|
+
if (event.data.step > candidate.step || event.data.step === candidate.step && !provenPrecedingSameStepCall(candidate.step)) this.confirmMessageCandidate(activity);
|
|
5502
|
+
} else {
|
|
5503
|
+
const latest = activity.lastAssistantStep;
|
|
5504
|
+
if (latest !== void 0 && event.data.step > latest && activity.settledSteps.has(latest) && !activity.intermediateAssistantSteps.has(latest)) activity.intermediateAssistantSteps.add(latest);
|
|
5505
|
+
else if (latest !== void 0 && event.data.step === latest && activity.settledSteps.has(latest) && !provenPrecedingSameStepCall(latest) && !activity.intermediateAssistantSteps.has(latest)) activity.intermediateAssistantSteps.add(latest);
|
|
5506
|
+
}
|
|
5382
5507
|
this.syncMessage(activity);
|
|
5383
5508
|
activity.revision += 1;
|
|
5384
5509
|
}
|
|
@@ -5496,6 +5621,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5496
5621
|
case "turn/end": {
|
|
5497
5622
|
const endTurn = event.data.turn;
|
|
5498
5623
|
if (this.openTurn === endTurn) this.openTurn = void 0;
|
|
5624
|
+
for (const identity of this.claimedNextStepTurns.values()) if (identity.insertionTurn === endTurn) this.claimedNextStepTurns.delete(identity.id);
|
|
5499
5625
|
const endActivity = this.activityFor(endTurn);
|
|
5500
5626
|
endActivity.pendingPreSteerAnswerStep = void 0;
|
|
5501
5627
|
if (endActivity.completed) break;
|
|
@@ -5645,6 +5771,14 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5645
5771
|
}
|
|
5646
5772
|
}
|
|
5647
5773
|
};
|
|
5774
|
+
/** The official compaction lifecycle's admitted model-turn owner: a safe
|
|
5775
|
+
* non-negative integer from `compaction/start` or an end-only `compaction/end`.
|
|
5776
|
+
* The official `null` (standalone maintenance) and every missing/invalid value
|
|
5777
|
+
* admit NO numeric owner — never fall back to the fold's current/open turn.
|
|
5778
|
+
* Zero is a legal owner; this is a numeric test, never truthiness. */
|
|
5779
|
+
function compactionOwnerTurnOf(turn) {
|
|
5780
|
+
return typeof turn === "number" && Number.isSafeInteger(turn) && turn >= 0 ? turn : void 0;
|
|
5781
|
+
}
|
|
5648
5782
|
/** Validate and retain the official `command/done` outcome (post-PR166 plan
|
|
5649
5783
|
* §6): only a SUCCESS may carry the `sourceEventSeq` relationship, and the
|
|
5650
5784
|
* sequence must be a safe non-negative integer — anything malformed is
|
|
@@ -8095,6 +8229,139 @@ function initialEffortOf(row, choices) {
|
|
|
8095
8229
|
return advertised(row.configuredEffort) ?? advertised(row.defaultEffort) ?? choices[0].value;
|
|
8096
8230
|
}
|
|
8097
8231
|
//#endregion
|
|
8232
|
+
//#region src/tui/tsp/preset-guide-content.ts
|
|
8233
|
+
/** The official English Mode Guides of the four SHIPPED presets.
|
|
8234
|
+
*
|
|
8235
|
+
* The copy is a verbatim transcription of the official Web surface's curated
|
|
8236
|
+
* help, pinned to
|
|
8237
|
+
* `deepseek-ai/deepseek-harness@d743267388641bc76f17c45ce8b4c231aed1d32c`
|
|
8238
|
+
* `packages/client/ui-agent-preset/src/client/guide-locales.ts` (the `guideEn`
|
|
8239
|
+
* seat): the intro, the mode explanation and the usage examples, unchanged.
|
|
8240
|
+
* Refreshing the official wording means refreshing that pin — this module never
|
|
8241
|
+
* translates, rewrites or generates guide text of its own.
|
|
8242
|
+
*
|
|
8243
|
+
* Source license: the upstream repository is MIT (`Copyright (c) 2026
|
|
8244
|
+
* DeepSeek`); this transcription keeps the upstream wording and attributes the
|
|
8245
|
+
* source in this header rather than duplicating a license file, per the
|
|
8246
|
+
* repository's vendoring-attribution practice for small quoted excerpts.
|
|
8247
|
+
*
|
|
8248
|
+
* The Guide is READ-ONLY static content: it is not part of the live roster and
|
|
8249
|
+
* carries no business authority. A Custom declaration that reuses a shipped id
|
|
8250
|
+
* must never borrow an official Guide, so the lookup requires the caller's
|
|
8251
|
+
* ALREADY-DERIVED shipped classification instead of trusting the id alone.
|
|
8252
|
+
* @module tui/tsp/preset-guide-content
|
|
8253
|
+
*/
|
|
8254
|
+
/** The two Markdown sections the official Web dialog renders, in order. */
|
|
8255
|
+
const GUIDE_SECTION_HEADS = {
|
|
8256
|
+
modeDetails: "Mode details",
|
|
8257
|
+
howToUse: "How to use"
|
|
8258
|
+
};
|
|
8259
|
+
/** The four shipped presets' pinned official copy, keyed by shipped id. */
|
|
8260
|
+
const BUILT_IN_GUIDES = {
|
|
8261
|
+
standard: {
|
|
8262
|
+
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.",
|
|
8263
|
+
explanation: [
|
|
8264
|
+
"### How it works",
|
|
8265
|
+
"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.",
|
|
8266
|
+
"### When to choose it",
|
|
8267
|
+
"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."
|
|
8268
|
+
].join("\n\n"),
|
|
8269
|
+
usage: [
|
|
8270
|
+
"### Fix a bug",
|
|
8271
|
+
"> 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.",
|
|
8272
|
+
"Expected output: a code change, the relevant test results, and an explanation of the cause.",
|
|
8273
|
+
"### Organize project notes",
|
|
8274
|
+
"> Read the Markdown notes in this project. Summarize the agreed decisions and open questions, with links to the source files.",
|
|
8275
|
+
"Expected output: a summary with references that you can check against the original notes."
|
|
8276
|
+
].join("\n\n")
|
|
8277
|
+
},
|
|
8278
|
+
ptc: {
|
|
8279
|
+
intro: "Choose PTC mode when starting a new task. Specify the input files, processing rules, and output format. The agent writes the code.",
|
|
8280
|
+
explanation: [
|
|
8281
|
+
"### How tools are called",
|
|
8282
|
+
"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.",
|
|
8283
|
+
"### What reaches the model",
|
|
8284
|
+
"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.",
|
|
8285
|
+
"### Compared with Standard mode",
|
|
8286
|
+
"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."
|
|
8287
|
+
].join("\n\n"),
|
|
8288
|
+
usage: [
|
|
8289
|
+
"### Check a set of configuration files",
|
|
8290
|
+
"> 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.",
|
|
8291
|
+
"Expected output: an issue summary and a CSV report. The program can repeat the same checks, handle individual failures, and collect the results.",
|
|
8292
|
+
"### Summarize error logs",
|
|
8293
|
+
"> 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.",
|
|
8294
|
+
"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."
|
|
8295
|
+
].join("\n\n")
|
|
8296
|
+
},
|
|
8297
|
+
minimal: {
|
|
8298
|
+
intro: "Choose Minimal mode for a new task. For a comparison, hold the model, permissions, input, and starting workspace state constant across runs.",
|
|
8299
|
+
explanation: [
|
|
8300
|
+
"### What is included",
|
|
8301
|
+
"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.",
|
|
8302
|
+
"### When to choose it",
|
|
8303
|
+
"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."
|
|
8304
|
+
].join("\n\n"),
|
|
8305
|
+
usage: [
|
|
8306
|
+
"### Compare performance on a small bug fix",
|
|
8307
|
+
"> 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.",
|
|
8308
|
+
"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."
|
|
8309
|
+
].join("\n\n")
|
|
8310
|
+
},
|
|
8311
|
+
cordis: {
|
|
8312
|
+
intro: "Choose Creator mode for a new task. Describe the capability you want, where it should appear, and how you will verify it.",
|
|
8313
|
+
explanation: [
|
|
8314
|
+
"### What you can create",
|
|
8315
|
+
"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.",
|
|
8316
|
+
"### Plugins and modes",
|
|
8317
|
+
"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.",
|
|
8318
|
+
"### How the result takes effect",
|
|
8319
|
+
"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."
|
|
8320
|
+
].join("\n\n"),
|
|
8321
|
+
usage: [
|
|
8322
|
+
"### Add a UI",
|
|
8323
|
+
"> 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.",
|
|
8324
|
+
"Expected output: an installed plugin with a working entry and preview page, plus any remaining activation steps.",
|
|
8325
|
+
"### Add a tool",
|
|
8326
|
+
"> 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.",
|
|
8327
|
+
"Expected output: a plugin with a callable tool and a verified sample call.",
|
|
8328
|
+
"### Create my own mode",
|
|
8329
|
+
"> 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.",
|
|
8330
|
+
"Expected output: a custom preset for new tasks. These review instructions guide the agent; permission settings determine which actions it can execute."
|
|
8331
|
+
].join("\n\n")
|
|
8332
|
+
}
|
|
8333
|
+
};
|
|
8334
|
+
/**
|
|
8335
|
+
* The complete read-only Markdown body of one shipped preset's Mode guide: the
|
|
8336
|
+
* two official sections the Web dialog shows, rendered as ONE continuous
|
|
8337
|
+
* scrolling body instead of behind a second layer of tabs or a modal.
|
|
8338
|
+
*/
|
|
8339
|
+
function copyMarkdown(copy) {
|
|
8340
|
+
return [
|
|
8341
|
+
`## ${GUIDE_SECTION_HEADS.modeDetails}`,
|
|
8342
|
+
copy.intro,
|
|
8343
|
+
copy.explanation,
|
|
8344
|
+
`## ${GUIDE_SECTION_HEADS.howToUse}`,
|
|
8345
|
+
copy.usage
|
|
8346
|
+
].join("\n\n");
|
|
8347
|
+
}
|
|
8348
|
+
/**
|
|
8349
|
+
* The official Mode guide of one row, or `undefined` when the row must not have
|
|
8350
|
+
* one.
|
|
8351
|
+
*
|
|
8352
|
+
* `builtIn` is the row's ALREADY-DERIVED shipped classification — the value
|
|
8353
|
+
* `isBuiltInPresetRow` produced from the raw roster DTO. It is checked FIRST and
|
|
8354
|
+
* on its own: the shipped-id table is consulted only for a row the official
|
|
8355
|
+
* classification really calls shipped, so a user declaration that happens to
|
|
8356
|
+
* reuse `standard`/`ptc`/`minimal`/`cordis` (and therefore publishes its own
|
|
8357
|
+
* `name`) keeps its own copy and never inherits an official Guide.
|
|
8358
|
+
*/
|
|
8359
|
+
function builtInGuide(row) {
|
|
8360
|
+
if (!row.builtIn) return void 0;
|
|
8361
|
+
const copy = BUILT_IN_GUIDES[row.id];
|
|
8362
|
+
return copy === void 0 ? void 0 : copyMarkdown(copy);
|
|
8363
|
+
}
|
|
8364
|
+
//#endregion
|
|
8098
8365
|
//#region src/tui/pickers/preset-display.ts
|
|
8099
8366
|
/** The shipped-preset display copy, shared by every preset picker surface.
|
|
8100
8367
|
*
|
|
@@ -8334,19 +8601,25 @@ const QUEUE_CHORDS = {
|
|
|
8334
8601
|
}
|
|
8335
8602
|
};
|
|
8336
8603
|
/**
|
|
8337
|
-
* The Session Workspace
|
|
8604
|
+
* The Session Workspace's FIXED local chords (PR2 tree cycle, PR3 Inspect).
|
|
8338
8605
|
*
|
|
8339
8606
|
* The fullscreen PiTUI tree is a per-surface COMPONENT contract, not a Host
|
|
8340
|
-
* command: Tab/Shift+Tab step between Workspace Folder titles and
|
|
8341
|
-
*
|
|
8342
|
-
* key-label authority means a footer
|
|
8343
|
-
* into two authorities — the same
|
|
8344
|
-
* fixed chords.
|
|
8345
|
-
*/
|
|
8346
|
-
const SESSION_WORKSPACE_CHORDS = {
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8607
|
+
* command: Tab/Shift+Tab step between Workspace Folder titles and F2 opens the
|
|
8608
|
+
* read-only Inspector, so none of them has a keymap action or remap. Keeping
|
|
8609
|
+
* the handler and painted label in this ONE key-label authority means a footer
|
|
8610
|
+
* hint and the admitted keys cannot drift into two authorities — the same
|
|
8611
|
+
* category as the History/Delivered-files fixed chords.
|
|
8612
|
+
*/
|
|
8613
|
+
const SESSION_WORKSPACE_CHORDS = {
|
|
8614
|
+
folderCycle: {
|
|
8615
|
+
keys: ["tab", "shift+tab"],
|
|
8616
|
+
label: "Tab/Shift+Tab"
|
|
8617
|
+
},
|
|
8618
|
+
inspect: {
|
|
8619
|
+
keys: ["f2"],
|
|
8620
|
+
label: "F2"
|
|
8621
|
+
}
|
|
8622
|
+
};
|
|
8350
8623
|
/** The display name of a bare (unmodified) key id. */
|
|
8351
8624
|
const BASE_KEY_LABELS = {
|
|
8352
8625
|
enter: "Enter",
|
|
@@ -8378,7 +8651,7 @@ function formatKeyId(key) {
|
|
|
8378
8651
|
else if (part === "shift") mods.push("Shift");
|
|
8379
8652
|
else if (part === "super") mods.push("Super");
|
|
8380
8653
|
else base = part;
|
|
8381
|
-
const baseLabel = BASE_KEY_LABELS[base] ?? (base.length === 1 ? base.toUpperCase() : base);
|
|
8654
|
+
const baseLabel = BASE_KEY_LABELS[base] ?? (base.length === 1 || /^f\d+$/u.test(base) ? base.toUpperCase() : base);
|
|
8382
8655
|
return [...mods, baseLabel].join("+");
|
|
8383
8656
|
}
|
|
8384
8657
|
/** Format a `<leader>X` sequence label (`<leader>t` → `Leader T`). */
|
|
@@ -8430,11 +8703,19 @@ const TSP_VISUAL_COPY_LABEL = formatKeyId(TSP_VISUAL_CHORDS.copy);
|
|
|
8430
8703
|
const JOB_LOCAL_KEYS = {
|
|
8431
8704
|
/** Switch between the Output and Command pages, in both directions. */
|
|
8432
8705
|
switchPage: "tab",
|
|
8706
|
+
/** Toggle the Output page's adaptive multi-line Command preview. */
|
|
8707
|
+
togglePreview: "f2",
|
|
8433
8708
|
/** Copy the current page's exact original. A BARE letter — the same key the
|
|
8434
8709
|
* Settings workspace's copy uses and the one the `[C]` affordance badges name —
|
|
8435
8710
|
* so the bar hint reads `c copy …` and badge and key agree (§4.1, §7.1). */
|
|
8436
8711
|
copy: "c"
|
|
8437
8712
|
};
|
|
8713
|
+
/** Fixed Job Find search-row keys (owned here so panels never hard-code chords). */
|
|
8714
|
+
const JOB_SEARCH_LOCAL_KEYS = {
|
|
8715
|
+
commit: "enter",
|
|
8716
|
+
next: "n",
|
|
8717
|
+
prev: "shift+n"
|
|
8718
|
+
};
|
|
8438
8719
|
/**
|
|
8439
8720
|
* The SVG Viewer's FIXED screen-local chords (PR2.5).
|
|
8440
8721
|
*
|
|
@@ -9927,79 +10208,77 @@ function renderWelcomeWhaleLines(variant) {
|
|
|
9927
10208
|
const colors = WELCOME_WHALE_COLORS;
|
|
9928
10209
|
return welcomeWhalePlainLines(variant).map((line, index) => hexPaint(colors[Math.min(index, colors.length - 1)], line));
|
|
9929
10210
|
}
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9949
|
-
* value is the bare hex prefix (the leading Session prefix stripped). */
|
|
9950
|
-
function cliAutoPrefix(query) {
|
|
9951
|
-
const bare = query.replace(/^session[-_]/i, "");
|
|
9952
|
-
return CLI_PREFIX.test(bare) ? bare : void 0;
|
|
9953
|
-
}
|
|
9954
|
-
/**
|
|
9955
|
-
* Resolve one session row for a typed resume query. A full id wins over the
|
|
9956
|
-
* row order; otherwise only a UNIQUE non-empty prefix (the `session-` form or
|
|
9957
|
-
* the short id) is resolved. An ambiguous or missing prefix returns undefined
|
|
9958
|
-
* so the read owner seeds the same global Browser search instead of guessing.
|
|
9959
|
-
* @param rows - the listed main-session rows (never re-filtered here).
|
|
9960
|
-
* @param query - the resume query.
|
|
9961
|
-
* @returns the matching row, or undefined.
|
|
9962
|
-
*/
|
|
9963
|
-
function findSessionMatch(rows, query) {
|
|
9964
|
-
const exact = rows.find((row) => row.id === query);
|
|
9965
|
-
if (exact !== void 0) return exact;
|
|
9966
|
-
const bare = query.replace(/^session[-_]/i, "");
|
|
9967
|
-
if (bare === "") return void 0;
|
|
9968
|
-
let candidate;
|
|
9969
|
-
for (const row of rows) {
|
|
9970
|
-
if (!row.id.replace(/^session[-_]/i, "").startsWith(bare) && !shortSessionId(row.id).startsWith(bare)) continue;
|
|
9971
|
-
if (candidate !== void 0) return void 0;
|
|
9972
|
-
candidate = row;
|
|
9973
|
-
}
|
|
9974
|
-
return candidate;
|
|
10211
|
+
//#endregion
|
|
10212
|
+
//#region src/app/command/session-browser-presentation.ts
|
|
10213
|
+
/** Whether the Client-root eligibility proves THIS Client may answer the
|
|
10214
|
+
* pending candidate the Host reported for `sessionId`. */
|
|
10215
|
+
function classifyLiveEligibility(sessionId, eligibility) {
|
|
10216
|
+
const live = eligibility?.filter((entry) => entry.live && entry.sessionId === sessionId) ?? [];
|
|
10217
|
+
if (live.some((entry) => entry.kind === "approval")) return {
|
|
10218
|
+
pending: "approval",
|
|
10219
|
+
answerable: true
|
|
10220
|
+
};
|
|
10221
|
+
const questions = live.filter((entry) => entry.kind === "question");
|
|
10222
|
+
if (questions.length === 0) return {
|
|
10223
|
+
pending: "unknown",
|
|
10224
|
+
answerable: false
|
|
10225
|
+
};
|
|
10226
|
+
return {
|
|
10227
|
+
pending: questions.every((entry) => entry.subtype === "plan-review") ? "plan-review" : "question",
|
|
10228
|
+
answerable: true
|
|
10229
|
+
};
|
|
9975
10230
|
}
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
}
|
|
9999
|
-
/**
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10231
|
+
function classifyPending(activity, eligibility) {
|
|
10232
|
+
if (activity === void 0) return {
|
|
10233
|
+
pending: "unknown",
|
|
10234
|
+
answerable: false
|
|
10235
|
+
};
|
|
10236
|
+
const { attention, attentionSourceState, continuedQuestionCallIds } = activity;
|
|
10237
|
+
if (attentionSourceState === "known" && (attention === "question" || attention === "plan-review") && (continuedQuestionCallIds?.length ?? 0) > 0 && eligibility !== void 0) return {
|
|
10238
|
+
pending: "late-answer",
|
|
10239
|
+
answerable: true
|
|
10240
|
+
};
|
|
10241
|
+
if (attention === "none") return {
|
|
10242
|
+
pending: attentionSourceState === "known" ? "none" : attentionSourceState,
|
|
10243
|
+
answerable: false
|
|
10244
|
+
};
|
|
10245
|
+
if (attention === "unknown") return {
|
|
10246
|
+
pending: attentionSourceState === "known" ? "unknown" : attentionSourceState,
|
|
10247
|
+
answerable: false
|
|
10248
|
+
};
|
|
10249
|
+
return {
|
|
10250
|
+
pending: "unverified",
|
|
10251
|
+
answerable: false
|
|
10252
|
+
};
|
|
10253
|
+
}
|
|
10254
|
+
/** The ONE pure Session Browser admission/classification policy.
|
|
10255
|
+
*
|
|
10256
|
+
* `activity` must be the exact accepted sample for this row and roster
|
|
10257
|
+
* revision. Search deliberately does not use Activity: every known blank is
|
|
10258
|
+
* excluded from an ordinary query, while Browse retains a proved Needs/Working
|
|
10259
|
+
* row as a real active-session exception. */
|
|
10260
|
+
function classifySessionBrowserRow(row, activity, eligibility, status) {
|
|
10261
|
+
const exactActivity = activity?.sessionId === row.id ? activity : void 0;
|
|
10262
|
+
const exactStatus = status?.sessionId === row.id ? status : void 0;
|
|
10263
|
+
const live = classifyLiveEligibility(row.id, eligibility);
|
|
10264
|
+
const derived = classifyPending(exactActivity, eligibility);
|
|
10265
|
+
const pending = live.answerable ? live.pending : derived.pending;
|
|
10266
|
+
const answerable = live.answerable || derived.answerable;
|
|
10267
|
+
const childRunning = exactActivity?.runningChildren;
|
|
10268
|
+
const completionUnread = exactStatus?.completionUnread === true;
|
|
10269
|
+
const working = exactActivity?.running === true || (childRunning ?? 0) > 0;
|
|
10270
|
+
const normal = row.origin !== "subagent";
|
|
10271
|
+
return {
|
|
10272
|
+
priority: answerable ? "needs" : working ? "working" : completionUnread ? "unread" : "recent",
|
|
10273
|
+
pending,
|
|
10274
|
+
running: exactActivity?.running,
|
|
10275
|
+
childRunning,
|
|
10276
|
+
completionUnread,
|
|
10277
|
+
answerable,
|
|
10278
|
+
source: exactActivity?.attentionSourceState ?? "unknown",
|
|
10279
|
+
browseEligible: normal && (row.blank !== true || answerable || working),
|
|
10280
|
+
searchEligible: normal && row.blank !== true
|
|
10281
|
+
};
|
|
10003
10282
|
}
|
|
10004
10283
|
//#endregion
|
|
10005
10284
|
//#region src/tui/pickers/sessions.ts
|
|
@@ -12177,11 +12456,34 @@ function subagentJobViewHint(status, detail) {
|
|
|
12177
12456
|
}
|
|
12178
12457
|
//#endregion
|
|
12179
12458
|
//#region src/tui/presentation/session-workspace-view.ts
|
|
12459
|
+
/**
|
|
12460
|
+
* M5-U-D — the ONE pure projection of the fullscreen PiTUI Session Workspace.
|
|
12461
|
+
*
|
|
12462
|
+
* This module is UI-only: it imports no backend, adapter, Agent or transport,
|
|
12463
|
+
* performs no IO and holds no state. It answers three questions for the ONE
|
|
12464
|
+
* panel that paints them, from facts the panel already received:
|
|
12465
|
+
*
|
|
12466
|
+
* 1. which single group each listed main Session belongs to
|
|
12467
|
+
* (`Needs attention` → `Working` → `Recent`),
|
|
12468
|
+
* 2. which Sessions the current Workspace scope really lists,
|
|
12469
|
+
* 3. what the header may truthfully say about attention OUTSIDE that scope.
|
|
12470
|
+
*
|
|
12471
|
+
* Authority chain (all read-only, all already sampled by their owner):
|
|
12472
|
+
* `SessionReader.list()` is the ONLY roster; `SessionWorkspaceFactsPort.
|
|
12473
|
+
* readActivity()` is the ONLY activity sample; the Client-root forwarded
|
|
12474
|
+
* answer eligibility (G567) is the ONLY positive answerability proof. A reader
|
|
12475
|
+
* `attention` value alone is NEVER the permission to answer, so a pending
|
|
12476
|
+
* candidate this Client cannot prove it can answer is `unverified` — never a
|
|
12477
|
+
* Needs row and never a fabricated `No pending`.
|
|
12478
|
+
*
|
|
12479
|
+
* @module @xmoon76/dsh-pi-tui/tui/presentation/session-workspace-view
|
|
12480
|
+
*/
|
|
12180
12481
|
/** The ONE verbose pending wording shared by Peek/Details. */
|
|
12181
12482
|
const SESSION_PENDING_LABEL = {
|
|
12182
12483
|
question: "Question",
|
|
12183
12484
|
approval: "Approval",
|
|
12184
12485
|
"plan-review": "Plan review",
|
|
12486
|
+
"late-answer": "Late answer",
|
|
12185
12487
|
none: "No pending",
|
|
12186
12488
|
unknown: "Pending unknown",
|
|
12187
12489
|
unavailable: "Pending unavailable",
|
|
@@ -12195,13 +12497,23 @@ const SESSION_SOURCE_LABEL = {
|
|
|
12195
12497
|
unavailable: "unavailable",
|
|
12196
12498
|
denied: "denied"
|
|
12197
12499
|
};
|
|
12198
|
-
/** The ONE
|
|
12500
|
+
/** The ONE verbose row status wording shared by Peek/Details and the panels. */
|
|
12199
12501
|
function workspaceRowStatusLabel(fact) {
|
|
12200
|
-
if (fact.priority === "needs")
|
|
12201
|
-
|
|
12502
|
+
if (fact.priority === "needs") {
|
|
12503
|
+
const base = `Needs attention · ${SESSION_PENDING_LABEL[fact.pending]}`;
|
|
12504
|
+
return fact.running === true || (fact.childRunning ?? 0) > 0 ? `${base} · ${workspaceWorkingLabel(fact)}` : base;
|
|
12505
|
+
}
|
|
12506
|
+
if (fact.priority === "working") return workspaceWorkingLabel(fact);
|
|
12507
|
+
if (fact.priority === "unread") return "Completed · unread";
|
|
12202
12508
|
if (fact.pending === "unverified") return "Pending · not actionable here";
|
|
12203
12509
|
return "";
|
|
12204
12510
|
}
|
|
12511
|
+
/** The ONE compact working wording: `0` is never printed as a positive fact. */
|
|
12512
|
+
function workspaceWorkingLabel(fact) {
|
|
12513
|
+
const count = fact.childRunning;
|
|
12514
|
+
if (count === void 0 || count <= 0) return "Working";
|
|
12515
|
+
return `Working · ${count} running ${count === 1 ? "child" : "children"}`;
|
|
12516
|
+
}
|
|
12205
12517
|
/** Display title collisions by the shortest unique Host path tail. The ID is a
|
|
12206
12518
|
* final fallback only when Host paths themselves remain indistinguishable. */
|
|
12207
12519
|
function workspaceDisplayLabels(workspaces) {
|
|
@@ -12268,9 +12580,10 @@ function visibleWorkspaceBrowserRows(model, display, selectedSessionId, currentS
|
|
|
12268
12580
|
const facts = group.ids.map((id) => model.rowsById.get(id));
|
|
12269
12581
|
const needs = facts.filter((fact) => fact.priority === "needs").length;
|
|
12270
12582
|
const working = facts.filter((fact) => fact.priority === "working").length;
|
|
12583
|
+
const unread = facts.filter((fact) => fact.priority === "unread").length;
|
|
12271
12584
|
const current = group.workspaceId === model.currentWorkspaceId;
|
|
12272
12585
|
const next = group.workspaceId === model.nextCreateWorkspaceId;
|
|
12273
|
-
const defaultExpanded = current || next || needs + working > 0;
|
|
12586
|
+
const defaultExpanded = current || next || needs + working + unread > 0;
|
|
12274
12587
|
const expanded = display.expanded.get(group.workspaceId) ?? defaultExpanded;
|
|
12275
12588
|
const groupRows = [];
|
|
12276
12589
|
rows.push({
|
|
@@ -12282,6 +12595,7 @@ function visibleWorkspaceBrowserRows(model, display, selectedSessionId, currentS
|
|
|
12282
12595
|
total: group.ids.length,
|
|
12283
12596
|
needs,
|
|
12284
12597
|
working,
|
|
12598
|
+
unread,
|
|
12285
12599
|
expanded,
|
|
12286
12600
|
current,
|
|
12287
12601
|
next
|
|
@@ -12342,41 +12656,13 @@ function inScope(fact, scope, currentWorkspaceId, baselineProven) {
|
|
|
12342
12656
|
case "unassigned": return baselineProven && fact.membership.kind === "unassigned";
|
|
12343
12657
|
}
|
|
12344
12658
|
}
|
|
12345
|
-
/** Whether the Client-root eligibility proves THIS Client may answer the
|
|
12346
|
-
* pending candidate the Host reported for `sessionId`. */
|
|
12347
|
-
function provedAnswerable(fact, eligibility) {
|
|
12348
|
-
if (fact.attentionSourceState !== "known") return false;
|
|
12349
|
-
if (fact.attention === "approval") return eligibility?.some((entry) => entry.sessionId === fact.sessionId && entry.kind === "approval") === true;
|
|
12350
|
-
if (fact.attention !== "question" && fact.attention !== "plan-review") return false;
|
|
12351
|
-
if (eligibility?.some((entry) => entry.sessionId === fact.sessionId && entry.kind === "question") === true) return true;
|
|
12352
|
-
return eligibility !== void 0 && (fact.continuedQuestionCallIds?.length ?? 0) > 0;
|
|
12353
|
-
}
|
|
12354
|
-
function classifyPending(activity, eligibility) {
|
|
12355
|
-
if (activity === void 0) return {
|
|
12356
|
-
pending: "unknown",
|
|
12357
|
-
answerable: false
|
|
12358
|
-
};
|
|
12359
|
-
const { attention, attentionSourceState } = activity;
|
|
12360
|
-
if (attention === "none") return {
|
|
12361
|
-
pending: attentionSourceState === "known" ? "none" : attentionSourceState,
|
|
12362
|
-
answerable: false
|
|
12363
|
-
};
|
|
12364
|
-
if (attention === "unknown") return {
|
|
12365
|
-
pending: attentionSourceState === "known" ? "unknown" : attentionSourceState,
|
|
12366
|
-
answerable: false
|
|
12367
|
-
};
|
|
12368
|
-
const answerable = provedAnswerable(activity, eligibility);
|
|
12369
|
-
return {
|
|
12370
|
-
pending: answerable ? attention : "unverified",
|
|
12371
|
-
answerable
|
|
12372
|
-
};
|
|
12373
|
-
}
|
|
12374
12659
|
/** Build the ONE view of one frame. Every input is an official fact or the
|
|
12375
12660
|
* previous pure ordering; nothing here reads, writes or invents a Session. */
|
|
12376
12661
|
function buildSessionWorkspaceView(input) {
|
|
12377
12662
|
const roster = input.rows.filter((row) => row.origin !== "subagent");
|
|
12378
12663
|
const activityById = /* @__PURE__ */ new Map();
|
|
12379
12664
|
for (const activity of input.activity ?? []) activityById.set(activity.sessionId, activity);
|
|
12665
|
+
const statusById = input.status;
|
|
12380
12666
|
const currentWorkspaceId = currentWorkspaceOf(input.workspaces, input.currentSessionId);
|
|
12381
12667
|
const rosterIndex = /* @__PURE__ */ new Map();
|
|
12382
12668
|
roster.forEach((row, index) => {
|
|
@@ -12388,17 +12674,31 @@ function buildSessionWorkspaceView(input) {
|
|
|
12388
12674
|
});
|
|
12389
12675
|
const rowsById = /* @__PURE__ */ new Map();
|
|
12390
12676
|
const classified = [];
|
|
12677
|
+
/** Derived in the SAME classification pass, before the skip: a hidden quiet
|
|
12678
|
+
* current blank may only move its marker onto the existing New action of its
|
|
12679
|
+
* ONE proved official Workspace. It is never added back to the eligible
|
|
12680
|
+
* projection or the group ids. */
|
|
12681
|
+
let currentQuietBlankWorkspaceId;
|
|
12391
12682
|
for (const row of roster) {
|
|
12392
|
-
const
|
|
12393
|
-
|
|
12683
|
+
const classification = classifySessionBrowserRow(row, activityById.get(row.id), input.answerEligibility, statusById?.get(row.id));
|
|
12684
|
+
if (!classification.browseEligible) {
|
|
12685
|
+
if (row.id === input.currentSessionId && row.blank === true && input.workspaceBaselineProven) {
|
|
12686
|
+
const membership = workspaceMembershipOf(input.workspaces, row.id, true);
|
|
12687
|
+
if (membership.kind === "assigned") currentQuietBlankWorkspaceId = membership.workspaceIds[0];
|
|
12688
|
+
}
|
|
12689
|
+
continue;
|
|
12690
|
+
}
|
|
12394
12691
|
const fact = {
|
|
12395
12692
|
sessionId: row.id,
|
|
12396
|
-
priority:
|
|
12397
|
-
group:
|
|
12398
|
-
pending,
|
|
12399
|
-
running:
|
|
12400
|
-
|
|
12401
|
-
|
|
12693
|
+
priority: classification.priority,
|
|
12694
|
+
group: classification.priority,
|
|
12695
|
+
pending: classification.pending,
|
|
12696
|
+
running: classification.running,
|
|
12697
|
+
childRunning: classification.childRunning,
|
|
12698
|
+
completionUnread: classification.completionUnread,
|
|
12699
|
+
isCurrent: row.id === input.currentSessionId,
|
|
12700
|
+
answerable: classification.answerable,
|
|
12701
|
+
source: classification.source,
|
|
12402
12702
|
membership: workspaceMembershipOf(input.workspaces, row.id, input.workspaceBaselineProven)
|
|
12403
12703
|
};
|
|
12404
12704
|
rowsById.set(row.id, fact);
|
|
@@ -12409,6 +12709,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12409
12709
|
const priority = [
|
|
12410
12710
|
"needs",
|
|
12411
12711
|
"working",
|
|
12712
|
+
"unread",
|
|
12412
12713
|
"recent"
|
|
12413
12714
|
];
|
|
12414
12715
|
const byPriority = priority.indexOf(left.priority) - priority.indexOf(right.priority);
|
|
@@ -12427,6 +12728,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12427
12728
|
for (const kind of [
|
|
12428
12729
|
"needs",
|
|
12429
12730
|
"working",
|
|
12731
|
+
"unread",
|
|
12430
12732
|
"recent"
|
|
12431
12733
|
]) {
|
|
12432
12734
|
const ids = scoped.filter((fact) => fact.priority === kind).sort(orderOf).map((fact) => fact.sessionId);
|
|
@@ -12434,9 +12736,10 @@ function buildSessionWorkspaceView(input) {
|
|
|
12434
12736
|
groups.push({
|
|
12435
12737
|
kind,
|
|
12436
12738
|
workspaceId: kind,
|
|
12437
|
-
title: kind === "needs" ? "Needs attention" : kind === "working" ? "Working" : "Recent",
|
|
12739
|
+
title: kind === "needs" ? "Needs attention" : kind === "working" ? "Working" : kind === "unread" ? "Completed · unread" : "Recent",
|
|
12438
12740
|
path: "",
|
|
12439
|
-
ids
|
|
12741
|
+
ids,
|
|
12742
|
+
unread: kind === "unread" ? ids.length : 0
|
|
12440
12743
|
});
|
|
12441
12744
|
listIds.push(...ids);
|
|
12442
12745
|
}
|
|
@@ -12446,6 +12749,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12446
12749
|
rowsById,
|
|
12447
12750
|
outsideAttention: { kind: "none" },
|
|
12448
12751
|
currentWorkspaceId,
|
|
12752
|
+
currentQuietBlankWorkspaceId,
|
|
12449
12753
|
nextCreateWorkspaceId: input.nextCreateWorkspaceId,
|
|
12450
12754
|
workspaceBaselineProven: input.workspaceBaselineProven
|
|
12451
12755
|
};
|
|
@@ -12457,6 +12761,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12457
12761
|
for (const kind of [
|
|
12458
12762
|
"needs",
|
|
12459
12763
|
"working",
|
|
12764
|
+
"unread",
|
|
12460
12765
|
"recent"
|
|
12461
12766
|
]) {
|
|
12462
12767
|
const ids = scoped.filter((fact) => fact.priority === kind).sort(orderOf).map((fact) => fact.sessionId);
|
|
@@ -12464,9 +12769,10 @@ function buildSessionWorkspaceView(input) {
|
|
|
12464
12769
|
legacyGroups.push({
|
|
12465
12770
|
kind,
|
|
12466
12771
|
workspaceId: kind,
|
|
12467
|
-
title: kind === "needs" ? "Needs attention" : kind === "working" ? "Working" : "Recent",
|
|
12772
|
+
title: kind === "needs" ? "Needs attention" : kind === "working" ? "Working" : kind === "unread" ? "Completed · unread" : "Recent",
|
|
12468
12773
|
path: "",
|
|
12469
|
-
ids
|
|
12774
|
+
ids,
|
|
12775
|
+
unread: kind === "unread" ? ids.length : 0
|
|
12470
12776
|
});
|
|
12471
12777
|
legacyListIds.push(...ids);
|
|
12472
12778
|
}
|
|
@@ -12476,6 +12782,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12476
12782
|
rowsById,
|
|
12477
12783
|
outsideAttention: { kind: "none" },
|
|
12478
12784
|
currentWorkspaceId,
|
|
12785
|
+
currentQuietBlankWorkspaceId,
|
|
12479
12786
|
nextCreateWorkspaceId: input.nextCreateWorkspaceId,
|
|
12480
12787
|
workspaceBaselineProven: false
|
|
12481
12788
|
};
|
|
@@ -12489,7 +12796,8 @@ function buildSessionWorkspaceView(input) {
|
|
|
12489
12796
|
workspaceId: workspace.workspaceId,
|
|
12490
12797
|
title: workspace.title,
|
|
12491
12798
|
path: workspace.path,
|
|
12492
|
-
ids
|
|
12799
|
+
ids,
|
|
12800
|
+
unread: ids.filter((id) => rowsById.get(id)?.priority === "unread").length
|
|
12493
12801
|
});
|
|
12494
12802
|
}
|
|
12495
12803
|
const ambiguous = classified.filter((fact) => fact.membership.kind === "ambiguous").sort(orderOf).map((fact) => fact.sessionId);
|
|
@@ -12498,13 +12806,15 @@ function buildSessionWorkspaceView(input) {
|
|
|
12498
12806
|
workspaceId: "ambiguous",
|
|
12499
12807
|
title: "Membership ambiguous",
|
|
12500
12808
|
path: "",
|
|
12501
|
-
ids: ambiguous
|
|
12809
|
+
ids: ambiguous,
|
|
12810
|
+
unread: ambiguous.filter((id) => rowsById.get(id)?.priority === "unread").length
|
|
12502
12811
|
});
|
|
12503
12812
|
if (unassigned.length > 0) groups.push({
|
|
12504
12813
|
workspaceId: "unassigned",
|
|
12505
12814
|
title: "Unassigned",
|
|
12506
12815
|
path: "",
|
|
12507
|
-
ids: unassigned
|
|
12816
|
+
ids: unassigned,
|
|
12817
|
+
unread: unassigned.filter((id) => rowsById.get(id)?.priority === "unread").length
|
|
12508
12818
|
});
|
|
12509
12819
|
const priorityWorkspaceId = currentWorkspaceId ?? input.nextCreateWorkspaceId;
|
|
12510
12820
|
if (priorityWorkspaceId !== void 0) {
|
|
@@ -12535,135 +12845,641 @@ function buildSessionWorkspaceView(input) {
|
|
|
12535
12845
|
rowsById,
|
|
12536
12846
|
outsideAttention,
|
|
12537
12847
|
currentWorkspaceId,
|
|
12848
|
+
currentQuietBlankWorkspaceId,
|
|
12538
12849
|
nextCreateWorkspaceId: input.nextCreateWorkspaceId,
|
|
12539
12850
|
workspaceBaselineProven: input.workspaceBaselineProven
|
|
12540
12851
|
};
|
|
12541
12852
|
}
|
|
12542
12853
|
//#endregion
|
|
12543
|
-
//#region src/
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
function
|
|
12549
|
-
if (
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
|
|
12553
|
-
|
|
12554
|
-
|
|
12555
|
-
|
|
12556
|
-
|
|
12557
|
-
|
|
12558
|
-
|
|
12559
|
-
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
*/
|
|
12563
|
-
function
|
|
12564
|
-
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
|
-
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12571
|
-
|
|
12572
|
-
|
|
12573
|
-
|
|
12574
|
-
|
|
12575
|
-
|
|
12576
|
-
|
|
12577
|
-
|
|
12578
|
-
|
|
12579
|
-
|
|
12580
|
-
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
|
|
12584
|
-
|
|
12585
|
-
|
|
12586
|
-
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
|
|
12854
|
+
//#region src/tui/presentation/session-inspector-view.ts
|
|
12855
|
+
/** The display token for an absent optional value: unknown, never zero. */
|
|
12856
|
+
const MISSING = "—";
|
|
12857
|
+
/** One display duration with a real unit. This is presentation only: the raw
|
|
12858
|
+
* millisecond values stay the Inspector DTO's authority. */
|
|
12859
|
+
function formatInspectorDuration(ms) {
|
|
12860
|
+
if (!Number.isFinite(ms) || ms < 0) return MISSING;
|
|
12861
|
+
if (ms < 1e3) return `${Math.round(ms)}ms`;
|
|
12862
|
+
const totalSeconds = Math.floor(ms / 1e3);
|
|
12863
|
+
const seconds = totalSeconds % 60;
|
|
12864
|
+
const totalMinutes = Math.floor(totalSeconds / 60);
|
|
12865
|
+
if (totalMinutes < 1) {
|
|
12866
|
+
const text = (ms / 1e3).toFixed(1);
|
|
12867
|
+
return `${text.endsWith(".0") ? text.slice(0, -2) : text}s`;
|
|
12868
|
+
}
|
|
12869
|
+
if (totalMinutes < 60) return `${totalMinutes}m${String(seconds).padStart(2, "0")}s`;
|
|
12870
|
+
const minutes = totalMinutes % 60;
|
|
12871
|
+
return `${Math.floor(totalMinutes / 60)}h${String(minutes).padStart(2, "0")}m${String(seconds).padStart(2, "0")}s`;
|
|
12872
|
+
}
|
|
12873
|
+
/** One display rate with a real unit; absent samples stay unknown. */
|
|
12874
|
+
function formatInspectorRate(tokensPerSec) {
|
|
12875
|
+
if (tokensPerSec === void 0 || !Number.isFinite(tokensPerSec)) return MISSING;
|
|
12876
|
+
const text = tokensPerSec.toFixed(1);
|
|
12877
|
+
return `${text.endsWith(".0") ? text.slice(0, -2) : text} tok/s`;
|
|
12878
|
+
}
|
|
12879
|
+
/** Context occupancy: approximate percentage and/or used/window, independently
|
|
12880
|
+
* missing. The percentage is never painted without a legal denominator. */
|
|
12881
|
+
function contextValue(data) {
|
|
12882
|
+
const context = data.context;
|
|
12883
|
+
if (context === void 0) return MISSING;
|
|
12884
|
+
const parts = [];
|
|
12885
|
+
if (context.percent !== void 0) parts.push(`≈${context.percent}%`);
|
|
12886
|
+
if (context.usedTokens !== void 0) parts.push(context.windowTokens === void 0 ? `${formatTokens(context.usedTokens)} tokens` : `${formatTokens(context.usedTokens)} / ${formatTokens(context.windowTokens)}`);
|
|
12887
|
+
else if (context.windowTokens !== void 0) parts.push(`window ${formatTokens(context.windowTokens)}`);
|
|
12888
|
+
return parts.length === 0 ? MISSING : parts.join(" · ");
|
|
12889
|
+
}
|
|
12890
|
+
/** One official membership label from the proven Workspace facts, never from a
|
|
12891
|
+
* cwd. Unknown/unassigned/ambiguous keep their own truthful words. */
|
|
12892
|
+
function membershipValue(fact, workspaces, baselineProven) {
|
|
12893
|
+
if (fact === void 0 || !baselineProven) return "Unknown";
|
|
12894
|
+
switch (fact.membership.kind) {
|
|
12895
|
+
case "unknown": return "Unknown";
|
|
12896
|
+
case "unassigned": return "Unassigned";
|
|
12897
|
+
case "ambiguous": return `Ambiguous (${fact.membership.workspaceIds.map(sanitizedPhysicalLine).join(", ")})`;
|
|
12898
|
+
case "assigned": return fact.membership.workspaceIds.map((id) => {
|
|
12899
|
+
const workspace = workspaces.find((candidate) => candidate.workspaceId === id);
|
|
12900
|
+
if (workspace === void 0) return sanitizedPhysicalLine(id);
|
|
12901
|
+
const title = sanitizedPhysicalLine(workspace.title);
|
|
12902
|
+
const path = sanitizedPhysicalLine(workspace.path);
|
|
12903
|
+
return path === "" ? title : `${title} · ${path}`;
|
|
12904
|
+
}).join(" · ");
|
|
12905
|
+
}
|
|
12906
|
+
}
|
|
12907
|
+
/** The positive identity/state facts of one Session row. Only proven facts are
|
|
12908
|
+
* painted; `ing`/`live`/`current` never imply one another. */
|
|
12909
|
+
function stateParts(row, fact, currentSessionId) {
|
|
12910
|
+
const parts = [];
|
|
12911
|
+
if (row.id === currentSessionId) parts.push("Current");
|
|
12912
|
+
parts.push(row.live ? "Live" : "Persisted");
|
|
12913
|
+
if (fact !== void 0) {
|
|
12914
|
+
const status = workspaceRowStatusLabel(fact);
|
|
12915
|
+
if (status === "Pending · not actionable here") parts.push("Pending unverified");
|
|
12916
|
+
else if (status !== "") parts.push(status);
|
|
12917
|
+
}
|
|
12918
|
+
if (row.formatStatus === "migration-required") parts.push("Migration required");
|
|
12919
|
+
return parts;
|
|
12590
12920
|
}
|
|
12591
|
-
|
|
12592
|
-
|
|
12593
|
-
|
|
12594
|
-
|
|
12595
|
-
|
|
12596
|
-
|
|
12597
|
-
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
|
|
12602
|
-
|
|
12603
|
-
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
*
|
|
12615
|
-
* No renderer state (width, theme, focus, TSP, TUI canvas) enters the plan.
|
|
12616
|
-
* @module @xmoon76/dsh-pi-tui/domain/visual/placement
|
|
12617
|
-
*/
|
|
12618
|
-
/** The strict marker label prefix. */
|
|
12619
|
-
const MARKER_LABEL_PREFIX = "dsh-visual-";
|
|
12620
|
-
/** The strict marker line: column 0, exact label, exact `<#>` destination. */
|
|
12621
|
-
const MARKER_LINE_PATTERN = /^\[dsh-visual-(sv2_[0-9a-f]{20})\]: <#>$/u;
|
|
12622
|
-
/**
|
|
12623
|
-
* The block-level visual label shape. A definition with this shape is NEVER
|
|
12624
|
-
* injected into the display-only shared-definition prefix, whether or not it
|
|
12625
|
-
* is published: the marker line must keep its own Markdown definition
|
|
12626
|
-
* semantics in the source.
|
|
12627
|
-
*/
|
|
12628
|
-
const VISUAL_LABEL_PATTERN = /^dsh-visual-sv2_[0-9a-f]{20}$/u;
|
|
12629
|
-
/** The renderer's own Marked version. Block `def` grammar is the default
|
|
12630
|
-
* grammar; the vendored inline extensions never change a top-level
|
|
12631
|
-
* definition's recognition. */
|
|
12632
|
-
const LEXER = new Marked();
|
|
12633
|
-
/** The ordered ContentBlocks of one Assistant body. */
|
|
12634
|
-
function blocksOf(input) {
|
|
12635
|
-
if (input.content !== void 0 && input.content.length > 0) return input.content;
|
|
12636
|
-
return input.text === "" ? [] : [{
|
|
12637
|
-
type: "text",
|
|
12638
|
-
text: input.text
|
|
12921
|
+
/** The official goal objective/phase, with legal null kept as 'No goal'. */
|
|
12922
|
+
function goalFacts(data) {
|
|
12923
|
+
const goal = data.goal;
|
|
12924
|
+
if (goal === void 0) return [{
|
|
12925
|
+
label: "Goal",
|
|
12926
|
+
value: "Unknown"
|
|
12927
|
+
}, {
|
|
12928
|
+
label: "Goal phase",
|
|
12929
|
+
value: MISSING
|
|
12930
|
+
}];
|
|
12931
|
+
if (goal === null) return [{
|
|
12932
|
+
label: "Goal",
|
|
12933
|
+
value: "No goal"
|
|
12934
|
+
}, {
|
|
12935
|
+
label: "Goal phase",
|
|
12936
|
+
value: MISSING
|
|
12937
|
+
}];
|
|
12938
|
+
return [{
|
|
12939
|
+
label: "Goal",
|
|
12940
|
+
value: sanitizedPhysicalLine(goal.objective)
|
|
12941
|
+
}, {
|
|
12942
|
+
label: "Goal phase",
|
|
12943
|
+
value: goal.phase
|
|
12639
12944
|
}];
|
|
12640
12945
|
}
|
|
12641
|
-
/**
|
|
12642
|
-
function
|
|
12643
|
-
const
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
offset += block.text.length;
|
|
12946
|
+
/** The official TODO status counts, preserving legal null and unknown. */
|
|
12947
|
+
function todoFacts(data) {
|
|
12948
|
+
const todos = data.todos;
|
|
12949
|
+
if (todos === void 0) return [
|
|
12950
|
+
{
|
|
12951
|
+
label: "Pending",
|
|
12952
|
+
value: "Unknown"
|
|
12953
|
+
},
|
|
12954
|
+
{
|
|
12955
|
+
label: "In progress",
|
|
12956
|
+
value: "Unknown"
|
|
12957
|
+
},
|
|
12958
|
+
{
|
|
12959
|
+
label: "Completed",
|
|
12960
|
+
value: "Unknown"
|
|
12657
12961
|
}
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
}
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12962
|
+
];
|
|
12963
|
+
if (todos === null) return [
|
|
12964
|
+
{
|
|
12965
|
+
label: "Pending",
|
|
12966
|
+
value: "No todo record"
|
|
12967
|
+
},
|
|
12968
|
+
{
|
|
12969
|
+
label: "In progress",
|
|
12970
|
+
value: MISSING
|
|
12971
|
+
},
|
|
12972
|
+
{
|
|
12973
|
+
label: "Completed",
|
|
12974
|
+
value: MISSING
|
|
12975
|
+
}
|
|
12976
|
+
];
|
|
12977
|
+
return [
|
|
12978
|
+
{
|
|
12979
|
+
label: "Pending",
|
|
12980
|
+
value: String(todos.pending)
|
|
12981
|
+
},
|
|
12982
|
+
{
|
|
12983
|
+
label: "In progress",
|
|
12984
|
+
value: String(todos.inProgress)
|
|
12985
|
+
},
|
|
12986
|
+
{
|
|
12987
|
+
label: "Completed",
|
|
12988
|
+
value: String(todos.completed)
|
|
12989
|
+
}
|
|
12990
|
+
];
|
|
12991
|
+
}
|
|
12992
|
+
/** The complete display groups, in reading order. Roster/Activity/Workspace/
|
|
12993
|
+
* Lineage facts stay available while the exact cut is loading or failed; only
|
|
12994
|
+
* the cut-owned values become unknown. */
|
|
12995
|
+
function inspectorGroups(input, data) {
|
|
12996
|
+
const row = input.row;
|
|
12997
|
+
const fact = input.fact;
|
|
12998
|
+
const model = data?.model;
|
|
12999
|
+
const modelValue = model === void 0 ? MISSING : `${sanitizedPhysicalLine(model.provider)}/${sanitizedPhysicalLine(model.model)}`;
|
|
13000
|
+
const rosterPreset = row.preset === void 0 ? "Unknown" : `${sanitizedPhysicalLine(row.preset)} (roster)`;
|
|
13001
|
+
return [
|
|
13002
|
+
{
|
|
13003
|
+
id: "session",
|
|
13004
|
+
head: "Whole session",
|
|
13005
|
+
facts: [
|
|
13006
|
+
{
|
|
13007
|
+
label: "Model",
|
|
13008
|
+
value: modelValue
|
|
13009
|
+
},
|
|
13010
|
+
{
|
|
13011
|
+
label: "Effort",
|
|
13012
|
+
value: model?.reasoningEffort === void 0 ? MISSING : sanitizedPhysicalLine(model.reasoningEffort)
|
|
13013
|
+
},
|
|
13014
|
+
{
|
|
13015
|
+
label: "Preset",
|
|
13016
|
+
value: data?.preset === void 0 ? rosterPreset : sanitizedPhysicalLine(data.preset)
|
|
13017
|
+
},
|
|
13018
|
+
{
|
|
13019
|
+
label: "Context",
|
|
13020
|
+
value: data === void 0 ? MISSING : contextValue(data)
|
|
13021
|
+
}
|
|
13022
|
+
]
|
|
13023
|
+
},
|
|
13024
|
+
{
|
|
13025
|
+
id: "activity",
|
|
13026
|
+
head: "Activity",
|
|
13027
|
+
facts: [
|
|
13028
|
+
{
|
|
13029
|
+
label: "Turns",
|
|
13030
|
+
value: data?.stats === void 0 ? MISSING : String(data.stats.turns)
|
|
13031
|
+
},
|
|
13032
|
+
{
|
|
13033
|
+
label: "Steps",
|
|
13034
|
+
value: data?.stats === void 0 ? MISSING : String(data.stats.steps)
|
|
13035
|
+
},
|
|
13036
|
+
{
|
|
13037
|
+
label: "Running",
|
|
13038
|
+
value: fact?.running === true ? "Yes" : fact?.running === false ? "No" : "Unknown"
|
|
13039
|
+
},
|
|
13040
|
+
{
|
|
13041
|
+
label: "Pending",
|
|
13042
|
+
value: fact === void 0 ? "Unknown" : SESSION_PENDING_LABEL[fact.pending]
|
|
13043
|
+
},
|
|
13044
|
+
{
|
|
13045
|
+
label: "Source",
|
|
13046
|
+
value: fact === void 0 ? "unknown" : SESSION_SOURCE_LABEL[fact.source]
|
|
13047
|
+
}
|
|
13048
|
+
]
|
|
13049
|
+
},
|
|
13050
|
+
{
|
|
13051
|
+
id: "usage",
|
|
13052
|
+
head: "Token usage",
|
|
13053
|
+
facts: data?.usage === void 0 ? [
|
|
13054
|
+
{
|
|
13055
|
+
label: "Uncached input",
|
|
13056
|
+
value: MISSING
|
|
13057
|
+
},
|
|
13058
|
+
{
|
|
13059
|
+
label: "Output",
|
|
13060
|
+
value: MISSING
|
|
13061
|
+
},
|
|
13062
|
+
{
|
|
13063
|
+
label: "Cache read",
|
|
13064
|
+
value: MISSING
|
|
13065
|
+
},
|
|
13066
|
+
{
|
|
13067
|
+
label: "Cache write",
|
|
13068
|
+
value: MISSING
|
|
13069
|
+
},
|
|
13070
|
+
{
|
|
13071
|
+
label: "Total",
|
|
13072
|
+
value: MISSING
|
|
13073
|
+
},
|
|
13074
|
+
{
|
|
13075
|
+
label: "Cache hit",
|
|
13076
|
+
value: MISSING
|
|
13077
|
+
}
|
|
13078
|
+
] : [
|
|
13079
|
+
{
|
|
13080
|
+
label: "Uncached input",
|
|
13081
|
+
value: formatTokens(data.usage.uncachedInputTokens)
|
|
13082
|
+
},
|
|
13083
|
+
{
|
|
13084
|
+
label: "Output",
|
|
13085
|
+
value: formatTokens(data.usage.outputTokens)
|
|
13086
|
+
},
|
|
13087
|
+
{
|
|
13088
|
+
label: "Cache read",
|
|
13089
|
+
value: formatTokens(data.usage.cacheReadTokens)
|
|
13090
|
+
},
|
|
13091
|
+
{
|
|
13092
|
+
label: "Cache write",
|
|
13093
|
+
value: formatTokens(data.usage.cacheWriteTokens)
|
|
13094
|
+
},
|
|
13095
|
+
{
|
|
13096
|
+
label: "Total",
|
|
13097
|
+
value: formatTokens(data.usage.totalTokens)
|
|
13098
|
+
},
|
|
13099
|
+
{
|
|
13100
|
+
label: "Cache hit",
|
|
13101
|
+
value: data.usage.cacheHitPct === void 0 ? MISSING : `${data.usage.cacheHitPct.toFixed(1)}%`
|
|
13102
|
+
}
|
|
13103
|
+
]
|
|
13104
|
+
},
|
|
13105
|
+
{
|
|
13106
|
+
id: "performance",
|
|
13107
|
+
head: "Performance",
|
|
13108
|
+
facts: data?.stats === void 0 ? [
|
|
13109
|
+
{
|
|
13110
|
+
label: "LLM",
|
|
13111
|
+
value: MISSING
|
|
13112
|
+
},
|
|
13113
|
+
{
|
|
13114
|
+
label: "Tool",
|
|
13115
|
+
value: MISSING
|
|
13116
|
+
},
|
|
13117
|
+
{
|
|
13118
|
+
label: "Avg TTFT",
|
|
13119
|
+
value: MISSING
|
|
13120
|
+
},
|
|
13121
|
+
{
|
|
13122
|
+
label: "Decode",
|
|
13123
|
+
value: MISSING
|
|
13124
|
+
}
|
|
13125
|
+
] : [
|
|
13126
|
+
{
|
|
13127
|
+
label: "LLM",
|
|
13128
|
+
value: formatInspectorDuration(data.stats.llmMs)
|
|
13129
|
+
},
|
|
13130
|
+
{
|
|
13131
|
+
label: "Tool",
|
|
13132
|
+
value: formatInspectorDuration(data.stats.toolMs)
|
|
13133
|
+
},
|
|
13134
|
+
{
|
|
13135
|
+
label: "Avg TTFT",
|
|
13136
|
+
value: data.stats.avgTtftMs === void 0 ? MISSING : formatInspectorDuration(data.stats.avgTtftMs)
|
|
13137
|
+
},
|
|
13138
|
+
{
|
|
13139
|
+
label: "Decode",
|
|
13140
|
+
value: formatInspectorRate(data.stats.decodeTokensPerSec)
|
|
13141
|
+
}
|
|
13142
|
+
]
|
|
13143
|
+
},
|
|
13144
|
+
{
|
|
13145
|
+
id: "workspace",
|
|
13146
|
+
head: "Workspace & dates",
|
|
13147
|
+
facts: [
|
|
13148
|
+
{
|
|
13149
|
+
label: "Workspace",
|
|
13150
|
+
value: membershipValue(fact, input.workspaces, input.workspaceBaselineProven)
|
|
13151
|
+
},
|
|
13152
|
+
{
|
|
13153
|
+
label: "Created in",
|
|
13154
|
+
value: row.cwd === void 0 ? "Unknown" : sanitizedPhysicalLine(row.cwd)
|
|
13155
|
+
},
|
|
13156
|
+
{
|
|
13157
|
+
label: "Effective cwd",
|
|
13158
|
+
value: data?.effectiveCwd === void 0 ? "Unknown" : sanitizedPhysicalLine(data.effectiveCwd)
|
|
13159
|
+
},
|
|
13160
|
+
{
|
|
13161
|
+
label: "Created",
|
|
13162
|
+
value: row.createdAt === void 0 ? "Unknown" : new Date(row.createdAt).toISOString()
|
|
13163
|
+
},
|
|
13164
|
+
{
|
|
13165
|
+
label: "Updated",
|
|
13166
|
+
value: new Date(row.updatedAt).toISOString()
|
|
13167
|
+
}
|
|
13168
|
+
]
|
|
13169
|
+
},
|
|
13170
|
+
{
|
|
13171
|
+
id: "goal",
|
|
13172
|
+
head: "Goal & todo",
|
|
13173
|
+
facts: data === void 0 ? [
|
|
13174
|
+
{
|
|
13175
|
+
label: "Goal",
|
|
13176
|
+
value: "Unknown"
|
|
13177
|
+
},
|
|
13178
|
+
{
|
|
13179
|
+
label: "Goal phase",
|
|
13180
|
+
value: MISSING
|
|
13181
|
+
},
|
|
13182
|
+
{
|
|
13183
|
+
label: "Pending",
|
|
13184
|
+
value: "Unknown"
|
|
13185
|
+
},
|
|
13186
|
+
{
|
|
13187
|
+
label: "In progress",
|
|
13188
|
+
value: "Unknown"
|
|
13189
|
+
},
|
|
13190
|
+
{
|
|
13191
|
+
label: "Completed",
|
|
13192
|
+
value: "Unknown"
|
|
13193
|
+
}
|
|
13194
|
+
] : [...goalFacts(data), ...todoFacts(data)]
|
|
13195
|
+
},
|
|
13196
|
+
{
|
|
13197
|
+
id: "lineage",
|
|
13198
|
+
head: "Lineage",
|
|
13199
|
+
facts: [{
|
|
13200
|
+
label: "Parent session",
|
|
13201
|
+
value: row.parentSession === void 0 ? "No parent session" : sanitizedPhysicalLine(row.parentSession)
|
|
13202
|
+
}]
|
|
13203
|
+
},
|
|
13204
|
+
...input.excerpt?.snippet === void 0 ? [] : [{
|
|
13205
|
+
id: "excerpt",
|
|
13206
|
+
head: `Host search excerpt · ${input.excerpt.source}`,
|
|
13207
|
+
facts: [{
|
|
13208
|
+
label: "Matching content",
|
|
13209
|
+
value: sanitizedPhysicalLine(input.excerpt.snippet)
|
|
13210
|
+
}],
|
|
13211
|
+
prose: true
|
|
13212
|
+
}]
|
|
13213
|
+
];
|
|
13214
|
+
}
|
|
13215
|
+
/** The compact selected-preview groups. Only facts the current cut really
|
|
13216
|
+
* carries are listed; a missing goal/todo/parent/model adds no fake entry, and
|
|
13217
|
+
* the roster preset/parent hints stay visibly labelled. Relative freshness is
|
|
13218
|
+
* the row's own `Updated` line, so the compact view never repeats ISO time. */
|
|
13219
|
+
function summaryGroupsOf(input, data, row) {
|
|
13220
|
+
const groups = [];
|
|
13221
|
+
if (input.excerpt !== void 0) groups.push({
|
|
13222
|
+
id: "excerpt",
|
|
13223
|
+
head: `Match · ${input.excerpt.source}`,
|
|
13224
|
+
facts: input.excerpt.snippet === void 0 ? [] : [{
|
|
13225
|
+
label: "Matching content",
|
|
13226
|
+
value: sanitizedPhysicalLine(input.excerpt.snippet)
|
|
13227
|
+
}],
|
|
13228
|
+
prose: true
|
|
13229
|
+
});
|
|
13230
|
+
const modelFacts = [];
|
|
13231
|
+
if (data?.model !== void 0) {
|
|
13232
|
+
modelFacts.push({
|
|
13233
|
+
label: "Model",
|
|
13234
|
+
value: `${sanitizedPhysicalLine(data.model.provider)}/${sanitizedPhysicalLine(data.model.model)}`
|
|
13235
|
+
});
|
|
13236
|
+
if (data.model.reasoningEffort !== void 0) modelFacts.push({
|
|
13237
|
+
label: "Effort",
|
|
13238
|
+
value: sanitizedPhysicalLine(data.model.reasoningEffort)
|
|
13239
|
+
});
|
|
13240
|
+
}
|
|
13241
|
+
const preset = data?.preset !== void 0 ? sanitizedPhysicalLine(data.preset) : row.preset === void 0 ? void 0 : `${sanitizedPhysicalLine(row.preset)} (roster)`;
|
|
13242
|
+
if (preset !== void 0) modelFacts.push({
|
|
13243
|
+
label: "Preset",
|
|
13244
|
+
value: preset
|
|
13245
|
+
});
|
|
13246
|
+
if (data?.context !== void 0) {
|
|
13247
|
+
const context = contextValue(data);
|
|
13248
|
+
if (context !== MISSING) modelFacts.push({
|
|
13249
|
+
label: "Context",
|
|
13250
|
+
value: context
|
|
13251
|
+
});
|
|
13252
|
+
}
|
|
13253
|
+
if (modelFacts.length > 0) groups.push({
|
|
13254
|
+
id: "model-context",
|
|
13255
|
+
head: "Model & Context",
|
|
13256
|
+
facts: modelFacts
|
|
13257
|
+
});
|
|
13258
|
+
const activityFacts = [];
|
|
13259
|
+
if (data?.stats !== void 0) {
|
|
13260
|
+
activityFacts.push({
|
|
13261
|
+
label: "Turns",
|
|
13262
|
+
value: String(data.stats.turns)
|
|
13263
|
+
});
|
|
13264
|
+
activityFacts.push({
|
|
13265
|
+
label: "Steps",
|
|
13266
|
+
value: String(data.stats.steps)
|
|
13267
|
+
});
|
|
13268
|
+
}
|
|
13269
|
+
if (data?.goal !== null && data?.goal !== void 0) activityFacts.push({
|
|
13270
|
+
label: "Goal phase",
|
|
13271
|
+
value: sanitizedPhysicalLine(data.goal.phase)
|
|
13272
|
+
});
|
|
13273
|
+
if (data?.todos !== null && data?.todos !== void 0) {
|
|
13274
|
+
const total = data.todos.pending + data.todos.inProgress + data.todos.completed;
|
|
13275
|
+
activityFacts.push({
|
|
13276
|
+
label: "Todo",
|
|
13277
|
+
value: `${data.todos.completed}/${total}`
|
|
13278
|
+
});
|
|
13279
|
+
}
|
|
13280
|
+
if (row.parentSession !== void 0) activityFacts.push({
|
|
13281
|
+
label: "Parent",
|
|
13282
|
+
value: sanitizedPhysicalLine(shortSessionId(row.parentSession))
|
|
13283
|
+
});
|
|
13284
|
+
if (activityFacts.length > 0) groups.push({
|
|
13285
|
+
id: "activity-goal",
|
|
13286
|
+
head: "Activity & Goal",
|
|
13287
|
+
facts: activityFacts
|
|
13288
|
+
});
|
|
13289
|
+
const usageFacts = [];
|
|
13290
|
+
if (data?.usage !== void 0) {
|
|
13291
|
+
usageFacts.push({
|
|
13292
|
+
label: "Total",
|
|
13293
|
+
value: formatTokens(data.usage.totalTokens)
|
|
13294
|
+
});
|
|
13295
|
+
if (data.usage.cacheHitPct !== void 0) usageFacts.push({
|
|
13296
|
+
label: "Cache hit",
|
|
13297
|
+
value: `${data.usage.cacheHitPct.toFixed(1)}%`
|
|
13298
|
+
});
|
|
13299
|
+
usageFacts.push({
|
|
13300
|
+
label: "Output",
|
|
13301
|
+
value: formatTokens(data.usage.outputTokens)
|
|
13302
|
+
});
|
|
13303
|
+
}
|
|
13304
|
+
if (data?.stats !== void 0) usageFacts.push({
|
|
13305
|
+
label: "LLM",
|
|
13306
|
+
value: formatInspectorDuration(data.stats.llmMs)
|
|
13307
|
+
});
|
|
13308
|
+
if (usageFacts.length > 0) groups.push({
|
|
13309
|
+
id: "usage",
|
|
13310
|
+
head: "Usage",
|
|
13311
|
+
facts: usageFacts
|
|
13312
|
+
});
|
|
13313
|
+
return groups;
|
|
13314
|
+
}
|
|
13315
|
+
/** Build the ONE display projection of the selected Session's Inspector. */
|
|
13316
|
+
function buildSessionInspectorView(input) {
|
|
13317
|
+
const row = input.row;
|
|
13318
|
+
const inspector = input.inspector;
|
|
13319
|
+
const matching = inspector !== void 0 && inspector.sessionId === row.id && (inspector.state !== "ready" || inspector.data.sessionId === row.id) ? inspector : void 0;
|
|
13320
|
+
const rosterTitle = row.title === void 0 || row.title.trim() === "" ? void 0 : sanitizedPhysicalLine(row.title);
|
|
13321
|
+
const stateLabel = stateParts(row, input.fact, input.currentSessionId).join(" · ");
|
|
13322
|
+
const identityState = `${row.id === input.currentSessionId ? "Current session" : row.live ? "Live session" : "Persisted session"}${row.formatStatus === "migration-required" ? " · Migration required" : ""}`;
|
|
13323
|
+
const data = matching?.state === "ready" ? matching.data : void 0;
|
|
13324
|
+
const title = data?.title === void 0 ? rosterTitle ?? sanitizedPhysicalLine(shortSessionId(row.id)) : sanitizedPhysicalLine(data.title);
|
|
13325
|
+
const groups = inspectorGroups(input, data);
|
|
13326
|
+
const base = {
|
|
13327
|
+
sessionId: row.id,
|
|
13328
|
+
fullId: sanitizedPhysicalLine(row.id),
|
|
13329
|
+
shortId: sanitizedPhysicalLine(shortSessionId(row.id)),
|
|
13330
|
+
title,
|
|
13331
|
+
stateLabel,
|
|
13332
|
+
identityState,
|
|
13333
|
+
freshness: `Updated ${formatSessionAge(row.updatedAt)}`,
|
|
13334
|
+
summaryGroups: summaryGroupsOf(input, data, row)
|
|
13335
|
+
};
|
|
13336
|
+
if (matching === void 0 || matching.state === "loading") return {
|
|
13337
|
+
...base,
|
|
13338
|
+
state: "loading",
|
|
13339
|
+
notice: "Loading statistics…",
|
|
13340
|
+
groups
|
|
13341
|
+
};
|
|
13342
|
+
if (matching.state !== "ready") {
|
|
13343
|
+
const notice = matching.state === "unavailable" ? "Statistics unavailable" : matching.state === "denied" ? "Access denied" : matching.state === "migration-required" ? "Migration required" : `Statistics failed: ${sanitizedPhysicalLine(matching.message)}`;
|
|
13344
|
+
return {
|
|
13345
|
+
...base,
|
|
13346
|
+
state: matching.state,
|
|
13347
|
+
notice,
|
|
13348
|
+
groups
|
|
13349
|
+
};
|
|
13350
|
+
}
|
|
13351
|
+
return {
|
|
13352
|
+
...base,
|
|
13353
|
+
state: matching.refreshing ? "refreshing" : "ready",
|
|
13354
|
+
notice: matching.refreshing ? "Refreshing" : "",
|
|
13355
|
+
groups
|
|
13356
|
+
};
|
|
13357
|
+
}
|
|
13358
|
+
//#endregion
|
|
13359
|
+
//#region src/domain/visual/presentation.ts
|
|
13360
|
+
const presentations = /* @__PURE__ */ new WeakMap();
|
|
13361
|
+
function sameKey(left, right) {
|
|
13362
|
+
return left.subjectKind === right.subjectKind && left.subjectId === right.subjectId && left.sourceIdentity === right.sourceIdentity && left.session === right.session && left.sessionId === right.sessionId && left.turn === right.turn && left.step === right.step && left.text === right.text && left.content === right.content && left.assistantRevision === right.assistantRevision;
|
|
13363
|
+
}
|
|
13364
|
+
function samePublications(left, right) {
|
|
13365
|
+
if (left.length !== right.length) return false;
|
|
13366
|
+
for (let index = 0; index < left.length; index += 1) if (left[index] !== right[index]) return false;
|
|
13367
|
+
return true;
|
|
13368
|
+
}
|
|
13369
|
+
/**
|
|
13370
|
+
* Publish the proven visual projection of one Assistant row.
|
|
13371
|
+
*
|
|
13372
|
+
* The publication ARRAY IS COPIED so a caller mutating its working list cannot
|
|
13373
|
+
* change an already-committed display fact.
|
|
13374
|
+
* @param message - the exact Assistant transcript row.
|
|
13375
|
+
* @param key - the complete identity the projection was derived from.
|
|
13376
|
+
* @param publications - the PR1-authorized publications, in durable order.
|
|
13377
|
+
* @returns whether the presentation revision advanced.
|
|
13378
|
+
*/
|
|
13379
|
+
function setAssistantVisualPresentation(message, key, publications) {
|
|
13380
|
+
const existing = presentations.get(message);
|
|
13381
|
+
if (existing !== void 0 && sameKey(existing.key, key) && samePublications(existing.publications, publications)) return false;
|
|
13382
|
+
presentations.set(message, {
|
|
13383
|
+
key,
|
|
13384
|
+
publications: [...publications],
|
|
13385
|
+
revision: (existing?.revision ?? 0) + 1
|
|
13386
|
+
});
|
|
13387
|
+
return true;
|
|
13388
|
+
}
|
|
13389
|
+
/**
|
|
13390
|
+
* Clear the visual projection of one Assistant row (a new derivation found no
|
|
13391
|
+
* eligible final / no publication, or the subject/source is no longer trusted).
|
|
13392
|
+
* @param message - the exact Assistant transcript row.
|
|
13393
|
+
* @returns whether a presentation existed.
|
|
13394
|
+
*/
|
|
13395
|
+
function clearAssistantVisualPresentation(message) {
|
|
13396
|
+
return presentations.delete(message);
|
|
13397
|
+
}
|
|
13398
|
+
/** Read the committed visual projection of one Assistant row, if any. */
|
|
13399
|
+
function assistantVisualPresentation(message) {
|
|
13400
|
+
return presentations.get(message);
|
|
13401
|
+
}
|
|
13402
|
+
/** The render-cache revision of one Assistant row's visual projection (0 when
|
|
13403
|
+
* no visual projection has ever been committed to it). */
|
|
13404
|
+
function assistantVisualPresentationRevision(message) {
|
|
13405
|
+
return presentations.get(message)?.revision ?? 0;
|
|
13406
|
+
}
|
|
13407
|
+
//#endregion
|
|
13408
|
+
//#region src/domain/visual/placement.ts
|
|
13409
|
+
/**
|
|
13410
|
+
* The ONE pure placement planner for Assistant-owned published visuals.
|
|
13411
|
+
*
|
|
13412
|
+
* A published chart/SVG becomes part of an eligible final Assistant only
|
|
13413
|
+
* through an explicit Markdown reference definition
|
|
13414
|
+
* (`[dsh-visual-sv2_…]: <#>`). This module turns the Assistant's original
|
|
13415
|
+
* ContentBlock text plus the PR1-qualified `PublishedVisual[]` into ONE
|
|
13416
|
+
* ordered source-span projection: text slices and visual occurrences, in the
|
|
13417
|
+
* exact original UTF-16 coordinates, with the marker text consumed and every
|
|
13418
|
+
* other byte preserved. It also collects the ordinary link definitions of each
|
|
13419
|
+
* continuous text run so a display-only definitions prefix can keep
|
|
13420
|
+
* cross-segment reference links resolvable without rewriting the source.
|
|
13421
|
+
*
|
|
13422
|
+
* The parser is deliberately layered and fail-closed:
|
|
13423
|
+
*
|
|
13424
|
+
* 1. the original text is scanned ONLY to propose strict marker lines;
|
|
13425
|
+
* 2. marked (the renderer's own dependency version) lexes the normalized run;
|
|
13426
|
+
* 3. every proposal must match a top-level `def` token by label, exact `<#>`
|
|
13427
|
+
* destination and normalized source position;
|
|
13428
|
+
* 4. text pieces are built from `source.slice()` and independently verified by
|
|
13429
|
+
* byte recovery before they leave this module.
|
|
13430
|
+
*
|
|
13431
|
+
* No renderer state (width, theme, focus, TSP, TUI canvas) enters the plan.
|
|
13432
|
+
* @module @xmoon76/dsh-pi-tui/domain/visual/placement
|
|
13433
|
+
*/
|
|
13434
|
+
/** The strict marker label prefix. */
|
|
13435
|
+
const MARKER_LABEL_PREFIX = "dsh-visual-";
|
|
13436
|
+
/** The strict marker line: column 0, exact label, exact `<#>` destination. */
|
|
13437
|
+
const MARKER_LINE_PATTERN = /^\[dsh-visual-(sv2_[0-9a-f]{20})\]: <#>$/u;
|
|
13438
|
+
/**
|
|
13439
|
+
* The block-level visual label shape. A definition with this shape is NEVER
|
|
13440
|
+
* injected into the display-only shared-definition prefix, whether or not it
|
|
13441
|
+
* is published: the marker line must keep its own Markdown definition
|
|
13442
|
+
* semantics in the source.
|
|
13443
|
+
*/
|
|
13444
|
+
const VISUAL_LABEL_PATTERN = /^dsh-visual-sv2_[0-9a-f]{20}$/u;
|
|
13445
|
+
/** The renderer's own Marked version. Block `def` grammar is the default
|
|
13446
|
+
* grammar; the vendored inline extensions never change a top-level
|
|
13447
|
+
* definition's recognition. */
|
|
13448
|
+
const LEXER = new Marked();
|
|
13449
|
+
/** The ordered ContentBlocks of one Assistant body. */
|
|
13450
|
+
function blocksOf(input) {
|
|
13451
|
+
if (input.content !== void 0 && input.content.length > 0) return input.content;
|
|
13452
|
+
return input.text === "" ? [] : [{
|
|
13453
|
+
type: "text",
|
|
13454
|
+
text: input.text
|
|
13455
|
+
}];
|
|
13456
|
+
}
|
|
13457
|
+
/** Partition the Assistant body into continuous Markdown text runs. */
|
|
13458
|
+
function textRunsOf(blocks) {
|
|
13459
|
+
const runs = [];
|
|
13460
|
+
let current = [];
|
|
13461
|
+
const finish = () => {
|
|
13462
|
+
if (current.length === 0) return;
|
|
13463
|
+
const raw = current.map((block) => block.text).join("");
|
|
13464
|
+
const blockStarts = [];
|
|
13465
|
+
let offset = 0;
|
|
13466
|
+
for (const block of current) {
|
|
13467
|
+
blockStarts.push({
|
|
13468
|
+
blockIndex: block.blockIndex,
|
|
13469
|
+
start: offset,
|
|
13470
|
+
end: offset + block.text.length
|
|
13471
|
+
});
|
|
13472
|
+
offset += block.text.length;
|
|
13473
|
+
}
|
|
13474
|
+
runs.push({
|
|
13475
|
+
runIndex: runs.length,
|
|
13476
|
+
blocks: current,
|
|
13477
|
+
raw,
|
|
13478
|
+
blockStarts
|
|
13479
|
+
});
|
|
13480
|
+
current = [];
|
|
13481
|
+
};
|
|
13482
|
+
for (const [blockIndex, block] of blocks.entries()) {
|
|
12667
13483
|
if (block.type === "text") {
|
|
12668
13484
|
current.push({
|
|
12669
13485
|
blockIndex,
|
|
@@ -14237,29 +15053,378 @@ function shellCommandIsOpen(lines) {
|
|
|
14237
15053
|
index += 2;
|
|
14238
15054
|
continue;
|
|
14239
15055
|
}
|
|
14240
|
-
if (character === "<" && line[index + 1] === "<") {
|
|
14241
|
-
const parsed = heredocAt(line, index);
|
|
14242
|
-
if (parsed !== void 0) {
|
|
14243
|
-
declared.push(parsed);
|
|
15056
|
+
if (character === "<" && line[index + 1] === "<") {
|
|
15057
|
+
const parsed = heredocAt(line, index);
|
|
15058
|
+
if (parsed !== void 0) {
|
|
15059
|
+
declared.push(parsed);
|
|
15060
|
+
index += 2;
|
|
15061
|
+
continue;
|
|
15062
|
+
}
|
|
15063
|
+
}
|
|
15064
|
+
if (substitution > 0) {
|
|
15065
|
+
if (character === "(") substitution += 1;
|
|
15066
|
+
else if (character === ")") substitution -= 1;
|
|
15067
|
+
index += 1;
|
|
15068
|
+
continue;
|
|
15069
|
+
}
|
|
15070
|
+
if (brace > 0) {
|
|
15071
|
+
if (character === "{") brace += 1;
|
|
15072
|
+
else if (character === "}") brace -= 1;
|
|
15073
|
+
}
|
|
15074
|
+
index += 1;
|
|
15075
|
+
}
|
|
15076
|
+
if (!trailingContinuation && declared.length > 0) bodies.push(...declared.splice(0, declared.length));
|
|
15077
|
+
}
|
|
15078
|
+
return quote !== void 0 || backtick || substitution > 0 || brace > 0 || declared.length > 0 || bodies.length > 0 || trailingContinuation;
|
|
15079
|
+
}
|
|
15080
|
+
/**
|
|
15081
|
+
* The PowerShell literal-path adaptation. A PowerShell Host shell has no
|
|
15082
|
+
* command/variable candidate source in this version, so ONLY a clearly
|
|
15083
|
+
* delimited single-line literal path token may reach the Host path bridge.
|
|
15084
|
+
* Backslash is an ordinary filename character in PowerShell; a single-quoted
|
|
15085
|
+
* literal is always literal (`''` is one apostrophe); double-quoted content is
|
|
15086
|
+
* accepted only while it stays literal (no `$` interpolation and no backtick
|
|
15087
|
+
* escape anywhere in the token). Variable/subexpression/backtick/here-string/
|
|
15088
|
+
* mixed quoting and multi-line continuations yield no candidates at all.
|
|
15089
|
+
*/
|
|
15090
|
+
/** The finite quote classes recognized by PowerShell's parser
|
|
15091
|
+
* (`CharTraits.IsSingleQuote` / `IsDoubleQuote`). This adapter only lets an
|
|
15092
|
+
* ASCII quote DELIMIT a raw token; recognized smart single quotes may appear
|
|
15093
|
+
* as doubled literal content, exactly as the adapter itself emits them. */
|
|
15094
|
+
const POWERSHELL_SINGLE_QUOTE_CHARACTERS = /* @__PURE__ */ new Set([
|
|
15095
|
+
"'",
|
|
15096
|
+
"‘",
|
|
15097
|
+
"’",
|
|
15098
|
+
"‚",
|
|
15099
|
+
"‛"
|
|
15100
|
+
]);
|
|
15101
|
+
const POWERSHELL_DOUBLE_QUOTE_CHARACTERS = /* @__PURE__ */ new Set([
|
|
15102
|
+
"\"",
|
|
15103
|
+
"“",
|
|
15104
|
+
"”",
|
|
15105
|
+
"„"
|
|
15106
|
+
]);
|
|
15107
|
+
function isPowerShellSingleQuoteCharacter(character) {
|
|
15108
|
+
return character !== void 0 && POWERSHELL_SINGLE_QUOTE_CHARACTERS.has(character);
|
|
15109
|
+
}
|
|
15110
|
+
function isPowerShellDoubleQuoteCharacter(character) {
|
|
15111
|
+
return character !== void 0 && POWERSHELL_DOUBLE_QUOTE_CHARACTERS.has(character);
|
|
15112
|
+
}
|
|
15113
|
+
/** One bare PowerShell word delimiter; unquoted whitespace and PowerShell
|
|
15114
|
+
* control operators/commas end the word. */
|
|
15115
|
+
function isPowerShellWordDelimiter(character) {
|
|
15116
|
+
return character === " " || character === " " || character === "\n" || character === ";" || character === "|" || character === "&" || character === "(" || character === ")" || character === "{" || character === "}" || character === "<" || character === ">" || character === ",";
|
|
15117
|
+
}
|
|
15118
|
+
/** Find the closing ASCII quote after `from`, honoring a doubled quote of the
|
|
15119
|
+
* SAME recognized class. A single smart delimiter is returned as the close;
|
|
15120
|
+
* the caller refuses it because only an ASCII delimiter is unambiguous here. */
|
|
15121
|
+
function findPowerShellClosingQuote(line, from, quote) {
|
|
15122
|
+
for (let index = from; index < line.length; index += 1) {
|
|
15123
|
+
const character = line[index];
|
|
15124
|
+
if (quote === "'") {
|
|
15125
|
+
if (!isPowerShellSingleQuoteCharacter(character)) continue;
|
|
15126
|
+
if (line[index + 1] === character) {
|
|
15127
|
+
index += 1;
|
|
15128
|
+
continue;
|
|
15129
|
+
}
|
|
15130
|
+
return index;
|
|
15131
|
+
}
|
|
15132
|
+
if (character === "`") {
|
|
15133
|
+
index += 1;
|
|
15134
|
+
continue;
|
|
15135
|
+
}
|
|
15136
|
+
if (character === "\"") {
|
|
15137
|
+
if (line[index + 1] === "\"") {
|
|
15138
|
+
index += 1;
|
|
15139
|
+
continue;
|
|
15140
|
+
}
|
|
15141
|
+
return index;
|
|
15142
|
+
}
|
|
15143
|
+
if (isPowerShellDoubleQuoteCharacter(character)) return index;
|
|
15144
|
+
}
|
|
15145
|
+
return -1;
|
|
15146
|
+
}
|
|
15147
|
+
function powerShellWordRole(line, prefixLength, tokenStart) {
|
|
15148
|
+
let index = prefixLength;
|
|
15149
|
+
let firstWord = "";
|
|
15150
|
+
let priorWords = 0;
|
|
15151
|
+
let current = "";
|
|
15152
|
+
let started = false;
|
|
15153
|
+
let quote;
|
|
15154
|
+
let initialCall = false;
|
|
15155
|
+
const finish = () => {
|
|
15156
|
+
if (!started) return;
|
|
15157
|
+
priorWords += 1;
|
|
15158
|
+
if (firstWord === "") firstWord = current;
|
|
15159
|
+
current = "";
|
|
15160
|
+
started = false;
|
|
15161
|
+
};
|
|
15162
|
+
while (index < tokenStart) {
|
|
15163
|
+
const character = line[index];
|
|
15164
|
+
if (quote === "'") {
|
|
15165
|
+
if (isPowerShellSingleQuoteCharacter(character)) {
|
|
15166
|
+
if (line[index + 1] === character) {
|
|
15167
|
+
current += character;
|
|
15168
|
+
index += 2;
|
|
15169
|
+
continue;
|
|
15170
|
+
}
|
|
15171
|
+
if (character !== "'") return { kind: "unavailable" };
|
|
15172
|
+
quote = void 0;
|
|
15173
|
+
index += 1;
|
|
15174
|
+
continue;
|
|
15175
|
+
}
|
|
15176
|
+
current += character;
|
|
15177
|
+
index += 1;
|
|
15178
|
+
continue;
|
|
15179
|
+
}
|
|
15180
|
+
if (quote === "\"") {
|
|
15181
|
+
if (character === "`" || character === "$") return { kind: "unavailable" };
|
|
15182
|
+
if (character === "\"") {
|
|
15183
|
+
if (line[index + 1] === "\"") {
|
|
15184
|
+
current += "\"";
|
|
15185
|
+
index += 2;
|
|
15186
|
+
continue;
|
|
15187
|
+
}
|
|
15188
|
+
quote = void 0;
|
|
15189
|
+
index += 1;
|
|
15190
|
+
continue;
|
|
15191
|
+
}
|
|
15192
|
+
if (isPowerShellDoubleQuoteCharacter(character)) return { kind: "unavailable" };
|
|
15193
|
+
current += character;
|
|
15194
|
+
index += 1;
|
|
15195
|
+
continue;
|
|
15196
|
+
}
|
|
15197
|
+
if (character === " " || character === " " || character === "\n" || character === ",") {
|
|
15198
|
+
finish();
|
|
15199
|
+
index += 1;
|
|
15200
|
+
continue;
|
|
15201
|
+
}
|
|
15202
|
+
if (character === "&") {
|
|
15203
|
+
if (priorWords === 0 && !started && current === "" && !initialCall && (index + 1 === line.length || line[index + 1] === " " || line[index + 1] === " ")) {
|
|
15204
|
+
initialCall = true;
|
|
15205
|
+
index += 1;
|
|
15206
|
+
continue;
|
|
15207
|
+
}
|
|
15208
|
+
return { kind: "unavailable" };
|
|
15209
|
+
}
|
|
15210
|
+
if (character === ";" || character === "|" || character === "(" || character === ")" || character === "{" || character === "}" || character === "<" || character === ">") return { kind: "unavailable" };
|
|
15211
|
+
if (character === "'" || character === "\"") {
|
|
15212
|
+
if (started) return { kind: "unavailable" };
|
|
15213
|
+
started = true;
|
|
15214
|
+
quote = character;
|
|
15215
|
+
index += 1;
|
|
15216
|
+
continue;
|
|
15217
|
+
}
|
|
15218
|
+
if (isPowerShellSingleQuoteCharacter(character) || isPowerShellDoubleQuoteCharacter(character)) return { kind: "unavailable" };
|
|
15219
|
+
if (character === "`" || character === "$") return { kind: "unavailable" };
|
|
15220
|
+
if (!started && (character === "#" || line.startsWith("--%", index) || character === "@" || character === "[")) return { kind: "unavailable" };
|
|
15221
|
+
current += character;
|
|
15222
|
+
started = true;
|
|
15223
|
+
index += 1;
|
|
15224
|
+
}
|
|
15225
|
+
if (quote !== void 0) return { kind: "unavailable" };
|
|
15226
|
+
finish();
|
|
15227
|
+
if (initialCall && priorWords === 0) return { kind: "callArgument" };
|
|
15228
|
+
if (priorWords === 0) return { kind: "command" };
|
|
15229
|
+
return {
|
|
15230
|
+
kind: "argument",
|
|
15231
|
+
firstWord,
|
|
15232
|
+
priorWords
|
|
15233
|
+
};
|
|
15234
|
+
}
|
|
15235
|
+
function scanPowerShellWord(line, prefixLength, col) {
|
|
15236
|
+
let tokenStart = prefixLength;
|
|
15237
|
+
let value = "";
|
|
15238
|
+
let rawLength = 0;
|
|
15239
|
+
let quote;
|
|
15240
|
+
let startedQuoted = false;
|
|
15241
|
+
let closedQuote = false;
|
|
15242
|
+
let uncertain = false;
|
|
15243
|
+
let index = prefixLength;
|
|
15244
|
+
while (index < col) {
|
|
15245
|
+
const character = line[index];
|
|
15246
|
+
if (quote === "'") {
|
|
15247
|
+
if (isPowerShellSingleQuoteCharacter(character)) {
|
|
15248
|
+
if (line[index + 1] === character) {
|
|
15249
|
+
value += character;
|
|
15250
|
+
rawLength += 2;
|
|
15251
|
+
index += 2;
|
|
15252
|
+
continue;
|
|
15253
|
+
}
|
|
15254
|
+
quote = void 0;
|
|
15255
|
+
closedQuote = true;
|
|
15256
|
+
index += 1;
|
|
15257
|
+
continue;
|
|
15258
|
+
}
|
|
15259
|
+
value += character;
|
|
15260
|
+
rawLength += 1;
|
|
15261
|
+
index += 1;
|
|
15262
|
+
continue;
|
|
15263
|
+
}
|
|
15264
|
+
if (quote === "\"") {
|
|
15265
|
+
if (character === "\"") {
|
|
15266
|
+
if (line[index + 1] === "\"") {
|
|
15267
|
+
value += "\"";
|
|
15268
|
+
rawLength += 2;
|
|
14244
15269
|
index += 2;
|
|
14245
15270
|
continue;
|
|
14246
15271
|
}
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
if (character === "(") substitution += 1;
|
|
14250
|
-
else if (character === ")") substitution -= 1;
|
|
15272
|
+
quote = void 0;
|
|
15273
|
+
closedQuote = true;
|
|
14251
15274
|
index += 1;
|
|
14252
15275
|
continue;
|
|
14253
15276
|
}
|
|
14254
|
-
if (
|
|
14255
|
-
|
|
14256
|
-
|
|
15277
|
+
if (character === "`" || character === "$" || isPowerShellDoubleQuoteCharacter(character)) {
|
|
15278
|
+
uncertain = true;
|
|
15279
|
+
break;
|
|
14257
15280
|
}
|
|
15281
|
+
value += character;
|
|
15282
|
+
rawLength += 1;
|
|
14258
15283
|
index += 1;
|
|
15284
|
+
continue;
|
|
14259
15285
|
}
|
|
14260
|
-
if (
|
|
15286
|
+
if (isPowerShellWordDelimiter(character)) {
|
|
15287
|
+
tokenStart = index + 1;
|
|
15288
|
+
value = "";
|
|
15289
|
+
rawLength = 0;
|
|
15290
|
+
quote = void 0;
|
|
15291
|
+
startedQuoted = false;
|
|
15292
|
+
closedQuote = false;
|
|
15293
|
+
index += 1;
|
|
15294
|
+
continue;
|
|
15295
|
+
}
|
|
15296
|
+
if (rawLength === 0) {
|
|
15297
|
+
if (character === "#") {
|
|
15298
|
+
uncertain = true;
|
|
15299
|
+
break;
|
|
15300
|
+
}
|
|
15301
|
+
if (character === "-" && line.startsWith("--%", index)) {
|
|
15302
|
+
uncertain = true;
|
|
15303
|
+
break;
|
|
15304
|
+
}
|
|
15305
|
+
}
|
|
15306
|
+
if (character === "'" || character === "\"") {
|
|
15307
|
+
if (rawLength > 0) {
|
|
15308
|
+
uncertain = true;
|
|
15309
|
+
break;
|
|
15310
|
+
}
|
|
15311
|
+
startedQuoted = true;
|
|
15312
|
+
quote = character;
|
|
15313
|
+
rawLength += 1;
|
|
15314
|
+
index += 1;
|
|
15315
|
+
continue;
|
|
15316
|
+
}
|
|
15317
|
+
if (isPowerShellSingleQuoteCharacter(character) || isPowerShellDoubleQuoteCharacter(character)) {
|
|
15318
|
+
uncertain = true;
|
|
15319
|
+
break;
|
|
15320
|
+
}
|
|
15321
|
+
if (character === "`" || character === "$") {
|
|
15322
|
+
uncertain = true;
|
|
15323
|
+
break;
|
|
15324
|
+
}
|
|
15325
|
+
if ((character === "@" || character === "[") && rawLength === 0) {
|
|
15326
|
+
uncertain = true;
|
|
15327
|
+
break;
|
|
15328
|
+
}
|
|
15329
|
+
value += character;
|
|
15330
|
+
rawLength += 1;
|
|
15331
|
+
index += 1;
|
|
14261
15332
|
}
|
|
14262
|
-
|
|
15333
|
+
if (closedQuote && quote === void 0) uncertain = true;
|
|
15334
|
+
if (quote === "'" && isPowerShellSingleQuoteCharacter(line[col - 1]) && line[col - 1] === line[col]) uncertain = true;
|
|
15335
|
+
if (quote === "\"" && (line[col - 1] === "`" || line[col - 1] === "\"" && line[col] === "\"")) uncertain = true;
|
|
15336
|
+
let end = col;
|
|
15337
|
+
if (!uncertain) {
|
|
15338
|
+
if (quote !== void 0) {
|
|
15339
|
+
const closing = findPowerShellClosingQuote(line, col, quote);
|
|
15340
|
+
if (closing === -1) {
|
|
15341
|
+
end = line.length;
|
|
15342
|
+
if (quote === "\"" && /[`$]/u.test(line.slice(col))) uncertain = true;
|
|
15343
|
+
} else {
|
|
15344
|
+
if (quote === "'" && line[closing] !== "'") uncertain = true;
|
|
15345
|
+
if (quote === "\"" && line[closing] !== "\"") uncertain = true;
|
|
15346
|
+
const tail = line.slice(col, closing);
|
|
15347
|
+
if (quote === "\"" && /[`$]/u.test(tail)) uncertain = true;
|
|
15348
|
+
end = closing + 1;
|
|
15349
|
+
if (end < line.length && !isPowerShellWordDelimiter(line[end])) uncertain = true;
|
|
15350
|
+
}
|
|
15351
|
+
} else {
|
|
15352
|
+
let tailIndex = col;
|
|
15353
|
+
while (tailIndex < line.length) {
|
|
15354
|
+
const character = line[tailIndex];
|
|
15355
|
+
if (isPowerShellWordDelimiter(character)) break;
|
|
15356
|
+
if (character === "$" || character === "`" || character === "'" || character === "\"" || isPowerShellSingleQuoteCharacter(character) || isPowerShellDoubleQuoteCharacter(character)) {
|
|
15357
|
+
uncertain = true;
|
|
15358
|
+
break;
|
|
15359
|
+
}
|
|
15360
|
+
tailIndex += 1;
|
|
15361
|
+
}
|
|
15362
|
+
end = tailIndex;
|
|
15363
|
+
}
|
|
15364
|
+
}
|
|
15365
|
+
const closingQuoteAfterCursor = quote !== void 0 && findPowerShellClosingQuote(line, col, quote) !== -1;
|
|
15366
|
+
return {
|
|
15367
|
+
start: tokenStart,
|
|
15368
|
+
value,
|
|
15369
|
+
quote,
|
|
15370
|
+
closingQuoteAfterCursor,
|
|
15371
|
+
startedQuoted,
|
|
15372
|
+
uncertain,
|
|
15373
|
+
end
|
|
15374
|
+
};
|
|
15375
|
+
}
|
|
15376
|
+
/** Whether a decoded PowerShell token is a literal PATH word in its proven
|
|
15377
|
+
* role. A bare executable command position is never admitted; only an initial
|
|
15378
|
+
* `&` call argument or an ordinary argument may complete. */
|
|
15379
|
+
function isPowerShellPathValue(value, role, startedQuoted) {
|
|
15380
|
+
if (role === "command" || role === "unavailable") return false;
|
|
15381
|
+
if (value === "") return role === "argument";
|
|
15382
|
+
if (!startedQuoted && value.startsWith("-")) return false;
|
|
15383
|
+
const pathShape = value === "." || value === ".." || value.startsWith(".\\") || value.startsWith("./") || value.startsWith("..\\") || value.startsWith("../") || value.startsWith("~") || /^[A-Za-z]:[\\/]/u.test(value) || value.includes("\\") || value.includes("/");
|
|
15384
|
+
if (role === "callArgument") return startedQuoted || pathShape;
|
|
15385
|
+
return true;
|
|
15386
|
+
}
|
|
15387
|
+
/** Parse one PowerShell `!`/`!!` line for a literal path position. */
|
|
15388
|
+
function powershellCompletionContext(line, col) {
|
|
15389
|
+
if (!line.startsWith("!")) return void 0;
|
|
15390
|
+
const prefixLength = line.startsWith("!!") ? 2 : 1;
|
|
15391
|
+
if (col < prefixLength) return void 0;
|
|
15392
|
+
const scan = scanPowerShellWord(line, prefixLength, col);
|
|
15393
|
+
if (scan.uncertain) return void 0;
|
|
15394
|
+
if (scan.start === col && scan.end > col) return void 0;
|
|
15395
|
+
const role = powerShellWordRole(line, prefixLength, scan.start);
|
|
15396
|
+
if (role.kind === "unavailable") return void 0;
|
|
15397
|
+
if (!isPowerShellPathValue(scan.value, role.kind, scan.startedQuoted)) return void 0;
|
|
15398
|
+
if (role.kind === "argument" && /^git$/iu.test(role.firstWord) && role.priorWords === 1) return void 0;
|
|
15399
|
+
return {
|
|
15400
|
+
kind: "paths",
|
|
15401
|
+
prefix: line.slice(scan.start, col),
|
|
15402
|
+
priorWords: [],
|
|
15403
|
+
word: {
|
|
15404
|
+
valuePrefix: scan.value,
|
|
15405
|
+
quote: scan.quote,
|
|
15406
|
+
closingQuoteAfterCursor: scan.closingQuoteAfterCursor
|
|
15407
|
+
}
|
|
15408
|
+
};
|
|
15409
|
+
}
|
|
15410
|
+
/** The RAW range one PowerShell literal-path acceptance replaces: the whole
|
|
15411
|
+
* current token, including a closing quote after the cursor. */
|
|
15412
|
+
function powershellWordRange(line, prefixLength, col) {
|
|
15413
|
+
const scan = scanPowerShellWord(line, prefixLength, col);
|
|
15414
|
+
if (scan.uncertain) return void 0;
|
|
15415
|
+
if (scan.start === col && scan.end > col) return void 0;
|
|
15416
|
+
if (powerShellWordRole(line, prefixLength, scan.start).kind === "unavailable") return void 0;
|
|
15417
|
+
return {
|
|
15418
|
+
start: scan.start,
|
|
15419
|
+
end: scan.end
|
|
15420
|
+
};
|
|
15421
|
+
}
|
|
15422
|
+
/** Encode one literal path as a PowerShell single-quoted literal. Every
|
|
15423
|
+
* single-quote character in the official class is a delimiter; doubling the
|
|
15424
|
+
* ORIGINAL character makes it literal content. Double-quote class characters
|
|
15425
|
+
* are plain content inside this single-quoted literal. */
|
|
15426
|
+
function powershellPathLiteral(value) {
|
|
15427
|
+
return `'${value.replace(/['\u2018\u2019\u201A\u201B]/gu, (quote) => `${quote}${quote}`)}'`;
|
|
14263
15428
|
}
|
|
14264
15429
|
/** The RAW range a WHOLE-WORD acceptance replaces: the raw word start, and the
|
|
14265
15430
|
* raw word end. A closing quote the cursor is inside is part of the range (the
|
|
@@ -14389,7 +15554,7 @@ async function suggestShellCompletion(context, port, target, options) {
|
|
|
14389
15554
|
items: candidates.map((candidate) => {
|
|
14390
15555
|
const directory = candidate.endsWith("/") || candidate.endsWith("\\");
|
|
14391
15556
|
return {
|
|
14392
|
-
value: port.pathAuthority === "host" && context.word !== void 0 ? hostPathLiteral(candidate, context.word, directory) : candidate,
|
|
15557
|
+
value: port.pathAuthority === "host" && context.word !== void 0 ? port.pathLiteralDialect === "powershell" ? powershellPathLiteral(candidate) : hostPathLiteral(candidate, context.word, directory) : candidate,
|
|
14393
15558
|
label: candidate
|
|
14394
15559
|
};
|
|
14395
15560
|
}),
|
|
@@ -15090,17 +16255,21 @@ var MentionProvider = class {
|
|
|
15090
16255
|
const currentLine = lines[cursorLine] ?? "";
|
|
15091
16256
|
const textBeforeCursor = currentLine.slice(0, cursorCol);
|
|
15092
16257
|
const requestScope = this.scopeOf();
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
16258
|
+
const shellDialect = this.hostShellCompletion?.pathLiteralDialect ?? "bash";
|
|
16259
|
+
if (this.inputModeSource() !== "prompt" && cursorLine > 0) {
|
|
16260
|
+
if (shellDialect === "powershell" || shellCommandIsOpen(lines.slice(0, cursorLine))) {
|
|
16261
|
+
if (generation === this.requestGeneration) this.requestSnapshot = null;
|
|
16262
|
+
return null;
|
|
16263
|
+
}
|
|
15096
16264
|
}
|
|
15097
16265
|
const shellLine = this.virtualWireShellContext(lines, cursorLine, cursorCol) ?? {
|
|
15098
16266
|
line: currentLine,
|
|
15099
16267
|
cursorCol,
|
|
15100
16268
|
prefixLength: 0
|
|
15101
16269
|
};
|
|
15102
|
-
const shellContext = this.hostShellCompletion === void 0 ? void 0 : shellCompletionContext(shellLine.line, shellLine.cursorCol);
|
|
15103
|
-
|
|
16270
|
+
const shellContext = this.hostShellCompletion === void 0 ? void 0 : shellDialect === "powershell" ? powershellCompletionContext(shellLine.line, shellLine.cursorCol) : shellCompletionContext(shellLine.line, shellLine.cursorCol);
|
|
16271
|
+
const quietPowerShellArgument = shellDialect === "powershell" && shellContext?.kind === "paths" && shellContext.word?.valuePrefix === "" && options.force !== true;
|
|
16272
|
+
if (shellContext !== void 0 && !quietPowerShellArgument) {
|
|
15104
16273
|
const port = this.hostShellCompletion;
|
|
15105
16274
|
if (!(shellContext.kind === "paths" && port.pathAuthority === "client")) {
|
|
15106
16275
|
const suggestions = await suggestShellCompletion(shellContext, port, shellCompletionTargetOf(requestScope), options);
|
|
@@ -15141,7 +16310,7 @@ var MentionProvider = class {
|
|
|
15141
16310
|
const literalShellLine = textBeforeCursor.trimStart().startsWith("!");
|
|
15142
16311
|
if (semantic !== null || literalShellLine) {
|
|
15143
16312
|
const port = this.hostShellCompletion;
|
|
15144
|
-
if (port === void 0 || port.pathAuthority === "host") return this.withRequestSnapshot(generation, requestScope, requestMode, requestLocalCwd, lines, cursorLine, cursorCol, null, false);
|
|
16313
|
+
if (port === void 0 || port.pathAuthority === "host" || port.pathLiteralDialect === "powershell") return this.withRequestSnapshot(generation, requestScope, requestMode, requestLocalCwd, lines, cursorLine, cursorCol, null, false);
|
|
15145
16314
|
try {
|
|
15146
16315
|
const result = await this.inner.getSuggestions(lines, cursorLine, cursorCol, options);
|
|
15147
16316
|
return this.withRequestSnapshot(generation, requestScope, requestMode, requestLocalCwd, lines, cursorLine, cursorCol, result, false);
|
|
@@ -15393,7 +16562,8 @@ var MentionProvider = class {
|
|
|
15393
16562
|
cursorLine,
|
|
15394
16563
|
cursorCol
|
|
15395
16564
|
};
|
|
15396
|
-
const
|
|
16565
|
+
const shellDialect = this.hostShellCompletion?.pathLiteralDialect ?? "bash";
|
|
16566
|
+
const shellContext = shellDialect === "powershell" ? powershellCompletionContext(shellLine.line, shellLine.cursorCol) : shellCompletionContext(shellLine.line, shellLine.cursorCol);
|
|
15397
16567
|
const wholeWordShell = shellContext?.kind === "command" || shellContext?.kind === "subcommand";
|
|
15398
16568
|
const start = cursorCol - bodyPrefix.length;
|
|
15399
16569
|
if (!wholeWordShell && (start < 0 || currentLine.slice(start, cursorCol) !== bodyPrefix)) return {
|
|
@@ -15426,6 +16596,25 @@ var MentionProvider = class {
|
|
|
15426
16596
|
cursorLine,
|
|
15427
16597
|
cursorCol
|
|
15428
16598
|
};
|
|
16599
|
+
if (shellDialect === "powershell") {
|
|
16600
|
+
const scanPrefixLength = wire === null ? currentLine.startsWith("!!") ? 2 : 1 : wire.prefixLength;
|
|
16601
|
+
const range = powershellWordRange(shellLine.line, scanPrefixLength, shellLine.cursorCol);
|
|
16602
|
+
if (range === void 0) return {
|
|
16603
|
+
lines,
|
|
16604
|
+
cursorLine,
|
|
16605
|
+
cursorCol
|
|
16606
|
+
};
|
|
16607
|
+
const directory = item.label.endsWith("/") || item.label.endsWith("\\");
|
|
16608
|
+
const rawStart = range.start - shellLine.prefixLength;
|
|
16609
|
+
const rawEnd = range.end - shellLine.prefixLength;
|
|
16610
|
+
const newLines = [...lines];
|
|
16611
|
+
newLines[cursorLine] = `${currentLine.slice(0, rawStart)}${item.value}${currentLine.slice(rawEnd)}`;
|
|
16612
|
+
return {
|
|
16613
|
+
lines: newLines,
|
|
16614
|
+
cursorLine,
|
|
16615
|
+
cursorCol: rawStart + item.value.length - (directory ? 1 : 0)
|
|
16616
|
+
};
|
|
16617
|
+
}
|
|
15429
16618
|
const suffix = shellWordSuffix(shellLine.line, shellLine.cursorCol, shellContext.word?.quote);
|
|
15430
16619
|
const before = currentLine.slice(0, start);
|
|
15431
16620
|
const after = currentLine.slice(cursorCol + suffix.length);
|
|
@@ -15638,6 +16827,12 @@ function createInstalledAutocompleteProvider(options) {
|
|
|
15638
16827
|
/** Find the Assistant entry that owns the structural latest step. A late
|
|
15639
16828
|
* durable message can append after newer process evidence, so physical array
|
|
15640
16829
|
* order is not a reliable final-answer identity. */
|
|
16830
|
+
/**
|
|
16831
|
+
* The structural Assistant row owning one exact step (the LAST physical row for
|
|
16832
|
+
* that step). Physical position alone is not step identity: a late older-step
|
|
16833
|
+
* settlement can be appended after the latest-step row, so callers that need
|
|
16834
|
+
* the turn's latest candidate must select by step first.
|
|
16835
|
+
*/
|
|
15641
16836
|
function assistantForStep(group, step) {
|
|
15642
16837
|
for (let index = group.length - 1; index >= 0; index -= 1) {
|
|
15643
16838
|
const member = group[index];
|
|
@@ -16606,13 +17801,15 @@ function clusterAdjacentAmbientContext(messages) {
|
|
|
16606
17801
|
*
|
|
16607
17802
|
* A Work span may CARRY a foldable Context row as a structural part without
|
|
16608
17803
|
* making it Process: the row keeps its Context semantics, its source bytes and
|
|
16609
|
-
* its own disclosure, but no longer splits one turn's Activity/Thought.
|
|
17804
|
+
* its own disclosure, but no longer splits one turn's Activity/Thought. Seven
|
|
16610
17805
|
* narrow forms qualify: a `form:'snapshot'` singleton / snapshot-only raw
|
|
16611
|
-
* cluster, a `tool-jobs` Notice, an `agent-message` relay
|
|
16612
|
-
* `subagent-settled` Notice,
|
|
16613
|
-
* `
|
|
16614
|
-
* `
|
|
16615
|
-
*
|
|
17806
|
+
* cluster, a `tool-jobs` Notice, an `agent-message` relay, a
|
|
17807
|
+
* `subagent-settled` Notice, a `repeat-tool-reminder` Notice and an
|
|
17808
|
+
* image-bearing `ptc-mode` Context, each of the last five with durable
|
|
17809
|
+
* same-turn `next-step` delivery evidence, plus a complete `skill-catalog`
|
|
17810
|
+
* replacement that may only TRAIL an already-established same-turn Work. A
|
|
17811
|
+
* mixed `instructions`/`catalog`/`snapshot` cluster and every other
|
|
17812
|
+
* Notice/relay form stay independent Context boundaries.
|
|
16616
17813
|
*
|
|
16617
17814
|
* The projector is a single forward pass plus the linear ambient-clustering
|
|
16618
17815
|
* pass (O(n)); wrappers are freshly allocated each call, but their
|
|
@@ -16637,12 +17834,19 @@ function clusterAdjacentAmbientContext(messages) {
|
|
|
16637
17834
|
* {@link isFoldableSnapshotContext} inside {@link projectTranscriptStructure}.
|
|
16638
17835
|
*/
|
|
16639
17836
|
function isTranscriptWorkMember(message) {
|
|
16640
|
-
return
|
|
17837
|
+
return transcriptTurnOf(message) !== void 0 && classifyTranscriptMessage(message).class === "process" && !isSurfacedInteractionTool(message) && !isPostTurnReplayEvidence(message);
|
|
16641
17838
|
}
|
|
16642
17839
|
/** Whether one row is a producer-declared Snapshot Context row (the ONE
|
|
16643
|
-
* ambient form whose disclosure follows the surrounding Work/Thought).
|
|
17840
|
+
* ambient form whose disclosure follows the surrounding Work/Thought).
|
|
17841
|
+
*
|
|
17842
|
+
* A `ptc-mode` row that declares ANY form is malformed/foreign (the real PTC
|
|
17843
|
+
* producer omits `form`): it must never borrow the Snapshot carriage through a
|
|
17844
|
+
* forged/legacy `form:'snapshot'`. The structured-media predicate remains
|
|
17845
|
+
* form-neutral, so such rows still render their original blocks standalone. */
|
|
16644
17846
|
function isSnapshotContext(message) {
|
|
16645
|
-
|
|
17847
|
+
if (!isSurfacedContext(message) || contextFormOf(message) !== "snapshot") return false;
|
|
17848
|
+
const presentation = message.contextPresentation;
|
|
17849
|
+
return !(presentation?.sourceKind === "ptc-mode" && presentation.formDeclared === true);
|
|
16646
17850
|
}
|
|
16647
17851
|
/** Per-cluster memo of {@link isSnapshotOnlyCluster}: cluster wrappers are
|
|
16648
17852
|
* freshly allocated per projection pass but may be queried once per member by
|
|
@@ -16677,69 +17881,17 @@ function isFoldableSnapshotContext(message, clusterByMember) {
|
|
|
16677
17881
|
const cluster = clusterByMember.get(message);
|
|
16678
17882
|
return cluster === void 0 || isSnapshotOnlyCluster(cluster);
|
|
16679
17883
|
}
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
* same-turn `next-step` delivery evidence.
|
|
16683
|
-
*
|
|
16684
|
-
* This is a NARROW exception, never a generic notice rule: the producer-declared
|
|
16685
|
-
* `sourceKind === 'tool-jobs'` AND `form === 'notice'` are both required, plus
|
|
16686
|
-
* the fold's presentation-only `sameTurnNextStep` flag derived from the durable
|
|
16687
|
-
* `agent/inbox/spliced` insert/claim identity chain. A `next-turn` wakeup, a
|
|
16688
|
-
* foreign/legacy log, a different producer (including `subagent-settled`) or a
|
|
16689
|
-
* missing claim carries no flag and therefore stays an independent Context
|
|
16690
|
-
* boundary.
|
|
16691
|
-
*/
|
|
16692
|
-
function isWorkingToolJobsNotice(message) {
|
|
16693
|
-
if (!isSurfacedContext(message)) return false;
|
|
16694
|
-
const presentation = message.contextPresentation;
|
|
16695
|
-
return presentation !== void 0 && presentation.sameTurnNextStep === true && presentation.form === "notice" && presentation.sourceKind === "tool-jobs";
|
|
16696
|
-
}
|
|
16697
|
-
/**
|
|
16698
|
-
* Whether one row is a same-turn delivered Agent relay (`agent-message` +
|
|
16699
|
-
* `relay`) with durable next-step delivery evidence.
|
|
16700
|
-
*
|
|
16701
|
-
* This is the narrow sibling of {@link isWorkingToolJobsNotice}: the
|
|
16702
|
-
* producer-declared `sourceKind === 'agent-message'` AND `form === 'relay'`
|
|
16703
|
-
* are both required, plus the fold's presentation-only `sameTurnNextStep`
|
|
16704
|
-
* flag derived from the durable `agent/inbox/spliced` insert/claim identity
|
|
16705
|
-
* chain. A `next-turn` wakeup, a foreign/legacy log, a crossed source/form
|
|
16706
|
-
* pair or a missing claim carries no flag and therefore stays an independent
|
|
16707
|
-
* Context boundary.
|
|
16708
|
-
*/
|
|
16709
|
-
function isWorkingAgentRelay(message) {
|
|
16710
|
-
if (!isSurfacedContext(message)) return false;
|
|
16711
|
-
const presentation = message.contextPresentation;
|
|
16712
|
-
return presentation !== void 0 && presentation.sameTurnNextStep === true && presentation.sourceKind === "agent-message" && presentation.form === "relay";
|
|
16713
|
-
}
|
|
16714
|
-
/**
|
|
16715
|
-
* Whether one row is a same-turn delivered subagent settlement Notice
|
|
16716
|
-
* (`subagent-settled` + `notice`) with durable next-step delivery evidence.
|
|
16717
|
-
*
|
|
16718
|
-
* This is the narrow sibling of {@link isWorkingToolJobsNotice}: the
|
|
16719
|
-
* producer-declared `sourceKind === 'subagent-settled'` AND `form === 'notice'`
|
|
16720
|
-
* are both required, plus the fold's presentation-only `sameTurnNextStep` flag
|
|
16721
|
-
* derived from the durable `agent/inbox/spliced` insert/claim identity chain.
|
|
16722
|
-
* The settlement's textual outcome (`completed` / `error` / `aborted` / …) is
|
|
16723
|
-
* deliberately NOT inspected: every settlement that arrived through the same
|
|
16724
|
-
* proven delivery is carried the same way, and its raw body is never rewritten.
|
|
16725
|
-
* A `next-turn` wakeup, a foreign/legacy log, a crossed source/form pair or a
|
|
16726
|
-
* missing claim carries no flag and therefore stays an independent Context
|
|
16727
|
-
* boundary.
|
|
16728
|
-
*/
|
|
16729
|
-
function isWorkingSubagentSettledNotice(message) {
|
|
16730
|
-
if (!isSurfacedContext(message)) return false;
|
|
17884
|
+
function workContextCarriageOf(message, clusterByMember) {
|
|
17885
|
+
if (!isSurfacedContext(message)) return void 0;
|
|
16731
17886
|
const presentation = message.contextPresentation;
|
|
16732
|
-
|
|
16733
|
-
|
|
16734
|
-
|
|
16735
|
-
|
|
16736
|
-
|
|
16737
|
-
|
|
16738
|
-
|
|
16739
|
-
|
|
16740
|
-
*/
|
|
16741
|
-
function isFoldableWorkContext(message, clusterByMember) {
|
|
16742
|
-
return isFoldableSnapshotContext(message, clusterByMember) || isWorkingToolJobsNotice(message) || isWorkingAgentRelay(message) || isWorkingSubagentSettledNotice(message);
|
|
17887
|
+
if (isFoldableSnapshotContext(message, clusterByMember)) return "thought";
|
|
17888
|
+
if (presentation?.sameTurnNextStep === true) {
|
|
17889
|
+
const sourceKind = presentation.sourceKind;
|
|
17890
|
+
const form = presentation.form;
|
|
17891
|
+
if (sourceKind === "tool-jobs" && form === "notice") return "thought";
|
|
17892
|
+
if (sourceKind === "agent-message" && form === "relay" || sourceKind === "subagent-settled" && form === "notice" || sourceKind === "repeat-tool-reminder" && form === "notice" || sourceKind === "ptc-mode" && form === void 0 && presentation.formDeclared !== true && isPtcImageContext(message)) return "work";
|
|
17893
|
+
}
|
|
17894
|
+
if (presentation?.completeCatalogUpdate === true && clusterByMember.get(message) === void 0) return "trailing-work";
|
|
16743
17895
|
}
|
|
16744
17896
|
/**
|
|
16745
17897
|
* Segment one raw transcript window into canonical structural blocks.
|
|
@@ -16836,9 +17988,28 @@ function projectTranscriptStructure(messages) {
|
|
|
16836
17988
|
}], cluster.members, cluster.turn);
|
|
16837
17989
|
continue;
|
|
16838
17990
|
}
|
|
16839
|
-
if (
|
|
16840
|
-
|
|
16841
|
-
|
|
17991
|
+
if (isSurfacedContext(message)) {
|
|
17992
|
+
const carriage = workContextCarriageOf(message, clustering.byMember);
|
|
17993
|
+
if (carriage === "thought" || carriage === "work") {
|
|
17994
|
+
if (runMembers.length > 0) {
|
|
17995
|
+
if (runTurn === message.turn) {
|
|
17996
|
+
runParts.push({
|
|
17997
|
+
kind: "message",
|
|
17998
|
+
message
|
|
17999
|
+
});
|
|
18000
|
+
runMembers.push(message);
|
|
18001
|
+
continue;
|
|
18002
|
+
}
|
|
18003
|
+
flush();
|
|
18004
|
+
}
|
|
18005
|
+
pushPending([{
|
|
18006
|
+
kind: "message",
|
|
18007
|
+
message
|
|
18008
|
+
}], [message], message.turn);
|
|
18009
|
+
continue;
|
|
18010
|
+
}
|
|
18011
|
+
if (carriage === "trailing-work") {
|
|
18012
|
+
if (runMembers.length > 0 && runTurn === message.turn) {
|
|
16842
18013
|
runParts.push({
|
|
16843
18014
|
kind: "message",
|
|
16844
18015
|
message
|
|
@@ -16847,12 +18018,12 @@ function projectTranscriptStructure(messages) {
|
|
|
16847
18018
|
continue;
|
|
16848
18019
|
}
|
|
16849
18020
|
flush();
|
|
18021
|
+
out.push({
|
|
18022
|
+
kind: "message",
|
|
18023
|
+
message
|
|
18024
|
+
});
|
|
18025
|
+
continue;
|
|
16850
18026
|
}
|
|
16851
|
-
pushPending([{
|
|
16852
|
-
kind: "message",
|
|
16853
|
-
message
|
|
16854
|
-
}], [message], message.turn);
|
|
16855
|
-
continue;
|
|
16856
18027
|
}
|
|
16857
18028
|
if (isSurfacedInteractionTool(message)) {
|
|
16858
18029
|
flush();
|
|
@@ -16933,16 +18104,22 @@ function clusterByMemberOf(structure) {
|
|
|
16933
18104
|
/**
|
|
16934
18105
|
* Renderer-neutral Focus presentation projection.
|
|
16935
18106
|
*
|
|
16936
|
-
* The Focus projection over one windowed transcript (plan §12/§33):
|
|
16937
|
-
*
|
|
16938
|
-
*
|
|
16939
|
-
*
|
|
16940
|
-
*
|
|
16941
|
-
*
|
|
16942
|
-
*
|
|
16943
|
-
* A
|
|
16944
|
-
*
|
|
16945
|
-
*
|
|
18107
|
+
* The Focus projection over one windowed transcript (plan §12/§33): ONE logical
|
|
18108
|
+
* turn owns ONE Thought summary. The turn's primary presentation region is its
|
|
18109
|
+
* maximal run of eligible rows, bridged across a bounded run of standalone
|
|
18110
|
+
* control rows (a command, or a source-command-correlated manual compaction)
|
|
18111
|
+
* only when eligible same-turn evidence continues after that run. A turn with an
|
|
18112
|
+
* initial prompt is grouped as `user(s) -> FocusActivity`; a turn with only
|
|
18113
|
+
* same-turn steers starts with `FocusActivity` and keeps those steers in process
|
|
18114
|
+
* order. A turn woken by injected-context keeps that LEADING prefix at its
|
|
18115
|
+
* original foundation position before the Thought. Collapsed turns HIDE process
|
|
18116
|
+
* rows (a committed pre-steer answer is the explicit exception) and expanded
|
|
18117
|
+
* turns restore raw chronology with the final assistant held back. A foldable
|
|
18118
|
+
* Context row (producer-declared Snapshot, a `tool-jobs` Notice, an
|
|
18119
|
+
* `agent-message` relay, a `subagent-settled` Notice, a
|
|
18120
|
+
* `repeat-tool-reminder` Notice or an image-bearing `ptc-mode` Context with
|
|
18121
|
+
* durable same-turn next-step evidence) follows the same rule unless it shares
|
|
18122
|
+
* a raw-adjacent
|
|
16946
18123
|
* cluster with `instructions`/`catalog`: it joins the Thought instead of
|
|
16947
18124
|
* becoming turn foundation, while a mixed ambient cluster keeps its indivisible
|
|
16948
18125
|
* foundation position.
|
|
@@ -16963,15 +18140,75 @@ function clusterByMemberOf(structure) {
|
|
|
16963
18140
|
* collapsed Focus reorder would otherwise lift it above the turn's held-back
|
|
16964
18141
|
* final and invert the real chronology (`assistant final` → `Context
|
|
16965
18142
|
* compacted`). Treating turn-less rows as BOUNDARIES makes the projection
|
|
16966
|
-
* agree with the fold:
|
|
16967
|
-
*
|
|
16968
|
-
*
|
|
16969
|
-
*
|
|
18143
|
+
* agree with the fold: the Turn keeps its ONE summary, the command stays a
|
|
18144
|
+
* standalone control row (bridged only while eligible same-Turn evidence
|
|
18145
|
+
* continues), and any later disjoint region fails open in raw order instead of
|
|
18146
|
+
* minting a second Thought. All of those rows may belong to one model turn; the
|
|
18147
|
+
* semantic disclosure identity stays the turn number.
|
|
16970
18148
|
*/
|
|
16971
18149
|
function focusProjectionTurnOf(message) {
|
|
16972
18150
|
if (message.kind === "command") return void 0;
|
|
16973
18151
|
if (message.kind === "compaction" && message.sourceCommand !== void 0) return void 0;
|
|
16974
|
-
return
|
|
18152
|
+
return transcriptTurnOf(message);
|
|
18153
|
+
}
|
|
18154
|
+
/**
|
|
18155
|
+
* The settled latest-step Assistant that is still the PENDING final of an open
|
|
18156
|
+
* Turn, or undefined when it has authoritative continuation evidence (the Fold's
|
|
18157
|
+
* step/continuation fact), is committed, has display blocks, or is not settled.
|
|
18158
|
+
*/
|
|
18159
|
+
function focusPendingFinal(rows, activity) {
|
|
18160
|
+
if (activity === void 0 || activity.completed) return void 0;
|
|
18161
|
+
const latestStep = assistantLatestStepOf(activity);
|
|
18162
|
+
if (latestStep === void 0) return void 0;
|
|
18163
|
+
const latestAssistant = assistantForStep(rows, latestStep);
|
|
18164
|
+
if (latestAssistant === void 0 || !assistantStepSettledOf(activity, latestAssistant) || latestAssistant.displayBlocks !== void 0 || assistantCommittedBeforeSteer(activity, latestAssistant) || assistantStepIntermediateOf(activity, latestAssistant)) return void 0;
|
|
18165
|
+
return latestAssistant;
|
|
18166
|
+
}
|
|
18167
|
+
/** The turn's PRIMARY presentation region derived from the canonical raw
|
|
18168
|
+
* window: the same `focusPrimaryRegion` the projection emits. Used by the live
|
|
18169
|
+
* tail placement so a SUPPRESSED pending final still answers by region
|
|
18170
|
+
* membership, never by its own identity. */
|
|
18171
|
+
function focusPrimaryRegionOfTurn(messages, activities, turn) {
|
|
18172
|
+
const activity = activities.get(turn);
|
|
18173
|
+
const rows = focusRowsByTurn(messages).get(turn);
|
|
18174
|
+
if (activity === void 0 || rows === void 0) return void 0;
|
|
18175
|
+
const startMessage = messages.find((message) => focusProjectionTurnOf(message) === turn && !isPostTurnReplayEvidence(message));
|
|
18176
|
+
if (startMessage === void 0) return void 0;
|
|
18177
|
+
const start = messages.indexOf(startMessage);
|
|
18178
|
+
if (start < 0) return void 0;
|
|
18179
|
+
return focusPrimaryRegion(messages, start, turn, eligibleFinalAssistant(activity, rows));
|
|
18180
|
+
}
|
|
18181
|
+
/** Every message the ACTUAL all-expanded Focus projection can materialize on
|
|
18182
|
+
* the current preset: top-level rows plus members of a materialized Work span.
|
|
18183
|
+
* A suppressed pending/final row is absent; a Work emitted raw by a fail-open
|
|
18184
|
+
* region contributes no span. Search reveal/root grants use this so a
|
|
18185
|
+
* nonrecoverable hidden row mints no ancestor. */
|
|
18186
|
+
function focusMaterializedMessages(messages, activities) {
|
|
18187
|
+
const out = /* @__PURE__ */ new Set();
|
|
18188
|
+
for (const block of projectFocus(messages, activities, new Set(activities.keys()), true)) if (block.kind === "message") out.add(block.message);
|
|
18189
|
+
else if (block.kind === "work") for (const member of block.span.members) out.add(member);
|
|
18190
|
+
return out;
|
|
18191
|
+
}
|
|
18192
|
+
/**
|
|
18193
|
+
* The row a turn's expanded Focus holds back / emits as its final, per turn:
|
|
18194
|
+
* the qualified final once `turn/end` authoritatively qualifies it, otherwise
|
|
18195
|
+
* the still-pending latest-step Assistant. One rows pass; consumers use it to
|
|
18196
|
+
* recognize the final by IDENTITY instead of `assistant without containerPath`.
|
|
18197
|
+
*/
|
|
18198
|
+
function focusHeldBackFinalByTurn(messages, activities) {
|
|
18199
|
+
const out = /* @__PURE__ */ new Map();
|
|
18200
|
+
for (const [turn, rows] of focusRowsByTurn(messages)) {
|
|
18201
|
+
const activity = activities.get(turn);
|
|
18202
|
+
if (activity === void 0) continue;
|
|
18203
|
+
const final = eligibleFinalAssistant(activity, rows);
|
|
18204
|
+
if (final !== void 0) {
|
|
18205
|
+
out.set(turn, final.message);
|
|
18206
|
+
continue;
|
|
18207
|
+
}
|
|
18208
|
+
const pending = focusPendingFinal(rows, activity);
|
|
18209
|
+
if (pending !== void 0) out.set(turn, pending);
|
|
18210
|
+
}
|
|
18211
|
+
return out;
|
|
16975
18212
|
}
|
|
16976
18213
|
/**
|
|
16977
18214
|
* The Thought block for one turn: the caller-resolved TURN-LEVEL Action
|
|
@@ -17005,25 +18242,102 @@ const EMPTY_ACTION_STATS = {
|
|
|
17005
18242
|
types: /* @__PURE__ */ new Map()
|
|
17006
18243
|
};
|
|
17007
18244
|
/**
|
|
18245
|
+
* Whether one turn-less row is a standalone control-plane row the shared region
|
|
18246
|
+
* policy may bridge: a `kind:'command'` lifecycle, or a manual compaction card
|
|
18247
|
+
* already fused with the exact command that owns it (`sourceCommand`). No other
|
|
18248
|
+
* turn-less row is transparent — a window summary, a replay artifact and an
|
|
18249
|
+
* unrelated compaction boundary all end the region.
|
|
18250
|
+
*/
|
|
18251
|
+
function isFocusBridgeControlRow(message) {
|
|
18252
|
+
return message.kind === "command" || message.kind === "compaction" && message.sourceCommand !== void 0;
|
|
18253
|
+
}
|
|
18254
|
+
/**
|
|
18255
|
+
* Every eligible row of each projection turn, in window order. Post-turn replay
|
|
18256
|
+
* evidence is transcript evidence, NOT turn identity: it may neither open nor
|
|
18257
|
+
* join a Focus root, so it is omitted here and emitted standalone. One linear
|
|
18258
|
+
* pass; the final candidate and the bridge fences read these rows once.
|
|
18259
|
+
*/
|
|
18260
|
+
function focusRowsByTurn(messages) {
|
|
18261
|
+
const byTurn = /* @__PURE__ */ new Map();
|
|
18262
|
+
for (const message of messages) {
|
|
18263
|
+
const turn = focusProjectionTurnOf(message);
|
|
18264
|
+
if (turn === void 0 || isPostTurnReplayEvidence(message)) continue;
|
|
18265
|
+
const rows = byTurn.get(turn);
|
|
18266
|
+
if (rows === void 0) byTurn.set(turn, [message]);
|
|
18267
|
+
else rows.push(message);
|
|
18268
|
+
}
|
|
18269
|
+
return byTurn;
|
|
18270
|
+
}
|
|
18271
|
+
/**
|
|
18272
|
+
* Segment the primary presentation region of one logical Turn.
|
|
18273
|
+
*
|
|
18274
|
+
* The region starts at the turn's first eligible row and continues through its
|
|
18275
|
+
* remaining eligible rows in raw order. A bounded, maximal run of standalone
|
|
18276
|
+
* control rows is consumed INTO the region only when the same turn's eligible
|
|
18277
|
+
* evidence resumes after that run and the run has not crossed the turn's
|
|
18278
|
+
* qualified final. Otherwise the region ends there: the control rows and every
|
|
18279
|
+
* later row of that turn render independently (a command at the window tail is
|
|
18280
|
+
* simply not bridged yet). A different turn, any other turn-less boundary and a
|
|
18281
|
+
* replay-marked row are hard fences; the bounded lookahead never scans the rest
|
|
18282
|
+
* of the window per row, so the whole projection stays linear.
|
|
18283
|
+
* @param messages - the windowed transcript.
|
|
18284
|
+
* @param start - the region's first eligible row index.
|
|
18285
|
+
* @param turn - the logical Turn being segmented.
|
|
18286
|
+
* @param final - the Turn's qualified final, when it has one. A final that has
|
|
18287
|
+
* already appeared before a control run makes that run a hard chronology
|
|
18288
|
+
* fence (nothing may move across it).
|
|
18289
|
+
*/
|
|
18290
|
+
function focusPrimaryRegion(messages, start, turn, final) {
|
|
18291
|
+
const members = [messages[start]];
|
|
18292
|
+
let sawFinal = final !== void 0 && messages[start] === final.message;
|
|
18293
|
+
let index = start + 1;
|
|
18294
|
+
while (index < messages.length) {
|
|
18295
|
+
const next = messages[index];
|
|
18296
|
+
const nextTurn = focusProjectionTurnOf(next);
|
|
18297
|
+
if (nextTurn === turn) {
|
|
18298
|
+
if (isPostTurnReplayEvidence(next)) break;
|
|
18299
|
+
members.push(next);
|
|
18300
|
+
if (final !== void 0 && next === final.message) sawFinal = true;
|
|
18301
|
+
index += 1;
|
|
18302
|
+
continue;
|
|
18303
|
+
}
|
|
18304
|
+
if (nextTurn !== void 0 || !isFocusBridgeControlRow(next)) break;
|
|
18305
|
+
let runEnd = index;
|
|
18306
|
+
while (runEnd < messages.length) {
|
|
18307
|
+
const candidate = messages[runEnd];
|
|
18308
|
+
if (focusProjectionTurnOf(candidate) !== void 0 || !isFocusBridgeControlRow(candidate)) break;
|
|
18309
|
+
runEnd += 1;
|
|
18310
|
+
}
|
|
18311
|
+
const continuation = messages[runEnd];
|
|
18312
|
+
if (sawFinal || continuation === void 0 || focusProjectionTurnOf(continuation) !== turn || isPostTurnReplayEvidence(continuation)) break;
|
|
18313
|
+
for (let run = index; run < runEnd; run += 1) members.push(messages[run]);
|
|
18314
|
+
index = runEnd;
|
|
18315
|
+
}
|
|
18316
|
+
return {
|
|
18317
|
+
members,
|
|
18318
|
+
end: index
|
|
18319
|
+
};
|
|
18320
|
+
}
|
|
18321
|
+
/**
|
|
17008
18322
|
* One linear pass over the window: each turn's WHOLE-TURN action aggregate
|
|
17009
|
-
* (addendum v2 §18). Focus stats describe the
|
|
17010
|
-
*
|
|
17011
|
-
*
|
|
17012
|
-
*
|
|
17013
|
-
*
|
|
17014
|
-
*
|
|
17015
|
-
* unchanged window.
|
|
18323
|
+
* (addendum v2 §18). Focus stats describe the logical Turn, not its primary
|
|
18324
|
+
* presentation region: bridged control rows and a fail-open later region change
|
|
18325
|
+
* neither the aggregate nor its loaded-window scope, and the ONE summary always
|
|
18326
|
+
* reports the same turn-level number. A search reveal / disclosure state cannot
|
|
18327
|
+
* change it because none of them participate here. O(n) once per projection,
|
|
18328
|
+
* never a per-frame rescan of an unchanged window.
|
|
17016
18329
|
*/
|
|
17017
18330
|
function focusActionStatsByTurn(messages) {
|
|
17018
18331
|
const accumulators = /* @__PURE__ */ new Map();
|
|
17019
18332
|
for (const message of messages) {
|
|
17020
|
-
|
|
18333
|
+
const turn = transcriptTurnOf(message);
|
|
18334
|
+
if (turn === void 0) continue;
|
|
17021
18335
|
const source = compactActionSourceOf(message);
|
|
17022
18336
|
if (source === void 0) continue;
|
|
17023
|
-
let accumulator = accumulators.get(
|
|
18337
|
+
let accumulator = accumulators.get(turn);
|
|
17024
18338
|
if (accumulator === void 0) {
|
|
17025
18339
|
accumulator = newCompactActionStats();
|
|
17026
|
-
accumulators.set(
|
|
18340
|
+
accumulators.set(turn, accumulator);
|
|
17027
18341
|
}
|
|
17028
18342
|
addCompactActionStats(accumulator, source);
|
|
17029
18343
|
}
|
|
@@ -17037,8 +18351,8 @@ function focusActionStatsByTurn(messages) {
|
|
|
17037
18351
|
* renders an UNQUALIFIED durable mid-turn `form:'notice'` AFTER the Thought
|
|
17038
18352
|
* (visible process feedback, never inside the hidden Action candidate set),
|
|
17039
18353
|
* and hides ordinary Process inside the collapsed root. A proven Working
|
|
17040
|
-
* `tool-jobs` Notice, same-turn Agent relay
|
|
17041
|
-
* carried by that same Thought instead.
|
|
18354
|
+
* `tool-jobs` Notice, same-turn Agent relay, subagent settlement Notice or
|
|
18355
|
+
* repeat-tool-reminder Notice is carried by that same Thought instead.
|
|
17042
18356
|
* Expanded Focus restores the exact raw chronology.
|
|
17043
18357
|
*/
|
|
17044
18358
|
function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
@@ -17047,12 +18361,42 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17047
18361
|
message
|
|
17048
18362
|
}));
|
|
17049
18363
|
const actionStatsByTurn = focusActionStatsByTurn(messages);
|
|
18364
|
+
const rowsByTurn = focusRowsByTurn(messages);
|
|
18365
|
+
const finalByTurn = /* @__PURE__ */ new Map();
|
|
18366
|
+
const pendingByTurn = /* @__PURE__ */ new Map();
|
|
18367
|
+
for (const [turn, rows] of rowsByTurn) {
|
|
18368
|
+
const final = eligibleFinalAssistant(activities.get(turn), rows);
|
|
18369
|
+
if (final !== void 0) finalByTurn.set(turn, final);
|
|
18370
|
+
const pending = focusPendingFinal(rows, activities.get(turn));
|
|
18371
|
+
if (pending !== void 0) pendingByTurn.set(turn, pending);
|
|
18372
|
+
}
|
|
17050
18373
|
const out = [];
|
|
18374
|
+
const rootedTurns = /* @__PURE__ */ new Set();
|
|
17051
18375
|
let index = 0;
|
|
17052
18376
|
while (index < messages.length) {
|
|
17053
18377
|
const message = messages[index];
|
|
17054
18378
|
const turn = focusProjectionTurnOf(message);
|
|
17055
|
-
|
|
18379
|
+
const activity = turn === void 0 ? void 0 : activities.get(turn);
|
|
18380
|
+
if (turn === void 0 || activity === void 0 || isPostTurnReplayEvidence(message) || rootedTurns.has(turn)) {
|
|
18381
|
+
if (!isPostTurnReplayEvidence(message) && turn !== void 0 && activity !== void 0 && rootedTurns.has(turn)) {
|
|
18382
|
+
if (pendingByTurn.get(turn) === message) {
|
|
18383
|
+
index += 1;
|
|
18384
|
+
continue;
|
|
18385
|
+
}
|
|
18386
|
+
const qualified = finalByTurn.get(turn);
|
|
18387
|
+
if (qualified !== void 0 && qualified.message === message) {
|
|
18388
|
+
out.push(qualified.truncated ? {
|
|
18389
|
+
kind: "message",
|
|
18390
|
+
message,
|
|
18391
|
+
truncated: true
|
|
18392
|
+
} : {
|
|
18393
|
+
kind: "message",
|
|
18394
|
+
message
|
|
18395
|
+
});
|
|
18396
|
+
index += 1;
|
|
18397
|
+
continue;
|
|
18398
|
+
}
|
|
18399
|
+
}
|
|
17056
18400
|
out.push({
|
|
17057
18401
|
kind: "message",
|
|
17058
18402
|
message
|
|
@@ -17060,38 +18404,26 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17060
18404
|
index += 1;
|
|
17061
18405
|
continue;
|
|
17062
18406
|
}
|
|
17063
|
-
const
|
|
17064
|
-
index
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
|
|
17069
|
-
message: member
|
|
17070
|
-
});
|
|
17071
|
-
continue;
|
|
17072
|
-
}
|
|
18407
|
+
const final = finalByTurn.get(turn);
|
|
18408
|
+
const region = focusPrimaryRegion(messages, index, turn, final);
|
|
18409
|
+
index = region.end;
|
|
18410
|
+
rootedTurns.add(turn);
|
|
18411
|
+
const members = region.members;
|
|
18412
|
+
const regionFinal = final !== void 0 && members.includes(final.message) ? final : void 0;
|
|
17073
18413
|
const actionStats = actionStatsByTurn.get(turn) ?? EMPTY_ACTION_STATS;
|
|
17074
18414
|
const expanded = expandedTurns.has(turn);
|
|
17075
|
-
const
|
|
17076
|
-
const isCommittedAnswer = (member) =>
|
|
17077
|
-
let latestAssistantIndex = -1;
|
|
17078
|
-
for (let memberIndex = group.length - 1; memberIndex >= 0; memberIndex -= 1) if (group[memberIndex]?.kind === "assistant") {
|
|
17079
|
-
latestAssistantIndex = memberIndex;
|
|
17080
|
-
break;
|
|
17081
|
-
}
|
|
17082
|
-
const latestAssistant = latestAssistantIndex < 0 ? void 0 : group[latestAssistantIndex];
|
|
17083
|
-
const laterProcess = latestAssistantIndex < 0 ? false : group.slice(latestAssistantIndex + 1).some((member) => member.kind !== "user" && !isSurfacedContext(member));
|
|
17084
|
-
const pendingFinalAssistant = !activity.completed && latestAssistant?.kind === "assistant" && assistantStepOf(latestAssistant) === assistantLatestStepOf(activity) && assistantStepSettledOf(activity, latestAssistant) && latestAssistant.displayBlocks === void 0 && !isCommittedAnswer(latestAssistant) && !laterProcess ? latestAssistant : void 0;
|
|
18415
|
+
const rootOwner = members[0];
|
|
18416
|
+
const isCommittedAnswer = (member) => assistantCommittedBeforeSteer(activity, member);
|
|
17085
18417
|
if (expanded) {
|
|
17086
|
-
const
|
|
17087
|
-
const
|
|
17088
|
-
for (const member of group.slice(0, boundary)) out.push({
|
|
18418
|
+
const boundary = focusThoughtLeadBoundary(members);
|
|
18419
|
+
for (const member of members.slice(0, boundary)) out.push({
|
|
17089
18420
|
kind: "message",
|
|
17090
18421
|
message: member
|
|
17091
18422
|
});
|
|
17092
|
-
|
|
18423
|
+
out.push(...focusActivityBlock(activity, rootOwner, actionStats, void 0));
|
|
18424
|
+
const pendingFinalAssistant = pendingByTurn.get(turn);
|
|
17093
18425
|
const emitTailRow = (member) => {
|
|
17094
|
-
if (isFocusPersistentInputRow(member)) {
|
|
18426
|
+
if (isFocusPersistentInputRow(member) || isFocusBridgeControlRow(member)) {
|
|
17095
18427
|
out.push({
|
|
17096
18428
|
kind: "message",
|
|
17097
18429
|
message: member,
|
|
@@ -17099,7 +18431,7 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17099
18431
|
});
|
|
17100
18432
|
return;
|
|
17101
18433
|
}
|
|
17102
|
-
if (
|
|
18434
|
+
if (regionFinal !== void 0 && member === regionFinal.message) return;
|
|
17103
18435
|
if (member === pendingFinalAssistant) return;
|
|
17104
18436
|
if (isCommittedAnswer(member)) {
|
|
17105
18437
|
out.push({
|
|
@@ -17119,7 +18451,7 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17119
18451
|
focusPresentationOwner: rootOwner
|
|
17120
18452
|
});
|
|
17121
18453
|
};
|
|
17122
|
-
for (const block of focusExpandedTailStructure(
|
|
18454
|
+
for (const block of focusExpandedTailStructure(members, boundary)) if (block.kind === "work") out.push({
|
|
17123
18455
|
kind: "work",
|
|
17124
18456
|
span: block.span,
|
|
17125
18457
|
focusOwnerTurn: turn,
|
|
@@ -17127,75 +18459,79 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17127
18459
|
});
|
|
17128
18460
|
else if (block.kind === "context-cluster") for (const member of block.cluster.members) emitTailRow(member);
|
|
17129
18461
|
else emitTailRow(block.message);
|
|
17130
|
-
if (
|
|
18462
|
+
if (regionFinal !== void 0) out.push(regionFinal.truncated ? {
|
|
17131
18463
|
kind: "message",
|
|
17132
|
-
message:
|
|
18464
|
+
message: regionFinal.message,
|
|
17133
18465
|
truncated: true
|
|
17134
18466
|
} : {
|
|
17135
18467
|
kind: "message",
|
|
17136
|
-
message:
|
|
18468
|
+
message: regionFinal.message
|
|
17137
18469
|
});
|
|
17138
18470
|
continue;
|
|
17139
18471
|
}
|
|
17140
|
-
const leadBoundary = focusThoughtLeadBoundary(
|
|
18472
|
+
const leadBoundary = focusThoughtLeadBoundary(members);
|
|
17141
18473
|
const foldableSnapshots = {
|
|
17142
|
-
clusterByMember: clusterAdjacentAmbientContext(
|
|
17143
|
-
workByMember: workByMemberOf(projectTranscriptStructure(
|
|
17144
|
-
thoughtOwned:
|
|
18474
|
+
clusterByMember: clusterAdjacentAmbientContext(members).byMember,
|
|
18475
|
+
workByMember: workByMemberOf(projectTranscriptStructure(members)),
|
|
18476
|
+
thoughtOwned: true
|
|
17145
18477
|
};
|
|
17146
|
-
const firstCommittedIndex =
|
|
18478
|
+
const firstCommittedIndex = members.findIndex(isCommittedAnswer);
|
|
17147
18479
|
const hidden = [];
|
|
17148
18480
|
const preThought = [];
|
|
17149
18481
|
const postThought = [];
|
|
17150
|
-
|
|
17151
|
-
|
|
17152
|
-
|
|
17153
|
-
|
|
17154
|
-
|
|
17155
|
-
|
|
18482
|
+
const preCommittedCompactions = [];
|
|
18483
|
+
if (firstCommittedIndex < 0) for (let memberIndex = 0; memberIndex < members.length; memberIndex += 1) {
|
|
18484
|
+
const member = members[memberIndex];
|
|
18485
|
+
if (isFocusBridgeControlRow(member)) {
|
|
18486
|
+
preThought.push(member);
|
|
18487
|
+
continue;
|
|
17156
18488
|
}
|
|
17157
|
-
|
|
17158
|
-
|
|
17159
|
-
|
|
17160
|
-
}
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
|
|
17164
|
-
|
|
17165
|
-
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
17169
|
-
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
|
|
17175
|
-
|
|
17176
|
-
|
|
18489
|
+
if (member.kind === "compaction") {
|
|
18490
|
+
preCommittedCompactions.push(member);
|
|
18491
|
+
continue;
|
|
18492
|
+
}
|
|
18493
|
+
if (regionFinal !== void 0 && member === regionFinal.message) continue;
|
|
18494
|
+
const disposition = collapsedFocusRowDisposition(member, memberIndex, leadBoundary, foldableSnapshots);
|
|
18495
|
+
if (disposition === "hidden") hidden.push(member);
|
|
18496
|
+
else (disposition === "pre-thought" ? preThought : postThought).push(member);
|
|
18497
|
+
}
|
|
18498
|
+
else {
|
|
18499
|
+
const beforeCommitted = members.slice(0, firstCommittedIndex);
|
|
18500
|
+
for (let memberIndex = 0; memberIndex < beforeCommitted.length; memberIndex += 1) {
|
|
18501
|
+
const member = beforeCommitted[memberIndex];
|
|
18502
|
+
if (isFocusBridgeControlRow(member)) {
|
|
18503
|
+
preThought.push(member);
|
|
18504
|
+
continue;
|
|
18505
|
+
}
|
|
18506
|
+
if (member.kind === "compaction") {
|
|
18507
|
+
preCommittedCompactions.push(member);
|
|
18508
|
+
continue;
|
|
18509
|
+
}
|
|
18510
|
+
const disposition = collapsedFocusRowDisposition(member, memberIndex, leadBoundary, foldableSnapshots);
|
|
18511
|
+
if (disposition === "hidden") hidden.push(member);
|
|
18512
|
+
else (disposition === "pre-thought" ? preThought : postThought).push(member);
|
|
17177
18513
|
}
|
|
17178
18514
|
const postCommittedFoldableSnapshots = {
|
|
17179
18515
|
...foldableSnapshots,
|
|
17180
18516
|
thoughtOwned: false
|
|
17181
18517
|
};
|
|
17182
18518
|
const postCommitted = [];
|
|
17183
|
-
for (let
|
|
17184
|
-
const member =
|
|
17185
|
-
if (
|
|
17186
|
-
if (collapsedFocusRowDisposition(member,
|
|
18519
|
+
for (let memberIndex = firstCommittedIndex; memberIndex < members.length; memberIndex += 1) {
|
|
18520
|
+
const member = members[memberIndex];
|
|
18521
|
+
if (regionFinal !== void 0 && member === regionFinal.message) continue;
|
|
18522
|
+
if (collapsedFocusRowDisposition(member, memberIndex, leadBoundary, postCommittedFoldableSnapshots) !== "hidden" || isFocusBridgeControlRow(member) || member.kind === "compaction" || isCommittedAnswer(member)) postCommitted.push(member);
|
|
17187
18523
|
else hidden.push(member);
|
|
17188
18524
|
}
|
|
17189
18525
|
out.push(...preThought.map((member) => ({
|
|
17190
18526
|
kind: "message",
|
|
17191
18527
|
message: member
|
|
17192
18528
|
})));
|
|
17193
|
-
out.push(...focusActivityBlock(activity,
|
|
18529
|
+
out.push(...focusActivityBlock(activity, rootOwner, actionStats, hidden));
|
|
17194
18530
|
out.push(...postThought.map((member) => ({
|
|
17195
18531
|
kind: "message",
|
|
17196
18532
|
message: member
|
|
17197
18533
|
})));
|
|
17198
|
-
for (const member of
|
|
18534
|
+
for (const member of preCommittedCompactions) out.push({
|
|
17199
18535
|
kind: "message",
|
|
17200
18536
|
message: member
|
|
17201
18537
|
});
|
|
@@ -17203,32 +18539,91 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17203
18539
|
kind: "message",
|
|
17204
18540
|
message: member
|
|
17205
18541
|
});
|
|
18542
|
+
if (regionFinal !== void 0) out.push(regionFinal.truncated ? {
|
|
18543
|
+
kind: "message",
|
|
18544
|
+
message: regionFinal.message,
|
|
18545
|
+
truncated: true
|
|
18546
|
+
} : {
|
|
18547
|
+
kind: "message",
|
|
18548
|
+
message: regionFinal.message
|
|
18549
|
+
});
|
|
18550
|
+
continue;
|
|
17206
18551
|
}
|
|
17207
|
-
|
|
18552
|
+
out.push(...preThought.map((member) => ({
|
|
18553
|
+
kind: "message",
|
|
18554
|
+
message: member
|
|
18555
|
+
})));
|
|
18556
|
+
out.push(...focusActivityBlock(activity, rootOwner, actionStats, hidden));
|
|
18557
|
+
out.push(...postThought.map((member) => ({
|
|
18558
|
+
kind: "message",
|
|
18559
|
+
message: member
|
|
18560
|
+
})));
|
|
18561
|
+
for (const member of preCommittedCompactions) out.push({
|
|
17208
18562
|
kind: "message",
|
|
17209
|
-
message:
|
|
18563
|
+
message: member
|
|
18564
|
+
});
|
|
18565
|
+
if (regionFinal !== void 0) out.push(regionFinal.truncated ? {
|
|
18566
|
+
kind: "message",
|
|
18567
|
+
message: regionFinal.message,
|
|
17210
18568
|
truncated: true
|
|
17211
18569
|
} : {
|
|
17212
18570
|
kind: "message",
|
|
17213
|
-
message:
|
|
18571
|
+
message: regionFinal.message
|
|
17214
18572
|
});
|
|
17215
18573
|
}
|
|
17216
18574
|
return out;
|
|
17217
18575
|
}
|
|
17218
18576
|
/**
|
|
17219
|
-
* The canonical structural blocks the expanded Focus TAIL consumes: one
|
|
17220
|
-
*
|
|
17221
|
-
*
|
|
17222
|
-
*
|
|
17223
|
-
*
|
|
18577
|
+
* The canonical structural blocks the expanded Focus TAIL consumes: one logical
|
|
18578
|
+
* Turn's primary presentation region from its Thought-lead boundary onward
|
|
18579
|
+
* (bridged control rows included at their raw positions). The held-back final is
|
|
18580
|
+
* included, so cluster membership is computed from exactly the raw adjacency the
|
|
18581
|
+
* window would give. `projectFocus` emits a canonical Work span as a nested
|
|
18582
|
+
* `work` block (F6); this exported seam lets the convergence oracle compare
|
|
17224
18583
|
* Work/cluster boundary IDENTITY (owner and member objects) instead of display
|
|
17225
18584
|
* strings (plan §25).
|
|
17226
|
-
* @param
|
|
17227
|
-
* @param boundary - the
|
|
17228
|
-
* Passed in so one expanded
|
|
18585
|
+
* @param region - one logical Turn's primary region members, in raw order.
|
|
18586
|
+
* @param boundary - the region's Thought-lead boundary
|
|
18587
|
+
* ({@link focusThoughtLeadBoundary}). Passed in so one expanded region
|
|
18588
|
+
* computes the boundary once.
|
|
17229
18589
|
*/
|
|
17230
|
-
function focusExpandedTailStructure(
|
|
17231
|
-
return projectTranscriptStructure(
|
|
18590
|
+
function focusExpandedTailStructure(region, boundary) {
|
|
18591
|
+
return projectTranscriptStructure(region.slice(boundary));
|
|
18592
|
+
}
|
|
18593
|
+
/**
|
|
18594
|
+
* The projected live-call owner at the RAW transcript tail: the ONE root of the
|
|
18595
|
+
* open Turn whose PRIMARY region actually reaches the tail, plus the exact
|
|
18596
|
+
* canonical Work when that Work owns the call. `undefined` when the tail is an
|
|
18597
|
+
* independent boundary (a turn-less command/window row, replay evidence, a
|
|
18598
|
+
* foreign/completed Turn) or belongs to a later fail-open region of the same
|
|
18599
|
+
* Turn.
|
|
18600
|
+
*
|
|
18601
|
+
* PiTui and TSP use this ONE placement. The authority is the ACTUAL expanded
|
|
18602
|
+
* projection (the region's emitted rows/Work), never "the numeric turn of the
|
|
18603
|
+
* canonical tail": a later disjoint region of the same open Turn is not the
|
|
18604
|
+
* root's region, so its rows may not adopt the live call.
|
|
18605
|
+
*/
|
|
18606
|
+
function focusLiveTailPlacement(messages, activities, expandedBlocks) {
|
|
18607
|
+
const expanded = expandedBlocks ?? projectFocus(messages, activities, new Set(activities.keys()), true);
|
|
18608
|
+
const openActivityOf = (turn) => {
|
|
18609
|
+
const block = expanded.find((candidate) => candidate.kind === "activity" && candidate.activity.turn === turn);
|
|
18610
|
+
return block?.kind === "activity" && !block.activity.completed ? block : void 0;
|
|
18611
|
+
};
|
|
18612
|
+
const trailing = projectTranscriptStructure(messages).at(-1);
|
|
18613
|
+
if (trailing === void 0) return void 0;
|
|
18614
|
+
const tailWork = trailing.kind === "work" ? trailing.span : void 0;
|
|
18615
|
+
const tailMessage = trailing.kind === "work" ? void 0 : trailing.kind === "message" ? trailing.message : trailing.kind === "context-cluster" ? trailing.cluster.members.at(-1) : void 0;
|
|
18616
|
+
const tailTurn = tailWork !== void 0 ? tailWork.turn : tailMessage !== void 0 && "turn" in tailMessage ? tailMessage.turn : void 0;
|
|
18617
|
+
if (tailTurn === void 0) return void 0;
|
|
18618
|
+
const activity = openActivityOf(tailTurn);
|
|
18619
|
+
if (activity === void 0) return void 0;
|
|
18620
|
+
if (tailWork !== void 0) return expanded.some((block) => block.kind === "work" && block.span.owner === tailWork.owner) ? {
|
|
18621
|
+
rootOwner: activity.owner,
|
|
18622
|
+
workOwner: tailWork.owner
|
|
18623
|
+
} : void 0;
|
|
18624
|
+
if (tailMessage === void 0) return void 0;
|
|
18625
|
+
const primary = focusPrimaryRegionOfTurn(messages, activities, tailTurn);
|
|
18626
|
+
return primary !== void 0 && primary.members.includes(tailMessage) ? { rootOwner: activity.owner } : void 0;
|
|
17232
18627
|
}
|
|
17233
18628
|
/** Rows that remain visible outside the collapsed Thought as persistent
|
|
17234
18629
|
* input/context boundaries. The semantic class stays Context for injected
|
|
@@ -17241,50 +18636,25 @@ function isFocusPersistentInputRow(message) {
|
|
|
17241
18636
|
}
|
|
17242
18637
|
function collapsedFocusRowDisposition(message, index, leadBoundary, foldableSnapshots) {
|
|
17243
18638
|
if (!isFocusPersistentInputRow(message)) return "hidden";
|
|
17244
|
-
if (foldableSnapshots.thoughtOwned && index >= leadBoundary
|
|
18639
|
+
if (foldableSnapshots.thoughtOwned && index >= leadBoundary) {
|
|
18640
|
+
const carriage = workContextCarriageOf(message, foldableSnapshots.clusterByMember);
|
|
18641
|
+
if (carriage === "thought" || (carriage === "work" || carriage === "trailing-work") && foldableSnapshots.workByMember.has(message)) return "hidden";
|
|
18642
|
+
}
|
|
17245
18643
|
if (index >= leadBoundary && isNoticeContext(message)) return "post-thought";
|
|
17246
18644
|
return "pre-thought";
|
|
17247
18645
|
}
|
|
17248
|
-
/**
|
|
17249
|
-
* One turn's maximal run of CONSECUTIVE same-turn rows starting at `start`.
|
|
17250
|
-
* A turn-less entry (window summary) may SPLIT a turn into separate runs, and
|
|
17251
|
-
* the projection folds each run independently — this helper is shared by the
|
|
17252
|
-
* projection and the collapsed visibility predicate so their index and
|
|
17253
|
-
* `focusThoughtLeadBoundary` math can never diverge on a non-monotonic window.
|
|
17254
|
-
* @param messages - the transcript window.
|
|
17255
|
-
* @param start - the run's first index.
|
|
17256
|
-
* @param turn - the run's turn number.
|
|
17257
|
-
*/
|
|
17258
|
-
/**
|
|
17259
|
-
* The consecutive rows of ONE Focus projection turn, starting at `start`.
|
|
17260
|
-
*
|
|
17261
|
-
* Exported so a caller that needs the Focus disposition of a SINGLE row can
|
|
17262
|
-
* project that turn's own group instead of the whole loaded history (the search
|
|
17263
|
-
* seat's ancestry probe). It is the SAME segmentation `projectFocus` walks, so
|
|
17264
|
-
* the slice and the full projection can never disagree.
|
|
17265
|
-
*/
|
|
17266
|
-
function consecutiveTurnGroup(messages, start, turn) {
|
|
17267
|
-
const group = [messages[start]];
|
|
17268
|
-
let index = start + 1;
|
|
17269
|
-
while (index < messages.length) {
|
|
17270
|
-
const next = messages[index];
|
|
17271
|
-
if (focusProjectionTurnOf(next) !== turn) break;
|
|
17272
|
-
group.push(next);
|
|
17273
|
-
index += 1;
|
|
17274
|
-
}
|
|
17275
|
-
return group;
|
|
17276
|
-
}
|
|
17277
18646
|
/** The Thought-lead boundary of one turn group: the prefix that stays above the
|
|
17278
18647
|
* Thought. It starts after the FIRST unmarked user row when one exists; a turn
|
|
17279
18648
|
* with no human user (an inject-woken / next-turn wakeup turn) starts at the
|
|
17280
18649
|
* group beginning. In both cases the boundary then consumes leading surfaced
|
|
17281
|
-
* Context rows that are NOT
|
|
17282
|
-
* `
|
|
17283
|
-
*
|
|
17284
|
-
*
|
|
17285
|
-
*
|
|
17286
|
-
*
|
|
17287
|
-
*
|
|
18650
|
+
* Context rows that are NOT Thought/Work carriage candidates (the wakeup cause,
|
|
18651
|
+
* `instructions`, an independent or not-yet-attachable `catalog`, an
|
|
18652
|
+
* unqualified notice or relay). The first carried Context row (`thought` or
|
|
18653
|
+
* `work`) ends the foundation and becomes Thought content — so a next-turn
|
|
18654
|
+
* wakeup notice stays visible while the Snapshot and same-turn deliveries that
|
|
18655
|
+
* arrive during the work fold with it. A `trailing-work` catalog (and an
|
|
18656
|
+
* independent catalog) remains foundation content until a real preceding Work
|
|
18657
|
+
* exists and it is actually carried. A mixed
|
|
17288
18658
|
* `instructions`/`catalog` + Snapshot cluster keeps its indivisible foundation
|
|
17289
18659
|
* position. `llm/retry`/max-token orchestration rows are not surfaced Context,
|
|
17290
18660
|
* so they never enter the prefix. Without steer metadata the first user remains
|
|
@@ -17296,7 +18666,8 @@ function focusThoughtLeadBoundary(group) {
|
|
|
17296
18666
|
while (true) {
|
|
17297
18667
|
const member = group[end];
|
|
17298
18668
|
if (member === void 0 || !isSurfacedContext(member)) break;
|
|
17299
|
-
|
|
18669
|
+
const carriage = workContextCarriageOf(member, clusterByMember);
|
|
18670
|
+
if (carriage === "thought" || carriage === "work") break;
|
|
17300
18671
|
end += 1;
|
|
17301
18672
|
}
|
|
17302
18673
|
return end;
|
|
@@ -17530,7 +18901,7 @@ function summarizeWorkSpan(span) {
|
|
|
17530
18901
|
* nothing; an equal-time following row, by contrast, is already visible and
|
|
17531
18902
|
* closes the Activity from the same instant (a point span hides its duration —
|
|
17532
18903
|
* a coarse clock must never leave it live). A following block with NO proven
|
|
17533
|
-
* time (a local
|
|
18904
|
+
* time (a Client-local shell card, a synthetic window summary) keeps the span out of
|
|
17534
18905
|
* the live tail without closing it. The lookup is an exact offline 2D
|
|
17535
18906
|
* dominance-min, so no ordering assumption about the Activities' starts is
|
|
17536
18907
|
* needed.
|
|
@@ -17539,15 +18910,15 @@ function summarizeWorkSpan(span) {
|
|
|
17539
18910
|
* end after its turn, so a row of a later turn can never lengthen an
|
|
17540
18911
|
* already-frozen Activity.
|
|
17541
18912
|
*
|
|
17542
|
-
* KNOWN LIMIT (
|
|
17543
|
-
*
|
|
17544
|
-
*
|
|
17545
|
-
* hydration
|
|
17546
|
-
*
|
|
17547
|
-
*
|
|
17548
|
-
*
|
|
17549
|
-
*
|
|
17550
|
-
*
|
|
18913
|
+
* KNOWN LIMIT: the canonical Work MEMBERSHIP (which Process rows share one
|
|
18914
|
+
* span) is decided by the display-order authority — `projectTranscriptStructure`
|
|
18915
|
+
* plus the fold's lane/read-group convergence — never by this clock. A cold
|
|
18916
|
+
* hydration materializes a settlement at its raw log position while the live
|
|
18917
|
+
* lane may have projected its first visible text earlier; the existing
|
|
18918
|
+
* convergence mechanism and its live/cold parity tests supply the qualified
|
|
18919
|
+
* order. This clock derives lifetimes from the rows that authority already
|
|
18920
|
+
* ordered; it never reorders membership and never fabricates a boundary from
|
|
18921
|
+
* an unqualified row position.
|
|
17551
18922
|
* @param structure - the canonical structural blocks for one window.
|
|
17552
18923
|
* @param turnActivities - the folded turn boundary facts of the SAME snapshot.
|
|
17553
18924
|
*/
|
|
@@ -17665,8 +19036,9 @@ function interactionBoundaryOf(span) {
|
|
|
17665
19036
|
/** The first ACTUALLY VISIBLE time of one non-Process boundary block: the
|
|
17666
19037
|
* earliest reliable sidecar start among the row(s) that carry the boundary.
|
|
17667
19038
|
* `undefined` means the block has no provable first-visible evidence (a
|
|
17668
|
-
* synthetic window summary,
|
|
17669
|
-
*
|
|
19039
|
+
* synthetic window summary, or a row the fold could not time) — the Activity
|
|
19040
|
+
* then stays open rather than freezing at a fabricated time. A real command
|
|
19041
|
+
* row carries its own point sidecar and therefore closes the Activity. */
|
|
17670
19042
|
function boundaryTimeOf(block) {
|
|
17671
19043
|
if (block.kind === "message") return transcriptTimingOf(block.message)?.startedAt;
|
|
17672
19044
|
if (block.kind === "context-cluster") {
|
|
@@ -19284,11 +20656,19 @@ function toolNode(message, key, options) {
|
|
|
19284
20656
|
}, ...body.args, ...children, ...body.result);
|
|
19285
20657
|
}
|
|
19286
20658
|
/**
|
|
19287
|
-
* The safe body of one injected Context row
|
|
19288
|
-
*
|
|
19289
|
-
*
|
|
19290
|
-
|
|
19291
|
-
|
|
20659
|
+
* The safe body of one injected Context row.
|
|
20660
|
+
*
|
|
20661
|
+
* An image-bearing `ptc-mode` Context renders its ORIGINAL structured content
|
|
20662
|
+
* through the same ordered body path User/Assistant messages use: text blocks
|
|
20663
|
+
* stay text and each image block becomes its identity line plus (when the pane
|
|
20664
|
+
* negotiated native images) the shared `ui.image` node. The flat text is not
|
|
20665
|
+
* painted beside it — it carries the same markers and would duplicate them.
|
|
20666
|
+
* Every other Context keeps the existing `systemContextBody` XML-envelope
|
|
20667
|
+
* treatment (never a raw `<system-reminder>` frame), with a body that is not an
|
|
20668
|
+
* envelope shown verbatim.
|
|
20669
|
+
*/
|
|
20670
|
+
function contextBodyNodes(message, options) {
|
|
20671
|
+
if (isPtcImageContext(message)) return bodyContentNodes(message.content, options);
|
|
19292
20672
|
const body = systemContextBody(message.text);
|
|
19293
20673
|
if (body === void 0) return [ui.md({
|
|
19294
20674
|
key: "body",
|
|
@@ -19300,7 +20680,7 @@ function contextBodyNodes(message) {
|
|
|
19300
20680
|
text: sanitizeDisplayText(body.join("\n"))
|
|
19301
20681
|
})];
|
|
19302
20682
|
}
|
|
19303
|
-
function contextMemberNode(message, key) {
|
|
20683
|
+
function contextMemberNode(message, key, options) {
|
|
19304
20684
|
const kind = contextPresentationKind(message);
|
|
19305
20685
|
const head = sanitizedPhysicalLine(message.label ?? contextFormOf(message) ?? "Context");
|
|
19306
20686
|
return ui.card({
|
|
@@ -19309,7 +20689,7 @@ function contextMemberNode(message, key) {
|
|
|
19309
20689
|
}, ui.badge({
|
|
19310
20690
|
key: "kind",
|
|
19311
20691
|
text: kind ?? "generic"
|
|
19312
|
-
}), ...contextBodyNodes(message));
|
|
20692
|
+
}), ...contextBodyNodes(message, options));
|
|
19313
20693
|
}
|
|
19314
20694
|
function contextClusterMemberNode(message, key, options) {
|
|
19315
20695
|
const kind = contextPresentationKind(message);
|
|
@@ -19323,14 +20703,14 @@ function contextClusterMemberNode(message, key, options) {
|
|
|
19323
20703
|
key: "identity",
|
|
19324
20704
|
text: head,
|
|
19325
20705
|
wrap: "none"
|
|
19326
|
-
}), ...contextBodyNodes(message));
|
|
20706
|
+
}), ...contextBodyNodes(message, options));
|
|
19327
20707
|
const expanded = disclosure.expandedContextRowOwners.has(message);
|
|
19328
20708
|
return ui.section({
|
|
19329
20709
|
key,
|
|
19330
20710
|
head,
|
|
19331
20711
|
collapsible: true,
|
|
19332
20712
|
collapsed: !expanded
|
|
19333
|
-
}, ...expanded ? contextBodyNodes(message) : []);
|
|
20713
|
+
}, ...expanded ? contextBodyNodes(message, options) : []);
|
|
19334
20714
|
}
|
|
19335
20715
|
function canCollapseContextRow(message) {
|
|
19336
20716
|
const kind = contextPresentationKind(message);
|
|
@@ -19387,7 +20767,7 @@ function relayContextRowNode(message, key, options, allowDisclosure) {
|
|
|
19387
20767
|
if (!allowDisclosure || disclosure === void 0 || !canCollapseContextRow(message)) return ui.card({
|
|
19388
20768
|
key,
|
|
19389
20769
|
head: title
|
|
19390
|
-
}, ...contextBodyNodes(message));
|
|
20770
|
+
}, ...contextBodyNodes(message, options));
|
|
19391
20771
|
const expanded = disclosure.expandedContextRowOwners.has(message);
|
|
19392
20772
|
const preview = relayHeadPreview(sanitizeDisplayText(message.text));
|
|
19393
20773
|
return ui.section({
|
|
@@ -19412,13 +20792,13 @@ function relayContextRowNode(message, key, options, allowDisclosure) {
|
|
|
19412
20792
|
})]),
|
|
19413
20793
|
collapsible: true,
|
|
19414
20794
|
collapsed: !expanded
|
|
19415
|
-
}, ...expanded ? contextBodyNodes(message) : []);
|
|
20795
|
+
}, ...expanded ? contextBodyNodes(message, options) : []);
|
|
19416
20796
|
}
|
|
19417
20797
|
function contextRowNode(message, key, options, allowDisclosure = true) {
|
|
19418
20798
|
const disclosure = options.innerDisclosure;
|
|
19419
20799
|
const kind = contextPresentationKind(message);
|
|
19420
20800
|
if (message.context === true && kind === "relay") return relayContextRowNode(message, key, options, allowDisclosure);
|
|
19421
|
-
if (message.context !== true || !allowDisclosure || disclosure === void 0 || !canCollapseContextRow(message)) return contextMemberNode(message, key);
|
|
20801
|
+
if (message.context !== true || !allowDisclosure || disclosure === void 0 || !canCollapseContextRow(message)) return contextMemberNode(message, key, options);
|
|
19422
20802
|
const expanded = disclosure.expandedContextRowOwners.has(message);
|
|
19423
20803
|
if (kind === "notice") {
|
|
19424
20804
|
const title = message.label === void 0 || message.label === "" ? "Notice" : sanitizedPhysicalLine(message.label);
|
|
@@ -19438,7 +20818,7 @@ function contextRowNode(message, key, options, allowDisclosure = true) {
|
|
|
19438
20818
|
})]),
|
|
19439
20819
|
collapsible: true,
|
|
19440
20820
|
collapsed: !expanded
|
|
19441
|
-
}, ...expanded ? contextBodyNodes(message) : []);
|
|
20821
|
+
}, ...expanded ? contextBodyNodes(message, options) : []);
|
|
19442
20822
|
}
|
|
19443
20823
|
const identity = kind === "recall" ? message.label === void 0 || message.label === "" ? "Session recall" : `Session recall · ${sanitizedPhysicalLine(message.label)}` : message.label ?? contextFormOf(message) ?? "Context";
|
|
19444
20824
|
return ui.section({
|
|
@@ -19446,7 +20826,7 @@ function contextRowNode(message, key, options, allowDisclosure = true) {
|
|
|
19446
20826
|
head: sanitizedPhysicalLine(identity),
|
|
19447
20827
|
collapsible: true,
|
|
19448
20828
|
collapsed: !expanded
|
|
19449
|
-
}, ...expanded ? contextBodyNodes(message) : []);
|
|
20829
|
+
}, ...expanded ? contextBodyNodes(message, options) : []);
|
|
19450
20830
|
}
|
|
19451
20831
|
function systemNode(message, key, options, allowDisclosure = true) {
|
|
19452
20832
|
if (message.context === true) return contextRowNode(message, key, options, allowDisclosure);
|
|
@@ -20094,7 +21474,8 @@ function imageRefIdsOf(message) {
|
|
|
20094
21474
|
if (message.displayBlocks !== void 0) {
|
|
20095
21475
|
for (const display of message.displayBlocks) if (display.kind === "content") pushBlocks([display.block]);
|
|
20096
21476
|
} else if (message.content !== void 0) pushBlocks(message.content);
|
|
20097
|
-
} else if (message.kind === "
|
|
21477
|
+
} else if (message.kind === "system") pushBlocks(message.content);
|
|
21478
|
+
else if (message.kind === "tool") visitRow(message);
|
|
20098
21479
|
imageRefIdsCache.set(message, {
|
|
20099
21480
|
display,
|
|
20100
21481
|
assistant,
|
|
@@ -20202,6 +21583,7 @@ function messageStampOf(message, key, options) {
|
|
|
20202
21583
|
break;
|
|
20203
21584
|
case "system":
|
|
20204
21585
|
parts.push(disclosureTokenOf(message, key, options));
|
|
21586
|
+
parts.push(imageTokensOf(message, options));
|
|
20205
21587
|
break;
|
|
20206
21588
|
case "command":
|
|
20207
21589
|
case "compaction":
|
|
@@ -20283,6 +21665,17 @@ function focusDuration(activity, options) {
|
|
|
20283
21665
|
const duration = formatCompactDuration(options.focusElapsedMs?.get(activity));
|
|
20284
21666
|
return duration === "0s" ? void 0 : duration;
|
|
20285
21667
|
}
|
|
21668
|
+
/** The bounded one-line collapsed Action body the Focus root head paints (and
|
|
21669
|
+
* the root stamp must follow): the SAME derivation for the head and the stamp,
|
|
21670
|
+
* never a content hash. */
|
|
21671
|
+
function focusRootActionBody(action, options) {
|
|
21672
|
+
if (action === void 0) return void 0;
|
|
21673
|
+
const body = compactActionBody(compactActionPresentation(action, {
|
|
21674
|
+
...options.toolPresenter === void 0 ? {} : { presenter: options.toolPresenter },
|
|
21675
|
+
...options.cwd === void 0 ? {} : { cwd: options.cwd }
|
|
21676
|
+
}));
|
|
21677
|
+
return body === void 0 ? void 0 : sanitizedPhysicalLine(body);
|
|
21678
|
+
}
|
|
20286
21679
|
function focusRootHead(slot, options) {
|
|
20287
21680
|
const phase = options.focusPhase ?? "working";
|
|
20288
21681
|
const duration = focusDuration(slot.activity, options);
|
|
@@ -20314,10 +21707,7 @@ function focusRootHead(slot, options) {
|
|
|
20314
21707
|
index: preview.index,
|
|
20315
21708
|
...preview.name === void 0 ? {} : { name: preview.name }
|
|
20316
21709
|
})));
|
|
20317
|
-
const action =
|
|
20318
|
-
...options.toolPresenter === void 0 ? {} : { presenter: options.toolPresenter },
|
|
20319
|
-
...options.cwd === void 0 ? {} : { cwd: options.cwd }
|
|
20320
|
-
}));
|
|
21710
|
+
const action = focusRootActionBody(slot.action, options);
|
|
20321
21711
|
if (preparing !== void 0 || action !== void 0) head.push(ui.text({
|
|
20322
21712
|
key: "action",
|
|
20323
21713
|
text: sanitizedPhysicalLine(`Action: ${preparing ?? action}`),
|
|
@@ -20396,7 +21786,7 @@ function focusNestedWorkDescriptor(span, keys, options, prefix, lifetime, prepar
|
|
|
20396
21786
|
materialize: () => focusNestedWorkNode(span, keys, options, prefix, lifetime, preparing)
|
|
20397
21787
|
};
|
|
20398
21788
|
}
|
|
20399
|
-
function focusMainBlocks(blocks, keys, options, prefix, preparingByRootOwner, preparingByWorkOwner, standalonePreparing, workLifetimes) {
|
|
21789
|
+
function focusMainBlocks(blocks, keys, options, prefix, preparingByRootOwner, preparingByWorkOwner, standalonePreparing, attachedPreparingRootOwner, workLifetimes) {
|
|
20400
21790
|
const slotsByOwner = /* @__PURE__ */ new Map();
|
|
20401
21791
|
const rootsWithWorkPreparing = /* @__PURE__ */ new Set();
|
|
20402
21792
|
const rows = [];
|
|
@@ -20437,11 +21827,20 @@ function focusMainBlocks(blocks, keys, options, prefix, preparingByRootOwner, pr
|
|
|
20437
21827
|
slot.children.push(focusNestedWorkDescriptor(block.span, keys, options, prefix, workLifetimes.get(block.span.owner), preparingByWorkOwner.get(block.span.owner) ?? []));
|
|
20438
21828
|
}
|
|
20439
21829
|
}
|
|
21830
|
+
const deferredStandalone = [];
|
|
20440
21831
|
for (const slot of slotsByOwner.values()) {
|
|
20441
21832
|
if (!slot.expanded || slot.preparing.length === 0 || rootsWithWorkPreparing.has(slot.owner)) continue;
|
|
20442
|
-
|
|
21833
|
+
if (attachedPreparingRootOwner === slot.owner) {
|
|
21834
|
+
slot.children.push(...slot.preparing.map((preview) => preparingDescriptor(preview, options.cwd, "")));
|
|
21835
|
+
continue;
|
|
21836
|
+
}
|
|
21837
|
+
deferredStandalone.push(...slot.preparing);
|
|
20443
21838
|
}
|
|
20444
|
-
return [
|
|
21839
|
+
return [
|
|
21840
|
+
...rows.map((row) => "draft" in row ? focusRootDescriptor(row, keys, options, prefix) : row),
|
|
21841
|
+
...standalonePreparing.map((preview) => preparingDescriptor(preview, options.cwd, prefix)),
|
|
21842
|
+
...deferredStandalone.map((preview) => preparingDescriptor(preview, options.cwd, prefix))
|
|
21843
|
+
];
|
|
20445
21844
|
}
|
|
20446
21845
|
/** The ONE Focus Activity root descriptor (canonical occurrence owner). */
|
|
20447
21846
|
function focusRootDescriptor(slot, keys, options, prefix) {
|
|
@@ -20458,6 +21857,9 @@ function focusRootDescriptor(slot, keys, options, prefix) {
|
|
|
20458
21857
|
];
|
|
20459
21858
|
for (const preview of slot.preparing) stamp.push(...preparingStampOf(preview, options.cwd));
|
|
20460
21859
|
for (const child of slot.children) stamp.push(...child.stamp);
|
|
21860
|
+
for (const part of compactActionStatParts(slot.actionStats)) stamp.push(sanitizedPhysicalLine(part));
|
|
21861
|
+
const actionBody = focusRootActionBody(slot.action, options);
|
|
21862
|
+
if (actionBody !== void 0) stamp.push(actionBody);
|
|
20461
21863
|
if (slot.action !== void 0) stamp.push(options.cwd ?? "");
|
|
20462
21864
|
return {
|
|
20463
21865
|
key,
|
|
@@ -20482,48 +21884,72 @@ function focusRootDescriptor(slot, keys, options, prefix) {
|
|
|
20482
21884
|
}
|
|
20483
21885
|
};
|
|
20484
21886
|
}
|
|
20485
|
-
/** Preparing belongs either to the exact canonical trailing Work owner, to
|
|
20486
|
-
*
|
|
21887
|
+
/** Preparing belongs either to the exact canonical trailing Work owner, to the
|
|
21888
|
+
* ONE open logical Turn whose region reaches the raw tail, or stays standalone.
|
|
21889
|
+
* A Turn whose collapsed summary still owns the Action slot while an independent
|
|
21890
|
+
* trailing control boundary sits outside its region is reported as a header-only
|
|
21891
|
+
* root: `attachedPreparingRootOwner` is then absent so an EXPANDED root renders
|
|
21892
|
+
* the live run standalone after that boundary instead of fabricating ancestry.
|
|
21893
|
+
*/
|
|
20487
21894
|
function focusPreparingPlacement(messages, blocks, options) {
|
|
20488
21895
|
const groups = groupPreparingPreviews(options.preparingPreviews ?? []);
|
|
20489
21896
|
if (groups.length === 0 || options.window?.hasNewer !== false) return {
|
|
20490
21897
|
byRootOwner: /* @__PURE__ */ new Map(),
|
|
20491
21898
|
byWorkOwner: /* @__PURE__ */ new Map(),
|
|
20492
|
-
standalone: []
|
|
21899
|
+
standalone: [],
|
|
21900
|
+
attachedRootOwner: void 0
|
|
20493
21901
|
};
|
|
20494
21902
|
const activities = options.turnActivities ?? EMPTY_TURN_ACTIVITIES;
|
|
20495
21903
|
const expandedBlocks = projectFocus(messages, activities, new Set(activities.keys()), true);
|
|
20496
21904
|
const trailing = projectTranscriptStructure(messages).at(-1);
|
|
20497
|
-
|
|
20498
|
-
|
|
21905
|
+
const placement = focusLiveTailPlacement(messages, activities, expandedBlocks);
|
|
21906
|
+
const placementTurn = placement === void 0 || !("turn" in placement.rootOwner) ? void 0 : placement.rootOwner.turn;
|
|
21907
|
+
const rootOfTurn = (turn) => {
|
|
21908
|
+
const projected = expandedBlocks.find((block) => block.kind === "activity" && block.activity.turn === turn);
|
|
21909
|
+
return projected?.kind === "activity" ? projected.owner : void 0;
|
|
21910
|
+
};
|
|
21911
|
+
const standalone = () => ({
|
|
21912
|
+
byRootOwner: /* @__PURE__ */ new Map(),
|
|
21913
|
+
byWorkOwner: /* @__PURE__ */ new Map(),
|
|
21914
|
+
standalone: groups.flatMap(([, previews]) => previews),
|
|
21915
|
+
attachedRootOwner: void 0
|
|
21916
|
+
});
|
|
21917
|
+
const selectionFor = (turn) => groups.find(([groupTurn]) => groupTurn === turn)?.[1] ?? [];
|
|
20499
21918
|
let turn;
|
|
21919
|
+
let workOwner;
|
|
21920
|
+
let attachedRootOwner;
|
|
20500
21921
|
if (trailing?.kind === "work") {
|
|
20501
|
-
|
|
20502
|
-
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
20509
|
-
}
|
|
20510
|
-
|
|
20511
|
-
|
|
20512
|
-
|
|
20513
|
-
|
|
20514
|
-
|
|
20515
|
-
|
|
21922
|
+
if (placement?.workOwner !== void 0 && placement.workOwner === trailing.span.owner) {
|
|
21923
|
+
turn = placementTurn;
|
|
21924
|
+
attachedRootOwner = placement.rootOwner;
|
|
21925
|
+
workOwner = placement.workOwner;
|
|
21926
|
+
}
|
|
21927
|
+
} else if (placement !== void 0) {
|
|
21928
|
+
turn = placementTurn;
|
|
21929
|
+
attachedRootOwner = placement.rootOwner;
|
|
21930
|
+
}
|
|
21931
|
+
if (turn === void 0) {
|
|
21932
|
+
const openPreviewTurn = groups.map(([groupTurn]) => groupTurn).filter((groupTurn) => activities.get(groupTurn)?.completed === false).at(-1);
|
|
21933
|
+
const rootOwner = openPreviewTurn === void 0 ? void 0 : rootOfTurn(openPreviewTurn);
|
|
21934
|
+
const selected = openPreviewTurn === void 0 ? [] : selectionFor(openPreviewTurn);
|
|
21935
|
+
if (rootOwner === void 0 || openPreviewTurn === void 0 || selected.length === 0 || !blocks.some((block) => block.kind === "activity" && block.owner === rootOwner)) return {
|
|
21936
|
+
...standalone(),
|
|
21937
|
+
standalone: [...groups.filter(([groupTurn]) => groupTurn !== openPreviewTurn).flatMap(([, previews]) => previews), ...selected]
|
|
21938
|
+
};
|
|
21939
|
+
return {
|
|
21940
|
+
byRootOwner: /* @__PURE__ */ new Map([[rootOwner, selected]]),
|
|
21941
|
+
byWorkOwner: /* @__PURE__ */ new Map(),
|
|
21942
|
+
standalone: groups.filter(([groupTurn]) => groupTurn !== openPreviewTurn).flatMap(([, previews]) => previews),
|
|
21943
|
+
attachedRootOwner: void 0
|
|
21944
|
+
};
|
|
20516
21945
|
}
|
|
20517
|
-
if (
|
|
20518
|
-
|
|
20519
|
-
byWorkOwner: /* @__PURE__ */ new Map(),
|
|
20520
|
-
standalone: groups.flatMap(([, previews]) => previews)
|
|
20521
|
-
};
|
|
20522
|
-
const selected = groups.find(([groupTurn]) => groupTurn === turn)?.[1] ?? [];
|
|
21946
|
+
if (attachedRootOwner === void 0 || !blocks.some((block) => block.kind === "activity" && block.owner === attachedRootOwner)) return standalone();
|
|
21947
|
+
const selected = selectionFor(turn);
|
|
20523
21948
|
return {
|
|
20524
|
-
byRootOwner: selected.length === 0 ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map([[
|
|
21949
|
+
byRootOwner: selected.length === 0 ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map([[attachedRootOwner, selected]]),
|
|
20525
21950
|
byWorkOwner: workOwner === void 0 || selected.length === 0 ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map([[workOwner, selected]]),
|
|
20526
|
-
standalone: groups.filter(([groupTurn]) => groupTurn !== turn).flatMap(([, previews]) => previews)
|
|
21951
|
+
standalone: groups.filter(([groupTurn]) => groupTurn !== turn).flatMap(([, previews]) => previews),
|
|
21952
|
+
attachedRootOwner
|
|
20527
21953
|
};
|
|
20528
21954
|
}
|
|
20529
21955
|
/** The members whose current transcript body is actually materialized. */
|
|
@@ -20695,9 +22121,10 @@ function settledFinalAssistantStats(messages, activities) {
|
|
|
20695
22121
|
if (activities === void 0) return EMPTY_ASSISTANT_STATS;
|
|
20696
22122
|
const rowsByTurn = /* @__PURE__ */ new Map();
|
|
20697
22123
|
for (const message of messages) {
|
|
20698
|
-
|
|
20699
|
-
|
|
20700
|
-
|
|
22124
|
+
const turn = transcriptTurnOf(message);
|
|
22125
|
+
if (turn === void 0) continue;
|
|
22126
|
+
const rows = rowsByTurn.get(turn);
|
|
22127
|
+
if (rows === void 0) rowsByTurn.set(turn, [message]);
|
|
20701
22128
|
else rows.push(message);
|
|
20702
22129
|
}
|
|
20703
22130
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -20784,7 +22211,7 @@ function describeTranscriptMainBlocksForPreset(messages, keys, options) {
|
|
|
20784
22211
|
const focusBlocks = projectFocus(messages, options.turnActivities ?? EMPTY_TURN_ACTIVITIES, options.expandedFocusTurns ?? EMPTY_TURN_SET, true);
|
|
20785
22212
|
const workLifetimes = resolveWorkLifetimes(structure, options.turnActivities ?? EMPTY_TURN_ACTIVITIES);
|
|
20786
22213
|
const preparing = focusPreparingPlacement(messages, focusBlocks, options);
|
|
20787
|
-
return focusMainBlocks(focusBlocks, keys, renderOptions, prefix, preparing.byRootOwner, preparing.byWorkOwner, preparing.standalone, workLifetimes);
|
|
22214
|
+
return focusMainBlocks(focusBlocks, keys, renderOptions, prefix, preparing.byRootOwner, preparing.byWorkOwner, preparing.standalone, preparing.attachedRootOwner, workLifetimes);
|
|
20788
22215
|
}
|
|
20789
22216
|
return legacyMainBlocks(structure, keys, renderOptions, prefix, trailing, adopted, standalone);
|
|
20790
22217
|
}
|
|
@@ -20823,4 +22250,4 @@ const EMPTY_TURN_SET = /* @__PURE__ */ new Set();
|
|
|
20823
22250
|
const EMPTY_TURN_ACTIVITIES = /* @__PURE__ */ new Map();
|
|
20824
22251
|
const EMPTY_ASSISTANT_STATS = /* @__PURE__ */ new Map();
|
|
20825
22252
|
//#endregion
|
|
20826
|
-
export {
|
|
22253
|
+
export { advanceWorkflowDisclosureState as $, TSP_VISUAL_COPY_LABEL as $n, effectiveCustomCommandRefreshMs as $r, imageFoldedPreview as $t, summarizeWorkSpan as A, userBlocksVisibleNow as Ai, WELCOME_WHALE_WIDTH as An, suggestPathArgument as Ar, workspaceRowStatusLabel as At, workContextCarriageOf as B, shortCwd as Bn, createSessionScopeAuthority as Br, viewerAccessHint as Bt, proveCaretEdit as C, isSurfacedContext as Ci, iconLead as Cn, taskStatusWord as Cr, assistantVisualPresentationRevision as Ct, contextClusterSummaryParts as D, finalizedBlockFallbackText as Di, sessionBrowserErrorNotice as Dn, sanitizeDisplaySegment as Dr, buildSessionWorkspaceView as Dt, FocusTimingStore as E, latestLine as Ei, sanitizeTerminalText as En, sanitizeDisplayLog as Er, buildSessionInspectorView as Et, focusProjectionTurnOf as F, FooterCustomItemCatalog as Fn, queueManagerCommandResult as Fr, subagentJobTranscriptId as Ft, compactActionPresentation as G, QUEUE_CHORDS as Gn, TSP_FOOTER_NOTICES as Gr, compactToolExpandedLines as Gt, FocusActivityComponent as H, HISTORY_CHORDS as Hn, detectThemeFromBackground as Hr, GOAL_TOOL_NAMES as Ht, projectFocus as I, createBuiltinFooterRegistry as In, formatBytes as Ir, subagentJobViewHint as It, compactActionStatsSignature as J, SVG_VIEWER_SCROLL_LABEL as Jn, DEFAULT_CUSTOM_COMMAND_REFRESH_MS as Jr, foldedCallPreview as Jt, compactActionSignature as K, SESSION_WORKSPACE_CHORDS as Kn, resolveTspNativeFooterConfig as Kr, compactToolPresentation as Kt, clusterByMemberOf as L, modelItem as Ln, SessionOperationBarrier as Lr, taskRowLabel as Lt, focusHeldBackFinalByTurn as M, historyFilePath as Mi, renderWelcomeWhaleLines as Mn, clientPathQueryEnvironment as Mr, isTaskItemFailure as Mt, focusLiveTailPlacement as N, loadHistoryFile as Ni, welcomeWhaleGradientColors as Nn, QueueManagerController as Nr, projectTaskItems as Nt, activityClockOf as O, openOpaqueBlockFallbackText as Oi, workspaceKey as On, sanitizeDisplayText as Or, currentWorkspaceOf as Ot, focusMaterializedMessages as P, loadHistoryRecords as Pi, welcomeWhalePlainLines as Pn, attachmentCountLabel as Pr, rowGroup as Pt, createDisplayProjection as Q, TSP_VISUAL_CHORDS as Qn, customItemName as Qr, goalResultSummary as Qt, projectTranscriptStructure as R, tasksItem as Rn, TransitionInProgressError as Rr, taskRowSelectionDisposition as Rt, pastedBodySpan as S, isPtcImageContext as Si, iconFor as Sn, taskStatusColor as Sr, assistantVisualPresentation as St, isLocalShellCard as T, transcriptTurnOf as Ti, formatSessionAge as Tn, singlePhysicalLine as Tr, setAssistantVisualPresentation as Tt, compactActionStatParts as U, JOB_LOCAL_KEYS as Un, lightColors as Ur, askAnswersLines as Ut, contextPresentationKind as V, DELIVERED_FILES_CHORDS as Vn, darkColors as Vr, FOLDED_JSON_RESULT_TOOLS as Vt, formatCompactDuration as W, JOB_SEARCH_LOCAL_KEYS as Wn, withSearchCurrentTokens as Wr, askAnswersSummary as Wt, compactSlotLine as X, TSP_SEARCH_CHORD as Xn, customCommandConfigOf as Xr, genericRawInputLines as Xt, compactPreparingSummary as Y, TSP_CONTINUED_INSPECTION_LABEL as Yn, activeFooterItemIds as Yr, foldedResultSummaryFor as Yt, compactThinkSlotLine as Z, TSP_SEARCH_CHORD_LABEL as Zn, customItemId as Zr, goalResultLines as Zt, VISUAL_COPY_ROLE as _, rawSourceRangeForNormalizedMatch as _i, webCardLines as _n, editorTheme as _r, serializedDraftHasPayload as _t, dockDraftImageNodes as a, resolveTrustedFooterCommand as ai, parseWriteEnvelope as an, parseShellWords as ar, workflowRunViewAllVisible as at, publishedVisualTitle as b, workflowReadablePhase as bi, imageProtocolPreference as bn, setTheme as br, createHistoryRecallScope as bt, imageRefProblem as c, resolveUserLayerFooterMode as ci, resultTextLines as cn, builtInGuide as cr, createInstalledAutocompleteProvider as ct, visibleTranscriptMembers as d, assistantPresentationRevision as di, systemContextBody as dn, initialEffortOf as dr, isOpenQuotedToken as dt, effectiveCustomCommandTimeoutMs as ei, isCompactActionTool as en, TSP_VISUAL_SELECT_LABEL as er, effectiveWorkflowPhaseOpen as et, TSP_WORKFLOW_BROWSE_ACTION as f, assistantStepOf as fi, toolCardHeader as fn, modelIdentity as fr, splitQueryRemainder as ft, VISUAL_COPY_KEY as g, TranscriptWindowController as gi, toolTitle as gn, currentPalette as gr, serializeEditorInput as gt, VISUAL_COPY_ACTION as h, textOf as hi, toolSummaryKeys as hn, color as hr, editorModeFromHistoryEntry as ht, describeTranscriptMainBlocksForPreset as i, parseFooterCommandConfig as ii, parseSkillEnvelope as in, matchesKeyId as ir, workflowRunSummaryText as it, projectCompact as j, appendHistoryRecord as ji, pickWelcomeWhaleVariant as jn, ClientLocalDiscoveryDriver as jr, isTaskItemActive as jt, resolveWorkLifetimes as k, textWithAttachmentMarkers as ki, classifySessionBrowserRow as kn, FILE_ARGUMENT_COMMANDS as kr, visibleWorkspaceBrowserRows as kt, toolRowImageBlocks as l, MAX_COMMAND_TIMEOUT_MS as li, skillFoldedPreview as ln, PROVIDER_DEFAULT as lr, classifyFileCompletionContext as lt, transcriptCopyPayload as m, subCallDisplayStatus as mi, toolPresenterFrom as mn, HOST_MARKDOWN_OPTIONS as mr, extractInlineSkillPrefix as mt, TranscriptNodeKeys as n, parseFooterCustomItem as ni, parseImageEnvelope as nn, formatKeyId as nr, workflowCountsText as nt, imageDisplayName as o, resolveUserCommandItemActivationIds as oi, readFoldedPreview as on, isBuiltInPresetRow as or, workflowStatusCounts as ot, TRANSCRIPT_COPY_ACTION as p, childOwnEvents as pi, toolIconSemantic as pn, projectModelDirectory as pr, splitTokenRemainder as pt, compactActionSlotLine as q, SVG_VIEWER_CHORDS as qn, CUSTOM_FOOTER_ITEM_PREFIX as qr, firstLine as qt, describeTranscriptMainBlocks as r, parseFooterCustomItems as ri, parseReadEnvelopes as rn, formatLeaderSequence as rr, workflowPhasePresentations as rt, imageIdentityText as s, resolveUserCommandItemFallbackActivationIds as si, relativizeToCwd as sn, presetDisplayText as sr, eligibleFinalAssistant as st, MAX_IMAGE_BLOB_BYTES as t, executableCommandItemIds as ti, parseCallPreview as tn, formatHintKeys as tr, effectiveWorkflowRunOpen as tt, toolRowProjectsImages as u, TranscriptFolder as ui, subagentModelDisplay as un, effortChoicesOf as ur, stripAtQuotes as ut, VISUAL_FIGURE_KEY_PREFIX as v, transcriptSearchMatchKey as vi, writeFoldedPreview as vn, markdownTheme as vr, shellPrefixForMode as vt, candidateImagePathFromPaste as w, isSurfacedInteractionTool as wi, iconPrefix as wn, sanitizedPhysicalLine as wr, clearAssistantVisualPresentation as wt, PasteRangeTracker as x, recentTurnThreshold as xi, thinkingPreviewTail as xn, settingsListTheme as xr, planVisualPlacement as xt, VISUAL_FIGURE_ROLE as y, transcriptSearchSourceKey as yi, fileAttachmentSummary as yn, selectListTheme as yr, FileHistorySearchSource as yt, workByMemberOf as z, FooterItemRegistry as zn, SessionScopeSupersededError as zr, taskTreePrefix as zt };
|