Skip to content

fix(core): save a location's project only after its folder is found - #59001

Open
andreivince wants to merge 3 commits into
anomalyco:devfrom
andreivince:missing-project-directory
Open

andreivince wants to merge 3 commits into
anomalyco:devfrom
andreivince:missing-project-directory

Conversation

@andreivince

@andreivince andreivince commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #57988

Type of change

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

What does this PR do?

A request for a folder that no longer exists already returns 404, but booting the location saved its Project first, so the missing folder showed up in GET /api/project and stayed there after a restart. Existing rows for missing folders also got time_active bumped on every such request.

Location now resolves the Project without saving it, and a new LocationProject node saves it and records activity once FileSystem has accepted the folder. Profiles whose FileSystem doesn't check the host, like workerd, still save projects, and creating a session in a missing folder is unchanged. This moves where the Project gets saved during a location boot, so a maintainer's view on the placement is welcome. The Desktop "recently closed" side of the issue isn't covered here.

#58997 stops session routes from booting a Location at all; this PR only changes what a Location boot saves, so the two don't overlap in behavior (they touch instance.ts and fetch.test.ts in different places).

How did you verify your code works?

New tests in packages/server/test/fetch.test.ts (a missing folder is not listed, and is listed once it exists) and packages/server/test/workerd.test.ts (workerd locations are still saved), plus a time_active check in the existing missing-folder test. The fetch test and the time_active check fail on dev and pass now. I also ran the issue's steps against a real opencode serve, including a restart. bun run test and bun typecheck pass in packages/server and packages/core, apart from ripgrep and bash tests that fail on this Mac on dev too.

Screenshots / recordings

Not a UI change.

Checklist

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

Added by the opencode bot (AI-generated).

Related: #51197, #57987, #50951

Copilot AI balanced review requested due to automatic review settings October 25, 2026 15:30

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 was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@opencode-agent opencode-agent Bot 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.

Looks good. I ran the reproduction from #57988 against a server built from source, on the base and with this change. On the base, a 404 location request for a missing folder still saves a project, and it survives a restart. With this change, nothing is saved, and the project appears once the folder exists. The new tests fail without the fix and pass with it; the core location and project tests and tsc in packages/core and packages/server pass.

Public API is unchanged: no HTTP routes, SDK, events or config change.

The new node that saves the project depends on FileSystem, so a missing folder fails the boot before anything is written. Workerd keeps saving projects, and activity tracking from session events stays in LocationLifecycle. Resolving the project twice per boot (once without saving in Location, then again to save it) costs little thanks to the git-discovery cache. No blocking concerns.

Related: #51197, #57987, #50951

@opencode-agent opencode-agent Bot 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.

The new commit only merges dev; the pull request's own changes are unchanged. I re-ran the #57988 reproduction on the new head: requests for the missing folder still return 404 and save nothing, and the project appears once the folder exists. The server tests in fetch.test.ts and workerd.test.ts pass, and tsc passes in packages/core. Public API is unchanged. No new concerns.

@opencode-agent opencode-agent Bot 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.

The new commit only merges dev (including #58997); the pull request's own changes are unchanged and combine cleanly with #58997's test changes. I re-ran the #57988 reproduction on the new head: requests for the missing folder still return 404 and save nothing, and the project appears once the folder exists. The server tests in fetch.test.ts and workerd.test.ts pass, and tsc passes in packages/core and packages/server. Public API is unchanged. No new concerns.

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.

A folder that no longer exists gets turned into a new project

2 participants