Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(llm_chat): name the new title of a rename before it runs
Elian Dorand57104a15c5e
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.css b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.cssindex 1c331570ff..1e1456be4a 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.css+++ b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.css@@ -105,6 +105,17 @@margin-left: 0.3rem;}+.llm-chat-tool-call-new-title {+ font-size: 0.75rem;++ &::before {+ content: "→";+ display: inline-block;+ margin-right: 0.3rem;+ opacity: 0.75;+ }+}+/* Sized as the glyphs beside it in `.expandable-line` (0.9rem in a 1.4rem line). */.llm-chat-tool-call-provider {diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.spec.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.spec.tsxindex 46a5bff1c0..06e29b3159 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.spec.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.spec.tsx@@ -513,6 +513,14 @@ describe("ToolCallCard", () => {expect(older?.querySelector(".llm-chat-tool-call-old-title")).toBeNull();});+ it("names the title a rename would give, after the note link, before the call runs", () => {+ const target = renderCard([ { id: "1", toolName: "rename_note", input: { noteId: "n", newTitle: "New" } } ]);+ const newTitle = target.querySelector(".llm-chat-tool-call-new-title");+ expect(newTitle?.textContent).toBe("New");+ expect(newTitle?.previousElementSibling?.querySelector(".note-link-stub")?.textContent).toBe("n");+ expect(target.querySelector(".llm-chat-tool-call-old-title")).toBeNull();+ });+it("says where a move took a note from and to", () => {const move = (id: string, result: object): ToolCall => ({id, toolName: "move_note", input: { noteId: "n", newParentNoteId: "to" }, result: JSON.stringify(result)diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.tsxindex 719216cf11..de9d4a2cb1 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallCard.tsx@@ -191,6 +191,7 @@ function ToolCallLabel({ toolCall, view }: { toolCall: ToolCall; view: ToolCallV<NoteRef noteId={refNoteId} parentNoteId={refParentId} move={move} /></span>)}+ {view?.trail}{view?.summary && <span className="llm-chat-tool-call-result-count">{view.summary}</span>}{toolCall.approval === "declined" && (<span className="llm-chat-tool-call-approval-badge">diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallViews.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallViews.tsxindex 30c7894f2b..a9dbec17a3 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ToolCallViews.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ToolCallViews.tsx@@ -26,6 +26,8 @@ const SVG_MIME = "image/svg+xml";export interface ToolCallView {/** Shown on the summary line before the note link, such as the title a rename replaced. */lead?: ComponentChildren;+ /** Shown on the summary line after the note link, such as the title a rename would give. */+ trail?: ComponentChildren;summary?: string;body?: ComponentChildren;}@@ -63,6 +65,14 @@ export function getToolCallView(toolCall: ToolCall): ToolCallView | null {return attribute ? { lead: <AttributePill {...attribute} /> } : null;}+ if (toolCall.toolName === "rename_note" && !toolCall.result) {+ // Before the rename, the note link still shows the title the rename replaces.+ const { newTitle } = toolCall.input;+ return typeof newTitle === "string"+ ? { trail: <span className="llm-chat-tool-call-new-title">{newTitle}</span> }+ : null;+ }+if (!toolCall.result) return null;switch (toolCall.toolName) {