Proposed fix

This commit is contained in:
Tat Dat Duong
2025-03-07 21:26:48 +01:00
parent 5d4e33bb52
commit 6204bb984d
3 changed files with 15 additions and 14 deletions

View File

@@ -89,15 +89,16 @@ export async function executor(
],
};
ui.write("proposed-change", {
const msg = ui.create("proposed-change", {
toolCallId,
change: updateFileContents,
planItem,
});
msg.additional_kwargs["message_id"] = aiMessage.id;
return {
messages: [aiMessage],
ui: ui.collect as OpenCodeUpdate["ui"],
ui: [msg],
timestamp: Date.now(),
};
}

View File

@@ -55,11 +55,12 @@ export async function planner(
],
};
ui.write("code-plan", {
const msg = ui.create("code-plan", {
toolCallId,
executedPlans,
remainingPlans,
});
msg.additional_kwargs["message_id"] = aiMessage.id;
const toolMessage: ToolMessage = {
type: "tool",
@@ -70,7 +71,7 @@ export async function planner(
return {
messages: [aiMessage, toolMessage],
ui: ui.collect as OpenCodeUpdate["ui"],
ui: [msg],
timestamp: Date.now(),
};
}

View File

@@ -18,29 +18,28 @@ function CustomComponent({
const [apiUrl] = useQueryParam("apiUrl", StringParam);
const meta = thread.getMessagesMetadata(message);
const seenState = meta?.firstSeenState;
const customComponent = seenState?.values.ui
const customComponents = seenState?.values.ui
?.slice()
.reverse()
.find(
.filter(
({ additional_kwargs }) =>
additional_kwargs.run_id === seenState.metadata?.run_id,
additional_kwargs.run_id === seenState.metadata?.run_id &&
(!additional_kwargs.message_id ||
additional_kwargs.message_id === message.id),
);
if (!customComponent) {
return null;
}
if (!customComponents?.length) return null;
return (
<div key={message.id}>
{customComponent && (
{customComponents.map((customComponent) => (
<LoadExternalComponent
key={customComponent.id}
apiUrl={apiUrl ?? undefined}
assistantId="agent"
stream={thread}
message={customComponent}
meta={{ ui: customComponent }}
/>
)}
))}
</div>
);
}