Repository navigation
Add AI Chats sidebar section with list and + New chat - #2178
Merged
Merged
Conversation
Adds a top-level "AI Chats" sidebar section, a sibling of Collections and
Schema Types (not nested under Schema Types, and ai-chat is not added to
SIDENAV_CORE_TYPES). It lists existing ai-chat nodes most-recently-modified
first, with a "+ New chat" action that creates immediately (no name prompt,
unlike collections) and opens the new chat in a tab.
- New aiChatsData store (ai-chats.svelte.ts): loads via
backendAdapter.queryNodes({ nodeType: 'ai-chat', limit: 50 }), sorts
client-side by modifiedAt (the query has no order-by), and exposes
createChat() backed by createSchemaInstance('ai-chat') with
createBusy/createError for the button's in-flight/failure states.
- layout store gains aiChatsExpanded (interface field, default false,
persisted-hydration, setAiChatsExpanded, module export), and
layout-persistence-service bumps to schema version 4 to persist it,
with a v3->v4 migration step.
- navigation-sidebar.svelte renders the new Collapsible section (expanded
and collapsed-icon variants), reusing the existing aiSquare glyph markup.
Clicking a chat reuses the tab-reuse pattern from handleSchemaClick, but
routes nodeType: 'ai-chat' so it opens via AiChatNodeViewer instead of
QueryNodeViewer. Empty-content chats show "Untitled chat".
- database.svelte.ts reloads aiChatsData on database switch, mirroring the
existing collectionsData/schemasData reload.
Tests: layout-store/persistence-service round-trip of aiChatsExpanded
(including the v1->v4 and v3->v4 migration paths), and ai-chats store
load-sort/create/error-recovery behavior.
…race - loadAiChats() no longer passes a fetch-side limit to queryNodes. The backend query has no order-by, so a fetch-side LIMIT returns an arbitrary (effectively insertion-order) subset with no ORDER BY clause; sorting that subset afterward could not recover chats the LIMIT had already excluded, silently hiding genuinely-recent ones once a user passed 50 ai-chat nodes. Now fetches everything, sorts by modifiedAt, then slices to DISPLAY_LIMIT — mirroring collectionsData.loadCollections(), which also fetches its full list unbounded. - createChat() gains a #generation guard (mirroring collectionsData's #generation around createCollection): if a database switch invalidates the store mid-create, the result is discarded instead of being written into (or erroring against) a store that now represents a different database. - New invalidateForDatabaseSwitch() bumps that generation and clears any stale createError left over from the previous database; wired into database.svelte.ts's switchTo alongside collectionsData.forgetLocallyCreated().
Contributor
Author
|
APPROVE Adversarial review (code-review skill, effort=high) ran against the initial diff and found 4 issues, ranked real-bug/blocker-adjacent:
Fix commit: c8820a9. Full test suite (223 files / 4765 tests) and |
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a top-level "AI Chats" sidebar section — a sibling of Collections and Schema Types (not nested under Schema Types, and
ai-chatis NOT added toSIDENAV_CORE_TYPES). It lists existingai-chatnodes most-recently-modified first, with a "+ New chat" action that creates immediately (no name prompt, unlike Collections) and opens the new chat in a tab.This lands before core#2152 (which removes the
/ai-chatslash command), so there is no window where users lose a way to start a conversation.Changes
aiChatsDatastore (stores/ai-chats.svelte.ts): loads viabackendAdapter.queryNodes({ nodeType: 'ai-chat', limit: 50 }), sorts client-side bymodifiedAt(the query has no order-by), and exposescreateChat()backed bycreateSchemaInstance('ai-chat')withcreateBusy/createErrorfor the button's in-flight/failure states.layout.svelte.tsgainsaiChatsExpanded(interface field, defaultfalse, persisted-hydration line,setAiChatsExpanded, module export), andlayout-persistence-service.tsbumps its schema to version 4 to persist it, with a v3→v4 migration step.navigation-sidebar.svelterenders the newCollapsiblesection (expanded list + collapsed-icon variant), reusing the existingaiSquareglyph markup (design/icons/ui/ai-square.ts) inline since it doesn't fit through the shared icon-component path used elsewhere in the nav. Clicking a chat reuses the tab-reuse pattern fromhandleSchemaClick, but routesnodeType: 'ai-chat'so it opens viaAiChatNodeViewerinstead ofQueryNodeViewer. Empty-content chats (the normal state before core#1698's background titling runs) show "Untitled chat".database.svelte.tsreloadsaiChatsDataon database switch, mirroring the existingcollectionsData/schemasDatareload.Acceptance criteria
ai-chatNOT added toSIDENAV_CORE_TYPESaiChatsExpandedadded to layout store, persists across restartsAiChatNodeViewer; already-open chat activates existing tab instead of duplicatingconsole.*— usescreateLoggerTest plan
bun run test— all 223 test files / 4761 tests pass, including newai-chats.test.tsand updatedlayout.test.ts/layout-persistence-service.test.ts/database.test.tsbun run --cwd packages/desktop-app quality:fix— eslint + svelte-check clean (0 errors, 0 warnings)Closes #2153
🤖 Generated with Claude Code