Repository navigation
AI-Chat provider picker: per-node dispatcher + hydration fix (#1220 follow-up) - #1225
Conversation
Follow-up to merged #1220. Turns the inert provider picker into a dropdown-driven, per-provider flow and fixes the real root cause of "clicking a provider does nothing". See .claude/HANDOFF-issue-1220-picker-redesign.md for the FULL context, decisions, and remaining work (read it first). ## Root cause found (via Playwright/WebKit live debugging) The picker persisted `provider` fine, but the viewer hydrates nodes from the `children-tree` endpoint, which returned `"properties": {}` — a #1222 (SurrealDB→libsql) regression: build_node_tree_recursive ran flatten_properties_for_api (drops props when the namespaced shape doesn't match) while every other endpoint returns raw props. Plus the ai-chat provider enum rejected the ADR-034 modes. ## Completed in this session - [x] Backend fix A: build_node_tree_recursive returns RAW properties (matches get_node/get_children/etc.). Regression test added. packages/core/src/services/node_service.rs - [x] Backend fix B: AiChatNodeBehavior::validate provider enum widened to native|ollama|openai|pty (ADR-034). Tests updated. packages/core/src/behaviors/mod.rs - [x] cargo test -p nodespace-core (behaviors + children-tree) green; daemon builds. - [x] tauri-commands.ts: added ChatModelEntry type + ollamaAvailable() wrapper; fixed chatModelList() return type (was wrongly ModelInfo[]). - [x] Renamed ai-chat-pty-view.svelte -> ai-chat-pty-session.svelte (naming: no *View/*Viewer suffix on helpers; AiChatNodeViewer is THE viewer). - [x] Added ai-chat-model-picker.svelte (native gguf + ollama model lists, download w/ progress, RAM-aware recommend). - [x] Stripped [DIAG] debug logs from ai-chat-node-viewer selectProvider. ## Remaining work (see HANDOFF doc for detail) - [ ] Move DisplayMessage -> packages/desktop-app/src/lib/components/chat/types.ts (architect-confirmed: it's a legit view-model; NOT in agent-types.ts/protocol boundary, NOT inside the .svelte). Repoint importers (viewer, chat-message, ai-chat-viewer.test). - [ ] Rewrite AiChatNodeViewer as the single dispatcher: header provider DROPDOWN (native / ollama[gray if !ollamaAvailable] / openai[disabled] / pty); route placeholder->dropdown, pty->ai-chat-pty-session, native|ollama w/o model-> ai-chat-model-picker, native|ollama w/ model->message UI. - [ ] Per-node send/stream (Option 1): the viewer owns its OWN session (localAgentNewSession/localAgentSend/streaming events/ensureModelReady using node.properties.provider+model), persists to node.properties.messages (ADR-028). NO shared store. - [ ] DELETE chatStore + ChatPanel (pre-ADR-034 ephemeral singleton; user: "no need to keep chatStore"). Remove: chat-store.svelte.ts, chat-panel.svelte, chat-store.test.ts; 'chat' tab type (navigation.ts), <ChatPanel> branch (pane-content.svelte:101), persistence guard (tab-persistence-service.ts); repoint "AI Chat" nav item to create/open a new ai-chat node. - [ ] Verify: cargo test -p nodespace-core; bun run test / test:all; quality:fix (NB: runs cargo fmt --all — revert stray reformats); Playwright e2e of the original bug (pick provider -> children-tree returns provider -> persists across reload); pty under tauri:dev only. ## Deferred to a SEPARATE follow-up issue - "AI Chat" sidebar item -> collapsible LIST of ai-chat nodes (like Collections). This PR only repoints it to create-a-node. - Typed canonical persisted-message schema owned by the ai-chat behavior + typed persisted<->DisplayMessage converters (replaces the untyped Record<string,unknown> mappers in the viewer — the real type-safety win). ## Current state - Branch: issue-1220-followup-provider-picker-conflict (== origin/main + this WIP; includes #1222 libsql + #1224 sqlite-vec). - Also carries the earlier skipConflictDetection fix in selectProvider (#1220 re-review follow-on) — intentional intentional-config-write guard. - Tests: Rust green; frontend NOT yet run against the new components (viewer rewrite pending — handleSend still references chatStore, will break build until the rewrite lands). - Dev env (this machine): daemon sidecar staged at target/debug/binaries/ *-aarch64-apple-darwin; old RocksDB daemon-db moved to daemon-db.surreal-bak-* (libsql needs a fresh DB); dev-tools @grpc deps installed; Playwright MCP set to --browser webkit. ## Key decisions (rationale in HANDOFF doc) - One inference engine (daemon) serves all ai-chat nodes via independent sessions. - Three message shapes kept distinct: ChatMessage (protocol), DisplayMessage (view-model), ADR-028 persisted JSON. Do NOT converge. - All providers (native/ollama/openai/pty) route through the daemon; never direct from the frontend. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…anel Completes the #1220 follow-up frontend integration on top of the backend fixes already on this branch (children-tree raw properties; provider enum widened to native|ollama|openai|pty). AiChatNodeViewer is now THE single dispatcher for the ai-chat type: - Header provider dropdown (Built-in / Ollama [grayed when not running] / OpenAI [disabled, no backend] / Agent terminal). - Routes on provider (+model): unset -> prompt; pty -> AiChatPtySession; native|ollama without model -> AiChatModelPicker; with model -> message UI. - Owns its OWN per-node daemon session (ensureModelReady -> localAgentNewSession -> localAgentSend + streaming/download/load event listeners), keyed off the node's provider/model. No shared store (Option 1, ADR-034). Persists to node.properties.messages with debounced flush + ADR-028 tool-result archival. - Hydration fallback: fetches the node by id on mount if absent from sharedNodeStore, so the dispatcher always has properties to route on (closes the root-cause class behind the original "picker does nothing"). DisplayMessage moved to components/chat/types.ts as the view-model type (architect-confirmed layering: protocol / view-model / persisted stay distinct). Importers repointed (chat-message, viewer, ai-chat-viewer.test). Deletions (pre-ADR-034 ephemeral singleton, no dual-mode per CLAUDE.md): chat-store.svelte.ts, chat-panel.svelte, chat-store.test.ts; the 'chat' tab type (navigation.ts), its <ChatPanel> branch (pane-content.svelte), persistence guard (tab-persistence-service.ts), and the dead chat-tab nav override (app-shell.svelte). "AI Chat" sidebar item commented out pending its rework into an expandable list of recent ai-chat nodes (follow-up issue). Incidental: the WIP's chatModelList() retype (ChatModelEntry[]) had broken its two consumers; retyped modelToAgent (agent-store) and added a ChatModelEntry -> ModelInfo adapter in model-store.refreshModels. Verified: svelte-check 0 errors; eslint clean; vitest 3913 passed / 129 files. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Pragmatic Code Review — PR #1225Review Type: Initial Review Requirements Check (vs HANDOFF "REVISED SCOPE")
Code Review Findings🟢 Suggestion — Ollama rows entering
|
malibio
left a comment
There was a problem hiding this comment.
Initial pragmatic code review posted as a PR comment. Recommendation: COMMENT (net-positive, no blockers; all findings are 🟢 suggestions). Leaving the merge call to a human per process.
… placeholder Addresses 🟢 suggestions from the PR #1225 review. - model-store now manages only built-in (GGUF) models — its consumers (model-manager, ai-onboarding-dialog) download by URL and recommend a model to fetch. refreshModels() filters to backend === 'gguf', so Ollama rows (which carry no URL here and are surfaced separately by AiChatModelPicker) can no longer leak into the list. This removes the dead-download-button and un-downloadable-recommendedModel hazards in one move. (findings #1, #2) - chatEntryToModelInfo infers family from the id (gemma* -> gemma4) instead of always 'ministral', and no longer carries a now-dead 'ollama' branch. (#2) - ai-chat-node-viewer: the transient model-prep progress placeholder is now updated by id (renderProgress helper) to match its by-id removal, so it's order-independent rather than relying on positional slice(0,-1). (#3) Skipped: adding unit tests for archiveMessages/loadMessagesFromNode (#4) — these functions are already covered by the "Tool result archival" and "Write buffering" suites in ai-chat-viewer.test.ts; adding more would duplicate existing coverage. Verified: svelte-check 0 errors; eslint clean; vitest 3913 passed / 129 files. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Review feedback addressed (commit
|
…ollow-up) (#1225) * WIP: AI-Chat provider picker redesign + hydration fix (handoff) Follow-up to merged #1220. Turns the inert provider picker into a dropdown-driven, per-provider flow and fixes the real root cause of "clicking a provider does nothing". See .claude/HANDOFF-issue-1220-picker-redesign.md for the FULL context, decisions, and remaining work (read it first). ## Root cause found (via Playwright/WebKit live debugging) The picker persisted `provider` fine, but the viewer hydrates nodes from the `children-tree` endpoint, which returned `"properties": {}` — a #1222 (SurrealDB→libsql) regression: build_node_tree_recursive ran flatten_properties_for_api (drops props when the namespaced shape doesn't match) while every other endpoint returns raw props. Plus the ai-chat provider enum rejected the ADR-034 modes. ## Completed in this session - [x] Backend fix A: build_node_tree_recursive returns RAW properties (matches get_node/get_children/etc.). Regression test added. packages/core/src/services/node_service.rs - [x] Backend fix B: AiChatNodeBehavior::validate provider enum widened to native|ollama|openai|pty (ADR-034). Tests updated. packages/core/src/behaviors/mod.rs - [x] cargo test -p nodespace-core (behaviors + children-tree) green; daemon builds. - [x] tauri-commands.ts: added ChatModelEntry type + ollamaAvailable() wrapper; fixed chatModelList() return type (was wrongly ModelInfo[]). - [x] Renamed ai-chat-pty-view.svelte -> ai-chat-pty-session.svelte (naming: no *View/*Viewer suffix on helpers; AiChatNodeViewer is THE viewer). - [x] Added ai-chat-model-picker.svelte (native gguf + ollama model lists, download w/ progress, RAM-aware recommend). - [x] Stripped [DIAG] debug logs from ai-chat-node-viewer selectProvider. ## Remaining work (see HANDOFF doc for detail) - [ ] Move DisplayMessage -> packages/desktop-app/src/lib/components/chat/types.ts (architect-confirmed: it's a legit view-model; NOT in agent-types.ts/protocol boundary, NOT inside the .svelte). Repoint importers (viewer, chat-message, ai-chat-viewer.test). - [ ] Rewrite AiChatNodeViewer as the single dispatcher: header provider DROPDOWN (native / ollama[gray if !ollamaAvailable] / openai[disabled] / pty); route placeholder->dropdown, pty->ai-chat-pty-session, native|ollama w/o model-> ai-chat-model-picker, native|ollama w/ model->message UI. - [ ] Per-node send/stream (Option 1): the viewer owns its OWN session (localAgentNewSession/localAgentSend/streaming events/ensureModelReady using node.properties.provider+model), persists to node.properties.messages (ADR-028). NO shared store. - [ ] DELETE chatStore + ChatPanel (pre-ADR-034 ephemeral singleton; user: "no need to keep chatStore"). Remove: chat-store.svelte.ts, chat-panel.svelte, chat-store.test.ts; 'chat' tab type (navigation.ts), <ChatPanel> branch (pane-content.svelte:101), persistence guard (tab-persistence-service.ts); repoint "AI Chat" nav item to create/open a new ai-chat node. - [ ] Verify: cargo test -p nodespace-core; bun run test / test:all; quality:fix (NB: runs cargo fmt --all — revert stray reformats); Playwright e2e of the original bug (pick provider -> children-tree returns provider -> persists across reload); pty under tauri:dev only. ## Deferred to a SEPARATE follow-up issue - "AI Chat" sidebar item -> collapsible LIST of ai-chat nodes (like Collections). This PR only repoints it to create-a-node. - Typed canonical persisted-message schema owned by the ai-chat behavior + typed persisted<->DisplayMessage converters (replaces the untyped Record<string,unknown> mappers in the viewer — the real type-safety win). ## Current state - Branch: issue-1220-followup-provider-picker-conflict (== origin/main + this WIP; includes #1222 libsql + #1224 sqlite-vec). - Also carries the earlier skipConflictDetection fix in selectProvider (#1220 re-review follow-on) — intentional intentional-config-write guard. - Tests: Rust green; frontend NOT yet run against the new components (viewer rewrite pending — handleSend still references chatStore, will break build until the rewrite lands). - Dev env (this machine): daemon sidecar staged at target/debug/binaries/ *-aarch64-apple-darwin; old RocksDB daemon-db moved to daemon-db.surreal-bak-* (libsql needs a fresh DB); dev-tools @grpc deps installed; Playwright MCP set to --browser webkit. ## Key decisions (rationale in HANDOFF doc) - One inference engine (daemon) serves all ai-chat nodes via independent sessions. - Three message shapes kept distinct: ChatMessage (protocol), DisplayMessage (view-model), ADR-028 persisted JSON. Do NOT converge. - All providers (native/ollama/openai/pty) route through the daemon; never direct from the frontend. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Make AiChatNodeViewer the per-node dispatcher; delete chatStore/ChatPanel Completes the #1220 follow-up frontend integration on top of the backend fixes already on this branch (children-tree raw properties; provider enum widened to native|ollama|openai|pty). AiChatNodeViewer is now THE single dispatcher for the ai-chat type: - Header provider dropdown (Built-in / Ollama [grayed when not running] / OpenAI [disabled, no backend] / Agent terminal). - Routes on provider (+model): unset -> prompt; pty -> AiChatPtySession; native|ollama without model -> AiChatModelPicker; with model -> message UI. - Owns its OWN per-node daemon session (ensureModelReady -> localAgentNewSession -> localAgentSend + streaming/download/load event listeners), keyed off the node's provider/model. No shared store (Option 1, ADR-034). Persists to node.properties.messages with debounced flush + ADR-028 tool-result archival. - Hydration fallback: fetches the node by id on mount if absent from sharedNodeStore, so the dispatcher always has properties to route on (closes the root-cause class behind the original "picker does nothing"). DisplayMessage moved to components/chat/types.ts as the view-model type (architect-confirmed layering: protocol / view-model / persisted stay distinct). Importers repointed (chat-message, viewer, ai-chat-viewer.test). Deletions (pre-ADR-034 ephemeral singleton, no dual-mode per CLAUDE.md): chat-store.svelte.ts, chat-panel.svelte, chat-store.test.ts; the 'chat' tab type (navigation.ts), its <ChatPanel> branch (pane-content.svelte), persistence guard (tab-persistence-service.ts), and the dead chat-tab nav override (app-shell.svelte). "AI Chat" sidebar item commented out pending its rework into an expandable list of recent ai-chat nodes (follow-up issue). Incidental: the WIP's chatModelList() retype (ChatModelEntry[]) had broken its two consumers; retyped modelToAgent (agent-store) and added a ChatModelEntry -> ModelInfo adapter in model-store.refreshModels. Verified: svelte-check 0 errors; eslint clean; vitest 3913 passed / 129 files. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Address review: exclude Ollama rows from model-store; robust progress placeholder Addresses 🟢 suggestions from the PR #1225 review. - model-store now manages only built-in (GGUF) models — its consumers (model-manager, ai-onboarding-dialog) download by URL and recommend a model to fetch. refreshModels() filters to backend === 'gguf', so Ollama rows (which carry no URL here and are surfaced separately by AiChatModelPicker) can no longer leak into the list. This removes the dead-download-button and un-downloadable-recommendedModel hazards in one move. (findings #1, #2) - chatEntryToModelInfo infers family from the id (gemma* -> gemma4) instead of always 'ministral', and no longer carries a now-dead 'ollama' branch. (#2) - ai-chat-node-viewer: the transient model-prep progress placeholder is now updated by id (renderProgress helper) to match its by-id removal, so it's order-independent rather than relying on positional slice(0,-1). (#3) Skipped: adding unit tests for archiveMessages/loadMessagesFromNode (#4) — these functions are already covered by the "Tool result archival" and "Write buffering" suites in ai-chat-viewer.test.ts; adding more would duplicate existing coverage. Verified: svelte-check 0 errors; eslint clean; vitest 3913 passed / 129 files. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Follow-up to merged #1220. Turns the inert
ai-chatprovider picker into adropdown-driven, per-provider flow and fixes the real root cause of "clicking a
provider does nothing".
Root cause (found via live Playwright/WebKit debugging)
The picker persisted
providerfine, but the viewer hydrates nodes from thechildren-treeendpoint, which returned"properties": {}— a #1222(SurrealDB→libsql) regression:
build_node_tree_recursiveranflatten_properties_for_api(drops props when the namespaced shape doesn't match)while every other endpoint returns raw props. Plus the ai-chat provider enum
rejected the ADR-034 modes.
Backend (first commit)
build_node_tree_recursivereturns raw properties, matchingget_node/get_children/etc. Regression test added. (node_service.rs)AiChatNodeBehavior::validateprovider enum widened tonative|ollama|openai|pty(ADR-034). Tests updated. (behaviors/mod.rs)Frontend (second commit)
AiChatNodeVieweris now THE single dispatcher for the ai-chat type:OpenAI [disabled — no backend] / Agent terminal).
provider(+model): unset → prompt;pty→AiChatPtySession;native|ollamawithout model →AiChatModelPicker; with model → message UI.daemon session (
ensureModelReady→localAgentNewSession→localAgentSendprovider/model.Persists to
node.properties.messages(debounced flush + ADR-028 tool-resultarchival).
sharedNodeStore, so the dispatcher always has properties to route on.DisplayMessagemoved tocomponents/chat/types.ts(view-model type;protocol / view-model / persisted layering kept distinct). Importers repointed.
Deletions (pre-ADR-034 ephemeral singleton — no dual-mode per CLAUDE.md):
chat-store.svelte.ts,chat-panel.svelte,chat-store.test.ts; thechattabtype, its
<ChatPanel>branch + persistence guard, and the dead chat-tab navoverride. The "AI Chat" sidebar item is commented out pending its rework into an
expandable list of recent ai-chat nodes (deferred follow-up issue).
Incidental: the WIP's
chatModelList()retype (ChatModelEntry[]) had brokenits two consumers; retyped
modelToAgent(agent-store) and added aChatModelEntry → ModelInfoadapter inmodel-store.refreshModels.Deferred to a separate follow-up issue
persisted↔DisplayMessage converters (replaces the untyped
Record<string,unknown>mappers in the viewer).
Verification
cargo test -p nodespace-core(behaviors + children-tree) green; daemon builds.svelte-check: 0 errors / 0 warnings.eslint: clean on all touched files.vitest: 3913 passed / 129 files.test:all(browser + Rust), Playwright e2e of the original bug,pty under
tauri:dev.🤖 Generated with Claude Code