Skip to content

Conversation

@dzianisv
Copy link

@dzianisv dzianisv commented Feb 3, 2026

Summary

Fixes an issue where opencode -c (continue) and opencode session list showed sessions from all worktrees of the same repository instead of only sessions for the current directory.

Problem

When running opencode from a git worktree directory (e.g., ~/workspace/project.worktree1), the CLI commands would incorrectly show/continue sessions from the main repository or other worktrees. This happened because:

  1. Sessions are stored with a directory field that correctly identifies which worktree they belong to
  2. Sessions are grouped by projectID (derived from git root commit hash) - this is the same for all worktrees
  3. The CLI commands were not filtering sessions by the current directory

Changes

  • run.ts: Pass process.cwd() to sdk.session.list() when using the -c (continue) flag
  • session.ts: Filter session list to only show sessions where session.directory === Instance.directory

Testing

This change aligns CLI behavior with the TUI, which already filters sessions by directory in packages/app/src/pages/layout.tsx.

Before: Running opencode session list from project.worktree1 shows sessions from project, project.worktree1, project.worktree2, etc.
After: Running opencode session list from project.worktree1 shows only sessions created in project.worktree1.

dzianisv and others added 16 commits December 17, 2025 12:28
- Add JWT expiration check utility
- Implement dynamic base URL resolution based on token environment
- Add missing x-api-key and Authorization: Bearer headers
- Add organizationId to ApiAuth schema
- Add proactive token expiration warnings in CLI and model discovery
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…itely

When network issues occur mid-stream (TCP half-open connections, stalled LLM
providers, proxy timeouts), the streaming loop would hang forever waiting for
the next chunk. This fix adds an idle timeout that detects when no data has
been received for a configurable period (default 60 seconds) and triggers a
retry with exponential backoff.

Changes:
- Add StreamIdleTimeoutError class to message-v2.ts
- Add withIdleTimeout() async generator wrapper in processor.ts
- Wrap stream.fullStream with idle timeout in the process loop
- Mark StreamIdleTimeoutError as retryable so sessions recover automatically
- Add stream_idle_timeout config option under experimental settings
- Add additional network error types (ETIMEDOUT, ENOTFOUND, etc) as retryable

Fixes issues where sessions get stuck for hours on LLM requests.
Related: anomalyco#8383, anomalyco#2512, anomalyco#2819, anomalyco#4255
fix: add stream idle timeout to prevent sessions from hanging indefinitely
Integrate Kilo Code provider:
- Add kilocode device authorization flow in auth.ts
- Add kilocode provider loader in provider.ts
- Add dynamic model discovery from Kilo Code API in models.ts
- Add JWT expiry check for kilocode tokens in run.ts
- Add install:local script for developer convenience
- Add desktop infra import in sst.config.ts

Preserves dev branch improvements:
- Provider filtering (enabled/disabled providers)
- Improved Data lazy loading with Flag support
- Better message handling in run command
- Plugin auth handling
When running 'opencode -c' (continue) or 'opencode session list' from a
git worktree directory, the CLI was incorrectly showing sessions from
all worktrees of the same repository. This happened because sessions
are grouped by projectID (git root commit hash), which is the same for
all worktrees.

Changes:
- run.ts: Pass current directory to sdk.session.list() when using -c flag
- session.ts: Filter sessions to only show those matching Instance.directory

This matches the existing TUI behavior which already filters by directory.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

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.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

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

I found a related PR that appears to be addressing a similar issue:

Potential Related PR:

Also note:

These are not duplicates of PR #12008, but rather related efforts that address the same underlying issue in different parts of the codebase (TUI vs CLI).

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