Skip to content

fix(studio): stopping a recording keeps the test block it started with - #763

Merged
pbertsch merged 4 commits into
mainfrom
fix/record-header
Nov 17, 2026
Merged

pbertsch merged 4 commits into
mainfrom
fix/record-header

Conversation

@pbertsch

Copy link
Copy Markdown
Member

Summary

From the window check (after a restart, Record then Stop gave only two steps and no test "recorded flow" header). Not a restart problem: the header is added when the recording starts (btn-record, main.ts), and stopping replaced the whole editor with what StopRecording returned, which is the recorded steps alone. So every Studio recording lost its test block and open the app line, leaving steps outside any test. (probe record writes the block; Studio's stop did not.)

  • New pure recording-script.ts (recordingHeader, recordedScript): stop puts the steps under the header the recording started with; no steps leaves the header alone.
  • Node tests (test:recording, added to studio-ci.yml and ci-local.sh): one test block, steps under it, indentation kept, blank edges dropped, no-step cases.
  • This is a design reading, not a decision: the header is kept at stop rather than moved to the save step, so the editor always shows a runnable file.

The real recording path (Stop in the window with a device) was not run here; the function is what the stop handler now calls.

Test plan

  • npm run test:recording (4 pass); frontend build
  • disclosure scan

🤖 Generated with Claude Code

https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF

@pbertsch
pbertsch requested a review from a team as a code owner November 17, 2026 05:09
pbertsch and others added 3 commits November 17, 2026 07:21
…ader; merge main

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NxVy8Kr2nZk8HoMNcxZPFF
@pbertsch
pbertsch merged commit 8e168e5 into main Nov 17, 2026
11 of 12 checks passed
jay23606 added a commit to jay23606/flutter-probe that referenced this pull request Nov 17, 2026
AlphaWaveSystems#763)

## Summary
From the window check (after a restart, Record then Stop gave only two steps and no `test "recorded flow"` header). Not a restart problem: the header is added when the recording **starts** (`btn-record`, `main.ts`), and **stopping** replaced the whole editor with what `StopRecording` returned, which is the recorded steps alone. So every Studio recording lost its `test` block and `open the app` line, leaving steps outside any test. (`probe record` writes the block; Studio's stop did not.)

- New pure `recording-script.ts` (`recordingHeader`, `recordedScript`): stop puts the steps under the header the recording started with; no steps leaves the header alone.
- Node tests (`test:recording`, added to `studio-ci.yml` and `ci-local.sh`): one `test` block, steps under it, indentation kept, blank edges dropped, no-step cases.
- This is a design reading, not a decision: the header is kept at stop rather than moved to the save step, so the editor always shows a runnable file.

The real recording path (Stop in the window with a device) was not run here; the function is what the stop handler now calls.

## Test plan
- [x] `npm run test:recording` (4 pass); frontend build
- [x] disclosure scan
pbertsch added a commit that referenced this pull request Nov 17, 2026
…s a new file (#820)

## Summary
Fixes #397. After Record and Stop the buffer had no file, so Save was disabled and Cmd/Ctrl+S did nothing: a recording could not be saved. (The `test "recorded flow"` header at Stop was fixed in #763.) Now Save on a buffer with no file asks for a name in a dialog in the page (no native prompt: the window's webview shows none), default `recorded.probe` for a recording and `untitled.probe` otherwise, and writes it in the folder the Workspace pane shows (the workspace root when it shows another place). The new file becomes the open one, so Save and Run work on it.

Rules for the name (pure, node-tested): a file that exists is never replaced (compared without case); a slash, colon, wildcard, quote, leading dot, hidden or direction character, a name only `.probe`, one over 100 code points or an extension other than `.probe` is refused in the dialog, which stays open with the reason; a name without an extension gets `.probe`. Escape, Cancel and a click on the dark area save nothing; with no workspace open Save says it needs one. The write is exclusive: a new bound method, `CreateFile`, creates the file with `O_EXCL` under the same root confinement as `WriteFile` (only `.probe`, inside an allowed folder, no folder is created), so a file that appeared after the name was checked, a link in its place (even a dangling one) or the same name in another case on a case-insensitive file system fails with "already exists: Save never replaces a file"; a half-written new file is removed. `WriteFile`, which saves an open file in place, is unchanged. The allowlist entry (`writesWorkspace`, window and bridge, files) and the bindings are added.

Also after review: `CreateFile` checks the name itself (a script can call it): `.probe` only (lower case), no leading dot, no trailing dot or space before `.probe`, no Windows device names (CON, PRN, AUX, NUL, COM1-9, LPT1-9, also as `CON.x.probe`), no hidden, direction or control character, at most 255 bytes, and compares the folder's listing folded (NFC and case) so a name that differs only by case or normalisation is refused on every file system, with the exclusive create as the check that cannot race. The window applies the same rules (and writes `x.PROBE` as `x.probe`). Save is not re-entrant: while a file is being written Save is off, its shortcut is ignored and nothing lists the folder again. The old `WriteFile` entry now says it replaces in place and creates folders, and does not claim Save-as. Not changed: `WriteFile` can write a `.probe` under `.git` inside the workspace (existing behaviour).

## Test plan
- [x] Go: a file created between the check and the write is not replaced (the answer says it exists); a link, a dangling link, a folder, a non-`.probe` name, a path outside the workspace and a missing folder are refused and nothing is created or changed; the same name in another case where the file system ignores case. Mutants: `O_TRUNC` instead of `O_EXCL` (plain overwrite) fails 3 tests; neither flag fails 3.
- [x] Go: a file that appears between the listing and the create (a test seam) is not replaced; 40 concurrent creates of one name: exactly one wins; the folding is tested as data (case, NFC/NFD, both); mutants: no O_EXCL, no folding, no normalisation, no case folding, no name rules all killed.
- [x] Playwright sa-06: a second Save while the first is writing is ignored and writes once (the no-guard mutant fails it); sa-03 also refuses `a..probe`, `CON`, `nul.probe`.
- [x] Playwright sa-05: a refused write leaves the buffer unsaved and shows the reason.
- [x] Node tests of the name rules (6) and of the Save reason; wired into ci-local.sh and studio-ci.yml.
- [x] Playwright sa-01..sa-06, each with its own Studio on a fresh folder: save and open the new file; an existing name (other case) refused and nothing replaced; paths, hidden file, other extension, hidden character and empty refused and no file written; Escape, Cancel and the dark area write nothing. Mutants: the existing-name check dropped (sa-02 fails), the forbidden-character check dropped (sa-03 fails).
- [x] Full web suite 206 passed (no device), `go test ./studio`, the other frontend node suites.
- [x] CHANGELOG, `docs/tools/studio.md`, e2e README.
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