Commit 105839e
authored
perf(vscode): pre-spawned rs fmt standby for the active editor (#6)
* feat(vscode): keep a pre-spawned rs fmt standby for the active editor
A cold format pays ~130ms of process start-up and config load before any
formatting happens. The fmt stack now keeps one pre-spawned rs fmt child
parked on stdin for the active editor's file, so the next format of that
file writes to a process that has already paid both.
The standby is bounded on purpose: one process, one file, one request. It is
armed 2s after the active editor settles (immediately at registration and
after a format), killed whenever it could have gone stale — a config content
edit, a detection change, restart or dispose — and reaped after five idle
minutes. Anything it cannot serve falls back to the cold path unchanged, and
the whole mechanism is invisible above debug level except for the hot/cold
marker on the completion line.
CONTEXT.md records the vocabulary the code and logs use, and the fmt gotcha
in AGENTS.md now states the exception and its limits.
* chore(vscode): quiet the F5 playground's launch notifications
The isolated playground profile installs no extensions, so
--disable-extensions only contributed its own notification on every launch.
Git is a built-in and ignores that flag entirely: it offered to open the
parent repository each time, because every fixture lives inside this repo.
Disable that one extension instead.
* fix(vscode): drop the standby when the active editor cannot be armed
An active editor the provider matches but the stack cannot resolve — an
undetected folder, a missing or too-old rstack package — logged the skip and
returned, leaving the previous file's standby parked for up to five idle
minutes. The editor had still moved on, so that standby no longer tracked it
and could serve a programmatic request for a file the user had left.
Arming already kills a standby it replaces; this path has nothing to arm, so
it has to kill on its own. An editor holding nothing formattable at all still
leaves the standby alone: a peek at the output panel must not cost the user
their warm process.
* docs(vscode): correct the standby's active-editor wording
The docstring justified keeping a standby across an ineligible editor with
a peek at the output panel, which cannot happen: the active editor is the
focused one or, when nothing is focused, the most recently changed one, so
focusing a panel leaves it pointing at the same file and fires no change.
Name the cases that do reach it — no text document at all, or one this stack
does not format — and say why neither is worth a kill. CONTEXT.md stated the
invariant more strongly than the code holds it; it now states both outcomes.
* docs(vscode): correct the standby's active-editor wording, rename reap to expire
The docstring justified keeping a standby across an ineligible editor with a
peek at the output panel, which cannot happen: the active editor is the
focused one or, when nothing is focused, the most recently changed one, so
focusing a panel leaves it pointing at the same file and fires no change.
Name the cases that do reach it — no text document at all, or one this stack
does not format — and say why neither is worth a kill. CONTEXT.md stated the
invariant more strongly than the code holds it; it now states both outcomes.
'Reap' reads as jargon for what the idle timer does, so the term is now
'expire' in the glossary, the log reason and the tests.
* fix(vscode): invalidate the standby on every rstack config event
The config watcher listened for content changes only, on the reasoning that
a create or a delete moves the detection signature and arrives as a detection
change instead. That holds for a real create or delete, not for the
delete/create pair an editor emits when it saves by atomically replacing the
file: the config path is gone and back within one scan, the signature records
paths rather than content, and no detection change fires. Both halves were
also ignored here, so nothing invalidated the standby and the parked process
kept serving the config it had loaded at spawn — the same file then formatted
one way hot and another way cold.
Watch all three events. A redundant kill costs nothing: it is idempotent and
the active editor re-arms through the usual debounce.1 parent 048ba8c commit 105839e
10 files changed
Lines changed: 1069 additions & 165 deletions
File tree
- .vscode
- packages/vscode
- src/stacks/fmt
- tests/e2e/suite
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
0 commit comments