Skip to content

Add ai-chat rename, and stop tab titles sticking on "Loading..." - #2463

Merged
mstomar125 merged 2 commits into
mainfrom
issue-2380-ai-chat-rename-and-tab-title
Sep 8, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-2380-ai-chat-rename-and-tab-title

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Closes #2380.

1. Rename an ai-chat node

An ai-chat's title lives in its content field with no UI path to edit it. Added click-to-edit in the viewer header: click the title text, an input replaces it, Enter or blur commits, Escape cancels and discards the draft.

  • aiChatDisplayTitle (new ai-chat-title.ts): empty/whitespace-only content displays as "Untitled chat" — matching the sidebar's existing convention, not the previous, different "AI Chat" fallback the viewer used. The sidebar's local aiChatLabel helper is deleted in favor of this shared one.
  • resolveChatTitleCommit: returns the trimmed draft to persist, or null when the trimmed draft is identical to what's already stored (a no-op write is skipped — it would otherwise bump modifiedAt and re-run the backend's mention extraction for nothing). Clearing a previously-set title returns '' (not null) — that's a real, intentional change that must persist.
  • aiChatsData.updateChatContent patches the sidebar's local chat list in place after a rename, mirroring how createChat already does an optimistic local update — no reload needed.

2. Tab title stuck on "Loading..." after load

Root-caused rather than patched: tab titles are already computed live on every render by computeTabTitle (tab-title.ts), driven reactively off the node in sharedNodeStore — so a rename already propagates to any open tab automatically, including tabs in the background, with no push mechanism needed. (I originally assumed no such live-recompute existed and started building one — it already exists, tab-system.svelte already calls it per render.)

The actual bug was computeTabTitle's own fallback: once a node is hydrated but resolves to no title of its own (e.g. a brand-new ai-chat with empty content), it fell back to tab.title — the tab's own stale placeholder — which is exactly "Loading...", and a genuinely titleless node never makes pluginRegistry.getNodeTitle return truthy, so it never cleared. Now it falls through to formatTabTitle's own 'Untitled' default instead, which is only reached once the node has actually loaded.

This is a single, generic fix (not ai-chat-specific) — it applies to every node type opened with the 'Loading...' placeholder. After #2432 merged, all four of the placeholder's original call sites (3x navigation-sidebar.svelte, 1x search-pane.svelte) were already consolidated into one function, NavigationService.focusOrOpenNode, whose stale doc comment ("viewers replace the placeholder on mount") is also corrected here to point at computeTabTitle instead.

Scoped out, with reasoning: "a node that fails to load leaves the tab stuck" — a node genuinely not found already closes its tab (pane-content.svelte's hydrateNode), and a fetch that fails for daemon-connectivity reasons already retries via onDaemonReconnect. No new failure mode is introduced by this PR, and I didn't find a concrete repro for an indefinitely-stuck tab beyond those two already-handled cases.

Test plan

  • 11 new tests for aiChatDisplayTitle/resolveChatTitleCommit (ai-chat-title.test.ts), each individually mutation-tested
  • 2 new tests for aiChatsData.updateChatContent, each individually mutation-tested
  • Modified computeTabTitle test re-verified via mutation testing (reverting to the old buggy fallback makes exactly the intended test fail, and only that one)
  • bun run test — 233 files / 4908 tests pass
  • svelte-check / tsc --noEmit / eslint — clean
  • Full pre-push gate (test:all + cargo build --bin nodespaced + test:e2e) — green (took several retries due to unrelated system-load flakiness from 4 parallel agents doing heavy builds on this machine — 3 different failures across 3 unrelated subsystems never touched by this diff: model-store/browser-sync-service fake-timer runaway, architecture-benchmarks timing thresholds, packages/agent's pty::manager pruning timeout — all confirmed unrelated by file scope and by passing in isolation)

🤖 Generated with Claude Code

mstomar125 and others added 2 commits September 8, 2026 12:01
1. ai-chat's title lives in its content field with no UI path to edit
it. Add click-to-edit in the viewer header: click the title to get an
input, Enter/blur commits, Escape cancels. Empty/whitespace-only titles
fall back to "Untitled chat" for display (aiChatDisplayTitle), matching
the sidebar's existing convention rather than the previous, different
"AI Chat" fallback. The commit itself is a no-op write when the trimmed
draft matches what's already stored (resolveChatTitleCommit). Both
functions live in the new ai-chat-title.ts so the viewer and the
sidebar's chat list can't drift on what "no title yet" means.

2. Root-caused the "Loading..." tab title that never updates: tab
titles are computed live every render by computeTabTitle
(tab-title.ts), driven reactively off the node in sharedNodeStore — so
renaming already propagates to any open tab automatically, no push
mechanism needed. The actual bug was computeTabTitle's own fallback:
once a node is hydrated but resolves to no title (e.g. a brand-new
ai-chat with empty content), it fell back to tab.title — the tab's
OWN stale placeholder — which is exactly "Loading..." and never
changes again. Now it falls through to formatTabTitle's own 'Untitled'
default instead, which only ever applies once the node has genuinely
loaded.

Also: patches ai-chats.svelte's local list in place after a rename
(updateChatContent) so the sidebar reflects it without a reload, and
corrects a stale doc comment on NavigationService.FocusOrOpenOptions
that claimed viewers replace the "Loading..." placeholder on mount —
no viewer ever did; computeTabTitle is what actually replaces it.

"A node that fails to load leaves the tab stuck" is not separately
addressed: a node genuinely not found already closes its tab
(pane-content.svelte), and a fetch that fails for daemon-connectivity
reasons already retries via onDaemonReconnect — no new failure mode
introduced here.

Co-Authored-By: Claude <[email protected]>
Address review: computeTabTitle's hydrated-but-titleless fallback
previously replaced tab.title unconditionally with the generic
'Untitled', not just the literal 'Loading...' placeholder it was meant
to clear. That silently regressed the relationship picker's target
tabs — relationship-grouping.ts's rowLabel falls back to a related
node's raw id as a stable, distinguishing label when it has neither a
title nor content, and relationship-viewer-modal.svelte passes that as
the tab's initial title specifically so the tab bar shows something
other than "Loading...". Once such a node hydrated, the id was
discarded in favor of the same generic 'Untitled' every other titleless
node would also show — the identical-placeholder-rows problem the
fallback exists to avoid, reintroduced at the tab level.

Added LOADING_TAB_TITLE (navigation.svelte.ts) as the one canonical
value for the placeholder a new tab opens with. computeTabTitle now
only replaces tab.title with the generic fallback when it's exactly
that placeholder; any other caller-supplied title (real or a stable
stand-in like an id) survives hydration unchanged.

Not changed: pane-content.svelte's hydration-failure handling (the
review's other finding, "a node that fails to load leaves the tab
stuck"). A bounded retry-then-close there would fight the existing,
deliberate onDaemonReconnect design, which waits indefinitely for the
daemon to become healthy rather than giving up — exactly the mechanism
a fresh-install boot race (the daemon's socket not bound yet) depends
on. Closing the tab after one or two quick failures would reintroduce
that exact hang as a regression of its own. Left as originally scoped:
"not found" already closes the tab; a healthy daemon that still fails
a single fetch has no repro or existing mechanism to hang off here.

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot rename an ai-chat node, and its tab title stays 'Loading...' after load

1 participant