Skip to content

fix(project): trust a folder before the window loads it when opening with trust - #372

Open
Exeloo wants to merge 4 commits into
mainfrom
fix/trust-reopen
Open

Exeloo wants to merge 4 commits into
mainfrom
fix/trust-reopen

Conversation

@Exeloo

@Exeloo Exeloo commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Closes #313

The first Trust and open on /load logged two 404s and Could not load the project plugins RpcError: Project … is not open, and could show a git error toast. The window loaded the untrusted project, then trusting it made the server close that instance and open a new one under the same id, so reads still in flight went to a closed project.

  • packages/project (ProjectService.open): open(ref, { trust }) now trusts the folder on the server before the window loads it. If the window already holds that project untrusted, it closes it first. trust() is unchanged.
  • apps/editor (follow-project-plugins.ts): a per-call counter drops the remaining steps and errors of an earlier call, even when the project reopens under the same id.
  • /load page: Trust and open calls open(ref, { trust: true }) instead of open then trust() (3 lines).
open(ref, { trust }) -> projects.open -> projects.trust (if untrusted) -> projects.open -> load(id)

How do you test this PR?

Test Before After
e2e trust.spec.ts "the first Trust and open of a folder logs no error" (collects console errors, waits for the plugins and git reads, checks no git toast) failed: two 404s and Could not load the project plugins RpcError: Project … is not open trust.spec.ts --repeat-each 8 --retries 0: 16 passed; after the last round, --repeat-each 4: 8 passed
Unit packages/project/test/service/project-service.spec.ts (3 tests) 3 failed against the old service (the project stayed untrusted) 3 passed
Unit apps/editor/test/plugin/follow-project-plugins.spec.ts (stale call guard) failed against the old follow() passed

The unit test checks that no request reaches the untrusted instance: the calls are exactly projects.open, projects.trust, projects.open, with no fs or model request in between.

The last round (test only) names each trust copy per repeat and retry, so a CI retry still runs the trust branch, and replaces a fixed sleep with a wait on the plugins and git responses. With the old /load call put back, the new wait still fails the test (red); with the fix it passes.

Commands run from the worktree on cc9483b: pnpm build (17/17), pnpm lint (29/29, knip included), pnpm typecheck (41/41), packages/project unit tests (66 passed), apps/editor unit tests (13 passed, 1 skipped: editor-native.spec.ts, no .examples/), trust e2e on Chromium. On 5fe854a: the trust e2e, the two unit specs and pnpm lint. Not run: the full e2e suite on this branch, Firefox.

Integration: a scratch branch with every editor branch of this sweep merged passed pnpm build, lint, typecheck, pnpm test --force (1014 passed, 1 skipped) and the full e2e suite with the engine (141/141, Chromium only).

Merge danger

Follow-up issues

Quality gate

Lane Result HEAD covered
Docs N/A: no user-visible change (lessons only, recorded in the workspace) cc9483b
Correctness Pass (M1 retry reused a trusted folder, M2 fixed wait: both fixed in 5fe854a) cc9483b
Performance Not recorded -
Accessibility N/A: no UI change cc9483b
Security Pass cc9483b
Style Pass (2 lines over 100 columns, fixed in 306e063 and 5fe854a) cc9483b

Last round 306e063 and 5fe854a (test only): producer red→green, not re-reviewed.

@Exeloo
Exeloo requested a review from Tchips46 as a code owner November 29, 2026 11:12
@github-actions github-actions Bot added apps:editor Related to Editor app packages:project Related to Project package labels Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apps:editor Related to Editor app packages:project Related to Project package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First Trust and open logs Project is not open errors and a git toast

1 participant