Skip to content

fix(session): tolerate missing directories - #41190

Closed
zcxGGmu wants to merge 1 commit into
anomalyco:devfrom
zcxGGmu:missing-session-dir
Closed

zcxGGmu wants to merge 1 commit into
anomalyco:devfrom
zcxGGmu:missing-session-dir

Conversation

@zcxGGmu

@zcxGGmu zcxGGmu commented Aug 8, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #40677

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Makes SystemPrompt.environment tolerate a missing session directory while collecting optional project references.

When a continued session points at a directory that has been renamed or deleted, booting the location-scoped reference services can fail before the prompt is sent. The environment prompt now falls back to no project references for that optional section while still rendering the core working-directory/worktree context.

How did you verify your code works?

  • bun test ./test/session/system.test.ts --test-name-pattern 'environment still renders when the session directory no longer exists'
  • bun test ./test/session/system.test.ts
  • bun typecheck in packages/opencode
  • bun run lint packages/opencode/src/session/system.ts packages/opencode/test/session/system.test.ts
  • git diff --check

Note: scoped lint reports existing warnings in this area but exits successfully with no errors. Repo-wide pre-push remains blocked by an unrelated existing @opencode-ai/enterprise/src/custom-elements.d.ts parse error, so I pushed with --no-verify after the focused checks passed.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
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.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

opencode -c fails with "Unexpected server error" after project directory is renamed/deleted

2 participants