Use full workspace context for root AI chats#365
Conversation
Reviewer's GuideImplements workspace-aware initial AI chat settings so root workspace chats use full workspace context with empty rag_ids, while non-root chats preserve explicit source rag_ids, and wires these settings into chat creation and related-views selection behavior. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
collectSelectableViewIds, consider guarding againstview.childrenbeing undefined (e.g.stack.push(...(view.children ?? []))) to avoid potential runtime errors if a view has no children array. - The
handleAddPagecallback now callstoast.dismiss(loadingToastId)in both the try and catch branches; refactoring to afinallyblock (or a helper) would avoid duplicating this cleanup logic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `collectSelectableViewIds`, consider guarding against `view.children` being undefined (e.g. `stack.push(...(view.children ?? []))`) to avoid potential runtime errors if a view has no children array.
- The `handleAddPage` callback now calls `toast.dismiss(loadingToastId)` in both the try and catch branches; refactoring to a `finally` block (or a helper) would avoid duplicating this cleanup logic.
## Individual Comments
### Comment 1
<location path="src/components/chat/components/chat-input/related-views/index.tsx" line_range="31" />
<code_context>
+ if (!view || view.layout === ViewLayout.AIChat) continue;
+
+ ids.push(view.view_id);
+ stack.push(...view.children);
+ }
+
</code_context>
<issue_to_address>
**issue:** Guard against `view.children` being undefined when pushing onto the stack.
Elsewhere in this file `children` is treated as optional (e.g. `folder?.children || []`), but `stack.push(...view.children)` will throw if `children` is undefined. Use a safe fallback, e.g. `stack.push(...(view.children || []));`, so the traversal doesn’t break when `children` is missing.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if (!view || view.layout === ViewLayout.AIChat) continue; | ||
|
|
||
| ids.push(view.view_id); | ||
| stack.push(...view.children); |
There was a problem hiding this comment.
issue: Guard against view.children being undefined when pushing onto the stack.
Elsewhere in this file children is treated as optional (e.g. folder?.children || []), but stack.push(...view.children) will throw if children is undefined. Use a safe fallback, e.g. stack.push(...(view.children || []));, so the traversal doesn’t break when children is missing.
8df587c to
cd42f17
Compare
cd42f17 to
941ffe6
Compare
Summary
Verification
Summary by Sourcery
Initialize AI chat pages with workspace-aware context settings and update related views selection to reflect full-workspace chats.
New Features:
Enhancements:
Tests: