Skip to content

feat(vscode): rs fmt document formatter stack - #5

Merged
fi3ework merged 10 commits into
mainfrom
feat/fmt-stack
Aug 7, 2026
Merged

feat(vscode): rs fmt document formatter stack#5
fi3ework merged 10 commits into
mainfrom
feat/fmt-stack

Conversation

@fi3ework

@fi3ework fi3ework commented Aug 7, 2026

Copy link
Copy Markdown
Member

What

iShot_2026-08-07_11.33.24.mp4

Brings the fmt stack from detection-only to a working document formatter, plus the observability and tooling that debugging it demanded.

  • Formatter provider (stacks/fmt): spawn-per-request rs fmt --stdin-filepath through VS Code's bundled Node (process.execPath + ELECTRON_RUN_AS_NODE), registered for the 24 language ids of the pinned prettier's getSupportInfo(). The spawn cwd is the nearest governing rstack.config.* directory because rs fmt resolves config from cwd only. A single minimal edit is produced from a prefix/suffix diff; formatting errors are log-only by design, and only launch failures mark the stack crashed.
  • Version floor: rstack >= 0.3.5, the first release with the full supported config and formatter surface. Older versions surface as a status-bar version mismatch, never a crash.
  • Logging: status-bar state transitions land in the shell log with their reason; the fmt channel logs each request prettier-style (entry + outcome with duration at info, resolution detail at debug) and forwards the CLI's stderr tail. A request in a folder without an rstack setup is explained once per folder instead of silently returning no edits.
  • F5 playground isolation: the extension-host debugger inherits the developer's personal profile, so a personal language-scoped editor.defaultFormatter could silently win over the fixture's settings while --disable-extensions makes that formatter unavailable — format-on-save then does nothing. The launch config now uses an isolated auto-created --profile (the debugger strips --user-data-dir), and the rstack fixture opts into format-on-save through the extension under development.
  • E2E hosts run at --log=warn to keep VS Code's own info noise out of test output (VSCODE_TEST_LOG_LEVEL opts back in).

Test plan

  • pnpm lint — 0 errors, 0 type errors.
  • pnpm test:unit — all passing (fmt run/pickConfigDir/minimalEdit units included).
  • pnpm test:e2e:vscode — exit 0; the fmt suite formats a fixture file through vscode.executeFormatDocumentProvider (quote normalization proves the edit came from prettier, not the built-in TS formatter) and asserts no edits for a folder where fmt is not detected.

Not in this PR

A lightweight pre-spawned standby to cut the ~130 ms cold-start latency is planned as a follow-up PR.

Status-bar state changes now land in the shell log with their reason, and
identical re-reports skip both the log line and the tooltip rebuild. The fmt
stack logs each request the way prettier-vscode does (entry and outcome at
info with duration, resolution detail at debug), forwards the CLI's stderr
tail on successful runs, and explains once per folder why a request in an
undetected folder did nothing.
The extension-host debugger inherits the developer's own profile, so a
personal language-scoped defaultFormatter silently outranks the fixture's
folder settings; with extensions disabled that formatter is unavailable and
format-on-save does nothing. Launch the playground with an isolated,
auto-created profile instead (the debugger strips --user-data-dir, so
--profile is the supported mechanism), and give the rstack fixture
format-on-save through the extension under development.
VS Code's CI-only extension inventory and AgentHost info logs drowned the
test output; --log=warn keeps them out while VSCODE_TEST_LOG_LEVEL preserves
an opt-in for verbose diagnosis.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff3ea28a84

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/vscode/src/stacks/fmt/index.ts
The watch matcher's endsPattern matched the per-target "built in" line, and
the worker bundle finishes seconds before the extension bundle — the first
F5 launched against a half-written dist/ and the extension failed to load.
Match the once-per-build "build completed" line instead.
A config or lockfile change can reshape the set of fmt-detected folders
while reconciliation deliberately keeps the controller alive, leaving the
status hover and shell log with stale folder names until the next
successful format. Report from the detection listener instead; an empty
snapshot stays silent because the shell's retire path owns the off states.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4fbf53787e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/vscode/src/stacks/fmt/index.ts Outdated
Mocha's reporter writes to the extension host's stdout, which never reaches
the harness log — CI showed only the failure count. The rejection message is
the one channel that does surface, so it now carries each failed test's
title and assertion message.
Detection can change while a format request is in flight; the success path
reported from the request's captured snapshot and reverted the hover and
shell log to the pre-change folder list.
The Windows runners check fixtures out with CRLF (autocrlf), and VS Code
drops EOL-only changes from computeMoreMinimalEdits, so the formatted
document keeps \r\n and the fmt E2E's exact-output assertion fails. Byte-
identical fixtures make the assertion hold everywhere without loosening it.
@fi3ework
fi3ework merged commit d8e196e into main Aug 7, 2026
3 checks passed
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