Skip to content

Commit 431e058

Browse files
authored
fix(app): filter non-renderable part types from browser store (#18926)
1 parent fde201c commit 431e058

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

packages/app/src/context/global-sync/event-reducer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import type { State, VcsCache } from "./types"
1515
import { trimSessions } from "./session-trim"
1616
import { dropSessionCaches } from "./session-cache"
1717

18+
const SKIP_PARTS = new Set(["patch", "step-start", "step-finish"])
19+
1820
export function applyGlobalEvent(input: {
1921
event: { type: string; properties?: unknown }
2022
project: Project[]
@@ -211,6 +213,7 @@ export function applyDirectoryEvent(input: {
211213
}
212214
case "message.part.updated": {
213215
const part = (event.properties as { part: Part }).part
216+
if (SKIP_PARTS.has(part.type)) break
214217
const parts = input.store.part[part.messageID]
215218
if (!parts) {
216219
input.setStore("part", part.messageID, [part])

packages/app/src/context/sync.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { useSDK } from "./sdk"
1414
import type { Message, Part } from "@opencode-ai/sdk/v2/client"
1515
import { SESSION_CACHE_LIMIT, dropSessionCaches, pickSessionCacheEvictions } from "./global-sync/session-cache"
1616

17+
const SKIP_PARTS = new Set(["patch", "step-start", "step-finish"])
18+
1719
function sortParts(parts: Part[]) {
1820
return parts.filter((part) => !!part?.id).sort((a, b) => cmp(a.id, b.id))
1921
}
@@ -336,7 +338,8 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
336338
batch(() => {
337339
input.setStore("message", input.sessionID, reconcile(message, { key: "id" }))
338340
for (const p of next.part) {
339-
input.setStore("part", p.id, p.part)
341+
const filtered = p.part.filter((x) => !SKIP_PARTS.has(x.type))
342+
if (filtered.length) input.setStore("part", p.id, filtered)
340343
}
341344
setMeta("limit", key, message.length)
342345
setMeta("cursor", key, next.cursor)

0 commit comments

Comments
 (0)