Skip to content

feat(studio-server): stamp a project hf-ids without holding the event loop - #7004

Merged
miguel-heygen merged 1 commit into
mainfrom
dscan/stamp-yield
Nov 2, 2026
Merged

miguel-heygen merged 1 commit into
mainfrom
dscan/stamp-yield

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

A host can stamp a project's hf-ids without freezing its event loop.

stampProjectHfIds reads, parses and stamps every HTML file in one synchronous run. For a desktop app that is its main thread: a 40-page project (about 330 KB of HTML) took 627 ms to stamp, with nothing else able to run. The new stampProjectHfIdsAsync runs the same pass and yields to the event loop after each file. Both are driven by one generator (stampPass), so the record, the hash skip and the per-file stamp stay in one place; the synchronous function is unchanged in what it writes.

Design: none (an async entry beside the sync one)

fails without the fix: lets the event loop run between files of a project

What I measured

  • The new test fails when the yield is removed and passes with it (a timer set after starting the pass fires with some, not all, of 40 files stamped); the sync and async passes leave identical files; all 635 studio-server helper tests pass; typecheck clean.

What I did NOT exercise

  • A host calling it; the walk of the project's folder (walkDir) is still one synchronous listing.

Size

3 files, about +90 -25.

@heygengenesis heygengenesis 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.

Verdict: APPROVE · 0 blocker · 0 important · 0 nits · head 03f338a2

The refactor keeps what the sync pass writes: hashAfterStamp's early return is the old condition turned around. Yielding between files only gives other code a chance to edit a file after its hash is taken. The worst outcome is a stale record entry, which just means that file is parsed again next time. stampFileHfIds still only writes when the file is unchanged, and walkDir lists the folder once up front, so a file deleted mid-pass reads as null and is skipped.

Checks
  • hfIdPersist* tests: 12/12 on 3 runs.
  • 'fails without the fix' holds. With the setImmediate yield replaced by await Promise.resolve(), lets the event loop run between files of a project fails with expected -1 to be greater than 0. It passes with the yield.
  • Nothing calls the async function yet: cli/src/server/studioServer.ts:445 still uses the sync pass, as the body says.
  • CI: no failures at review time; some jobs still running.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 101 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (4)

  • seqplainkeys-none-center-r0-nested-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true
  • seqrotatenudge-none-pct-r0-root-z100: tracking 0.03, pressJump 0, drop 0, reload 3.03, render 0.04, renderKey -, undo false, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.08, renderKey -, undo true, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.08, renderKey -, undo true, teleport true
  • seqab-none-center-r0-root-z100: tracking 0.03, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.03, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true
  • seqplainkeys-none-pct-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 2, 2026
@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit d17b958 Nov 2, 2026
82 checks passed
@miguel-heygen
miguel-heygen deleted the dscan/stamp-yield branch November 2, 2026 11:30
@heygengenesis heygengenesis Bot mentioned this pull request Nov 2, 2026
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.

1 participant