Skip to content

fix(desktop): recover from missing or inaccessible project folders - #50952

Open
OpeOginni wants to merge 2 commits into
anomalyco:devfrom
OpeOginni:missing-project-folder
Open

OpeOginni wants to merge 2 commits into
anomalyco:devfrom
OpeOginni:missing-project-folder

Conversation

@OpeOginni

@OpeOginni OpeOginni commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #50951

Depends on #51171. This branch is stacked on it, so the fix(server) commit here belongs to #51171. Review only the fix(desktop) commit. Once #51171 merges, this diff will show only the app and Desktop changes.

Type of change

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

What does this PR do?

The server now explains unavailable project folders: LocationNotFoundError (404) from #52668, plus LocationPermissionDeniedError (403) and the location.get re-check from #51171. Desktop still shows broken screens or a generic error page for both. This PR uses those errors to explain the problem and offer recovery.

  • Session and draft tabs: when the folder is missing or blocked, the tab shows a panel instead of a composer whose requests all fail.
    • Session tab: Move session (uses the existing move API, which does not need the old folder), Try again, Close project / Close tab.
    • Draft tab: Choose directory, Try again, Close project / Close tab.
    • Close project only appears when the unavailable folder is a saved root project, so a missing worktree never closes its parent.
  • Folders lost while OpenCode is running: the background server keeps a project's services cached, and the client caches its details too. When a cached project or restored tab is entered, Desktop calls location.get again, which re-checks the folder (fix(server): report location permission errors #51171), so the panel also appears for a folder deleted or renamed mid-session.
  • Permission wording: a blocked folder says the account needs read access. When the server runs on this Mac, it instead points to System Settings > Privacy & Security > Files & Folders (or Full Disk Access). It also notes that a terminal-started OpenCode needs the terminal allowed, and that opencode service restart may be needed.
  • Adding a project: a missing or blocked folder shows a persistent toast. A missing folder also gets Remove project. Other failures keep the current quiet behavior.
  • Error page: a saved route that fails this way explains the folder problem instead of "HTTP 404/403", and Desktop forgets that route so Restart returns to the project list.
  • First launch on macOS: if macOS blocks creating the default project in Documents, onboarding still completes (so the declined privacy prompt is not repeated on every launch) and explains how to grant access. This is detected locally in the main process.

How did you verify your code works?

  • bun run check from the repository root.
  • packages/app: bun run test:unit passes, including a case that recognizes both server errors (direct and SDK-wrapped), uses the macOS wording only when asked, and ignores unrelated errors.
  • packages/desktop: default-project tests cover creation and the denied-then-restored case.
  • Session entry benchmark (session-entry-benchmark.spec.ts, cold session from Home, 5 runs each), since entering a cached project now makes one extra location.get: stable time 282–394 ms on v2, 250–301 ms with this PR.

Screenshots / recordings

Server-side before/after recordings for both cases are on #51171. Desktop panel recordings are not captured yet; they require an unavailable local project folder.

Checklist

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

@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:

@OpeOginni OpeOginni changed the title fix(app): recover from missing project folders fix(app): recover from unavailable project folders Sep 23, 2026
@OpeOginni OpeOginni changed the title fix(app): recover from unavailable project folders fix(desktop): recover from unavailable projects Sep 24, 2026
@OpeOginni OpeOginni changed the title fix(desktop): recover from unavailable projects fix: recover from missing or inaccessible project folders Sep 24, 2026
@OpeOginni
OpeOginni force-pushed the missing-project-folder branch from cf98f17 to 7798c43 Compare September 24, 2026 16:48
@OpeOginni OpeOginni changed the title fix: recover from missing or inaccessible project folders fix(desktop): recover from missing or inaccessible project folders Sep 24, 2026
@OpeOginni
OpeOginni force-pushed the missing-project-folder branch from 7798c43 to f3cee21 Compare September 24, 2026 17:22
@OpeOginni
OpeOginni force-pushed the missing-project-folder branch from f3cee21 to 0a6ca86 Compare September 25, 2026 11:50
@OpeOginni
OpeOginni force-pushed the missing-project-folder branch from 0a6ca86 to 730ceea Compare September 28, 2026 10:15
@OpeOginni

Copy link
Copy Markdown
Contributor Author

macOS permission-denied project folder

Before (v2) After
Desktop.V2_No.Perm.mov
Desktop.Perm.Issue.FIx.mov

Deleted or renamed project folder

Before (v2) After
Desktop.V2_Renamed.Project.Issue.mov
Desktop.Deleted.Project.FIx.mov

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 3, 2026
@OpeOginni
OpeOginni force-pushed the missing-project-folder branch from f1e4ecc to d342a5f Compare October 3, 2026 18:01
@OpeOginni OpeOginni changed the title fix(desktop): recover from missing or inaccessible project folders fix(desktop): recover from missing project folders Oct 3, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

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

@OpeOginni
OpeOginni force-pushed the missing-project-folder branch from d342a5f to ce2b2ff Compare October 4, 2026 21:17
@OpeOginni OpeOginni changed the title fix(desktop): recover from missing project folders fix(desktop): recover from missing or inaccessible project folders Oct 4, 2026

This branch has not been deployed

No deployments
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.

desktop: missing or inaccessible project folder breaks project requests

1 participant