Skip to content

[M11] Start dialog that writes the snippet (M11.8) - #98

Closed
ssoufii wants to merge 1 commit into
mainfrom
auto/m11.8-start-dialog
Closed

ssoufii wants to merge 1 commit into
mainfrom
auto/m11.8-start-dialog

Conversation

@ssoufii

@ssoufii ssoufii commented Nov 17, 2026

Copy link
Copy Markdown
Owner

The last section of the page: an open "new database" dialog that writes the Python for the choices a visitor makes, beside the closing line.

The snippet is code that has been run

There is one template, web/src/data/snippet.json. The page renders it (snippet.ts) and tests/test_snippet.py renders the same template for every fsync choice, writes it to a file, runs it as a subprocess, checks what it printed, and then reopens the database it claims to have written to confirm the record is really there. A snippet composed by the page alone would be code nobody ever ran, and "getting started takes one copy" is only true if the thing copied works.

A second test asserts the snippet still matches the engine's real constructor and parameter names, so renaming fsync_policy in src/ledgerlog breaks a test rather than quietly shipping a snippet that no longer runs.

The directory field is free text, so it is escaped into a Python string literal on both sides, and a test parses the rendered snippet with a quote and a backslash in the path.

Acceptance criteria

  • The start section is built as section 6 describes: the "new database" dialog with an editable directory field, a segmented fsync choice and the "copy the code" button, beside the closing line.
  • The snippet uses the real constructor and parameter names from src/ledgerlog, and pytest executes the snippet the page generates for each fsync choice, from one shared template.
  • Copying shows "copied" for 1.5 seconds and works by keyboard; a link goes to the GitHub repository.
  • Playwright: changing the directory and the fsync choice changes the snippet; the copy button writes the snippet to the clipboard.

What ran, and what passed

  • pytest: 1311 passed (7 new). ruff check src tests and ruff format --check src tests: clean.
  • In web/: npm ci, lint, typecheck, build: clean.
  • npx playwright test: 118 passed across both projects. Playwright ran locally, not only in CI.

The clipboard test reads the clipboard back rather than trusting the button's label, so "copied" cannot be true while nothing was copied. The keyboard test drives the whole dialog with no pointer at all: type the directory, arrow between the fsync segments, Enter on the button, then read the clipboard and check it is the snippet for those choices.

I looked at the section at 1440 and 390.

Two more house rules tightened

Both came out of the spec failing on this work rather than being designed around:

  1. The dialog's shadow was a literal. Section 7 allows exactly one shadow on the page, inside an open dialog in a [data-ui] fragment, and it is now --shadow-dialog in the token file, where a second one would be visible as a second token.
  2. The tab walk did not know about radio groups. Sequential focus navigation gives a group of native radios one tab stop, the checked member, and the arrow keys move within it. The walk now skips the unchecked members for that reason, which is the platform's rule rather than this page's, and start.spec.ts asserts the arrow key movement.

Decisions taken without asking

  • The dialog is a real <dialog open> laid out as a panel. Section 6 asks for a dialog that is already open, and using the element means the shadow section 7 permits is permitted by the rule as written rather than by an exception. A non-modal <dialog open> is absolutely positioned by default, which took it out of the grid and over the closing line, so it is set back to static.
  • The fsync choice is native radios with the label as the segment. The visible segment is the label and the radio inside it is hidden from the eye but not from the keyboard or a screen reader, so arrow key movement comes from the platform rather than from a key handler, and the focus ring is drawn on the segment around the hidden input.
  • The default choice is always, the engine's own constructor default, so the snippet a visitor copies without touching anything is the snippet for the engine's defaults.

Closes #86


Generated by Claude Code

Story M11.8. The start section is an open "new database" dialog beside the
closing line: a directory field, a segmented fsync choice, the snippet for
those choices, and one button that copies it and says so for 1.5 seconds.

The snippet comes from one template in web/src/data/snippet.json.
tests/test_snippet.py renders the same template for every fsync choice,
writes it to a file, runs it as a subprocess and reopens the database it
claims to have written to check the record is there. Another test asserts
the snippet still matches the engine's real constructor, so renaming a
parameter breaks a test rather than shipping a snippet that no longer runs.

The directory is free text, so it is escaped into a Python string literal
and a test parses the result with a quote and a backslash in the path.

Two more house rules were tightened on the way: the one shadow the page is
allowed is now a token, and the tab walk knows that a radio group is one
tab stop, which is the platform's rule and not this page's.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWNkuNh5Bysnfo2KrxL9Sp
@ssoufii

ssoufii commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

Closing as a duplicate: M11.8 was implemented and merged in #97 from a local session, at the owner's request to take over the remaining stories by hand. The routine has been disabled.

@ssoufii ssoufii closed this Nov 17, 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.

[M11] Start dialog that writes the snippet (M11.8)

2 participants