summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-03-06 09:55:23 -0600
committerAdam <[email protected]>2026-03-06 09:56:02 -0600
commite0ca52ed1f77e2ffeaa5a455949c8d7c913b9175 (patch)
tree9645c682dbb15531260ff6982b217f850d0269c6
parent1d9dcd2a27736b83d20abc0111141fdd6bffde7e (diff)
downloadopencode-e0ca52ed1f77e2ffeaa5a455949c8d7c913b9175.tar.gz
opencode-e0ca52ed1f77e2ffeaa5a455949c8d7c913b9175.zip
fix(app): part type gate
-rw-r--r--packages/ui/src/components/message-part.tsx15
1 files changed, 10 insertions, 5 deletions
diff --git a/packages/ui/src/components/message-part.tsx b/packages/ui/src/components/message-part.tsx
index fbeb8bda2..f59b17e9a 100644
--- a/packages/ui/src/components/message-part.tsx
+++ b/packages/ui/src/components/message-part.tsx
@@ -494,7 +494,8 @@ export function AssistantParts(props: {
{(() => {
const parts = createMemo(
() => {
- const entry = entryAccessor() as { type: "context"; refs: PartRef[] }
+ const entry = entryAccessor()
+ if (entry.type !== "context") return emptyTools
return entry.refs
.map((ref) => partByID(list(data.store.part?.[ref.messageID], emptyParts), ref.partID))
.filter((part): part is ToolPart => !!part && isContextGroupTool(part))
@@ -514,11 +515,13 @@ export function AssistantParts(props: {
<Match when={entryType() === "part"}>
{(() => {
const message = createMemo(() => {
- const entry = entryAccessor() as { type: "part"; ref: PartRef }
+ const entry = entryAccessor()
+ if (entry.type !== "part") return
return props.messages.find((item) => item.id === entry.ref.messageID)
})
const part = createMemo(() => {
- const entry = entryAccessor() as { type: "part"; ref: PartRef }
+ const entry = entryAccessor()
+ if (entry.type !== "part") return
return partByID(list(data.store.part?.[entry.ref.messageID], emptyParts), entry.ref.partID)
})
@@ -711,7 +714,8 @@ export function AssistantMessageDisplay(props: {
{(() => {
const parts = createMemo(
() => {
- const entry = entryAccessor() as { type: "context"; refs: PartRef[] }
+ const entry = entryAccessor()
+ if (entry.type !== "context") return emptyTools
return entry.refs
.map((ref) => partByID(props.parts, ref.partID))
.filter((part): part is ToolPart => !!part && isContextGroupTool(part))
@@ -730,7 +734,8 @@ export function AssistantMessageDisplay(props: {
<Match when={entryType() === "part"}>
{(() => {
const part = createMemo(() => {
- const entry = entryAccessor() as { type: "part"; ref: PartRef }
+ const entry = entryAccessor()
+ if (entry.type !== "part") return
return partByID(props.parts, entry.ref.partID)
})