Skip to content

fix(server): reject prompts when the session directory no longer exists - #52106

Closed
craigmoliver wants to merge 3 commits into
anomalyco:devfrom
craigmoliver:fix/missing-session-directory
Closed

craigmoliver wants to merge 3 commits into
anomalyco:devfrom
craigmoliver:fix/missing-session-directory

Conversation

@craigmoliver

@craigmoliver craigmoliver commented Sep 29, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #52108

Type of change

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

What does this PR do?

Sessions store their directory. If that folder is renamed, moved, or deleted, prompt_async returns 204 and the run then dies in FileSystem.realPath with ENOENT, so the app shows nothing at all.

This adds a requireRunnableSession check to the prompt, prompt_async, command, and shell handlers. If the session directory is gone, the request fails up front with a NotFoundError ("Session directory no longer exists: …"). The app's submit path already shows a "Prompt send failed" toast using data.message, so no app changes are needed.

How did you verify your code works?

  • Added a test that renames a session's directory, calls prompt_async, and expects a 404 with that message
  • bun test test/server/httpapi-session.test.ts: 22 pass
  • bun run typecheck: clean
  • Hit this myself in the desktop app after renaming a project folder

Screenshots / recordings

N/A, server-side change.

Checklist

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

Sessions persist their directory. If it is moved, renamed, or deleted,
prompt_async returns 204 and then dies inside filesystem resolution, so
clients see nothing happen. Check the directory up front for prompt,
prompt_async, command, and shell and return a NotFoundError with a
message the app surfaces in its "Prompt send failed" toast.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Lnd6NhhWiX7Z168fTNWnhM
Copilot AI balanced review requested due to automatic review settings September 29, 2026 16:07
@github-actions github-actions Bot added needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Sep 29, 2026
@github-actions

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

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused validation and regression test correctly address the reported silent failure.

Review effort: Balanced
Findings: None

What changed in this PR

Rejects runnable session operations when their persisted directory is missing, allowing clients to surface a clear 404 error.

Changes:

  • Adds shared directory validation for prompt, async prompt, command, and shell handlers.
  • Adds regression coverage for renamed session directories.
File Description
packages/​opencode/​src/​server/​routes/​instance/​httpapi/​handlers/​session.ts Validates persisted session directories before execution.
packages/​opencode/​test/​server/​httpapi-session.test.ts Tests the prompt_async 404 response.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Sep 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The shared validation correctly addresses the reported failure and is covered by a focused regression test.

Review effort: Balanced
Findings: None

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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.

Desktop: sending a prompt does nothing after the project folder is renamed

4 participants