Skip to content

Conversation

@harshav167
Copy link

Summary

This PR adds directory-based filtering to session listing, so sessions are scoped to the current working directory by default rather than showing all sessions across the entire project.

Problem

Currently, when running oc in different directories within the same git repository, all sessions from all directories are visible. This creates noise and confusion - for example, running oc session list in /project/frontend shows sessions created in /project/backend, /project/docs, etc.

This is a common workflow issue for developers working on monorepos or projects with multiple subdirectories.

Solution

  • Default behavior: Session.list() now filters to only return sessions where session.directory matches the current working directory (Instance.directory)
  • Opt-out: Pass { all: true } to get all sessions (previous behavior)
  • CLI: Added --all / -a flag to oc session list
  • API: Added ?all=true query parameter to /session endpoint

Prior Art

This behavior aligns with how Codex and Claude Code handle session visibility - they scope sessions to the current working directory rather than globally across the machine or project. This provides better isolation when:

  • Working in different subdirectories of a monorepo
  • Running opencode in non-git folders where sessions should be folder-specific
  • Switching between related but distinct workspaces

Changes

File Change
src/session/index.ts Added ListOptions interface, modified list() to filter by directory
src/cli/cmd/session.ts Added --all flag to session list command
src/server/server.ts Added ?all=true query param support

Testing

  • Built locally and verified:
    • oc session list returns empty when no sessions match current directory
    • oc session list --all returns all sessions (previous behavior)
    • --help shows the new flag correctly

@harshav167 harshav167 force-pushed the feature/session-directory-filtering branch 2 times, most recently from 1e2b5cf to 673ed2b Compare January 6, 2026 04:10
@harshav167 harshav167 force-pushed the feature/session-directory-filtering branch from 673ed2b to 576b348 Compare January 13, 2026 08:53
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@harshav167
Copy link
Author

Bumping this with a fresh force-push that now sits on v1.1.16 plus the three session-filtering files. Ran • Packages in scope: @opencode-ai/app, @opencode-ai/console-app, @opencode-ai/console-core, @opencode-ai/console-function, @opencode-ai/console-mail, @opencode-ai/console-resource, @opencode-ai/desktop, @opencode-ai/enterprise, @opencode-ai/function, @opencode-ai/plugin, @opencode-ai/script, @opencode-ai/sdk, @opencode-ai/slack, @opencode-ai/ui, @opencode-ai/util, @opencode-ai/web, opencode
• Running typecheck in 17 packages
• Remote caching disabled
@opencode-ai/plugin:typecheck: cache hit, replaying logs e9de2b2b263d8292
@opencode-ai/slack:typecheck: cache hit, replaying logs 090668a9b53753cd
@opencode-ai/desktop:typecheck: cache hit, replaying logs af3abedc14465f05
@opencode-ai/plugin:typecheck: $ tsgo --noEmit
@opencode-ai/desktop:typecheck: $ tsgo -b
@opencode-ai/slack:typecheck: $ tsgo --noEmit
@opencode-ai/enterprise:typecheck: cache hit, replaying logs d3f3de3a459a6a7f
@opencode-ai/enterprise:typecheck: $ tsgo --noEmit
@opencode-ai/console-function:typecheck: cache hit, replaying logs af8894bff26be78d
@opencode-ai/console-function:typecheck: $ tsgo --noEmit
@opencode-ai/sdk:typecheck: cache hit, replaying logs 54073f55f7e6b875
@opencode-ai/sdk:typecheck: $ tsgo --noEmit
@opencode-ai/app:typecheck: cache hit, replaying logs 079500c6a97aab9e
@opencode-ai/app:typecheck: $ tsgo -b
@opencode-ai/ui:typecheck: cache hit, replaying logs 3cab659f1e2cbe9a
@opencode-ai/ui:typecheck: $ tsgo --noEmit
@opencode-ai/util:typecheck: cache hit, replaying logs 78fb0a35d25f1957
@opencode-ai/util:typecheck: $ tsc --noEmit
@opencode-ai/console-core:typecheck: cache hit, replaying logs 24cf33269fb2c13d
@opencode-ai/console-core:typecheck: $ tsgo --noEmit
opencode:typecheck: cache hit, replaying logs aeb81070b67a1486
opencode:typecheck: $ tsgo --noEmit
@opencode-ai/console-app:typecheck: cache hit, replaying logs a7244c85fa1630ca
@opencode-ai/console-app:typecheck: $ tsgo --noEmit

Tasks: 12 successful, 12 total
Cached: 12 cached, 12 total
Time: 178ms >>> FULL TURBO and opencode script {
"channel": "feature/session-directory-filtering",
"version": "0.0.0-feature/session-directory-filtering-202601130856",
"preview": true
}
bun add v1.3.5 (1e86cebd)

installed @opentui/core@0.1.72

[209.00ms] done
bun add v1.3.5 (1e86cebd)

installed @parcel/watcher@2.5.1

[113.00ms] done
building opencode-linux-arm64
building opencode-linux-x64
building opencode-linux-x64-baseline
building opencode-linux-arm64-musl
building opencode-linux-x64-musl
building opencode-linux-x64-baseline-musl
building opencode-darwin-arm64
building opencode-darwin-x64
building opencode-darwin-x64-baseline
building opencode-windows-x64
building opencode-windows-x64-baseline (macOS/Linux/Windows binaries) on this branch — builds succeed and binaries generated. Could someone from @anomalyco/opencode take a look when you have a moment?

@harshav167 harshav167 force-pushed the feature/session-directory-filtering branch from 0af5040 to e38b10f Compare January 14, 2026 03:33
@harshav167
Copy link
Author

Rebased this branch onto the latest (includes commit ), reinstalled dependencies, and reran • Packages in scope: @opencode-ai/app, @opencode-ai/console-app, @opencode-ai/console-core, @opencode-ai/console-function, @opencode-ai/console-mail, @opencode-ai/console-resource, @opencode-ai/desktop, @opencode-ai/enterprise, @opencode-ai/function, @opencode-ai/plugin, @opencode-ai/script, @opencode-ai/sdk, @opencode-ai/slack, @opencode-ai/ui, @opencode-ai/util, @opencode-ai/web, opencode
• Running typecheck in 17 packages
• Remote caching disabled
@opencode-ai/slack:typecheck: cache hit, replaying logs af3c5a11db7bf363
@opencode-ai/slack:typecheck: $ tsgo --noEmit
@opencode-ai/plugin:typecheck: cache hit, replaying logs 35404b6d24e9e55e
@opencode-ai/plugin:typecheck: $ tsgo --noEmit
@opencode-ai/ui:typecheck: cache hit, replaying logs f578c5d0cf842d7b
@opencode-ai/ui:typecheck: $ tsgo --noEmit
opencode:typecheck: cache hit, replaying logs f9da8dd226ff6325
opencode:typecheck: $ tsgo --noEmit
@opencode-ai/enterprise:typecheck: cache hit, replaying logs 6f8f29a54a7a466c
@opencode-ai/enterprise:typecheck: $ tsgo --noEmit
@opencode-ai/console-function:typecheck: cache hit, replaying logs 57dcc1902de0f81e
@opencode-ai/console-function:typecheck: $ tsgo --noEmit
@opencode-ai/desktop:typecheck: cache hit, replaying logs 3aa397b8e0f64ed2
@opencode-ai/desktop:typecheck: $ tsgo -b
@opencode-ai/util:typecheck: cache hit, replaying logs 7053f7781b6e91d9
@opencode-ai/util:typecheck: $ tsc --noEmit
@opencode-ai/app:typecheck: cache hit, replaying logs 5cbc2b6406d498c8
@opencode-ai/app:typecheck: $ tsgo -b
@opencode-ai/console-core:typecheck: cache hit, replaying logs 1ed45aefb63f6b7a
@opencode-ai/console-core:typecheck: $ tsgo --noEmit
@opencode-ai/sdk:typecheck: cache hit, replaying logs d174359a9080ff32
@opencode-ai/sdk:typecheck: $ tsgo --noEmit
@opencode-ai/console-app:typecheck: cache hit, replaying logs e4f2f79742cd02a7
@opencode-ai/console-app:typecheck: $ tsgo --noEmit

Tasks: 12 successful, 12 total
Cached: 12 cached, 12 total
Time: 153ms >>> FULL TURBO. Everything passes on the new base and the branch is now force-pushed with those results. Could @anomalyco/opencode give it another pass for merge?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant