gsd-pi 2.73.1-dev.6ddfa43 → 2.73.1-dev.9a4cd44
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/dist/cli-web-branch.d.ts +4 -3
- package/dist/cli-web-branch.js +10 -7
- package/dist/cli.js +99 -206
- package/dist/logo.d.ts +1 -1
- package/dist/logo.js +1 -1
- package/dist/onboarding.js +59 -53
- package/dist/resource-loader.js +2 -2
- package/dist/resources/extensions/gsd/auto/phases.js +15 -9
- package/dist/resources/extensions/gsd/auto-dispatch.js +11 -3
- package/dist/resources/extensions/gsd/auto-post-unit.js +41 -1
- package/dist/resources/extensions/gsd/auto-start.js +3 -0
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +13 -0
- package/dist/resources/extensions/gsd/auto-verification.js +88 -3
- package/dist/resources/extensions/gsd/auto.js +29 -8
- package/dist/resources/extensions/gsd/commands-handlers.js +8 -2
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +1 -1
- package/dist/resources/extensions/gsd/notification-widget.js +2 -2
- package/dist/resources/extensions/gsd/state.js +61 -14
- package/dist/update-check.d.ts +1 -0
- package/dist/update-check.js +13 -5
- package/dist/update-cmd.js +4 -3
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +14 -14
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +14 -14
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/package.json +1 -2
- package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/overflow.js +12 -0
- package/packages/pi-ai/dist/utils/overflow.js.map +1 -1
- package/packages/pi-ai/dist/utils/tests/overflow.test.d.ts +2 -0
- package/packages/pi-ai/dist/utils/tests/overflow.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/tests/overflow.test.js +50 -0
- package/packages/pi-ai/dist/utils/tests/overflow.test.js.map +1 -0
- package/packages/pi-ai/src/utils/overflow.ts +14 -1
- package/packages/pi-ai/src/utils/tests/overflow.test.ts +58 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +138 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/utils.js +5 -5
- package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.js +45 -0
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts +2 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +9 -3
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.test.js +52 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +21 -4
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +11 -3
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +157 -0
- package/packages/pi-coding-agent/src/core/compaction/utils.ts +5 -5
- package/packages/pi-coding-agent/src/core/compaction-utils.test.ts +50 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.test.ts +73 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.ts +9 -3
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +21 -4
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +11 -3
- package/packages/pi-tui/dist/__tests__/tui.test.js +60 -1
- package/packages/pi-tui/dist/__tests__/tui.test.js.map +1 -1
- package/packages/pi-tui/dist/tui.d.ts +8 -0
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +32 -3
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/src/__tests__/tui.test.ts +76 -1
- package/packages/pi-tui/src/tui.ts +31 -3
- package/src/resources/extensions/gsd/auto/phases.ts +22 -9
- package/src/resources/extensions/gsd/auto-dispatch.ts +10 -4
- package/src/resources/extensions/gsd/auto-post-unit.ts +47 -1
- package/src/resources/extensions/gsd/auto-start.ts +3 -0
- package/src/resources/extensions/gsd/auto-timeout-recovery.ts +17 -0
- package/src/resources/extensions/gsd/auto-verification.ts +98 -3
- package/src/resources/extensions/gsd/auto.ts +31 -14
- package/src/resources/extensions/gsd/commands-handlers.ts +8 -2
- package/src/resources/extensions/gsd/docs/preferences-reference.md +1 -1
- package/src/resources/extensions/gsd/notification-widget.ts +2 -2
- package/src/resources/extensions/gsd/state.ts +71 -15
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/auto-post-unit-step-message.test.ts +53 -0
- package/src/resources/extensions/gsd/tests/complete-milestone-false-merge.test.ts +142 -0
- package/src/resources/extensions/gsd/tests/completed-at-reconcile.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/derive-state-crossval.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/derive-state-helpers.test.ts +68 -8
- package/src/resources/extensions/gsd/tests/derive-state.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/integration/state-machine-edge-cases.test.ts +4 -2
- package/src/resources/extensions/gsd/tests/state-machine-full-walkthrough.test.ts +5 -7
- package/src/resources/extensions/gsd/tests/token-profile.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/validate-milestone-stuck-guard.test.ts +179 -0
- /package/dist/web/standalone/.next/static/{r6AvNu-aMwn4nwqjHqAfw → ASJ2RGD7E1iiUYzA0xT2i}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{r6AvNu-aMwn4nwqjHqAfw → ASJ2RGD7E1iiUYzA0xT2i}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { serializeConversation } from "./compaction/index.js";
|
|
4
|
+
test("serializeConversation uses narrative role markers instead of chat-style delimiters (#4054)", () => {
|
|
5
|
+
const messages = [
|
|
6
|
+
{ role: "user", content: "Please refactor the parser." },
|
|
7
|
+
{
|
|
8
|
+
role: "assistant",
|
|
9
|
+
content: [
|
|
10
|
+
{ type: "thinking", thinking: "I should inspect the parser entry points first." },
|
|
11
|
+
{ type: "text", text: "I'll start with the parser entry points." },
|
|
12
|
+
{ type: "toolCall", id: "tool-1", name: "Read", arguments: { path: "src/parser.ts" } },
|
|
13
|
+
],
|
|
14
|
+
api: "anthropic-messages",
|
|
15
|
+
provider: "anthropic",
|
|
16
|
+
model: "claude-sonnet-4-6",
|
|
17
|
+
usage: {
|
|
18
|
+
input: 0,
|
|
19
|
+
output: 0,
|
|
20
|
+
cacheRead: 0,
|
|
21
|
+
cacheWrite: 0,
|
|
22
|
+
totalTokens: 0,
|
|
23
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
24
|
+
},
|
|
25
|
+
stopReason: "stop",
|
|
26
|
+
timestamp: Date.now(),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
role: "toolResult",
|
|
30
|
+
content: [{ type: "text", text: "parser contents" }],
|
|
31
|
+
toolName: "Read",
|
|
32
|
+
toolCallId: "tool-1",
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
const serialized = serializeConversation(messages);
|
|
36
|
+
assert.match(serialized, /\*\*User said:\*\* Please refactor the parser\./);
|
|
37
|
+
assert.match(serialized, /\*\*Assistant thinking:\*\* I should inspect the parser entry points first\./);
|
|
38
|
+
assert.match(serialized, /\*\*Assistant responded:\*\* I'll start with the parser entry points\./);
|
|
39
|
+
assert.match(serialized, /\*\*Assistant tool calls:\*\* Read\(path="src\/parser\.ts"\)/);
|
|
40
|
+
assert.match(serialized, /\*\*Tool result:\*\* parser contents/);
|
|
41
|
+
assert.ok(!serialized.includes("[User]:"), "chat-style [User]: markers should not remain");
|
|
42
|
+
assert.ok(!serialized.includes("[Assistant]:"), "chat-style [Assistant]: markers should not remain");
|
|
43
|
+
assert.ok(!serialized.includes("[Tool result]:"), "chat-style [Tool result]: markers should not remain");
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=compaction-utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-utils.test.js","sourceRoot":"","sources":["../../src/core/compaction-utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,IAAI,CAAC,4FAA4F,EAAE,GAAG,EAAE;IACvG,MAAM,QAAQ,GAAc;QAC3B,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,6BAA6B,EAAa;QACnE;YACC,IAAI,EAAE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AAM,CAAC,KAAK,CAAC,UAAU,EAAE,sCAAsC,CAAC,CAAC;IACjE,MAAM,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,8CAA8C,CAAC,CAAC;IAC3F,MAAM,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,mDAAmD,CAAC,CAAC;IACrG,MAAM,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,qDAAqD,CAAC,CAAC;AAC1G,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport test from \"node:test\";\n\nimport type { Message } from \"@gsd/pi-ai\";\n\nimport { serializeConversation } from \"./compaction/index.js\";\n\ntest(\"serializeConversation uses narrative role markers instead of chat-style delimiters (#4054)\", () => {\n\tconst messages: Message[] = [\n\t\t{ role: \"user\", content: \"Please refactor the parser.\" } as Message,\n\t\t{\n\t\t\trole: \"assistant\",\n\t\t\tcontent: [\n\t\t\t\t{ type: \"thinking\", thinking: \"I should inspect the parser entry points first.\" },\n\t\t\t\t{ type: \"text\", text: \"I'll start with the parser entry points.\" },\n\t\t\t\t{ type: \"toolCall\", id: \"tool-1\", name: \"Read\", arguments: { path: \"src/parser.ts\" } },\n\t\t\t],\n\t\t\tapi: \"anthropic-messages\",\n\t\t\tprovider: \"anthropic\",\n\t\t\tmodel: \"claude-sonnet-4-6\",\n\t\t\tusage: {\n\t\t\t\tinput: 0,\n\t\t\t\toutput: 0,\n\t\t\t\tcacheRead: 0,\n\t\t\t\tcacheWrite: 0,\n\t\t\t\ttotalTokens: 0,\n\t\t\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\t\t},\n\t\t\tstopReason: \"stop\",\n\t\t\ttimestamp: Date.now(),\n\t\t} as Message,\n\t\t{\n\t\t\trole: \"toolResult\",\n\t\t\tcontent: [{ type: \"text\", text: \"parser contents\" }],\n\t\t\ttoolName: \"Read\",\n\t\t\ttoolCallId: \"tool-1\",\n\t\t} as Message,\n\t];\n\n\tconst serialized = serializeConversation(messages);\n\n\tassert.match(serialized, /\\*\\*User said:\\*\\* Please refactor the parser\\./);\n\tassert.match(serialized, /\\*\\*Assistant thinking:\\*\\* I should inspect the parser entry points first\\./);\n\tassert.match(serialized, /\\*\\*Assistant responded:\\*\\* I'll start with the parser entry points\\./);\n\tassert.match(serialized, /\\*\\*Assistant tool calls:\\*\\* Read\\(path=\"src\\/parser\\.ts\"\\)/);\n\tassert.match(serialized, /\\*\\*Tool result:\\*\\* parser contents/);\n\tassert.ok(!serialized.includes(\"[User]:\"), \"chat-style [User]: markers should not remain\");\n\tassert.ok(!serialized.includes(\"[Assistant]:\"), \"chat-style [Assistant]: markers should not remain\");\n\tassert.ok(!serialized.includes(\"[Tool result]:\"), \"chat-style [Tool result]: markers should not remain\");\n});\n"]}
|
|
@@ -14,11 +14,12 @@ export declare class DynamicBorder implements Component {
|
|
|
14
14
|
private spinnerIndex;
|
|
15
15
|
private spinnerInterval;
|
|
16
16
|
private spinnerColorFn?;
|
|
17
|
+
private lastExternalRender;
|
|
17
18
|
constructor(color?: (str: string) => string, label?: string);
|
|
18
19
|
setLabel(label: string | undefined): void;
|
|
19
20
|
/**
|
|
20
21
|
* Start an animated spinner that prepends to the label.
|
|
21
|
-
* The spinner rotates every
|
|
22
|
+
* The spinner rotates every 200ms and triggers a re-render via the TUI.
|
|
22
23
|
*/
|
|
23
24
|
startSpinner(ui: TUI, colorFn: (str: string) => string): void;
|
|
24
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-border.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/dynamic-border.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAIlD;;;;;;;GAOG;AACH,qBAAa,aAAc,YAAW,SAAS;IAC9C,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,aAAa,CAAsD;IAC3E,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,cAAc,CAAC,CAA0B;
|
|
1
|
+
{"version":3,"file":"dynamic-border.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/dynamic-border.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAIlD;;;;;;;GAOG;AACH,qBAAa,aAAc,YAAW,SAAS;IAC9C,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,aAAa,CAAsD;IAC3E,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,cAAc,CAAC,CAA0B;IACjD,OAAO,CAAC,kBAAkB,CAAK;gBAEnB,KAAK,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAEnC,EAAE,KAAK,CAAC,EAAE,MAAM;IAKjB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIzC;;;OAGG;IACH,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI;IAe7D;;OAEG;IACH,WAAW,IAAI,IAAI;IAQnB,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,UAAU,IAAI,IAAI;IAIlB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAkB/B"}
|
|
@@ -20,6 +20,7 @@ export class DynamicBorder {
|
|
|
20
20
|
this.spinnerFrames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
21
21
|
this.spinnerIndex = 0;
|
|
22
22
|
this.spinnerInterval = null;
|
|
23
|
+
this.lastExternalRender = 0;
|
|
23
24
|
this.color = color;
|
|
24
25
|
this.label = label;
|
|
25
26
|
}
|
|
@@ -28,7 +29,7 @@ export class DynamicBorder {
|
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Start an animated spinner that prepends to the label.
|
|
31
|
-
* The spinner rotates every
|
|
32
|
+
* The spinner rotates every 200ms and triggers a re-render via the TUI.
|
|
32
33
|
*/
|
|
33
34
|
startSpinner(ui, colorFn) {
|
|
34
35
|
this.stopSpinner();
|
|
@@ -36,8 +37,12 @@ export class DynamicBorder {
|
|
|
36
37
|
this.spinnerIndex = 0;
|
|
37
38
|
this.spinnerInterval = setInterval(() => {
|
|
38
39
|
this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
// Only trigger standalone render if no other source rendered recently.
|
|
41
|
+
// During active streaming, message_update already calls requestRender().
|
|
42
|
+
if (Date.now() - this.lastExternalRender > 200) {
|
|
43
|
+
ui.requestRender();
|
|
44
|
+
}
|
|
45
|
+
}, 200);
|
|
41
46
|
ui.requestRender();
|
|
42
47
|
}
|
|
43
48
|
/**
|
|
@@ -57,6 +62,7 @@ export class DynamicBorder {
|
|
|
57
62
|
// No cached state to invalidate currently
|
|
58
63
|
}
|
|
59
64
|
render(width) {
|
|
65
|
+
this.lastExternalRender = Date.now();
|
|
60
66
|
const spinnerPrefix = this.spinnerInterval && this.spinnerColorFn
|
|
61
67
|
? this.spinnerColorFn(this.spinnerFrames[this.spinnerIndex]) + " "
|
|
62
68
|
: "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-border.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/dynamic-border.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;
|
|
1
|
+
{"version":3,"file":"dynamic-border.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/dynamic-border.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IASzB,YAAY,QAAiC,CAAC,GAAG,EAAE,EAAE;QACpD,IAAI,CAAC;YAAC,OAAO,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,OAAO,GAAG,CAAC;QAAC,CAAC;IAC9D,CAAC,EAAE,KAAc;QART,kBAAa,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACnE,iBAAY,GAAG,CAAC,CAAC;QACjB,oBAAe,GAA0B,IAAI,CAAC;QAE9C,uBAAkB,GAAG,CAAC,CAAC;QAK9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ,CAAC,KAAyB;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,EAAO,EAAE,OAAgC;QACrD,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE;YACvC,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,GAAG,IAAI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M,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;YACpD,gEAAgE;YAChE,wDAAwD;YACxD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;CACD","sourcesContent":["import type { Component, TUI } from \"@gsd/pi-tui\";\nimport { visibleWidth } from \"@gsd/pi-tui\";\nimport { theme } from \"../theme/theme.js\";\n\n/**\n * Dynamic border component that adjusts to viewport width.\n * Supports an optional animated spinner in the label area.\n *\n * Note: When used from extensions loaded via jiti, the global `theme` may be undefined\n * because jiti creates a separate module cache. Always pass an explicit color\n * function when using DynamicBorder in components exported for extension use.\n */\nexport class DynamicBorder implements Component {\n\tprivate color: (str: string) => string;\n\tprivate label?: string;\n\tprivate spinnerFrames = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\n\tprivate spinnerIndex = 0;\n\tprivate spinnerInterval: NodeJS.Timeout | null = null;\n\tprivate spinnerColorFn?: (str: string) => string;\n\tprivate lastExternalRender = 0;\n\n\tconstructor(color: (str: string) => string = (str) => {\n\t\ttry { return theme.fg(\"border\", str); } catch { return str; }\n\t}, label?: string) {\n\t\tthis.color = color;\n\t\tthis.label = label;\n\t}\n\n\tsetLabel(label: string | undefined): void {\n\t\tthis.label = label;\n\t}\n\n\t/**\n\t * Start an animated spinner that prepends to the label.\n\t * The spinner rotates every 200ms and triggers a re-render via the TUI.\n\t */\n\tstartSpinner(ui: TUI, colorFn: (str: string) => string): void {\n\t\tthis.stopSpinner();\n\t\tthis.spinnerColorFn = colorFn;\n\t\tthis.spinnerIndex = 0;\n\t\tthis.spinnerInterval = setInterval(() => {\n\t\t\tthis.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n\t\t\t// Only trigger standalone render if no other source rendered recently.\n\t\t\t// During active streaming, message_update already calls requestRender().\n\t\t\tif (Date.now() - this.lastExternalRender > 200) {\n\t\t\t\tui.requestRender();\n\t\t\t}\n\t\t}, 200);\n\t\tui.requestRender();\n\t}\n\n\t/**\n\t * Stop the spinner animation. The border reverts to a static label.\n\t */\n\tstopSpinner(): void {\n\t\tif (this.spinnerInterval) {\n\t\t\tclearInterval(this.spinnerInterval);\n\t\t\tthis.spinnerInterval = null;\n\t\t}\n\t\tthis.spinnerColorFn = undefined;\n\t}\n\n\tget isSpinning(): boolean {\n\t\treturn this.spinnerInterval !== null;\n\t}\n\n\tinvalidate(): void {\n\t\t// No cached state to invalidate currently\n\t}\n\n\trender(width: number): string[] {\n\t\tthis.lastExternalRender = Date.now();\n\t\tconst spinnerPrefix = this.spinnerInterval && this.spinnerColorFn\n\t\t\t? this.spinnerColorFn(this.spinnerFrames[this.spinnerIndex]) + \" \"\n\t\t\t: \"\";\n\n\t\tif (this.label) {\n\t\t\tconst labelText = ` ${spinnerPrefix}${this.label} `;\n\t\t\tconst labelVisible = visibleWidth(labelText);\n\t\t\tconst leading = \"── \";\n\t\t\tconst remaining = Math.max(0, width - labelVisible - leading.length);\n\t\t\tconst trailing = \"─\".repeat(Math.max(1, remaining));\n\t\t\t// Color leading and trailing separately so embedded ANSI in the\n\t\t\t// spinner/label doesn't bleed into the trailing dashes.\n\t\t\treturn [this.color(leading) + labelText + this.color(trailing)];\n\t\t}\n\t\treturn [this.color(\"─\".repeat(Math.max(1, width)))];\n\t}\n}\n"]}
|
package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-border.test.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/dynamic-border.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import { DynamicBorder } from "./dynamic-border.js";
|
|
4
|
+
function makeTUI() {
|
|
5
|
+
return {
|
|
6
|
+
renderCount: 0,
|
|
7
|
+
requestRender() {
|
|
8
|
+
this.renderCount++;
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
describe("DynamicBorder spinner", () => {
|
|
13
|
+
it("suppresses standalone render when an external render occurred recently", () => {
|
|
14
|
+
const border = new DynamicBorder((s) => s);
|
|
15
|
+
const tui = makeTUI();
|
|
16
|
+
border.startSpinner(tui, (s) => s);
|
|
17
|
+
// startSpinner calls requestRender once immediately
|
|
18
|
+
assert.equal(tui.renderCount, 1, "initial render on startSpinner");
|
|
19
|
+
// Simulate an externally-triggered render (e.g. from streaming)
|
|
20
|
+
border.render(80);
|
|
21
|
+
// Access the private interval callback by advancing the timer
|
|
22
|
+
// Instead, we directly test the render-batching logic:
|
|
23
|
+
// After render() sets lastExternalRender, a spinner tick within 200ms
|
|
24
|
+
// should NOT call requestRender.
|
|
25
|
+
const anyBorder = border;
|
|
26
|
+
assert.ok(Date.now() - anyBorder.lastExternalRender < 200, "lastExternalRender should be recent after render()");
|
|
27
|
+
border.stopSpinner();
|
|
28
|
+
});
|
|
29
|
+
it("triggers standalone render when no external render occurred recently", async () => {
|
|
30
|
+
const border = new DynamicBorder((s) => s);
|
|
31
|
+
const tui = makeTUI();
|
|
32
|
+
// Set lastExternalRender to a time well in the past
|
|
33
|
+
const anyBorder = border;
|
|
34
|
+
anyBorder.lastExternalRender = 0;
|
|
35
|
+
border.startSpinner(tui, (s) => s);
|
|
36
|
+
const initialCount = tui.renderCount;
|
|
37
|
+
// Wait for one spinner tick (200ms interval + buffer)
|
|
38
|
+
await new Promise((r) => setTimeout(r, 250));
|
|
39
|
+
assert.ok(tui.renderCount > initialCount, "spinner should trigger requestRender when no recent external render");
|
|
40
|
+
border.stopSpinner();
|
|
41
|
+
});
|
|
42
|
+
it("updates lastExternalRender on each render() call", () => {
|
|
43
|
+
const border = new DynamicBorder((s) => s);
|
|
44
|
+
const anyBorder = border;
|
|
45
|
+
const before = Date.now();
|
|
46
|
+
border.render(80);
|
|
47
|
+
const after = Date.now();
|
|
48
|
+
assert.ok(anyBorder.lastExternalRender >= before);
|
|
49
|
+
assert.ok(anyBorder.lastExternalRender <= after);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=dynamic-border.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-border.test.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/dynamic-border.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAQ,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,SAAS,OAAO;IACf,OAAO;QACN,WAAW,EAAE,CAAC;QACd,aAAa;YACZ,IAAI,CAAC,WAAW,EAAE,CAAC;QACpB,CAAC;KACD,CAAC;AACH,CAAC;AAED,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,wEAAwE,EAAE,GAAG,EAAE;QACjF,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;QAEtB,MAAM,CAAC,YAAY,CAAC,GAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1C,oDAAoD;QACpD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,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AC;QAEhC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC;QAClD,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,kBAAkB,IAAI,KAAK,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { describe, it, mock } from \"node:test\";\n\nimport { DynamicBorder } from \"./dynamic-border.js\";\n\nfunction makeTUI() {\n\treturn {\n\t\trenderCount: 0,\n\t\trequestRender() {\n\t\t\tthis.renderCount++;\n\t\t},\n\t};\n}\n\ndescribe(\"DynamicBorder spinner\", () => {\n\tit(\"suppresses standalone render when an external render occurred recently\", () => {\n\t\tconst border = new DynamicBorder((s) => s);\n\t\tconst tui = makeTUI();\n\n\t\tborder.startSpinner(tui as any, (s) => s);\n\t\t// startSpinner calls requestRender once immediately\n\t\tassert.equal(tui.renderCount, 1, \"initial render on startSpinner\");\n\n\t\t// Simulate an externally-triggered render (e.g. from streaming)\n\t\tborder.render(80);\n\n\t\t// Access the private interval callback by advancing the timer\n\t\t// Instead, we directly test the render-batching logic:\n\t\t// After render() sets lastExternalRender, a spinner tick within 200ms\n\t\t// should NOT call requestRender.\n\t\tconst anyBorder = border as any;\n\t\tassert.ok(\n\t\t\tDate.now() - anyBorder.lastExternalRender < 200,\n\t\t\t\"lastExternalRender should be recent after render()\",\n\t\t);\n\n\t\tborder.stopSpinner();\n\t});\n\n\tit(\"triggers standalone render when no external render occurred recently\", async () => {\n\t\tconst border = new DynamicBorder((s) => s);\n\t\tconst tui = makeTUI();\n\n\t\t// Set lastExternalRender to a time well in the past\n\t\tconst anyBorder = border as any;\n\t\tanyBorder.lastExternalRender = 0;\n\n\t\tborder.startSpinner(tui as any, (s) => s);\n\t\tconst initialCount = tui.renderCount;\n\n\t\t// Wait for one spinner tick (200ms interval + buffer)\n\t\tawait new Promise((r) => setTimeout(r, 250));\n\n\t\tassert.ok(\n\t\t\ttui.renderCount > initialCount,\n\t\t\t\"spinner should trigger requestRender when no recent external render\",\n\t\t);\n\n\t\tborder.stopSpinner();\n\t});\n\n\tit(\"updates lastExternalRender on each render() call\", () => {\n\t\tconst border = new DynamicBorder((s) => s);\n\t\tconst anyBorder = border as any;\n\n\t\tconst before = Date.now();\n\t\tborder.render(80);\n\t\tconst after = Date.now();\n\n\t\tassert.ok(anyBorder.lastExternalRender >= before);\n\t\tassert.ok(anyBorder.lastExternalRender <= after);\n\t});\n});\n"]}
|
package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-controller.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/controllers/chat-controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-controller.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/controllers/chat-controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAqCnG,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAgBxE;AAWD,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,wBAAwB,GAAG;IACvE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,4BAA4B,EAAE,MAAM,GAAG,CAAC;IACxC,gBAAgB,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACxD,qBAAqB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC;IACpD,2BAA2B,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,CAAC;IACvD,sBAAsB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,uBAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,oBAAoB,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,4BAA4B,EAAE,MAAM,IAAI,CAAC;IACzC,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,uBAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,wBAAwB,EAAE;QAAE,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;CAChD,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAukB7C"}
|
|
@@ -6,6 +6,9 @@ import { DynamicBorder } from "../components/dynamic-border.js";
|
|
|
6
6
|
import { appKey } from "../components/keybinding-hints.js";
|
|
7
7
|
// Tracks the last processed content index to avoid re-scanning all blocks on every message_update
|
|
8
8
|
let lastProcessedContentIndex = 0;
|
|
9
|
+
// Tracks the previous content[] length so we can detect when an adapter resets
|
|
10
|
+
// the assistant content array for a new provider sub-turn within one lifecycle.
|
|
11
|
+
let lastContentLength = 0;
|
|
9
12
|
let renderedSegments = [];
|
|
10
13
|
function hasVisibleAssistantContent(message) {
|
|
11
14
|
return message.content.some((c) => (c.type === "text" && typeof c.text === "string" && c.text.trim().length > 0)
|
|
@@ -51,6 +54,7 @@ export async function handleAgentEvent(host, event) {
|
|
|
51
54
|
// Reset content index tracker and pinned state when a new assistant message starts
|
|
52
55
|
if (event.type === "message_start" && event.message.role === "assistant") {
|
|
53
56
|
lastProcessedContentIndex = 0;
|
|
57
|
+
lastContentLength = 0;
|
|
54
58
|
lastPinnedText = "";
|
|
55
59
|
hasToolsInTurn = false;
|
|
56
60
|
renderedSegments = [];
|
|
@@ -74,6 +78,7 @@ export async function handleAgentEvent(host, event) {
|
|
|
74
78
|
lastPinnedText = "";
|
|
75
79
|
hasToolsInTurn = false;
|
|
76
80
|
renderedSegments = [];
|
|
81
|
+
lastContentLength = 0;
|
|
77
82
|
if (pinnedBorder)
|
|
78
83
|
pinnedBorder.stopSpinner();
|
|
79
84
|
pinnedBorder = undefined;
|
|
@@ -170,12 +175,23 @@ export async function handleAgentEvent(host, event) {
|
|
|
170
175
|
}
|
|
171
176
|
}
|
|
172
177
|
const contentBlocks = host.streamingMessage.content;
|
|
173
|
-
// Some adapters reuse a single assistant
|
|
174
|
-
// spanning multiple provider turns.
|
|
175
|
-
//
|
|
176
|
-
|
|
178
|
+
// Some adapters (notably claude-code) reuse a single assistant
|
|
179
|
+
// lifecycle while internally spanning multiple provider sub-turns.
|
|
180
|
+
// When a new sub-turn starts, content[] length shrinks back to 0/1.
|
|
181
|
+
// The scan loop needs its index reset, AND the segment walker's
|
|
182
|
+
// renderedSegments map must be cleared so existing text-run
|
|
183
|
+
// components don't get overwritten in place with new sub-turn
|
|
184
|
+
// content (#4144 regression). Prior sub-turn children stay in
|
|
185
|
+
// chatContainer as frozen history; new segments append after them.
|
|
186
|
+
if (contentBlocks.length < lastContentLength) {
|
|
187
|
+
renderedSegments = [];
|
|
188
|
+
lastPinnedText = "";
|
|
189
|
+
lastProcessedContentIndex = 0;
|
|
190
|
+
}
|
|
191
|
+
else if (lastProcessedContentIndex >= contentBlocks.length) {
|
|
177
192
|
lastProcessedContentIndex = 0;
|
|
178
193
|
}
|
|
194
|
+
lastContentLength = contentBlocks.length;
|
|
179
195
|
for (let i = lastProcessedContentIndex; i < contentBlocks.length; i++) {
|
|
180
196
|
const content = contentBlocks[i];
|
|
181
197
|
if (content.type === "toolCall") {
|
|
@@ -393,6 +409,7 @@ export async function handleAgentEvent(host, event) {
|
|
|
393
409
|
host.streamingComponent = undefined;
|
|
394
410
|
host.streamingMessage = undefined;
|
|
395
411
|
renderedSegments = [];
|
|
412
|
+
lastContentLength = 0;
|
|
396
413
|
// Clear pinned output once the message is finalized in the chat
|
|
397
414
|
// container — prevents duplicate display when the agent continues
|
|
398
415
|
// (e.g. form elicitation) after the assistant message ends.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-controller.js","sourceRoot":"","sources":["../../../../src/modes/interactive/controllers/chat-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAG7D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3D,kGAAkG;AAClG,IAAI,yBAAyB,GAAG,CAAC,CAAC;AAOlC,IAAI,gBAAgB,GAAsB,EAAE,CAAC;AAE7C,SAAS,0BAA0B,CAAC,OAAgC;IACnE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAC1B,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;WAC1E,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,Q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,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjD,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM;QAEP,KAAK,0BAA0B;YAC9B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7B,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM;QAEP,KAAK,yBAAyB;YAC7B,IAAI,CAAC,UAAU,CACd,WAAW,KAAK,CAAC,aAAa,wDAAwD,CACtF,CAAC;YACF,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM;IACR,CAAC;AACF,CAAC","sourcesContent":["import { Loader, Markdown, Spacer, Text } from \"@gsd/pi-tui\";\n\nimport type { InteractiveModeEvent, InteractiveModeStateHost } from \"../interactive-mode-state.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { AssistantMessageComponent } from \"../components/assistant-message.js\";\nimport { ToolExecutionComponent } from \"../components/tool-execution.js\";\nimport { DynamicBorder } from \"../components/dynamic-border.js\";\nimport { appKey } from \"../components/keybinding-hints.js\";\n\n// Tracks the last processed content index to avoid re-scanning all blocks on every message_update\nlet lastProcessedContentIndex = 0;\n\n// --- Segment walker state (per streaming assistant turn) ---\ntype RenderedSegment =\n\t| { kind: \"text-run\"; startIndex: number; endIndex: number; component: AssistantMessageComponent }\n\t| { kind: \"tool\"; contentIndex: number; component: ToolExecutionComponent };\n\nlet renderedSegments: RenderedSegment[] = [];\n\nfunction hasVisibleAssistantContent(message: { content: Array<any> }): boolean {\n\treturn message.content.some(\n\t\t(c) =>\n\t\t\t(c.type === \"text\" && typeof c.text === \"string\" && c.text.trim().length > 0)\n\t\t\t|| (c.type === \"thinking\" && typeof c.thinking === \"string\" && c.thinking.trim().length > 0),\n\t);\n}\n\nfunction hasAssistantToolBlocks(message: { content: Array<any> }): boolean {\n\treturn message.content.some((c) => c.type === \"toolCall\" || c.type === \"serverToolUse\");\n}\n\n// Pick the latest non-empty text block that appears strictly before the most\n// recent tool call. Text blocks that come after the last tool call are still\n// streaming live into the chat container, so mirroring them into the pinned\n// \"Latest Output\" zone would render the same tokens twice.\nexport function findLatestPinnableText(contentBlocks: Array<any>): string {\n\tlet lastToolIdx = -1;\n\tfor (let i = contentBlocks.length - 1; i >= 0; i--) {\n\t\tconst c = contentBlocks[i];\n\t\tif (c?.type === \"toolCall\" || c?.type === \"serverToolUse\") {\n\t\t\tlastToolIdx = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor (let i = lastToolIdx - 1; i >= 0; i--) {\n\t\tconst c = contentBlocks[i];\n\t\tif (c?.type === \"text\" && typeof c.text === \"string\" && c.text.trim()) {\n\t\t\treturn c.text.trim();\n\t\t}\n\t}\n\treturn \"\";\n}\n\n// Tracks the latest assistant text for the pinned message zone\nlet lastPinnedText = \"\";\n// Whether any tool execution has been added in this assistant turn (triggers pinned display)\nlet hasToolsInTurn = false;\n// Reference to the pinned border so we can toggle its label between working/idle\nlet pinnedBorder: DynamicBorder | undefined;\n// Reference to the pinned markdown component below the border\nlet pinnedTextComponent: Markdown | undefined;\n\nexport async function handleAgentEvent(host: InteractiveModeStateHost & {\n\tinit: () => Promise<void>;\n\tgetMarkdownThemeWithSettings: () => any;\n\taddMessageToChat: (message: any, options?: any) => void;\n\tformatWebSearchResult: (content: unknown) => string;\n\tgetRegisteredToolDefinition: (toolName: string) => any;\n\tcheckShutdownRequested: () => Promise<void>;\n\trebuildChatFromMessages: () => void;\n\tflushCompactionQueue: (options?: { willRetry?: boolean }) => Promise<void>;\n\tshowStatus: (message: string) => void;\n\tshowError: (message: string) => void;\n\tupdatePendingMessagesDisplay: () => void;\n\tupdateTerminalTitle: () => void;\n\tupdateEditorBorderColor: () => void;\n\tpendingMessagesContainer: { clear: () => void };\n}, event: InteractiveModeEvent): Promise<void> {\n\tif (!host.isInitialized) {\n\t\tawait host.init();\n\t}\n\n\thost.footer.invalidate();\n\n\t// Reset content index tracker and pinned state when a new assistant message starts\n\tif (event.type === \"message_start\" && event.message.role === \"assistant\") {\n\t\tlastProcessedContentIndex = 0;\n\t\tlastPinnedText = \"\";\n\t\thasToolsInTurn = false;\n\t\trenderedSegments = [];\n\t\tif (pinnedBorder) pinnedBorder.stopSpinner();\n\t\tpinnedBorder = undefined;\n\t\tpinnedTextComponent = undefined;\n\t\thost.pinnedMessageContainer.clear();\n\t}\n\n\tswitch (event.type) {\n\t\tcase \"session_state_changed\":\n\t\t\tswitch (event.reason) {\n\t\t\t\tcase \"new_session\":\n\t\t\t\tcase \"switch_session\":\n\t\t\t\tcase \"fork\":\n\t\t\t\t\thost.streamingComponent = undefined;\n\t\t\t\t\thost.streamingMessage = undefined;\n\t\t\t\t\thost.pendingTools.clear();\n\t\t\t\t\thost.pendingMessagesContainer.clear();\n\t\t\t\t\thost.pinnedMessageContainer.clear();\n\t\t\t\t\tlastPinnedText = \"\";\n\t\t\t\t\thasToolsInTurn = false;\n\t\t\t\t\trenderedSegments = [];\n\t\t\t\t\tif (pinnedBorder) pinnedBorder.stopSpinner();\n\t\t\t\t\tpinnedBorder = undefined;\n\t\t\t\t\tpinnedTextComponent = undefined;\n\t\t\t\t\thost.compactionQueuedMessages = [];\n\t\t\t\t\thost.rebuildChatFromMessages();\n\t\t\t\t\thost.updatePendingMessagesDisplay();\n\t\t\t\t\thost.updateTerminalTitle();\n\t\t\t\t\thost.updateEditorBorderColor();\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t\treturn;\n\t\t\t\tcase \"set_session_name\":\n\t\t\t\t\thost.updateTerminalTitle();\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t\treturn;\n\t\t\t\tcase \"set_model\":\n\t\t\t\tcase \"set_thinking_level\":\n\t\t\t\t\thost.updateEditorBorderColor();\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t\treturn;\n\t\t\t}\n\t\tcase \"agent_start\":\n\t\t\tif (host.retryEscapeHandler) {\n\t\t\t\thost.defaultEditor.onEscape = host.retryEscapeHandler;\n\t\t\t\thost.retryEscapeHandler = undefined;\n\t\t\t}\n\t\t\tif (host.retryLoader) {\n\t\t\t\thost.retryLoader.stop();\n\t\t\t\thost.retryLoader = undefined;\n\t\t\t}\n\t\t\tif (host.loadingAnimation) {\n\t\t\t\thost.loadingAnimation.stop();\n\t\t\t}\n\t\t\thost.statusContainer.clear();\n\t\t\thost.loadingAnimation = new Loader(\n\t\t\t\thost.ui,\n\t\t\t\t(spinner) => theme.fg(\"accent\", spinner),\n\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\thost.defaultWorkingMessage,\n\t\t\t);\n\t\t\thost.statusContainer.addChild(host.loadingAnimation);\n\t\t\tif (host.pendingWorkingMessage !== undefined) {\n\t\t\t\tif (host.pendingWorkingMessage) {\n\t\t\t\t\thost.loadingAnimation.setMessage(host.pendingWorkingMessage);\n\t\t\t\t}\n\t\t\t\thost.pendingWorkingMessage = undefined;\n\t\t\t}\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"message_start\":\n\t\t\tif (event.message.role === \"custom\") {\n\t\t\t\thost.addMessageToChat(event.message);\n\t\t\t\thost.ui.requestRender();\n\t\t\t} else if (event.message.role === \"user\") {\n\t\t\t\thost.addMessageToChat(event.message);\n\t\t\t\thost.updatePendingMessagesDisplay();\n\t\t\t\thost.ui.requestRender();\n\t\t\t} else if (event.message.role === \"assistant\") {\n\t\t\t\thost.streamingMessage = event.message;\n\t\t\t\t// External-tool providers can stream multiple assistant turns through\n\t\t\t\t// one response. Delay component creation until visible assistant text\n\t\t\t\t// arrives so tool outputs keep chronological ordering.\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase \"message_update\":\n\t\t\tif (event.message.role === \"assistant\") {\n\t\t\t\thost.streamingMessage = event.message;\n\t\t\t\tconst innerEvent = event.assistantMessageEvent;\n\n\t\t\t\tlet externalToolResult:\n\t\t\t\t\t| { toolCallId: string; content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; details: Record<string, unknown>; isError: boolean }\n\t\t\t\t\t| undefined;\n\t\t\t\tif (innerEvent.type === \"toolcall_end\" && innerEvent.toolCall) {\n\t\t\t\t\tconst tc = innerEvent.toolCall as any;\n\t\t\t\t\tconst ext = tc.externalResult;\n\t\t\t\t\tif (ext) {\n\t\t\t\t\t\texternalToolResult = {\n\t\t\t\t\t\t\ttoolCallId: tc.id,\n\t\t\t\t\t\t\tcontent: ext.content ?? [{ type: \"text\", text: \"\" }],\n\t\t\t\t\t\t\tdetails: ext.details ?? {},\n\t\t\t\t\t\t\tisError: ext.isError ?? false,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t} else if (innerEvent.type === \"server_tool_use\") {\n\t\t\t\t\tconst idx = typeof innerEvent.contentIndex === \"number\" ? innerEvent.contentIndex : -1;\n\t\t\t\t\tconst block = idx >= 0 ? (host.streamingMessage.content[idx] as any) : undefined;\n\t\t\t\t\tconst ext = block?.externalResult;\n\t\t\t\t\tif (block?.id && ext) {\n\t\t\t\t\t\texternalToolResult = {\n\t\t\t\t\t\t\ttoolCallId: block.id,\n\t\t\t\t\t\t\tcontent: ext.content ?? [{ type: \"text\", text: \"\" }],\n\t\t\t\t\t\t\tdetails: ext.details ?? {},\n\t\t\t\t\t\t\tisError: ext.isError ?? false,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst contentBlocks = host.streamingMessage.content;\n\t\t\t\t// Some adapters reuse a single assistant lifecycle while internally\n\t\t\t\t// spanning multiple provider turns. When a new turn starts, content\n\t\t\t\t// length can shrink back to 0/1; reset scan index to avoid skipping.\n\t\t\t\tif (lastProcessedContentIndex >= contentBlocks.length) {\n\t\t\t\t\tlastProcessedContentIndex = 0;\n\t\t\t\t}\n\t\t\t\tfor (let i = lastProcessedContentIndex; i < contentBlocks.length; i++) {\n\t\t\t\t\tconst content = contentBlocks[i];\n\t\t\t\t\tif (content.type === \"toolCall\") {\n\t\t\t\t\t\tif (!host.pendingTools.has(content.id)) {\n\t\t\t\t\t\t\tconst component = new ToolExecutionComponent(\n\t\t\t\t\t\t\t\tcontent.name,\n\t\t\t\t\t\t\t\tcontent.arguments,\n\t\t\t\t\t\t\t\t{ showImages: host.settingsManager.getShowImages() },\n\t\t\t\t\t\t\t\thost.getRegisteredToolDefinition(content.name),\n\t\t\t\t\t\t\t\thost.ui,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcomponent.setExpanded(host.toolOutputExpanded);\n\t\t\t\t\t\t\thost.chatContainer.addChild(component);\n\t\t\t\t\t\t\thost.pendingTools.set(content.id, component);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\thost.pendingTools.get(content.id)?.updateArgs(content.arguments);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (content.type === \"serverToolUse\") {\n\t\t\t\t\t\tif (!host.pendingTools.has(content.id)) {\n\t\t\t\t\t\t\tconst component = new ToolExecutionComponent(\n\t\t\t\t\t\t\t\tcontent.name,\n\t\t\t\t\t\t\t\tcontent.input ?? {},\n\t\t\t\t\t\t\t\t{ showImages: host.settingsManager.getShowImages() },\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\thost.ui,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcomponent.setExpanded(host.toolOutputExpanded);\n\t\t\t\t\t\t\thost.chatContainer.addChild(component);\n\t\t\t\t\t\t\thost.pendingTools.set(content.id, component);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (content.type === \"webSearchResult\") {\n\t\t\t\t\t\tconst component = host.pendingTools.get(content.toolUseId);\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\tif (process.env.PI_OFFLINE === \"1\") {\n\t\t\t\t\t\t\t\tcomponent.updateResult({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"Web search disabled (offline mode)\" }],\n\t\t\t\t\t\t\t\t\tisError: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst searchContent = content.content;\n\t\t\t\t\t\t\t\tconst isError = searchContent && typeof searchContent === \"object\" && \"type\" in (searchContent as any) && (searchContent as any).type === \"web_search_tool_result_error\";\n\t\t\t\t\t\t\t\tcomponent.updateResult({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: host.formatWebSearchResult(searchContent) }],\n\t\t\t\t\t\t\t\t\tisError: !!isError,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// When the stream adapter signals a completed tool call with an\n\t\t\t\t// external result (from Claude Code SDK), update the pending\n\t\t\t\t// ToolExecutionComponent immediately so output is visible in\n\t\t\t\t// real-time instead of waiting for the session to end.\n\t\t\t\tif (externalToolResult) {\n\t\t\t\t\tconst component = host.pendingTools.get(externalToolResult.toolCallId);\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\tcomponent.updateResult({\n\t\t\t\t\t\t\tcontent: externalToolResult.content,\n\t\t\t\t\t\t\tdetails: externalToolResult.details,\n\t\t\t\t\t\t\tisError: externalToolResult.isError,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Segment walker: render content blocks in stream order, append-only.\n\t\t\t\t// Build desired segment plan from content[].\n\t\t\t\t{\n\t\t\t\t\tconst blocks = host.streamingMessage.content;\n\t\t\t\t\ttype DesiredSegment =\n\t\t\t\t\t\t| { kind: \"text-run\"; startIndex: number; endIndex: number }\n\t\t\t\t\t\t| { kind: \"tool\"; contentIndex: number; toolId: string };\n\t\t\t\t\tconst desired: DesiredSegment[] = [];\n\t\t\t\t\tlet runStart = -1;\n\t\t\t\t\tfor (let i = 0; i < blocks.length; i++) {\n\t\t\t\t\t\tconst b = blocks[i];\n\t\t\t\t\t\tconst isText = b.type === \"text\" || b.type === \"thinking\";\n\t\t\t\t\t\tconst isTool = b.type === \"toolCall\" || b.type === \"serverToolUse\";\n\t\t\t\t\t\tif (isText) {\n\t\t\t\t\t\t\tif (runStart === -1) runStart = i;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (runStart !== -1) {\n\t\t\t\t\t\t\t\tdesired.push({ kind: \"text-run\", startIndex: runStart, endIndex: i - 1 });\n\t\t\t\t\t\t\t\trunStart = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (isTool) {\n\t\t\t\t\t\t\t\tdesired.push({ kind: \"tool\", contentIndex: i, toolId: b.id });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (runStart !== -1) {\n\t\t\t\t\t\tdesired.push({ kind: \"text-run\", startIndex: runStart, endIndex: blocks.length - 1 });\n\t\t\t\t\t}\n\n\t\t\t\t\t// Append any newly needed segments (never reorder existing ones).\n\t\t\t\t\tfor (const seg of desired) {\n\t\t\t\t\t\tif (seg.kind === \"tool\") {\n\t\t\t\t\t\t\t// Tool segments are already handled above via pendingTools; just\n\t\t\t\t\t\t\t// register them in renderedSegments if not yet tracked.\n\t\t\t\t\t\t\tconst existing = renderedSegments.find(\n\t\t\t\t\t\t\t\t(s) => s.kind === \"tool\" && s.contentIndex === seg.contentIndex,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (!existing) {\n\t\t\t\t\t\t\t\tconst comp = host.pendingTools.get(seg.toolId);\n\t\t\t\t\t\t\t\tif (comp) {\n\t\t\t\t\t\t\t\t\trenderedSegments.push({ kind: \"tool\", contentIndex: seg.contentIndex, component: comp });\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// text-run segment\n\t\t\t\t\t\t\tconst existing = renderedSegments.find(\n\t\t\t\t\t\t\t\t(s) => s.kind === \"text-run\" && s.startIndex === seg.startIndex,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (!existing) {\n\t\t\t\t\t\t\t\tconst comp = new AssistantMessageComponent(\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\thost.hideThinkingBlock,\n\t\t\t\t\t\t\t\t\thost.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\t\t\t\thost.settingsManager.getTimestampFormat(),\n\t\t\t\t\t\t\t\t\t{ startIndex: seg.startIndex, endIndex: seg.endIndex },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\thost.chatContainer.addChild(comp);\n\t\t\t\t\t\t\t\trenderedSegments.push({ kind: \"text-run\", startIndex: seg.startIndex, endIndex: seg.endIndex, component: comp });\n\t\t\t\t\t\t\t\thost.streamingComponent = comp;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update all trailing text-run segments with the latest message so\n\t\t\t\t\t// streaming text grows in place.\n\t\t\t\t\tfor (const seg of renderedSegments) {\n\t\t\t\t\t\tif (seg.kind === \"text-run\") {\n\t\t\t\t\t\t\t// Find corresponding desired segment to get current endIndex\n\t\t\t\t\t\t\tconst d = desired.find((ds) => ds.kind === \"text-run\" && ds.startIndex === seg.startIndex);\n\t\t\t\t\t\t\tif (d && d.kind === \"text-run\" && d.endIndex !== seg.endIndex) {\n\t\t\t\t\t\t\t\tseg.endIndex = d.endIndex;\n\t\t\t\t\t\t\t\tseg.component.setRange({ startIndex: seg.startIndex, endIndex: seg.endIndex });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tseg.component.updateContent(host.streamingMessage);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Keep streamingComponent pointing at the last text-run for message_end compatibility.\n\t\t\t\t\tconst lastTextSeg = [...renderedSegments].reverse().find((s) => s.kind === \"text-run\");\n\t\t\t\t\tif (lastTextSeg && lastTextSeg.kind === \"text-run\") {\n\t\t\t\t\t\thost.streamingComponent = lastTextSeg.component;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Update index: fully processed blocks won't need re-scanning.\n\t\t\t\t// Keep the last block's index (it may still be accumulating data),\n\t\t\t\t// so we re-check it next time but skip all earlier ones.\n\t\t\t\tif (contentBlocks.length > 0) {\n\t\t\t\t\tlastProcessedContentIndex = Math.max(0, contentBlocks.length - 1);\n\t\t\t\t}\n\n\t\t\t\t// Pinned message: mirror the latest assistant text above the editor\n\t\t\t\t// when tool executions push it out of the viewport.\n\t\t\t\tconst hasTools = contentBlocks.some(\n\t\t\t\t\t(c: any) => c.type === \"toolCall\" || c.type === \"serverToolUse\",\n\t\t\t\t);\n\t\t\t\tif (hasTools) hasToolsInTurn = true;\n\n\t\t\t\tif (hasToolsInTurn) {\n\t\t\t\t\tconst latestText = findLatestPinnableText(contentBlocks);\n\n\t\t\t\t\tif (latestText && latestText !== lastPinnedText) {\n\t\t\t\t\t\tlastPinnedText = latestText;\n\n\t\t\t\t\t\tif (!pinnedBorder) {\n\t\t\t\t\t\t\t// First time: create border + text component\n\t\t\t\t\t\t\thost.pinnedMessageContainer.clear();\n\t\t\t\t\t\t\tpinnedBorder = new DynamicBorder(\n\t\t\t\t\t\t\t\t(str: string) => theme.fg(\"dim\", str),\n\t\t\t\t\t\t\t\t\"Working · Latest Output\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tpinnedBorder.startSpinner(host.ui, (str: string) => theme.fg(\"accent\", str));\n\t\t\t\t\t\t\thost.pinnedMessageContainer.addChild(pinnedBorder);\n\t\t\t\t\t\t\tpinnedTextComponent = new Markdown(latestText, 1, 0, host.getMarkdownThemeWithSettings());\n\t\t\t\t\t\t\t// Cap pinned content to ~40% of terminal height so tall output\n\t\t\t\t\t\t\t// doesn't exceed the viewport and cause render flashing.\n\t\t\t\t\t\t\tpinnedTextComponent.maxLines = Math.max(3, Math.floor(host.ui.terminal.rows * 0.4));\n\t\t\t\t\t\t\thost.pinnedMessageContainer.addChild(pinnedTextComponent);\n\t\t\t\t\t\t\t// Hide the separate status loader — the pinned zone replaces it\n\t\t\t\t\t\t\tif (host.loadingAnimation) {\n\t\t\t\t\t\t\t\thost.loadingAnimation.stop();\n\t\t\t\t\t\t\t\thost.loadingAnimation = undefined;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thost.statusContainer.clear();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Update existing markdown component in-place\n\t\t\t\t\t\t\tpinnedTextComponent?.setText(latestText);\n\t\t\t\t\t\t\t// Refresh maxLines in case terminal was resized\n\t\t\t\t\t\t\tif (pinnedTextComponent) {\n\t\t\t\t\t\t\t\tpinnedTextComponent.maxLines = Math.max(3, Math.floor(host.ui.terminal.rows * 0.4));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase \"message_end\":\n\t\t\tif (event.message.role === \"user\") break;\n\t\t\tif (event.message.role === \"assistant\") {\n\t\t\t\thost.streamingMessage = event.message;\n\t\t\t\tlet errorMessage: string | undefined;\n\t\t\t\tif (host.streamingMessage.stopReason === \"aborted\") {\n\t\t\t\t\tconst retryAttempt = host.session.retryAttempt;\n\t\t\t\t\terrorMessage = retryAttempt > 0\n\t\t\t\t\t\t? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? \"s\" : \"\"}`\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\t\thost.streamingMessage.errorMessage = errorMessage;\n\t\t\t\t}\n\n\t\t\t\tconst shouldRenderAssistant = hasVisibleAssistantContent(host.streamingMessage)\n\t\t\t\t\t|| (\n\t\t\t\t\t\t(host.streamingMessage.stopReason === \"aborted\" || host.streamingMessage.stopReason === \"error\")\n\t\t\t\t\t\t&& !hasAssistantToolBlocks(host.streamingMessage)\n\t\t\t\t\t);\n\t\t\t\tif (!host.streamingComponent && shouldRenderAssistant) {\n\t\t\t\t\thost.streamingComponent = new AssistantMessageComponent(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\thost.hideThinkingBlock,\n\t\t\t\t\t\thost.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\thost.settingsManager.getTimestampFormat(),\n\t\t\t\t\t);\n\t\t\t\t\thost.chatContainer.addChild(host.streamingComponent);\n\t\t\t\t}\n\t\t\t\tif (host.streamingComponent) {\n\t\t\t\t\thost.streamingComponent.setShowMetadata(true);\n\t\t\t\t\thost.streamingComponent.updateContent(host.streamingMessage);\n\t\t\t\t}\n\n\t\t\t\tif (host.streamingMessage.stopReason === \"aborted\" || host.streamingMessage.stopReason === \"error\") {\n\t\t\t\t\tif (!errorMessage) {\n\t\t\t\t\t\terrorMessage = host.streamingMessage.errorMessage || \"Error\";\n\t\t\t\t\t}\n\t\t\t\t\tconst pendingComponents = Array.from(host.pendingTools.values());\n\t\t\t\t\tif (pendingComponents.length > 0) {\n\t\t\t\t\t\tconst [first, ...rest] = pendingComponents;\n\t\t\t\t\t\tfirst.completeWithError(errorMessage);\n\t\t\t\t\t\tfor (const component of rest) {\n\t\t\t\t\t\t\tcomponent.completeWithError();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thost.pendingTools.clear();\n\t\t\t\t} else {\n\t\t\t\t\tfor (const [, component] of host.pendingTools.entries()) {\n\t\t\t\t\t\tcomponent.setArgsComplete();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\thost.streamingComponent = undefined;\n\t\t\t\thost.streamingMessage = undefined;\n\t\t\t\trenderedSegments = [];\n\t\t\t\t// Clear pinned output once the message is finalized in the chat\n\t\t\t\t// container — prevents duplicate display when the agent continues\n\t\t\t\t// (e.g. form elicitation) after the assistant message ends.\n\t\t\t\tif (pinnedBorder) pinnedBorder.stopSpinner();\n\t\t\t\thost.pinnedMessageContainer.clear();\n\t\t\t\tlastPinnedText = \"\";\n\t\t\t\thasToolsInTurn = false;\n\t\t\t\tpinnedBorder = undefined;\n\t\t\t\tpinnedTextComponent = undefined;\n\t\t\t\thost.footer.invalidate();\n\t\t\t}\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"tool_execution_start\":\n\t\t\tif (!host.pendingTools.has(event.toolCallId)) {\n\t\t\t\tconst component = new ToolExecutionComponent(\n\t\t\t\t\tevent.toolName,\n\t\t\t\t\tevent.args,\n\t\t\t\t\t{ showImages: host.settingsManager.getShowImages() },\n\t\t\t\t\thost.getRegisteredToolDefinition(event.toolName),\n\t\t\t\t\thost.ui,\n\t\t\t\t);\n\t\t\t\tcomponent.setExpanded(host.toolOutputExpanded);\n\t\t\t\thost.chatContainer.addChild(component);\n\t\t\t\thost.pendingTools.set(event.toolCallId, component);\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase \"tool_execution_update\": {\n\t\t\tconst component = host.pendingTools.get(event.toolCallId);\n\t\t\tif (component) {\n\t\t\t\tcomponent.updateResult({ ...event.partialResult, isError: false }, true);\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"tool_execution_end\": {\n\t\t\tconst component = host.pendingTools.get(event.toolCallId);\n\t\t\tif (component) {\n\t\t\t\tcomponent.updateResult({ ...event.result, isError: event.isError });\n\t\t\t\thost.pendingTools.delete(event.toolCallId);\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"agent_end\":\n\t\t\tif (host.loadingAnimation) {\n\t\t\t\thost.loadingAnimation.stop();\n\t\t\t\thost.loadingAnimation = undefined;\n\t\t\t\thost.statusContainer.clear();\n\t\t\t}\n\t\t\tif (host.streamingComponent) {\n\t\t\t\thost.chatContainer.removeChild(host.streamingComponent);\n\t\t\t\thost.streamingComponent = undefined;\n\t\t\t\thost.streamingMessage = undefined;\n\t\t\t}\n\t\t\thost.pendingTools.clear();\n\t\t\t// Pinned output is only useful while work is actively streaming.\n\t\t\t// Keep chat history as the single source after completion.\n\t\t\tif (pinnedBorder) {\n\t\t\t\tpinnedBorder.stopSpinner();\n\t\t\t}\n\t\t\thost.pinnedMessageContainer.clear();\n\t\t\tlastPinnedText = \"\";\n\t\t\thasToolsInTurn = false;\n\t\t\tpinnedBorder = undefined;\n\t\t\tpinnedTextComponent = undefined;\n\t\t\tawait host.checkShutdownRequested();\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"auto_compaction_start\":\n\t\t\thost.autoCompactionEscapeHandler = host.defaultEditor.onEscape;\n\t\t\thost.defaultEditor.onEscape = () => host.session.abortCompaction();\n\t\t\thost.statusContainer.clear();\n\t\t\thost.autoCompactionLoader = new Loader(\n\t\t\t\thost.ui,\n\t\t\t\t(spinner) => theme.fg(\"accent\", spinner),\n\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\t`${event.reason === \"overflow\" ? \"Context overflow detected, \" : \"\"}Auto-compacting... (${appKey(host.keybindings, \"interrupt\")} to cancel)`,\n\t\t\t);\n\t\t\thost.statusContainer.addChild(host.autoCompactionLoader);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"auto_compaction_end\":\n\t\t\tif (host.autoCompactionEscapeHandler) {\n\t\t\t\thost.defaultEditor.onEscape = host.autoCompactionEscapeHandler;\n\t\t\t\thost.autoCompactionEscapeHandler = undefined;\n\t\t\t}\n\t\t\tif (host.autoCompactionLoader) {\n\t\t\t\thost.autoCompactionLoader.stop();\n\t\t\t\thost.autoCompactionLoader = undefined;\n\t\t\t\thost.statusContainer.clear();\n\t\t\t}\n\t\t\tif (event.aborted) {\n\t\t\t\thost.showStatus(\"Auto-compaction cancelled\");\n\t\t\t} else if (event.result) {\n\t\t\t\thost.chatContainer.clear();\n\t\t\t\thost.rebuildChatFromMessages();\n\t\t\t\thost.addMessageToChat({\n\t\t\t\t\trole: \"compactionSummary\",\n\t\t\t\t\ttokensBefore: event.result.tokensBefore,\n\t\t\t\t\tsummary: event.result.summary,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t});\n\t\t\t\thost.footer.invalidate();\n\t\t\t} else if (event.errorMessage) {\n\t\t\t\thost.chatContainer.addChild(new Spacer(1));\n\t\t\t\thost.chatContainer.addChild(new Text(theme.fg(\"error\", event.errorMessage), 1, 0));\n\t\t\t}\n\t\t\tvoid host.flushCompactionQueue({ willRetry: event.willRetry });\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"auto_retry_start\":\n\t\t\thost.retryEscapeHandler = host.defaultEditor.onEscape;\n\t\t\thost.defaultEditor.onEscape = () => host.session.abortRetry();\n\t\t\thost.statusContainer.clear();\n\t\t\thost.retryLoader = new Loader(\n\t\t\t\thost.ui,\n\t\t\t\t(spinner) => theme.fg(\"warning\", spinner),\n\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\t`Retrying (${event.attempt}/${event.maxAttempts}) in ${Math.round(event.delayMs / 1000)}s... (${appKey(host.keybindings, \"interrupt\")} to cancel)`,\n\t\t\t);\n\t\t\thost.statusContainer.addChild(host.retryLoader);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"auto_retry_end\":\n\t\t\tif (host.retryEscapeHandler) {\n\t\t\t\thost.defaultEditor.onEscape = host.retryEscapeHandler;\n\t\t\t\thost.retryEscapeHandler = undefined;\n\t\t\t}\n\t\t\tif (host.retryLoader) {\n\t\t\t\thost.retryLoader.stop();\n\t\t\t\thost.retryLoader = undefined;\n\t\t\t\thost.statusContainer.clear();\n\t\t\t}\n\t\t\tif (!event.success) {\n\t\t\t\thost.showError(`Retry failed after ${event.attempt} attempts: ${event.finalError || \"Unknown error\"}`);\n\t\t\t}\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"fallback_provider_switch\":\n\t\t\thost.showStatus(`Switched from ${event.from} → ${event.to} (${event.reason})`);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"fallback_provider_restored\":\n\t\t\thost.showStatus(`Restored to ${event.provider}`);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"fallback_chain_exhausted\":\n\t\t\thost.showError(event.reason);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"image_overflow_recovery\":\n\t\t\thost.showStatus(\n\t\t\t\t`Removed ${event.strippedCount} older image(s) to comply with API limits. Retrying...`,\n\t\t\t);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chat-controller.js","sourceRoot":"","sources":["../../../../src/modes/interactive/controllers/chat-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAG7D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3D,kGAAkG;AAClG,IAAI,yBAAyB,GAAG,CAAC,CAAC;AAElC,+EAA+E;AAC/E,gFAAgF;AAChF,IAAI,iBAAiB,GAAG,CAAC,CAAC;AAO1B,IAAI,gBAAgB,GAAsB,EAAE,CAAC;AAE7C,SAAS,0BAA0B,CAAC,OAAgC;IACnE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAC1B,CAAC,CAAC,EAAE,EAAE,CACL,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;WAC1E,CAAC,CAAC,CAAC,IAA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KAAK,CAAC,OAAO,EAAE,CAAC;gBACpB,IAAI,CAAC,SAAS,CAAC,sBAAsB,KAAK,CAAC,OAAO,cAAc,KAAK,CAAC,UAAU,IAAI,eAAe,EAAE,CAAC,CAAC;YACxG,CAAC;YACD,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM;QAEP,KAAK,0BAA0B;YAC9B,IAAI,CAAC,UAAU,CAAC,iBAAiB,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAC/E,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM;QAEP,KAAK,4BAA4B;YAChC,IAAI,CAAC,UAAU,CAAC,eAAe,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjD,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM;QAEP,KAAK,0BAA0B;YAC9B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7B,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM;QAEP,KAAK,yBAAyB;YAC7B,IAAI,CAAC,UAAU,CACd,WAAW,KAAK,CAAC,aAAa,wDAAwD,CACtF,CAAC;YACF,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM;IACR,CAAC;AACF,CAAC","sourcesContent":["import { Loader, Markdown, Spacer, Text } from \"@gsd/pi-tui\";\n\nimport type { InteractiveModeEvent, InteractiveModeStateHost } from \"../interactive-mode-state.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { AssistantMessageComponent } from \"../components/assistant-message.js\";\nimport { ToolExecutionComponent } from \"../components/tool-execution.js\";\nimport { DynamicBorder } from \"../components/dynamic-border.js\";\nimport { appKey } from \"../components/keybinding-hints.js\";\n\n// Tracks the last processed content index to avoid re-scanning all blocks on every message_update\nlet lastProcessedContentIndex = 0;\n\n// Tracks the previous content[] length so we can detect when an adapter resets\n// the assistant content array for a new provider sub-turn within one lifecycle.\nlet lastContentLength = 0;\n\n// --- Segment walker state (per streaming assistant turn) ---\ntype RenderedSegment =\n\t| { kind: \"text-run\"; startIndex: number; endIndex: number; component: AssistantMessageComponent }\n\t| { kind: \"tool\"; contentIndex: number; component: ToolExecutionComponent };\n\nlet renderedSegments: RenderedSegment[] = [];\n\nfunction hasVisibleAssistantContent(message: { content: Array<any> }): boolean {\n\treturn message.content.some(\n\t\t(c) =>\n\t\t\t(c.type === \"text\" && typeof c.text === \"string\" && c.text.trim().length > 0)\n\t\t\t|| (c.type === \"thinking\" && typeof c.thinking === \"string\" && c.thinking.trim().length > 0),\n\t);\n}\n\nfunction hasAssistantToolBlocks(message: { content: Array<any> }): boolean {\n\treturn message.content.some((c) => c.type === \"toolCall\" || c.type === \"serverToolUse\");\n}\n\n// Pick the latest non-empty text block that appears strictly before the most\n// recent tool call. Text blocks that come after the last tool call are still\n// streaming live into the chat container, so mirroring them into the pinned\n// \"Latest Output\" zone would render the same tokens twice.\nexport function findLatestPinnableText(contentBlocks: Array<any>): string {\n\tlet lastToolIdx = -1;\n\tfor (let i = contentBlocks.length - 1; i >= 0; i--) {\n\t\tconst c = contentBlocks[i];\n\t\tif (c?.type === \"toolCall\" || c?.type === \"serverToolUse\") {\n\t\t\tlastToolIdx = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor (let i = lastToolIdx - 1; i >= 0; i--) {\n\t\tconst c = contentBlocks[i];\n\t\tif (c?.type === \"text\" && typeof c.text === \"string\" && c.text.trim()) {\n\t\t\treturn c.text.trim();\n\t\t}\n\t}\n\treturn \"\";\n}\n\n// Tracks the latest assistant text for the pinned message zone\nlet lastPinnedText = \"\";\n// Whether any tool execution has been added in this assistant turn (triggers pinned display)\nlet hasToolsInTurn = false;\n// Reference to the pinned border so we can toggle its label between working/idle\nlet pinnedBorder: DynamicBorder | undefined;\n// Reference to the pinned markdown component below the border\nlet pinnedTextComponent: Markdown | undefined;\n\nexport async function handleAgentEvent(host: InteractiveModeStateHost & {\n\tinit: () => Promise<void>;\n\tgetMarkdownThemeWithSettings: () => any;\n\taddMessageToChat: (message: any, options?: any) => void;\n\tformatWebSearchResult: (content: unknown) => string;\n\tgetRegisteredToolDefinition: (toolName: string) => any;\n\tcheckShutdownRequested: () => Promise<void>;\n\trebuildChatFromMessages: () => void;\n\tflushCompactionQueue: (options?: { willRetry?: boolean }) => Promise<void>;\n\tshowStatus: (message: string) => void;\n\tshowError: (message: string) => void;\n\tupdatePendingMessagesDisplay: () => void;\n\tupdateTerminalTitle: () => void;\n\tupdateEditorBorderColor: () => void;\n\tpendingMessagesContainer: { clear: () => void };\n}, event: InteractiveModeEvent): Promise<void> {\n\tif (!host.isInitialized) {\n\t\tawait host.init();\n\t}\n\n\thost.footer.invalidate();\n\n\t// Reset content index tracker and pinned state when a new assistant message starts\n\tif (event.type === \"message_start\" && event.message.role === \"assistant\") {\n\t\tlastProcessedContentIndex = 0;\n\t\tlastContentLength = 0;\n\t\tlastPinnedText = \"\";\n\t\thasToolsInTurn = false;\n\t\trenderedSegments = [];\n\t\tif (pinnedBorder) pinnedBorder.stopSpinner();\n\t\tpinnedBorder = undefined;\n\t\tpinnedTextComponent = undefined;\n\t\thost.pinnedMessageContainer.clear();\n\t}\n\n\tswitch (event.type) {\n\t\tcase \"session_state_changed\":\n\t\t\tswitch (event.reason) {\n\t\t\t\tcase \"new_session\":\n\t\t\t\tcase \"switch_session\":\n\t\t\t\tcase \"fork\":\n\t\t\t\t\thost.streamingComponent = undefined;\n\t\t\t\t\thost.streamingMessage = undefined;\n\t\t\t\t\thost.pendingTools.clear();\n\t\t\t\t\thost.pendingMessagesContainer.clear();\n\t\t\t\t\thost.pinnedMessageContainer.clear();\n\t\t\t\t\tlastPinnedText = \"\";\n\t\t\t\t\thasToolsInTurn = false;\n\t\t\t\t\trenderedSegments = [];\n\t\t\t\t\tlastContentLength = 0;\n\t\t\t\t\tif (pinnedBorder) pinnedBorder.stopSpinner();\n\t\t\t\t\tpinnedBorder = undefined;\n\t\t\t\t\tpinnedTextComponent = undefined;\n\t\t\t\t\thost.compactionQueuedMessages = [];\n\t\t\t\t\thost.rebuildChatFromMessages();\n\t\t\t\t\thost.updatePendingMessagesDisplay();\n\t\t\t\t\thost.updateTerminalTitle();\n\t\t\t\t\thost.updateEditorBorderColor();\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t\treturn;\n\t\t\t\tcase \"set_session_name\":\n\t\t\t\t\thost.updateTerminalTitle();\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t\treturn;\n\t\t\t\tcase \"set_model\":\n\t\t\t\tcase \"set_thinking_level\":\n\t\t\t\t\thost.updateEditorBorderColor();\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\thost.ui.requestRender();\n\t\t\t\t\treturn;\n\t\t\t}\n\t\tcase \"agent_start\":\n\t\t\tif (host.retryEscapeHandler) {\n\t\t\t\thost.defaultEditor.onEscape = host.retryEscapeHandler;\n\t\t\t\thost.retryEscapeHandler = undefined;\n\t\t\t}\n\t\t\tif (host.retryLoader) {\n\t\t\t\thost.retryLoader.stop();\n\t\t\t\thost.retryLoader = undefined;\n\t\t\t}\n\t\t\tif (host.loadingAnimation) {\n\t\t\t\thost.loadingAnimation.stop();\n\t\t\t}\n\t\t\thost.statusContainer.clear();\n\t\t\thost.loadingAnimation = new Loader(\n\t\t\t\thost.ui,\n\t\t\t\t(spinner) => theme.fg(\"accent\", spinner),\n\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\thost.defaultWorkingMessage,\n\t\t\t);\n\t\t\thost.statusContainer.addChild(host.loadingAnimation);\n\t\t\tif (host.pendingWorkingMessage !== undefined) {\n\t\t\t\tif (host.pendingWorkingMessage) {\n\t\t\t\t\thost.loadingAnimation.setMessage(host.pendingWorkingMessage);\n\t\t\t\t}\n\t\t\t\thost.pendingWorkingMessage = undefined;\n\t\t\t}\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"message_start\":\n\t\t\tif (event.message.role === \"custom\") {\n\t\t\t\thost.addMessageToChat(event.message);\n\t\t\t\thost.ui.requestRender();\n\t\t\t} else if (event.message.role === \"user\") {\n\t\t\t\thost.addMessageToChat(event.message);\n\t\t\t\thost.updatePendingMessagesDisplay();\n\t\t\t\thost.ui.requestRender();\n\t\t\t} else if (event.message.role === \"assistant\") {\n\t\t\t\thost.streamingMessage = event.message;\n\t\t\t\t// External-tool providers can stream multiple assistant turns through\n\t\t\t\t// one response. Delay component creation until visible assistant text\n\t\t\t\t// arrives so tool outputs keep chronological ordering.\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase \"message_update\":\n\t\t\tif (event.message.role === \"assistant\") {\n\t\t\t\thost.streamingMessage = event.message;\n\t\t\t\tconst innerEvent = event.assistantMessageEvent;\n\n\t\t\t\tlet externalToolResult:\n\t\t\t\t\t| { toolCallId: string; content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; details: Record<string, unknown>; isError: boolean }\n\t\t\t\t\t| undefined;\n\t\t\t\tif (innerEvent.type === \"toolcall_end\" && innerEvent.toolCall) {\n\t\t\t\t\tconst tc = innerEvent.toolCall as any;\n\t\t\t\t\tconst ext = tc.externalResult;\n\t\t\t\t\tif (ext) {\n\t\t\t\t\t\texternalToolResult = {\n\t\t\t\t\t\t\ttoolCallId: tc.id,\n\t\t\t\t\t\t\tcontent: ext.content ?? [{ type: \"text\", text: \"\" }],\n\t\t\t\t\t\t\tdetails: ext.details ?? {},\n\t\t\t\t\t\t\tisError: ext.isError ?? false,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t} else if (innerEvent.type === \"server_tool_use\") {\n\t\t\t\t\tconst idx = typeof innerEvent.contentIndex === \"number\" ? innerEvent.contentIndex : -1;\n\t\t\t\t\tconst block = idx >= 0 ? (host.streamingMessage.content[idx] as any) : undefined;\n\t\t\t\t\tconst ext = block?.externalResult;\n\t\t\t\t\tif (block?.id && ext) {\n\t\t\t\t\t\texternalToolResult = {\n\t\t\t\t\t\t\ttoolCallId: block.id,\n\t\t\t\t\t\t\tcontent: ext.content ?? [{ type: \"text\", text: \"\" }],\n\t\t\t\t\t\t\tdetails: ext.details ?? {},\n\t\t\t\t\t\t\tisError: ext.isError ?? false,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst contentBlocks = host.streamingMessage.content;\n\t\t\t\t// Some adapters (notably claude-code) reuse a single assistant\n\t\t\t\t// lifecycle while internally spanning multiple provider sub-turns.\n\t\t\t\t// When a new sub-turn starts, content[] length shrinks back to 0/1.\n\t\t\t\t// The scan loop needs its index reset, AND the segment walker's\n\t\t\t\t// renderedSegments map must be cleared so existing text-run\n\t\t\t\t// components don't get overwritten in place with new sub-turn\n\t\t\t\t// content (#4144 regression). Prior sub-turn children stay in\n\t\t\t\t// chatContainer as frozen history; new segments append after them.\n\t\t\t\tif (contentBlocks.length < lastContentLength) {\n\t\t\t\t\trenderedSegments = [];\n\t\t\t\t\tlastPinnedText = \"\";\n\t\t\t\t\tlastProcessedContentIndex = 0;\n\t\t\t\t} else if (lastProcessedContentIndex >= contentBlocks.length) {\n\t\t\t\t\tlastProcessedContentIndex = 0;\n\t\t\t\t}\n\t\t\t\tlastContentLength = contentBlocks.length;\n\t\t\t\tfor (let i = lastProcessedContentIndex; i < contentBlocks.length; i++) {\n\t\t\t\t\tconst content = contentBlocks[i];\n\t\t\t\t\tif (content.type === \"toolCall\") {\n\t\t\t\t\t\tif (!host.pendingTools.has(content.id)) {\n\t\t\t\t\t\t\tconst component = new ToolExecutionComponent(\n\t\t\t\t\t\t\t\tcontent.name,\n\t\t\t\t\t\t\t\tcontent.arguments,\n\t\t\t\t\t\t\t\t{ showImages: host.settingsManager.getShowImages() },\n\t\t\t\t\t\t\t\thost.getRegisteredToolDefinition(content.name),\n\t\t\t\t\t\t\t\thost.ui,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcomponent.setExpanded(host.toolOutputExpanded);\n\t\t\t\t\t\t\thost.chatContainer.addChild(component);\n\t\t\t\t\t\t\thost.pendingTools.set(content.id, component);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\thost.pendingTools.get(content.id)?.updateArgs(content.arguments);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (content.type === \"serverToolUse\") {\n\t\t\t\t\t\tif (!host.pendingTools.has(content.id)) {\n\t\t\t\t\t\t\tconst component = new ToolExecutionComponent(\n\t\t\t\t\t\t\t\tcontent.name,\n\t\t\t\t\t\t\t\tcontent.input ?? {},\n\t\t\t\t\t\t\t\t{ showImages: host.settingsManager.getShowImages() },\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\thost.ui,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcomponent.setExpanded(host.toolOutputExpanded);\n\t\t\t\t\t\t\thost.chatContainer.addChild(component);\n\t\t\t\t\t\t\thost.pendingTools.set(content.id, component);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (content.type === \"webSearchResult\") {\n\t\t\t\t\t\tconst component = host.pendingTools.get(content.toolUseId);\n\t\t\t\t\t\tif (component) {\n\t\t\t\t\t\t\tif (process.env.PI_OFFLINE === \"1\") {\n\t\t\t\t\t\t\t\tcomponent.updateResult({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"Web search disabled (offline mode)\" }],\n\t\t\t\t\t\t\t\t\tisError: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst searchContent = content.content;\n\t\t\t\t\t\t\t\tconst isError = searchContent && typeof searchContent === \"object\" && \"type\" in (searchContent as any) && (searchContent as any).type === \"web_search_tool_result_error\";\n\t\t\t\t\t\t\t\tcomponent.updateResult({\n\t\t\t\t\t\t\t\t\tcontent: [{ type: \"text\", text: host.formatWebSearchResult(searchContent) }],\n\t\t\t\t\t\t\t\t\tisError: !!isError,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// When the stream adapter signals a completed tool call with an\n\t\t\t\t// external result (from Claude Code SDK), update the pending\n\t\t\t\t// ToolExecutionComponent immediately so output is visible in\n\t\t\t\t// real-time instead of waiting for the session to end.\n\t\t\t\tif (externalToolResult) {\n\t\t\t\t\tconst component = host.pendingTools.get(externalToolResult.toolCallId);\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\tcomponent.updateResult({\n\t\t\t\t\t\t\tcontent: externalToolResult.content,\n\t\t\t\t\t\t\tdetails: externalToolResult.details,\n\t\t\t\t\t\t\tisError: externalToolResult.isError,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Segment walker: render content blocks in stream order, append-only.\n\t\t\t\t// Build desired segment plan from content[].\n\t\t\t\t{\n\t\t\t\t\tconst blocks = host.streamingMessage.content;\n\t\t\t\t\ttype DesiredSegment =\n\t\t\t\t\t\t| { kind: \"text-run\"; startIndex: number; endIndex: number }\n\t\t\t\t\t\t| { kind: \"tool\"; contentIndex: number; toolId: string };\n\t\t\t\t\tconst desired: DesiredSegment[] = [];\n\t\t\t\t\tlet runStart = -1;\n\t\t\t\t\tfor (let i = 0; i < blocks.length; i++) {\n\t\t\t\t\t\tconst b = blocks[i];\n\t\t\t\t\t\tconst isText = b.type === \"text\" || b.type === \"thinking\";\n\t\t\t\t\t\tconst isTool = b.type === \"toolCall\" || b.type === \"serverToolUse\";\n\t\t\t\t\t\tif (isText) {\n\t\t\t\t\t\t\tif (runStart === -1) runStart = i;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (runStart !== -1) {\n\t\t\t\t\t\t\t\tdesired.push({ kind: \"text-run\", startIndex: runStart, endIndex: i - 1 });\n\t\t\t\t\t\t\t\trunStart = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (isTool) {\n\t\t\t\t\t\t\t\tdesired.push({ kind: \"tool\", contentIndex: i, toolId: b.id });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (runStart !== -1) {\n\t\t\t\t\t\tdesired.push({ kind: \"text-run\", startIndex: runStart, endIndex: blocks.length - 1 });\n\t\t\t\t\t}\n\n\t\t\t\t\t// Append any newly needed segments (never reorder existing ones).\n\t\t\t\t\tfor (const seg of desired) {\n\t\t\t\t\t\tif (seg.kind === \"tool\") {\n\t\t\t\t\t\t\t// Tool segments are already handled above via pendingTools; just\n\t\t\t\t\t\t\t// register them in renderedSegments if not yet tracked.\n\t\t\t\t\t\t\tconst existing = renderedSegments.find(\n\t\t\t\t\t\t\t\t(s) => s.kind === \"tool\" && s.contentIndex === seg.contentIndex,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (!existing) {\n\t\t\t\t\t\t\t\tconst comp = host.pendingTools.get(seg.toolId);\n\t\t\t\t\t\t\t\tif (comp) {\n\t\t\t\t\t\t\t\t\trenderedSegments.push({ kind: \"tool\", contentIndex: seg.contentIndex, component: comp });\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// text-run segment\n\t\t\t\t\t\t\tconst existing = renderedSegments.find(\n\t\t\t\t\t\t\t\t(s) => s.kind === \"text-run\" && s.startIndex === seg.startIndex,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (!existing) {\n\t\t\t\t\t\t\t\tconst comp = new AssistantMessageComponent(\n\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\thost.hideThinkingBlock,\n\t\t\t\t\t\t\t\t\thost.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\t\t\t\thost.settingsManager.getTimestampFormat(),\n\t\t\t\t\t\t\t\t\t{ startIndex: seg.startIndex, endIndex: seg.endIndex },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\thost.chatContainer.addChild(comp);\n\t\t\t\t\t\t\t\trenderedSegments.push({ kind: \"text-run\", startIndex: seg.startIndex, endIndex: seg.endIndex, component: comp });\n\t\t\t\t\t\t\t\thost.streamingComponent = comp;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update all trailing text-run segments with the latest message so\n\t\t\t\t\t// streaming text grows in place.\n\t\t\t\t\tfor (const seg of renderedSegments) {\n\t\t\t\t\t\tif (seg.kind === \"text-run\") {\n\t\t\t\t\t\t\t// Find corresponding desired segment to get current endIndex\n\t\t\t\t\t\t\tconst d = desired.find((ds) => ds.kind === \"text-run\" && ds.startIndex === seg.startIndex);\n\t\t\t\t\t\t\tif (d && d.kind === \"text-run\" && d.endIndex !== seg.endIndex) {\n\t\t\t\t\t\t\t\tseg.endIndex = d.endIndex;\n\t\t\t\t\t\t\t\tseg.component.setRange({ startIndex: seg.startIndex, endIndex: seg.endIndex });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tseg.component.updateContent(host.streamingMessage);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Keep streamingComponent pointing at the last text-run for message_end compatibility.\n\t\t\t\t\tconst lastTextSeg = [...renderedSegments].reverse().find((s) => s.kind === \"text-run\");\n\t\t\t\t\tif (lastTextSeg && lastTextSeg.kind === \"text-run\") {\n\t\t\t\t\t\thost.streamingComponent = lastTextSeg.component;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Update index: fully processed blocks won't need re-scanning.\n\t\t\t\t// Keep the last block's index (it may still be accumulating data),\n\t\t\t\t// so we re-check it next time but skip all earlier ones.\n\t\t\t\tif (contentBlocks.length > 0) {\n\t\t\t\t\tlastProcessedContentIndex = Math.max(0, contentBlocks.length - 1);\n\t\t\t\t}\n\n\t\t\t\t// Pinned message: mirror the latest assistant text above the editor\n\t\t\t\t// when tool executions push it out of the viewport.\n\t\t\t\tconst hasTools = contentBlocks.some(\n\t\t\t\t\t(c: any) => c.type === \"toolCall\" || c.type === \"serverToolUse\",\n\t\t\t\t);\n\t\t\t\tif (hasTools) hasToolsInTurn = true;\n\n\t\t\t\tif (hasToolsInTurn) {\n\t\t\t\t\tconst latestText = findLatestPinnableText(contentBlocks);\n\n\t\t\t\t\tif (latestText && latestText !== lastPinnedText) {\n\t\t\t\t\t\tlastPinnedText = latestText;\n\n\t\t\t\t\t\tif (!pinnedBorder) {\n\t\t\t\t\t\t\t// First time: create border + text component\n\t\t\t\t\t\t\thost.pinnedMessageContainer.clear();\n\t\t\t\t\t\t\tpinnedBorder = new DynamicBorder(\n\t\t\t\t\t\t\t\t(str: string) => theme.fg(\"dim\", str),\n\t\t\t\t\t\t\t\t\"Working · Latest Output\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tpinnedBorder.startSpinner(host.ui, (str: string) => theme.fg(\"accent\", str));\n\t\t\t\t\t\t\thost.pinnedMessageContainer.addChild(pinnedBorder);\n\t\t\t\t\t\t\tpinnedTextComponent = new Markdown(latestText, 1, 0, host.getMarkdownThemeWithSettings());\n\t\t\t\t\t\t\t// Cap pinned content to ~40% of terminal height so tall output\n\t\t\t\t\t\t\t// doesn't exceed the viewport and cause render flashing.\n\t\t\t\t\t\t\tpinnedTextComponent.maxLines = Math.max(3, Math.floor(host.ui.terminal.rows * 0.4));\n\t\t\t\t\t\t\thost.pinnedMessageContainer.addChild(pinnedTextComponent);\n\t\t\t\t\t\t\t// Hide the separate status loader — the pinned zone replaces it\n\t\t\t\t\t\t\tif (host.loadingAnimation) {\n\t\t\t\t\t\t\t\thost.loadingAnimation.stop();\n\t\t\t\t\t\t\t\thost.loadingAnimation = undefined;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thost.statusContainer.clear();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Update existing markdown component in-place\n\t\t\t\t\t\t\tpinnedTextComponent?.setText(latestText);\n\t\t\t\t\t\t\t// Refresh maxLines in case terminal was resized\n\t\t\t\t\t\t\tif (pinnedTextComponent) {\n\t\t\t\t\t\t\t\tpinnedTextComponent.maxLines = Math.max(3, Math.floor(host.ui.terminal.rows * 0.4));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase \"message_end\":\n\t\t\tif (event.message.role === \"user\") break;\n\t\t\tif (event.message.role === \"assistant\") {\n\t\t\t\thost.streamingMessage = event.message;\n\t\t\t\tlet errorMessage: string | undefined;\n\t\t\t\tif (host.streamingMessage.stopReason === \"aborted\") {\n\t\t\t\t\tconst retryAttempt = host.session.retryAttempt;\n\t\t\t\t\terrorMessage = retryAttempt > 0\n\t\t\t\t\t\t? `Aborted after ${retryAttempt} retry attempt${retryAttempt > 1 ? \"s\" : \"\"}`\n\t\t\t\t\t\t: \"Operation aborted\";\n\t\t\t\t\thost.streamingMessage.errorMessage = errorMessage;\n\t\t\t\t}\n\n\t\t\t\tconst shouldRenderAssistant = hasVisibleAssistantContent(host.streamingMessage)\n\t\t\t\t\t|| (\n\t\t\t\t\t\t(host.streamingMessage.stopReason === \"aborted\" || host.streamingMessage.stopReason === \"error\")\n\t\t\t\t\t\t&& !hasAssistantToolBlocks(host.streamingMessage)\n\t\t\t\t\t);\n\t\t\t\tif (!host.streamingComponent && shouldRenderAssistant) {\n\t\t\t\t\thost.streamingComponent = new AssistantMessageComponent(\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\thost.hideThinkingBlock,\n\t\t\t\t\t\thost.getMarkdownThemeWithSettings(),\n\t\t\t\t\t\thost.settingsManager.getTimestampFormat(),\n\t\t\t\t\t);\n\t\t\t\t\thost.chatContainer.addChild(host.streamingComponent);\n\t\t\t\t}\n\t\t\t\tif (host.streamingComponent) {\n\t\t\t\t\thost.streamingComponent.setShowMetadata(true);\n\t\t\t\t\thost.streamingComponent.updateContent(host.streamingMessage);\n\t\t\t\t}\n\n\t\t\t\tif (host.streamingMessage.stopReason === \"aborted\" || host.streamingMessage.stopReason === \"error\") {\n\t\t\t\t\tif (!errorMessage) {\n\t\t\t\t\t\terrorMessage = host.streamingMessage.errorMessage || \"Error\";\n\t\t\t\t\t}\n\t\t\t\t\tconst pendingComponents = Array.from(host.pendingTools.values());\n\t\t\t\t\tif (pendingComponents.length > 0) {\n\t\t\t\t\t\tconst [first, ...rest] = pendingComponents;\n\t\t\t\t\t\tfirst.completeWithError(errorMessage);\n\t\t\t\t\t\tfor (const component of rest) {\n\t\t\t\t\t\t\tcomponent.completeWithError();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thost.pendingTools.clear();\n\t\t\t\t} else {\n\t\t\t\t\tfor (const [, component] of host.pendingTools.entries()) {\n\t\t\t\t\t\tcomponent.setArgsComplete();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\thost.streamingComponent = undefined;\n\t\t\t\thost.streamingMessage = undefined;\n\t\t\t\trenderedSegments = [];\n\t\t\t\tlastContentLength = 0;\n\t\t\t\t// Clear pinned output once the message is finalized in the chat\n\t\t\t\t// container — prevents duplicate display when the agent continues\n\t\t\t\t// (e.g. form elicitation) after the assistant message ends.\n\t\t\t\tif (pinnedBorder) pinnedBorder.stopSpinner();\n\t\t\t\thost.pinnedMessageContainer.clear();\n\t\t\t\tlastPinnedText = \"\";\n\t\t\t\thasToolsInTurn = false;\n\t\t\t\tpinnedBorder = undefined;\n\t\t\t\tpinnedTextComponent = undefined;\n\t\t\t\thost.footer.invalidate();\n\t\t\t}\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"tool_execution_start\":\n\t\t\tif (!host.pendingTools.has(event.toolCallId)) {\n\t\t\t\tconst component = new ToolExecutionComponent(\n\t\t\t\t\tevent.toolName,\n\t\t\t\t\tevent.args,\n\t\t\t\t\t{ showImages: host.settingsManager.getShowImages() },\n\t\t\t\t\thost.getRegisteredToolDefinition(event.toolName),\n\t\t\t\t\thost.ui,\n\t\t\t\t);\n\t\t\t\tcomponent.setExpanded(host.toolOutputExpanded);\n\t\t\t\thost.chatContainer.addChild(component);\n\t\t\t\thost.pendingTools.set(event.toolCallId, component);\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase \"tool_execution_update\": {\n\t\t\tconst component = host.pendingTools.get(event.toolCallId);\n\t\t\tif (component) {\n\t\t\t\tcomponent.updateResult({ ...event.partialResult, isError: false }, true);\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"tool_execution_end\": {\n\t\t\tconst component = host.pendingTools.get(event.toolCallId);\n\t\t\tif (component) {\n\t\t\t\tcomponent.updateResult({ ...event.result, isError: event.isError });\n\t\t\t\thost.pendingTools.delete(event.toolCallId);\n\t\t\t\thost.ui.requestRender();\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase \"agent_end\":\n\t\t\tif (host.loadingAnimation) {\n\t\t\t\thost.loadingAnimation.stop();\n\t\t\t\thost.loadingAnimation = undefined;\n\t\t\t\thost.statusContainer.clear();\n\t\t\t}\n\t\t\tif (host.streamingComponent) {\n\t\t\t\thost.chatContainer.removeChild(host.streamingComponent);\n\t\t\t\thost.streamingComponent = undefined;\n\t\t\t\thost.streamingMessage = undefined;\n\t\t\t}\n\t\t\thost.pendingTools.clear();\n\t\t\t// Pinned output is only useful while work is actively streaming.\n\t\t\t// Keep chat history as the single source after completion.\n\t\t\tif (pinnedBorder) {\n\t\t\t\tpinnedBorder.stopSpinner();\n\t\t\t}\n\t\t\thost.pinnedMessageContainer.clear();\n\t\t\tlastPinnedText = \"\";\n\t\t\thasToolsInTurn = false;\n\t\t\tpinnedBorder = undefined;\n\t\t\tpinnedTextComponent = undefined;\n\t\t\tawait host.checkShutdownRequested();\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"auto_compaction_start\":\n\t\t\thost.autoCompactionEscapeHandler = host.defaultEditor.onEscape;\n\t\t\thost.defaultEditor.onEscape = () => host.session.abortCompaction();\n\t\t\thost.statusContainer.clear();\n\t\t\thost.autoCompactionLoader = new Loader(\n\t\t\t\thost.ui,\n\t\t\t\t(spinner) => theme.fg(\"accent\", spinner),\n\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\t`${event.reason === \"overflow\" ? \"Context overflow detected, \" : \"\"}Auto-compacting... (${appKey(host.keybindings, \"interrupt\")} to cancel)`,\n\t\t\t);\n\t\t\thost.statusContainer.addChild(host.autoCompactionLoader);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"auto_compaction_end\":\n\t\t\tif (host.autoCompactionEscapeHandler) {\n\t\t\t\thost.defaultEditor.onEscape = host.autoCompactionEscapeHandler;\n\t\t\t\thost.autoCompactionEscapeHandler = undefined;\n\t\t\t}\n\t\t\tif (host.autoCompactionLoader) {\n\t\t\t\thost.autoCompactionLoader.stop();\n\t\t\t\thost.autoCompactionLoader = undefined;\n\t\t\t\thost.statusContainer.clear();\n\t\t\t}\n\t\t\tif (event.aborted) {\n\t\t\t\thost.showStatus(\"Auto-compaction cancelled\");\n\t\t\t} else if (event.result) {\n\t\t\t\thost.chatContainer.clear();\n\t\t\t\thost.rebuildChatFromMessages();\n\t\t\t\thost.addMessageToChat({\n\t\t\t\t\trole: \"compactionSummary\",\n\t\t\t\t\ttokensBefore: event.result.tokensBefore,\n\t\t\t\t\tsummary: event.result.summary,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t});\n\t\t\t\thost.footer.invalidate();\n\t\t\t} else if (event.errorMessage) {\n\t\t\t\thost.chatContainer.addChild(new Spacer(1));\n\t\t\t\thost.chatContainer.addChild(new Text(theme.fg(\"error\", event.errorMessage), 1, 0));\n\t\t\t}\n\t\t\tvoid host.flushCompactionQueue({ willRetry: event.willRetry });\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"auto_retry_start\":\n\t\t\thost.retryEscapeHandler = host.defaultEditor.onEscape;\n\t\t\thost.defaultEditor.onEscape = () => host.session.abortRetry();\n\t\t\thost.statusContainer.clear();\n\t\t\thost.retryLoader = new Loader(\n\t\t\t\thost.ui,\n\t\t\t\t(spinner) => theme.fg(\"warning\", spinner),\n\t\t\t\t(text) => theme.fg(\"muted\", text),\n\t\t\t\t`Retrying (${event.attempt}/${event.maxAttempts}) in ${Math.round(event.delayMs / 1000)}s... (${appKey(host.keybindings, \"interrupt\")} to cancel)`,\n\t\t\t);\n\t\t\thost.statusContainer.addChild(host.retryLoader);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"auto_retry_end\":\n\t\t\tif (host.retryEscapeHandler) {\n\t\t\t\thost.defaultEditor.onEscape = host.retryEscapeHandler;\n\t\t\t\thost.retryEscapeHandler = undefined;\n\t\t\t}\n\t\t\tif (host.retryLoader) {\n\t\t\t\thost.retryLoader.stop();\n\t\t\t\thost.retryLoader = undefined;\n\t\t\t\thost.statusContainer.clear();\n\t\t\t}\n\t\t\tif (!event.success) {\n\t\t\t\thost.showError(`Retry failed after ${event.attempt} attempts: ${event.finalError || \"Unknown error\"}`);\n\t\t\t}\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"fallback_provider_switch\":\n\t\t\thost.showStatus(`Switched from ${event.from} → ${event.to} (${event.reason})`);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"fallback_provider_restored\":\n\t\t\thost.showStatus(`Restored to ${event.provider}`);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"fallback_chain_exhausted\":\n\t\t\thost.showError(event.reason);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\n\t\tcase \"image_overflow_recovery\":\n\t\t\thost.showStatus(\n\t\t\t\t`Removed ${event.strippedCount} older image(s) to comply with API limits. Retrying...`,\n\t\t\t);\n\t\t\thost.ui.requestRender();\n\t\t\tbreak;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive-mode.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-mode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,EAAoB,YAAY,EAAmC,MAAM,YAAY,CAAC;AAWlG,OAAO,EAUN,KAAK,QAAQ,IAAI,WAAW,EAK5B,MAAM,aAAa,CAAC;AASrB,OAAO,EAAE,KAAK,YAAY,EAA2C,MAAM,6BAA6B,CAAC;AAEzG,OAAO,KAAK,EAGX,kBAAkB,EAGlB,MAAM,gCAAgC,CAAC;AAgFxC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,4DAA4D;IAC5D,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;IAC/B,4DAA4D;IAC5D,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,0GAA0G;IAC1G,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mGAAmG;IACnG,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,cAAc,GAAG,SAAS,GAAG,QAAQ,CAAC;CACzD;AAED,qBAAa,eAAe;IAsH1B,OAAO,CAAC,OAAO;IAnHhB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAO;IAElD,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,EAAE,CAAM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AAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM9B,iBAAiB,IAAI,MAAM,GAAG,SAAS;IAIvC,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAsBpD;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,4BAA4B;IAmBpC,OAAO,CAAC,6BAA6B;IAqBrC,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,mBAAmB;YA0Bb,oBAAoB;IA6ElC,6DAA6D;IAC7D,OAAO,CAAC,0BAA0B;IAYlC;;;OAGG;IACH,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,oBAAoB;YA+Id,kBAAkB;YAIlB,mBAAmB;YAInB,kBAAkB;IAIhC,iFAAiF;YACnE,4BAA4B;IAI1C,OAAO,CAAC,iBAAiB;YA+BX,kBAAkB;IAsHhC,OAAO,CAAC,uBAAuB;IAmC/B,OAAO,CAAC,gBAAgB;IAgIxB,OAAO,CAAC,mBAAmB;YAmCb,mBAAmB;IA6BjC,OAAO,CAAC,mBAAmB;YAoCb,iBAAiB;YAuEjB,eAAe;YAgGf,mBAAmB;YAuEnB,kBAAkB;IA4BhC,OAAO,CAAC,kBAAkB;IAiC1B,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,qBAAqB;YAMf,iBAAiB;YA0FjB,iBAAiB;IAwD/B,aAAa,CAAC,KAAK,UAAQ,GAAG,IAAI;IAKlC,IAAI,IAAI,IAAI;CA2CZ"}
|
|
@@ -1084,7 +1084,9 @@ export class InteractiveMode {
|
|
|
1084
1084
|
return;
|
|
1085
1085
|
// widgetContainerAbove: spacer collapses when pinned content is visible
|
|
1086
1086
|
// so there's no extra blank line between pinned output and the editor border.
|
|
1087
|
-
|
|
1087
|
+
// Use detachChildren() (not clear()) — the extensionWidgetsAbove map owns
|
|
1088
|
+
// disposal; clear() would dispose every mounted widget on every re-render.
|
|
1089
|
+
this.widgetContainerAbove.detachChildren();
|
|
1088
1090
|
const pinned = this.pinnedMessageContainer;
|
|
1089
1091
|
this.widgetContainerAbove.addChild({
|
|
1090
1092
|
render: () => pinned.children.length > 0 ? [] : [""],
|
|
@@ -1097,7 +1099,9 @@ export class InteractiveMode {
|
|
|
1097
1099
|
this.ui.requestRender();
|
|
1098
1100
|
}
|
|
1099
1101
|
renderWidgetContainer(container, widgets, spacerWhenEmpty, leadingSpacer) {
|
|
1100
|
-
|
|
1102
|
+
// Detach without disposing — the widgets map owns lifecycle; disposing
|
|
1103
|
+
// here would kill refresh timers and subscriptions on every re-render.
|
|
1104
|
+
container.detachChildren();
|
|
1101
1105
|
if (widgets.size === 0) {
|
|
1102
1106
|
if (spacerWhenEmpty) {
|
|
1103
1107
|
container.addChild(new Spacer(1));
|
|
@@ -1843,9 +1847,13 @@ export class InteractiveMode {
|
|
|
1843
1847
|
}
|
|
1844
1848
|
rebuildChatFromMessages() {
|
|
1845
1849
|
this.chatContainer.clear();
|
|
1850
|
+
this.pinnedMessageContainer.clear();
|
|
1846
1851
|
const context = this.sessionManager.buildSessionContext();
|
|
1847
1852
|
this.renderSessionContext(context);
|
|
1848
|
-
|
|
1853
|
+
// Pinned content NOT re-populated here — the streaming lifecycle in
|
|
1854
|
+
// chat-controller.ts manages the pinned zone during active work.
|
|
1855
|
+
// populatePinnedFromMessages() remains in renderInitialMessages()
|
|
1856
|
+
// for the session-resume case at startup.
|
|
1849
1857
|
}
|
|
1850
1858
|
/**
|
|
1851
1859
|
* After rebuilding chat from messages, pin the last assistant text above the
|