Revert "feat(copilot): add persistent workspace panel and secure context hydration" - #192
Conversation
…ext hydr…" This reverts commit 81c8f1e.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (151)
📝 WalkthroughWalkthroughThe PR replaces the global Copilot panel with a workspace widget. It adds panel-scoped shared chat state, new context and execution-log processing, knowledge-base mentions, Copilot UI components, lifecycle cleanup, and updated documentation and tests. ChangesCopilot widget migration
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CopilotWidget
participant CopilotStore
participant ChatRoute
participant ContextProcessor
User->>CopilotWidget: Enter message and contexts
CopilotWidget->>CopilotStore: Update channel-scoped chat state
CopilotStore->>ChatRoute: Send message with live context
ChatRoute->>ContextProcessor: Hydrate workspace contexts
ContextProcessor-->>ChatRoute: Return processed contexts
ChatRoute-->>CopilotStore: Stream assistant response
CopilotStore-->>CopilotWidget: Update messages and tool state
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
| Filename | Overview |
|---|---|
| apps/tradinggoose/app/api/copilot/chat/route.ts | Removes context-count enforcement and moves request-controlled context hydration ahead of review-session loading. |
| apps/tradinggoose/lib/copilot/process-contents.ts | Removes context deduplication, cancellation, redaction, and byte limits while concurrently hydrating every supplied context. |
| apps/tradinggoose/lib/yjs/workflow-session-host.tsx | Removes workflowId-scoped Yjs write state, exposing the previous workflow document during identity transitions. |
| apps/tradinggoose/stores/copilot/store.ts | Restores indefinitely cached panel/pair stores without authenticated-user or workspace scoping. |
| apps/tradinggoose/stores/index.ts | Logout reset now clears only two fields in the default Copilot store, leaving widget-channel state retained. |
| apps/tradinggoose/widgets/widgets/copilot/index.tsx | Restores the Copilot dashboard widget and binds it directly to dashboard-derived channel identifiers. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Request[Copilot chat request] --> Contexts[Unbounded contexts array]
Contexts --> Hydration[Concurrent server hydration]
Hydration --> Upstream[External Copilot request]
Widget[Copilot dashboard widget] --> Channel[Pair or panel channel ID]
Channel --> Registry[Persistent Copilot store registry]
Logout[Logout reset] --> Default[Default store only]
Registry -. retained non-default stores .-> NextUser[Later workspace or user]
Editor[Workflow editor changes workflowId] --> Provider[Mounted WorkflowSessionProvider]
Provider --> OldDoc[Previous Yjs document until effect]
OldDoc --> WrongWorkflow[Wrong workflow read or mutation]
Prompt To Fix All With AI
### Issue 1
apps/tradinggoose/app/api/copilot/chat/route.ts:709
**Unbounded context hydration**
When an authenticated caller submits a large `contexts` array, the route accepts every entry and hydrates them concurrently without cardinality or aggregate-size limits, causing excessive server work and oversized upstream Copilot requests.
**How this was verified:** The request schema no longer applies the 16-context limit, and the complete array is mapped to concurrent hydration tasks without aggregate output-size enforcement.
### Issue 2
apps/tradinggoose/lib/yjs/workflow-session-host.tsx:81-83
**Stale workflow document scope**
When a mounted `WorkflowSessionProvider` changes from workflow A to workflow B, `writeState` still contains workflow A's document until the effect runs, so the transition render exposes the old document and writable ref under workflow B's identity and can read or mutate the wrong workflow.
### Issue 3
apps/tradinggoose/stores/index.ts:71
**Widget stores survive logout**
When a user signs out after using a non-default Copilot widget channel, `resetAllStores` clears only the default store while panel and pair-color stores remain cached, causing a reused channel to retain the previous user's conversation, tool state, and pending stream state.
**How this was verified:** Non-default stores remain in the module-level channel registry, while the logout reset updates only `getCopilotStore()` and no widget lifecycle clears those retained stores.
### Issue 4
apps/docs/content/docs/en/widgets/copilot.mdx:1-4
**Missing staging changelog entry**
This staging-targeted revert adds no dated markdown file under `changelog/`, leaving the change out of the repository's required branch history and changelog-aware downstream workflows.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "Revert "feat(copilot): add persistent wo..." | Re-trigger Greptile
| contexts: z.array(ChatContextSchema).optional(), | ||
| }) | ||
|
|
||
| /** POST /api/copilot/chat */ |
There was a problem hiding this comment.
When an authenticated caller submits a large contexts array, the route accepts every entry and hydrates them concurrently without cardinality or aggregate-size limits, causing excessive server work and oversized upstream Copilot requests.
How this was verified: The request schema no longer applies the 16-context limit, and the complete array is mapped to concurrent hydration tasks without aggregate output-size enforcement.
Knowledge Base Used: API Routes (apps/tradinggoose/app/api)
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/tradinggoose/app/api/copilot/chat/route.ts
Line: 709
Comment:
**Unbounded context hydration**
When an authenticated caller submits a large `contexts` array, the route accepts every entry and hydrates them concurrently without cardinality or aggregate-size limits, causing excessive server work and oversized upstream Copilot requests.
**How this was verified:** The request schema no longer applies the 16-context limit, and the complete array is mapped to concurrent hydration tasks without aggregate output-size enforcement.
**Knowledge Base Used:** [API Routes (`apps/tradinggoose/app/api`)](https://app.greptile.com/tradinggoose/-/custom-context/knowledge-base/tradinggoose/tradinggoose-studio/-/docs/api-routes.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| const [writeState, setWriteState] = useState<SharedWorkflowSessionState>(() => | ||
| getSharedWorkflowSessionState(workflowId) | ||
| ) |
There was a problem hiding this comment.
When a mounted WorkflowSessionProvider changes from workflow A to workflow B, writeState still contains workflow A's document until the effect runs, so the transition render exposes the old document and writable ref under workflow B's identity and can read or mutate the wrong workflow.
Rule Used: This repo is Yjs-first for collaborative workflow ... (source)
Knowledge Base Used: Frontend Stores
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/tradinggoose/lib/yjs/workflow-session-host.tsx
Line: 81-83
Comment:
**Stale workflow document scope**
When a mounted `WorkflowSessionProvider` changes from workflow A to workflow B, `writeState` still contains workflow A's document until the effect runs, so the transition render exposes the old document and writable ref under workflow B's identity and can read or mutate the wrong workflow.
**Rule Used:** This repo is Yjs-first for collaborative workflow ... ([source](greptile.json))
**Knowledge Base Used:** [Frontend Stores](https://app.greptile.com/tradinggoose/-/custom-context/knowledge-base/tradinggoose/tradinggoose-studio/-/docs/frontend-stores.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| useExecutionStore.getState().reset() | ||
| useConsoleStore.setState({ entries: [] }) | ||
| resetCopilotStoreRegistry() | ||
| getCopilotStore().setState({ messages: [], isSendingMessage: false }) |
There was a problem hiding this comment.
When a user signs out after using a non-default Copilot widget channel, resetAllStores clears only the default store while panel and pair-color stores remain cached, causing a reused channel to retain the previous user's conversation, tool state, and pending stream state.
How this was verified: Non-default stores remain in the module-level channel registry, while the logout reset updates only getCopilotStore() and no widget lifecycle clears those retained stores.
Knowledge Base Used:
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/tradinggoose/stores/index.ts
Line: 71
Comment:
**Widget stores survive logout**
When a user signs out after using a non-default Copilot widget channel, `resetAllStores` clears only the default store while panel and pair-color stores remain cached, causing a reused channel to retain the previous user's conversation, tool state, and pending stream state.
**How this was verified:** Non-default stores remain in the module-level channel registry, while the logout reset updates only `getCopilotStore()` and no widget lifecycle clears those retained stores.
**Knowledge Base Used:**
- [Frontend Stores](https://app.greptile.com/tradinggoose/-/custom-context/knowledge-base/tradinggoose/tradinggoose-studio/-/docs/frontend-stores.md)
- [Dashboard Widgets](https://app.greptile.com/tradinggoose/-/custom-context/knowledge-base/tradinggoose/tradinggoose-studio/-/docs/widgets.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Reverts #191
Summary by CodeRabbit
New Features
Documentation
Bug Fixes