feat: filter session history by workspace directory#11813
feat: filter session history by workspace directory#11813mvanhorn wants to merge 2 commits intocontinuedev:mainfrom
Conversation
Add optional workspaceDirectory field to ListHistoryOptions so callers can scope session lists to a specific workspace. Filtering is case-insensitive and applied before pagination. Omitting the field preserves the existing behavior of returning all sessions. Fixes continuedev#9936 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
2 issues found across 3 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="core/util/history.ts">
<violation number="1" location="core/util/history.ts:42">
P2: Workspace filter calls `.toLowerCase()` on unvalidated runtime values, which can throw and break `list()` for malformed session metadata.</violation>
</file>
<file name="core/util/history.test.ts">
<violation number="1" location="core/util/history.test.ts:139">
P2: Test claims to validate workspace filtering with both limit and offset, but offset is never passed, so the combined pagination behavior is untested.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Use typeof check instead of truthiness for workspaceDirectory to handle malformed session metadata safely - Rename test to match actual coverage (limit only) - Add separate test for combined limit+offset with workspace filter
There was a problem hiding this comment.
@mvanhorn this seems like a good change that would move towards solving a long running issue, but where is the workspaceDirectory option actually passed around? Is there missing UI? Seems maybe in current state this will not change any functionality?
|
You're right that nothing passes My plan was to keep this PR small and land the filtering logic first, then add the IDE-side wiring (reading the current workspace from the IDE context and passing it to |
Summary
Add optional
workspaceDirectoryfield toListHistoryOptionsso callers can scope session lists to a specific workspace. Sessions are stored with workspace info already (BaseSessionMetadata.workspaceDirectory) butHistoryManager.list()had no way to filter by it.Why this matters
Opening a project currently shows the last active session from any project, and session history shows all projects interleaved. Multi-window usage is confusing because sessions from different workspaces appear mixed together.
core/util/history.ts:25-list()returned all sessions without workspace filteringcore/protocol/core.ts:63-ListHistoryOptionsonly hadoffsetandlimitChanges
core/protocol/core.ts- AddedworkspaceDirectory?: stringtoListHistoryOptionscore/util/history.ts- Added workspace filter inlist(), applied before pagination. Case-insensitive comparison. Omitting the field returns all sessions (backward compatible).core/util/history.test.ts- 5 new tests: exact match, case-insensitive, empty returns all, non-matching returns empty, works with limit/offsetTesting
All 17 tests pass (12 existing + 5 new workspace filtering tests).
This contribution was developed with AI assistance (Claude Code).
Fixes #9936
Summary by cubic
Adds an optional workspace filter to session history so UIs can list sessions per workspace and avoid mixing projects. Improves multi-window behavior by scoping sessions to the active workspace. Fixes #9936.
New Features
workspaceDirectory?: stringtoListHistoryOptions.HistoryManager.list()before pagination; omit the field to return all.Bug Fixes
typeofguard onworkspaceDirectoryto handle malformed metadata.Written for commit d919e1d. Summary will update on new commits.