feat(editor): Add collapsible sidebar and deferred thread creation to Instance AI (no-changelog)#28459
feat(editor): Add collapsible sidebar and deferred thread creation to Instance AI (no-changelog)#28459
Conversation
Bundle ReportChanges will increase total bundle size by 4.93kB (0.01%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: editor-ui-esmAssets Changed:
Files in
Files in
Files in
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Performance ComparisonComparing current → latest master → 14-day baseline Idle baseline with Instance AI module loaded
docker-stats
Memory consumption baseline with starter plan resources
How to read this table
|
e3bca4e to
4991259
Compare
There was a problem hiding this comment.
4 issues found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/editor-ui/src/features/ai/instanceAi/components/InstanceAiThreadList.vue">
<violation number="1" location="packages/frontend/editor-ui/src/features/ai/instanceAi/components/InstanceAiThreadList.vue:131">
P2: `N8nScrollArea` should not reuse the old `overflow-y: auto` class; it overrides the component's required `overflow: hidden` root behavior.</violation>
</file>
<file name="packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiView.vue">
<violation number="1" location="packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiView.vue:126">
P1: Don't treat a missing sidebar entry as an invalid deep link unless the thread list load succeeded. A temporary `loadThreads()` failure will now bounce valid `/instance-ai/:threadId` URLs back to the base route.</violation>
<violation number="2" location="packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiView.vue:181">
P2: Use a width-relative threshold here; `ResizeData.x` is the mouse's viewport coordinate, so auto-collapse won't consistently trigger when the sidebar is dragged below 100px.</violation>
<violation number="3" location="packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiView.vue:380">
P2: Updating the URL before the first `sendMessage()` succeeds can leave users on a `/instance-ai/:threadId` route for a thread that was never created.</violation>
</file>
Architecture diagram
sequenceDiagram
participant User
participant View as InstanceAiView (UI)
participant Store as InstanceAiStore (Pinia)
participant Router as Vue Router
participant LS as LocalStorage
participant Backend as AI Service (Mastra/SSE)
Note over User,Backend: Initial Load & Validation Flow
View->>LS: NEW: Read 'instanceAi.sidebarCollapsed'
View->>Store: loadThreads()
Store->>Backend: Fetch existing threads
Backend-->>Store: Return thread list
Note over View,Router: Validation Logic
alt NEW: props.threadId exists but not in Store
View->>Router: CHANGED: router.replace('/instance-ai')
else threadId valid
View->>Store: switchThread(threadId)
Store->>Backend: loadHistoricalMessages()
end
Note over User,Backend: Deferred Thread Creation Flow (First Message)
User->>View: Enters first message at '/instance-ai'
View->>Store: sendMessage(message, attachments)
Store->>Backend: POST /chat (Initializes thread)
Note over View,Router: URL Update (Deferred)
opt NEW: No threadId in current route
View->>Router: CHANGED: router.replace('/instance-ai/:threadId')
View->>View: NEW: Thread now materializes in Sidebar
end
Note over User,LS: Sidebar UI State Flow
User->>View: Drags Sidebar resize handle
alt NEW: Resize width < 100px
View->>LS: Set 'instanceAi.sidebarCollapsed' = true
View->>View: UI Auto-collapses sidebar
else Normal resize
View->>View: Update sidebarWidth (200px - 400px)
end
User->>View: Clicks Toggle Button
View->>LS: Toggle 'instanceAi.sidebarCollapsed'
View-->>User: Show/Hide Sidebar
Note over User,Store: Unhappy Path: Navigation Guard
User->>View: Clicks "New Chat" button
alt CHANGED: Current thread is already empty
View->>View: NEW: Guard trigger (No-op)
else Current thread has messages
View->>Store: newThread()
View->>Router: router.push('/instance-ai')
end
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiView.vue
Outdated
Show resolved
Hide resolved
packages/frontend/editor-ui/src/features/ai/instanceAi/components/InstanceAiThreadList.vue
Show resolved
Hide resolved
packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiView.vue
Outdated
Show resolved
Hide resolved
packages/frontend/editor-ui/src/features/ai/instanceAi/InstanceAiView.vue
Outdated
Show resolved
Hide resolved
…is sent Thread no longer appears in sidebar or URL when landing on /instance-ai/. Instead, the thread is created in the sidebar and the URL updates to /instance-ai/:threadId only after the user sends their first message. - Remove eager thread bootstrap from route watcher and newThread() - Update URL optimistically via router.replace on first message send - Redirect to /instance-ai/ when navigating to a non-existent thread - Pass threadId as a route prop instead of reading route.params directly - Guard "New chat" button against redundant calls on empty threads
Replace manual store mocks with createTestingPinia + mockedStore, remove unnecessary child component vi.mock stubs in favor of global.stubs, and drop redundant ResizeObserver/design-system mocks.
Threads now only appear in the sidebar after a message is sent. Update tests to send a message before asserting thread count.
b226acb to
0108d82
Compare
… issues - Remove overflow-y:auto from threadList that conflicts with N8nScrollArea - Use resize width instead of viewport x for sidebar collapse threshold - Only redirect deep-links when loadThreads actually succeeded - Only update URL to thread route after sendMessage persists the thread
The route.params.threadId watcher in useCanvasPreview was closing the preview when the URL changed from /instance-ai to /instance-ai/:threadId after the first message. Skip the reset when oldThreadId is undefined (initial setup) or unchanged.
Wait for both threads to appear in the sidebar before interacting with the action menu. Remove force:true from action button click.
Replace brittle toHaveCount(2) with identity-based toBeVisible check on the target thread. Other parallel tests create threads in the same container, making count assertions unreliable.
Summary
Two improvements to the Instance AI view:
Deferred thread creation: Threads no longer appear in the sidebar or URL when landing on
/instance-ai/. The thread is created and the URL updates to/instance-ai/:threadIdonly after the user sends their first message. This prevents empty threads from cluttering the sidebar.Collapsible sidebar: The thread list sidebar can now be collapsed/expanded via a toggle button in the header. Dragging the resize handle below 100px auto-collapses it. The collapsed state is persisted to localStorage. The thread list now uses
N8nScrollAreafor proper overflow scrolling.Changes
newThread()router.replaceon first message send/instance-ai/when navigating to a non-existent threadthreadIdas a route prop instead of readingroute.paramsdirectlyN8nScrollAreafor proper overflow handlingRelated Linear tickets, Github issues, and Community forum posts
Review / Merge checklist
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)🤖 PR Summary generated by AI