Skip to content

Commit 0d31fdb

Browse files
committed
fix(app): part type gate
1 parent 09f37e9 commit 0d31fdb

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

packages/ui/src/components/message-part.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ export function AssistantParts(props: {
494494
{(() => {
495495
const parts = createMemo(
496496
() => {
497-
const entry = entryAccessor() as { type: "context"; refs: PartRef[] }
497+
const entry = entryAccessor()
498+
if (entry.type !== "context") return emptyTools
498499
return entry.refs
499500
.map((ref) => partByID(list(data.store.part?.[ref.messageID], emptyParts), ref.partID))
500501
.filter((part): part is ToolPart => !!part && isContextGroupTool(part))
@@ -514,11 +515,13 @@ export function AssistantParts(props: {
514515
<Match when={entryType() === "part"}>
515516
{(() => {
516517
const message = createMemo(() => {
517-
const entry = entryAccessor() as { type: "part"; ref: PartRef }
518+
const entry = entryAccessor()
519+
if (entry.type !== "part") return
518520
return props.messages.find((item) => item.id === entry.ref.messageID)
519521
})
520522
const part = createMemo(() => {
521-
const entry = entryAccessor() as { type: "part"; ref: PartRef }
523+
const entry = entryAccessor()
524+
if (entry.type !== "part") return
522525
return partByID(list(data.store.part?.[entry.ref.messageID], emptyParts), entry.ref.partID)
523526
})
524527

@@ -711,7 +714,8 @@ export function AssistantMessageDisplay(props: {
711714
{(() => {
712715
const parts = createMemo(
713716
() => {
714-
const entry = entryAccessor() as { type: "context"; refs: PartRef[] }
717+
const entry = entryAccessor()
718+
if (entry.type !== "context") return emptyTools
715719
return entry.refs
716720
.map((ref) => partByID(props.parts, ref.partID))
717721
.filter((part): part is ToolPart => !!part && isContextGroupTool(part))
@@ -730,7 +734,8 @@ export function AssistantMessageDisplay(props: {
730734
<Match when={entryType() === "part"}>
731735
{(() => {
732736
const part = createMemo(() => {
733-
const entry = entryAccessor() as { type: "part"; ref: PartRef }
737+
const entry = entryAccessor()
738+
if (entry.type !== "part") return
734739
return partByID(props.parts, entry.ref.partID)
735740
})
736741

0 commit comments

Comments
 (0)