Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions packages/core/test/tool-bash.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,9 @@ describe("BashTool — narration-only guidance", () => {
})
// Guidance is appended to the final content part (not injected into stdout)
const lastPart = settled.output?.content[settled.output.content.length - 1]
expect(lastPart?.text).toContain("[AlphaCode]")
expect(lastPart?.text).toContain("described an intended action")
const lastText = lastPart?.type === "text" ? lastPart.text : undefined
expect(lastText).toContain("[AlphaCode]")
expect(lastText).toContain("described an intended action")
// Exit code handling is not affected
expect(settled.output?.structured).toMatchObject({ exit: 0, truncated: false })
}),
Expand All @@ -467,7 +468,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
const lastPart = settled.output?.content[settled.output.content.length - 1]
expect(lastPart?.text).toContain("[AlphaCode]")
expect(lastPart?.type === "text" ? lastPart.text : undefined).toContain("[AlphaCode]")
}),
),
)
Expand All @@ -487,7 +488,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
const lastPart = settled.output?.content[settled.output.content.length - 1]
expect(lastPart?.text).toContain("[AlphaCode]")
expect(lastPart?.type === "text" ? lastPart.text : undefined).toContain("[AlphaCode]")
}),
),
)
Expand All @@ -507,7 +508,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
const lastPart = settled.output?.content[settled.output.content.length - 1]
expect(lastPart?.text).toContain("[AlphaCode]")
expect(lastPart?.type === "text" ? lastPart.text : undefined).toContain("[AlphaCode]")
}),
),
)
Expand All @@ -528,7 +529,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
for (const part of settled.output?.content ?? []) {
expect(part.text).not.toContain("[AlphaCode]")
if (part.type === "text") expect(part.text).not.toContain("[AlphaCode]")
}
}),
),
Expand All @@ -549,7 +550,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
for (const part of settled.output?.content ?? []) {
expect(part.text).not.toContain("[AlphaCode]")
if (part.type === "text") expect(part.text).not.toContain("[AlphaCode]")
}
}),
),
Expand All @@ -570,7 +571,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
for (const part of settled.output?.content ?? []) {
expect(part.text).not.toContain("[AlphaCode]")
if (part.type === "text") expect(part.text).not.toContain("[AlphaCode]")
}
}),
),
Expand All @@ -595,10 +596,11 @@ describe("BashTool — narration-only guidance", () => {
// Exit code is reported normally
expect(settled.output?.structured).toMatchObject({ exit: 1 })
const lastPart = settled.output?.content[settled.output.content.length - 1]
const lastText = lastPart?.type === "text" ? lastPart.text : undefined
// Guidance still appended
expect(lastPart?.text).toContain("[AlphaCode]")
expect(lastText).toContain("[AlphaCode]")
// Exit-code text still present
expect(lastPart?.text).toContain("Command exited with code 1")
expect(lastText).toContain("Command exited with code 1")
}),
),
)
Expand All @@ -623,7 +625,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
for (const part of settled.output?.content ?? []) {
expect(part.text).not.toContain("[AlphaCode]")
if (part.type === "text") expect(part.text).not.toContain("[AlphaCode]")
}
}),
),
Expand All @@ -644,7 +646,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
for (const part of settled.output?.content ?? []) {
expect(part.text).not.toContain("[AlphaCode]")
if (part.type === "text") expect(part.text).not.toContain("[AlphaCode]")
}
}),
),
Expand All @@ -665,7 +667,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
for (const part of settled.output?.content ?? []) {
expect(part.text).not.toContain("[AlphaCode]")
if (part.type === "text") expect(part.text).not.toContain("[AlphaCode]")
}
}),
),
Expand All @@ -690,7 +692,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
for (const part of settled.output?.content ?? []) {
expect(part.text).not.toContain("[AlphaCode]")
if (part.type === "text") expect(part.text).not.toContain("[AlphaCode]")
}
}),
),
Expand All @@ -711,7 +713,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
for (const part of settled.output?.content ?? []) {
expect(part.text).not.toContain("[AlphaCode]")
if (part.type === "text") expect(part.text).not.toContain("[AlphaCode]")
}
}),
),
Expand All @@ -732,7 +734,7 @@ describe("BashTool — narration-only guidance", () => {
Effect.andThen((settled) =>
Effect.sync(() => {
for (const part of settled.output?.content ?? []) {
expect(part.text).not.toContain("[AlphaCode]")
if (part.type === "text") expect(part.text).not.toContain("[AlphaCode]")
}
}),
),
Expand Down
32 changes: 26 additions & 6 deletions packages/tui/src/context/sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,21 +375,41 @@ export const {
break
}
case "message.part.updated": {
touchPart(event.properties.part.sessionID, event.properties.part.id)
const incoming = event.properties.part
touchPart(incoming.sessionID, incoming.id)
const parts = store.part[incoming.messageID]
if (!parts) {
setStore("part", incoming.messageID, [incoming])
break
}
// Mutate the existing part in place (via the store draft) so keyed
// `<For>` components over `part[messageID]` keep their identity and
// are not remounted for every streamed snapshot/delta — remounting
// rebuilds the markdown/syntax tree per token and shows up as
// aggressive redraw/flicker while streaming.
setStore(
"part",
event.properties.part.messageID,
applyPartUpdated(store.part[event.properties.part.messageID], event.properties.part),
incoming.messageID,
produce((draft) => {
applyPartUpdated(draft, incoming)
}),
)
break
}

case "message.part.delta": {
const parts = store.part[event.properties.messageID]
const next = applyPartDelta(parts, event.properties.partID, event.properties.field, event.properties.delta)
if (!next) break
if (!parts) break
const result = search(parts, event.properties.partID, (part) => part.id)
if (!result.found) break
touchPart(event.properties.sessionID, event.properties.partID)
setStore("part", event.properties.messageID, next)
setStore(
"part",
event.properties.messageID,
produce((draft) => {
applyPartDelta(draft, event.properties.partID, event.properties.field, event.properties.delta)
}),
)
break
}

Expand Down
Loading
Loading