Repository navigation
refactor: decouple assistant chat surfaces - #48973
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe AI assistant chat logic moved into ChangesAI assistant chat architecture
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant AIAssistant
participant AssistantChat
participant AssistantChatForm
participant useChat
AIAssistant->>AssistantChat: render active chat
AssistantChat->>AssistantChatForm: provide chat state and actions
AssistantChatForm->>AssistantChat: submit prompt
AssistantChat->>useChat: send prompt and context
useChat-->>AssistantChat: stream response or approval request
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
15ab2dd to
00e219b
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/studio/state/ai-assistant-state.tsx (1)
547-589: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
state.chatsandstate.chatInstancescan diverge for a chat that is not rendered. The PR makes chat mutation and chat rendering target an explicit chat id, but nothing keeps the storedChatinstance aligned withstate.chats[chatId].ensureChatInstanceonly creates a missing instance; it never refreshes an existing one, and no render path calls it.
apps/studio/state/ai-assistant-state.tsx#L547-L589: inclearMessages,deleteMessagesAfter, andupdateMessage, either dropstate.chatInstances[chatId]so it is rebuilt lazily, or callsetMessageson the stored instance.apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx#L197-L202: callstate.ensureChatInstance(chatId)beforeuseChat, so a rendered chat id never falls back to an internal chat without theonFinishstate sync.apps/studio/state/ai-assistant-state.test.ts#L78-L94: assert thatstate.chatInstances[explorerChatId]reflects the cleared messages, so the divergence is covered by a test.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/state/ai-assistant-state.tsx` around lines 547 - 589, Keep state.chats and state.chatInstances synchronized by invalidating or updating the stored instance in clearMessages, deleteMessagesAfter, and updateMessage within apps/studio/state/ai-assistant-state.tsx:547-589; call ensureChatInstance(chatId) before useChat in apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx:197-202; and add coverage in apps/studio/state/ai-assistant-state.test.ts:78-94 asserting the explorer chat instance reflects cleared messages.
🧹 Nitpick comments (10)
apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx (2)
29-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename the sidebar-activity flag and keep the shortcut prop separate.
Line 29 computes whether the assistant sidebar is the active sidebar. The name
shortcutsEnableddescribes only one of its uses. Line 45 reuses the same value to gate SQL snippet synchronization, which is not a shortcut concern. Rename the derived value to state the condition, then pass it to theshortcutsEnabledprops.Coding guidelines require boolean names that begin with
is,has,can, orshould.♻️ Proposed rename
- const shortcutsEnabled = activeSidebar?.id === SIDEBAR_KEYS.AI_ASSISTANT + const isAssistantSidebarActive = activeSidebar?.id === SIDEBAR_KEYS.AI_ASSISTANT const handleNewChat = () => state.newChat() useShortcut(SHORTCUT_IDS.AI_ASSISTANT_NEW_CHAT, handleNewChat, { - enabled: shortcutsEnabled, + enabled: isAssistantSidebarActive, }) @@ useEffect(() => { - if (shortcutsEnabled && isInSQLEditor && !!snippetContent) { + if (isAssistantSidebarActive && isInSQLEditor && !!snippetContent) { state.setSqlSnippets([ { label: 'Current Query', content: snippetContent, source: openSnippetSource }, ]) } - }, [shortcutsEnabled, isInSQLEditor, snippetContent, openSnippetSource, state]) + }, [isAssistantSidebarActive, isInSQLEditor, snippetContent, openSnippetSource, state])Then pass
shortcutsEnabled={isAssistantSidebarActive}toAssistantChatandAIAssistantHeader.Also applies to: 44-50
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx` at line 29, Rename the derived sidebar-activity flag in AIAssistant from shortcutsEnabled to isAssistantSidebarActive, preserving its active-sidebar condition. Use isAssistantSidebarActive for SQL snippet synchronization and pass it explicitly as shortcutsEnabled to AssistantChat and AIAssistantHeader.Source: Coding guidelines
62-73: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReplace the
ascast onsnap.sqlSnippets.Line 64 casts a Valtio snapshot value with
as SqlSnippet[] | undefined. The coding guidelines require avoiding TypeScriptascasts. The snapshot type isDeepReadonly, so widen thecomposerContextprop type to accept a readonly array instead of casting at the call site.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx` around lines 62 - 73, Remove the `as SqlSnippet[] | undefined` cast from `snap.sqlSnippets` in the `composerContext` passed by `AIAssistant`. Update the `composerContext` prop/type definition to accept a readonly `SqlSnippet` array, preserving compatibility with Valtio’s `DeepReadonly` snapshot value.Source: Coding guidelines
apps/studio/state/ai-assistant-state.tsx (1)
508-515: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse
ensureChatInstanceinloadPersistedState.
loadPersistedStatestill inlines the same "create instance if missing" logic for the active chat. Callstate.ensureChatInstance(state.activeChatId)there instead, so instance creation has one definition.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/state/ai-assistant-state.tsx` around lines 508 - 515, Update loadPersistedState to call state.ensureChatInstance(state.activeChatId) instead of duplicating the chat-instance creation logic. Remove the inline ref/createChatInstance block there, while preserving the existing active-chat loading behavior.apps/studio/components/ui/AIAssistantPanel/Message.tsx (1)
141-141: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd
satisfies MessageActionstomessageActions.
messageInfoon line 135 usessatisfies MessageInfo.messageActionshas no annotation. Addingsatisfies MessageActionscatches a missing or misspelled action at the definition site rather than at the provider.🔧 Proposed change
onCancelEdit: props.onCancelEdit, onRate: props.onRate, - } + } satisfies MessageActions🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/ui/AIAssistantPanel/Message.tsx` at line 141, Update the messageActions definition near onBranch to use the MessageActions type with satisfies, matching the existing messageInfo pattern. Keep the current action implementations unchanged while ensuring missing or misspelled actions are validated at definition time.apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx (5)
669-679: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFlatten the nested ternaries.
Two places nest ternaries. Line 669-679 nests four levels for
placeholder. Lines 496-502 nest two levels for theerrorprop. Extract each into a small function with early returns.🔧 Proposed change for the placeholder
+ const getPlaceholder = () => { + if (hasMessages) { + return isSupportChat + ? 'Share details so the assistant can help with your support request...' + : 'Ask a follow up question...' + } + if ((composerContext?.sqlSnippets ?? []).length > 0) { + return 'Ask a question or make a change...' + } + return isSupportChat ? 'Describe your support issue...' : 'Chat to Postgres...' + }- placeholder={ - hasMessages - ? isSupportChat - ? 'Share details so the assistant can help with your support request...' - : 'Ask a follow up question...' - : (composerContext?.sqlSnippets ?? []).length > 0 - ? 'Ask a question or make a change...' - : isSupportChat - ? 'Describe your support issue...' - : 'Chat to Postgres...' - } + placeholder={getPlaceholder()}As per coding guidelines: "Do not nest ternaries. Use a single ternary only for binary choices; flatten larger conditional rendering with early returns or sibling
&&blocks."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx` around lines 669 - 679, Replace the nested ternary used by the AssistantChat placeholder prop with a small helper function using early returns, preserving the existing hasMessages, isSupportChat, and sqlSnippets.length outcomes. Apply the same approach to the nested ternary in the error prop around the existing error-rendering logic, extracting a helper with early returns and keeping all current behavior unchanged.Source: Coding guidelines
462-481: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftSplit
AssistantChatinto smaller components.The component body spans roughly 625 lines and holds several distinct UI sections: the conversation list, the error block, the edit banner, the support actions, the admonitions, and the composer. Extract the edit banner and the composer block, at minimum.
As per coding guidelines: "Split components at approximately 200–300 lines or earlier when they contain multiple distinct UI sections, tangled conditionals, or unrelated state clusters."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx` around lines 462 - 481, Refactor AssistantChat into smaller focused components, extracting at minimum the edit banner and composer block from the main component. Keep the conversation list, error block, support actions, and admonitions behavior unchanged while passing only the required state, handlers, and values through clear props.Source: Coding guidelines
112-127: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDerive
selectedModelduring render withoutuseMemo.
selectedModelis a string. The computation is three comparisons. The memo adds no referential stability and no measured saving. Compute it inline.As per coding guidelines: "Do not use
useMemooruseCallbackby default; use them only for measured expense or referential stability required by a memoized child."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx` around lines 112 - 127, Remove the useMemo wrapper around selectedModel and derive the value directly during render using the existing entitlement, model validation, and access checks. Preserve the current fallback behavior and remove the now-unneeded memo dependency array and import if applicable.Source: Coding guidelines
404-404: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the unused
lastUserMessageRef
lastUserMessageRefis only assigned and never read. Remove the ref and both assignments.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx` at line 404, Remove the unused lastUserMessageRef declaration from AssistantChat and delete both assignments to lastUserMessageRef.current, including the assignment near payload handling, without changing the surrounding chat behavior.
395-401: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the
as MessageTypecast andcreatedAtfield.
UIMessagein@ai-sdk/react3.0.118 does not define top-levelcreatedAt. DeclarepayloadasMessageTypeso TypeScript checks the object shape. Move the timestamp tometadataonly if the metadata schema is extended.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx` around lines 395 - 401, Update the payload declaration in AssistantChat by removing the createdAt property and the `as MessageType` assertion; explicitly declare the object as MessageType so TypeScript validates its shape. Preserve the timestamp only through metadata if the existing metadata schema supports it, otherwise do not add it.Source: Coding guidelines
apps/studio/state/ai-assistant-state.test.ts (1)
78-94: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAdd an assertion for the stored
Chatinstance.This test proves that
state.chatsis isolated. It does not prove thatstate.chatInstances[explorerChatId]was also cleared. That gap is the failure mode described in theai-assistant-state.tsxcomment onclearMessages. Add an assertion on the instance messages once the mutation behavior is settled.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/studio/state/ai-assistant-state.test.ts` around lines 78 - 94, Add an assertion to the clearMessages test for state.chatInstances[explorerChatId].messages, verifying the stored Chat instance is also empty after mutating the explicit explorer chat. Keep the existing assertions for activeChatId and state.chats unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx`:
- Around line 44-50: Update the useEffect managing the Current Query attachment
to remove or relinquish that attachment when shortcutsEnabled, isInSQLEditor, or
snippetContent no longer applies. Use a targeted clear or ownership check that
preserves sqlSnippets supplied by non-SQL flows, rather than unconditionally
calling clearSqlSnippets(); keep setting the current SQL snippet unchanged for
valid SQL editor context.
In `@apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx`:
- Around line 178-184: Update the useEffect dependency in AssistantChat so it
uses the reactive organization slug value rather than
selectedOrganizationRef.current?.slug. Ensure organization changes re-run
state.setContext and remove the unverifiable ref-member dependency so
exhaustive-deps passes.
- Line 61: Update the aiOptInLevel prop type used by renderHeader to reuse the
return/source type from useOrgAiOptInLevel instead of declaring the redundant
literal-or-string union. Preserve the existing optional/undefined behavior while
allowing consumers to receive the source type’s intended narrowing.
---
Outside diff comments:
In `@apps/studio/state/ai-assistant-state.tsx`:
- Around line 547-589: Keep state.chats and state.chatInstances synchronized by
invalidating or updating the stored instance in clearMessages,
deleteMessagesAfter, and updateMessage within
apps/studio/state/ai-assistant-state.tsx:547-589; call
ensureChatInstance(chatId) before useChat in
apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx:197-202; and add
coverage in apps/studio/state/ai-assistant-state.test.ts:78-94 asserting the
explorer chat instance reflects cleared messages.
---
Nitpick comments:
In `@apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx`:
- Line 29: Rename the derived sidebar-activity flag in AIAssistant from
shortcutsEnabled to isAssistantSidebarActive, preserving its active-sidebar
condition. Use isAssistantSidebarActive for SQL snippet synchronization and pass
it explicitly as shortcutsEnabled to AssistantChat and AIAssistantHeader.
- Around line 62-73: Remove the `as SqlSnippet[] | undefined` cast from
`snap.sqlSnippets` in the `composerContext` passed by `AIAssistant`. Update the
`composerContext` prop/type definition to accept a readonly `SqlSnippet` array,
preserving compatibility with Valtio’s `DeepReadonly` snapshot value.
In `@apps/studio/components/ui/AIAssistantPanel/AssistantChat.tsx`:
- Around line 669-679: Replace the nested ternary used by the AssistantChat
placeholder prop with a small helper function using early returns, preserving
the existing hasMessages, isSupportChat, and sqlSnippets.length outcomes. Apply
the same approach to the nested ternary in the error prop around the existing
error-rendering logic, extracting a helper with early returns and keeping all
current behavior unchanged.
- Around line 462-481: Refactor AssistantChat into smaller focused components,
extracting at minimum the edit banner and composer block from the main
component. Keep the conversation list, error block, support actions, and
admonitions behavior unchanged while passing only the required state, handlers,
and values through clear props.
- Around line 112-127: Remove the useMemo wrapper around selectedModel and
derive the value directly during render using the existing entitlement, model
validation, and access checks. Preserve the current fallback behavior and remove
the now-unneeded memo dependency array and import if applicable.
- Line 404: Remove the unused lastUserMessageRef declaration from AssistantChat
and delete both assignments to lastUserMessageRef.current, including the
assignment near payload handling, without changing the surrounding chat
behavior.
- Around line 395-401: Update the payload declaration in AssistantChat by
removing the createdAt property and the `as MessageType` assertion; explicitly
declare the object as MessageType so TypeScript validates its shape. Preserve
the timestamp only through metadata if the existing metadata schema supports it,
otherwise do not add it.
In `@apps/studio/components/ui/AIAssistantPanel/Message.tsx`:
- Line 141: Update the messageActions definition near onBranch to use the
MessageActions type with satisfies, matching the existing messageInfo pattern.
Keep the current action implementations unchanged while ensuring missing or
misspelled actions are validated at definition time.
In `@apps/studio/state/ai-assistant-state.test.ts`:
- Around line 78-94: Add an assertion to the clearMessages test for
state.chatInstances[explorerChatId].messages, verifying the stored Chat instance
is also empty after mutating the explicit explorer chat. Keep the existing
assertions for activeChatId and state.chats unchanged.
In `@apps/studio/state/ai-assistant-state.tsx`:
- Around line 508-515: Update loadPersistedState to call
state.ensureChatInstance(state.activeChatId) instead of duplicating the
chat-instance creation logic. Remove the inline ref/createChatInstance block
there, while preserving the existing active-chat loading behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 90bfce1b-cb4f-42cc-924a-09c850777103
📒 Files selected for processing (8)
apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsxapps/studio/components/ui/AIAssistantPanel/AIAssistantChatSelector.tsxapps/studio/components/ui/AIAssistantPanel/AIAssistantHeader.tsxapps/studio/components/ui/AIAssistantPanel/AssistantChat.tsxapps/studio/components/ui/AIAssistantPanel/Message.Context.tsxapps/studio/components/ui/AIAssistantPanel/Message.tsxapps/studio/state/ai-assistant-state.test.tsapps/studio/state/ai-assistant-state.tsx
🎭 Playwright Test Results (next)Details
Flaky testsFeatures › queue-table-operations.spec.ts › Queue Table Operations - queue identity fixes › deleting a newly inserted row removes it from pending changes Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
cae676a to
53e92d1
Compare
53e92d1 to
c33e988
Compare
joshenlim
left a comment
There was a problem hiding this comment.
Preview test — ✅ all pass
Ran a regression sweep on the AI Assistant sidebar since this PR is a refactor (no explicit "To test" section, and the listed test plan was all local commands — out of scope here). Reused an existing project on studio-staging.
| # | Test | Result |
|---|---|---|
| 1 | Send a message in the AI Assistant | ✅ Sent "list my tables", assistant ran list_tables and returned the correct tables plus an RLS advisory. Chat auto-titled itself. |
| 2 | Edit a sent message | ✅ Edited message resubmitted cleanly, thread updated with no duplication or corruption. |
| 3 | Delete a message | ✅ Deleted a message + its response via the confirmation dialog; earlier messages stayed intact. |
| 4 | Rate an assistant response | ✅ Thumbs-up call succeeded (200), button state persisted. |
| 5 | Branch a message into a new chat | ✅ "Branch in new chat" created a new chat with copied history and an independent response; original chat verified untouched. |
| 6 | New chat + switch back (active-conversation isolation) | ✅ No message leakage between chats, no unexpected active-conversation changes — this is the specific class of bug the PR calls out as fixed. One minor nuance below. |
| 7 | SQL Editor → Assistant context sync | ✅ A "Current Query" context chip picked up the exact SQL from the editor; asking the assistant to explain it worked correctly. |
| 8 | Keyboard shortcut (⌘I) across states | ✅ Toggled open/closed correctly from both a blank state and while focus was in the SQL Monaco editor — no duplicate panels or no-ops. |
Notes:
- Skipped support escalation testing (external write, not authorized for this run) and all local commands from the PR's test plan (
tsc,vitest, ESLint, Prettier) — out of scope for preview testing. - Small nuance on #6, not a clear bug but worth a glance given the PR explicitly targets this bug class: clicking "Ask Assistant" from the Security Advisor opens an unsent draft chat as the active panel, but the History dropdown's selected marker still shows the prior chat until the draft's first message is sent. Reads as intentional (drafts aren't in history until sent), flagging for awareness.
- Left a few test chats in the reused project (edited/branched/deleted-message threads) — no side effects worth cleaning up, no SQL was executed against the DB, no projects created or deleted.
- No screenshots — no failures or visual claims to verify.
joshenlim
left a comment
There was a problem hiding this comment.
Code changes generally LGTM!
Braintrust eval report
|
<img width="1695" height="1042" alt="image" src="https://github.com/user-attachments/assets/b02e64ff-32ac-4aee-bda5-00b56f3a29e5" /> ## Summary - add routed Explorer chat pages backed by explicit assistant chat IDs - wait for persisted assistant state before creating chats so cold-load creation is not overwritten - register chat tabs and keep tab labels, navigation, close behavior, and missing-chat cleanup in sync - create and branch Explorer chats without changing the assistant sidebar selection - support both Next.js and TanStack Router paths This is PR 2 of 3 and is stacked on #48973. Review and merge #48973 first. The Explorer discovery, toolbar, and cross-surface entry points follow in #49032. This PR focuses purely on setting up chat tab types, routes and assistant conversation. ## To Test - Create a new assistant chat via the assistant sidebar, send a message etc - Copy the chat id - Visit /explorer/chat/[id] - Verify chat shows up, you can send more messages, chat is synced across tab and sidebar - Close the tab ## Test plan - `mise exec node@22 -- pnpm --dir apps/studio exec tsc --noEmit` - focused Vitest suite: 4 files / 30 tests covering assistant hydration, chat creation, routed chat rendering, and tab lifecycle - ESLint on changed TypeScript files - Prettier check on changed source files <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added Explorer chat pages with support for opening, selecting, and branching chats. * Added chat tabs, stable navigation, chat icons, and fallback behavior when tabs are closed. * Added chat creation that waits for assistant state to finish loading. * **Bug Fixes** * Removed tabs for deleted or unavailable chats. * Improved editor tab navigation and history clearing behavior. * **Tests** * Added coverage for chat routing, tab management, chat creation, and assistant-state loading. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 <[email protected]>
<img width="1693" height="1038" alt="image" src="https://github.com/user-attachments/assets/9ef52446-c517-4ea9-ada6-ac6dc57c8af4" /> ## Summary - add an Explorer-specific chat toolbar with rename, chat ID, permission, and branching controls - list searchable non-support chats in Explorer with reactive updates and safe rehydrated-date sorting - add chat creation entry points to Explorer home and navigation menus - route chat recent items correctly and show chat icons across shared tab surfaces - make the assistant sidebar expand action open the active chat in Explorer This is PR 3 of 3 and is stacked on #49031. Review #48973 first, then #49031, then this PR. Compared with its base, this PR contains only discovery, toolbar, and cross-surface integration work. ## To Test - visit /explorer - Create a new chat either via home tab chat input OR the chats sidebar - Validate chats show up in sidebar - Validate chat conversation works - Close the chat tab and open a chat via sidebar - Change permission settings via the chat tab toolbar and verify it persists ## Test plan - `mise exec node@22 -- pnpm --dir apps/studio exec tsc --noEmit` - focused Vitest suite: 4 files / 5 tests covering reactive chat lists, navigation filtering and sorting, recent-item routing, and sidebar handoff - ESLint on changed TypeScript files - Prettier check on changed source files <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added chat creation from the Explorer home, navigation, and new-tab menu. - Added an Explorer chat toolbar with editable names, ID copying, permissions, shortcuts, and metadata warnings. - Added searchable chat history with sorting, active-chat highlighting, and clear empty states. - Chats can now open directly in Explorer from the AI Assistant panel. - Recent items now link correctly to chats and notebooks. - **Bug Fixes** - Improved chat list updates after creation, deletion, and restored sessions. - Added safer handling for chats without update timestamps. - **Tests** - Expanded coverage for chat navigation, creation, metadata warnings, shortcuts, and recent-item links. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 <[email protected]>
Summary
This is PR 1 of 3. Review this foundation first, then #49031 for the routed Explorer chat lifecycle, followed by #49032 for discovery and cross-surface entry points.
Supersedes #48970 after renaming the branch to use the repository's
chore/convention.Test plan
mise exec node@22 -- pnpm --dir apps/studio exec tsc --noEmitmise exec node@22 -- pnpm --dir apps/studio exec vitest run state/ai-assistant-state.test.ts