Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

fix(tui): scope session list to current directory (#8836)#8886

Open
shoaibansari5398 wants to merge 1 commit intoanomalyco:devanomalyco/opencode:devfrom
shoaibansari5398:fix/issue-8836-session-scopingshoaibansari5398/opencode:fix/issue-8836-session-scopingCopy head branch name to clipboard
Open

fix(tui): scope session list to current directory (#8836)#8886
shoaibansari5398 wants to merge 1 commit intoanomalyco:devanomalyco/opencode:devfrom
shoaibansari5398:fix/issue-8836-session-scopingshoaibansari5398/opencode:fix/issue-8836-session-scopingCopy head branch name to clipboard

Conversation

@shoaibansari5398
Copy link

What does this PR do?

Fixes #8836 - Scopes the session list (/sessions command) to the current working directory.

Problem: When using /sessions or opening the session list dialog, it displayed ALL sessions from ALL directories/projects instead of only sessions that belong to the current working directory.

How did you verify your code works?

Root Cause: The
dialog-session-list.tsx
component only filtered sessions by parentID === undefined (to exclude child sessions) but didn't filter by the session's directory field.

Solution: Added a directory filter to only show sessions where session.directory === currentDirectory:

diff
const options = createMemo(() => {
const today = new Date().toDateString()

  • const currentDirectory = sync.data.path.directory || process.cwd()
    return sessions()
  •  .filter((x) => x.parentID === undefined)
    
  •  .filter((x) => x.parentID === undefined && x.directory === currentDirectory)
    

How did you verify your code works?

Code review confirmed that Session.Info schema has a directory field that stores the working directory when a session is created
The filter uses the same path source (sync.data.path.directory) that's used elsewhere in the TUI (e.g.,
useDirectory
context)
The || process.cwd() fallback ensures the filter still works if sync.data.path.directory is not yet populated

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found one potentially related PR:

Potential Duplicate:

This PR seems to have already attempted to solve the session filtering issue. You should check if PR #6724 is still open or if it was closed/merged, as the current PR #8886 may be re-implementing or completing the same functionality.

All other search results either returned the current PR itself (#8886) or unrelated features.

@allisoneer
Copy link

This is from Claude:

Thanks for working on this! I noticed this PR only filters at the UI display level in the session list dialog. There are a few other entry points where cross-directory sessions can still leak through:

  1. Bootstrap fetch (sync.tsx:334-336) - The initial session.list call doesn't pass a directory filter, so all sessions are still fetched on TUI startup
  2. Real-time events (sync.tsx:208-220) - session.updated SSE events are inserted unconditionally, so sessions created/updated in other directories will appear
  3. Session search - The search query in this same file (line 29) doesn't pass directory either

The API already supports GET /session?directory=<path> filtering - it just needs to be wired up in these places too. Would you be open to expanding this PR to cover those cases? Or I can submit a separate PR with a more complete fix if you prefer.

See my comment on #8836 for more details on the approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session list is showing all sessions not only the ones scopes to the curent dir

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.