Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(local-models): the proposal card stays through a follow-up turn, and the chat hides the raw plan block

rubenluetke10-beepf99d2a8ab791
diff --git a/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.tsx b/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.tsx
index ed73506abd..fc6511208b 100644
--- a/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/local-models/AssistantPanel.tsx
@@ -45,6 +45,7 @@ import {
matchesConfirmedStep,
proposalFromText,
proposalHash,
+ stripProposalBlocks,
type Proposal,
type ProposalStep,
} from "./assistantProposal";
@@ -66,7 +67,9 @@ function lastAssistantText(items: readonly { type: string }[]): { text: string;
const item = items[i];
if (item.type !== "turn") continue;
const turn = item as TurnItem;
- if (turn.status !== "done") return null;
+ // A turn still streaming has no plan yet; the previous finished one keeps
+ // its card instead of the card blinking out for the length of a follow-up.
+ if (turn.status !== "done") continue;
const text = turn.blocks
.filter((b): b is TextBlock => b.kind === "text")
.map((b) => b.text)
@@ -194,6 +197,26 @@ export function AssistantPanel({
if (!running) void loadHealth();
}, [running, loadHealth]);
+ // The chat shows the words, the card shows the plan: the raw JSON block is
+ // stripped from every finished turn's text before the timeline sees it.
+ const displayItems = useMemo(
+ () =>
+ items.map((item) => {
+ if (item.type !== "turn") return item;
+ const turn = item as TurnItem;
+ if (!turn.blocks.some((b) => b.kind === "text" && /```jarvis-proposal/.test((b as TextBlock).text))) {
+ return item;
+ }
+ return {
+ ...turn,
+ blocks: turn.blocks.map((b) =>
+ b.kind === "text" ? { ...b, text: stripProposalBlocks((b as TextBlock).text) } : b,
+ ),
+ };
+ }),
+ [items],
+ );
+
// The plan in the last finished turn, if any.
const proposal: { value: Proposal; turnId: string } | null = useMemo(() => {
const last = lastAssistantText(items);
@@ -336,7 +359,7 @@ export function AssistantPanel({
{items.length > 0 && (
<div className="flex max-h-[60vh] flex-col gap-5 overflow-y-auto pr-1" data-testid="assistant-timeline">
<AgentTimeline
- items={items}
+ items={displayItems}
assistantName={assistantName}
providerLabel={providerLabel}
onDecide={onDecide}
diff --git a/jarvis/ui/web/frontend/src/components/local-models/assistantProposal.test.ts b/jarvis/ui/web/frontend/src/components/local-models/assistantProposal.test.ts
index 7e282773c6..012c9c0877 100644
--- a/jarvis/ui/web/frontend/src/components/local-models/assistantProposal.test.ts
+++ b/jarvis/ui/web/frontend/src/components/local-models/assistantProposal.test.ts
@@ -114,3 +114,14 @@ describe("matchesConfirmedStep", () => {
expect(matchesConfirmedStep({ name: "lm_pull", input: { model: "nomic-embed-text" } }, withoutEmbed)).toBe(false);
});
});
+
+
+describe("stripProposalBlocks", () => {
+ it("removes the fenced plan and keeps the words around it", async () => {
+ const { stripProposalBlocks } = await import("./assistantProposal");
+ const text = 'Here is the plan:\n\n```jarvis-proposal\n{"version":1,"steps":[]}\n```\n\nGeorge';
+ expect(stripProposalBlocks(text)).toBe("Here is the plan:\n\nGeorge");
+ expect(stripProposalBlocks("no plan here")).toBe("no plan here");
+ expect(stripProposalBlocks('cut ```jarvis-proposal\n{"ver')).toBe("cut");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/local-models/assistantProposal.ts b/jarvis/ui/web/frontend/src/components/local-models/assistantProposal.ts
index a9c27ad10e..24a7b66446 100644
--- a/jarvis/ui/web/frontend/src/components/local-models/assistantProposal.ts
+++ b/jarvis/ui/web/frontend/src/components/local-models/assistantProposal.ts
@@ -266,3 +266,13 @@ export function matchesConfirmedStep(
return false;
}
}
+
+/**
+ * `text` without its ```jarvis-proposal block(s): the plan is shown as the
+ * checklist card, so the raw JSON has no business in the chat bubble. A block
+ * with no closing fence (a cut-off stream) is stripped to the end of the text.
+ */
+export function stripProposalBlocks(text: string): string {
+ const re = /```jarvis-proposal[^\n]*\n[\s\S]*?(?:```|$)/g;
+ return text.replace(re, "").replace(/\n{3,}/g, "\n\n").trim();
+}