Skip to content

GUI: terminal output in release builds, headless subcommands, --without demo, --base - #20

Merged
lnorton89 merged 6 commits into
mainfrom
claude/confident-edison-nqs7ek
Nov 19, 2026
Merged

lnorton89 merged 6 commits into
mainfrom
claude/confident-edison-nqs7ek

Conversation

@lnorton89

@lnorton89 lnorton89 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Works through the four open issues, one commit each, in dependency order (#17 builds on #15), plus a review fix. #16 was a duplicate of #15 and is closed.

Issue Commit What changed
#15 release build prints nothing from a terminal 5ac49d3, refined in e589df2 main() parses with try_parse(). It calls borrow_console() only when there's output: clap's help, version and usage errors (same exit codes as clap's exit()), the hand-rolled parser's equivalents, and a headless subcommand. That function wraps win::console::attach_parent(), a one-call safe leaf around AttachConsole(ATTACH_PARENT_PROCESS) inside the existing src/win/ unsafe boundary (plus the Win32_System_Console feature). Opening the window never attaches, so closing the terminal or pressing Ctrl+C in it doesn't close the app. Explorer launches have no parent console and are unchanged.
#18 --without demo 1a56b30 features.demo (default on). Off: Page has a single Home drawn by home(); no cards, selected_card, palette or about pages. Pages are now additive in both modes: Ctrl+1…9 come from a PAGE_KEYS table zipped with Page::ALL, and the shortcut test checks SHORTCUTS against Page::ALL.len() instead of a literal 3. docs/ARCHITECTURE.md has a fuller "Adding a page". With the demo on, the only code change is that generic shortcut table.
#19 --base ca86f1d --base <id> (or Customize › App) takes any theme in the shipped themes.toml, read by the new src/gen/themes.ts, so the catalog the app compiles in is the single source. The theme's mode, surfaces, text, status colours and span fill signature_spec through base* tokens, and its accent becomes FALLBACK_ACCENT. On a light base the accent retries go darker. The default midnight reproduces the old literals exactly; only comments change. A light base exposed two latent bugs, now fixed: emergency() borrowed FALLBACK_ACCENT for Midnight surfaces, and a test asserted the signature theme is dark.
#17 --with subcommands on GUI kinds 87fccb3 Cli gains command: Option<Command> with two jobs that are useful in any build: themes and paths. main() runs a subcommand headless right after parsing, before the single-instance check, and reports failures to stderr only, with no dialog. A bare run still opens the window. tests/cli.rs covers both paths. Works for gui and workspace, and needs clap.

Contract changes (CONTRACTS.md updated)

  • New answers: Answers.features.demo (bool, default true) and Answers.themeBase (a shipped theme id; '' without a GUI).
  • Widened answer: features.subcommands now applies to GUI kinds too.
  • New tokens: baseName baseMode baseApp basePanel baseRaised baseHover baseBorder baseText baseTextMuted baseDanger baseWarning baseSuccess baseSpan baseAccentRgb.
  • New flags: base_dark / base_light.

Test plan

🤖 Generated with Claude Code

https://claude.ai/code/session_01W2BaQmV2uiGiqUHSfS6KUH

main.rs sets windows_subsystem = "windows" in release builds so an
Explorer launch opens no console, but the app still parses a command
line: from a terminal, --help, --version and clap's usage errors went
nowhere (exit 0, nothing printed).

With arguments (Explorer passes none) main() now calls
win::console::attach_parent() before parsing: a one-call safe leaf
around AttachConsole(ATTACH_PARENT_PROCESS), inside the existing
src/win/ unsafe boundary. No parent console (Explorer) or an existing
one (debug builds) leaves things as they were. windows-sys gains the
Win32_System_Console feature.

Closes #15

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W2BaQmV2uiGiqUHSfS6KUH
Every desktop project started with demo content the first real commit
had to remove: six CARDS on an Overview page, Palette and About pages,
their glyphs, selected_card, a Ctrl+1..3 shortcut list and tests
pinned to three pages and three cards. Removing it by hand touched
four files and failed the dead-code lints until all of it was gone.

features.demo (default on, so the showcase stays for first-timers)
turns it off: Page has a single Home variant drawn by home(), with a
heading, a pointer to the docs and an Open settings button.

Pages are now additive in both modes: Ctrl+1..9 come from a PAGE_KEYS
table zipped with Page::ALL (the command palette already followed it),
and the shortcut test checks SHORTCUTS against Page::ALL.len() rather
than a literal 3. docs/ARCHITECTURE.md's 'Adding a page' says what's
left to do by hand.

Answers gains features.demo (CONTRACTS.md updated).

Closes #18

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W2BaQmV2uiGiqUHSfS6KUH
The signature theme always used Midnight's blue-black surfaces; a media
or editing app wanting neutral chrome had to hand-edit signature_spec
and re-check the readability tests.

--base <id> (or 'Signature theme surfaces' under Customize > App)
accepts any theme in the shipped themes.toml, read by the new
src/gen/themes.ts so the catalog the app compiles in is the single
source. Its mode, surfaces, text, status colours and rainbow span fill
signature_spec through base* tokens, and its own accent becomes
FALLBACK_ACCENT. On a light base the accent retries go darker instead
of lighter (base_light flag). The default, midnight, reproduces the
previous literals exactly; only comments change.

Two things a light base exposed, now fixed: emergency() took its accent
from FALLBACK_ACCENT though its surfaces are always Midnight's (it now
uses Midnight's accent), and a gui test asserted the signature theme is
dark (it now follows the theme's mode).

Checked with the full gate on graphite, daylight (pink and yellow
accents, the latter exercising the fallback), parchment without the
catalog, void (workspace) and the default.

Answers gains themeBase; Ctx gains the base* tokens and base_dark /
base_light flags (CONTRACTS.md updated).

Closes #19

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W2BaQmV2uiGiqUHSfS6KUH
Desktop apps often need the same binary to run headless jobs for
scripts, CI and agents, and open the window when run bare. That meant
hand-merging the cli template's Subcommand skeleton into the GUI.

With features.subcommands on a gui or workspace project (clap required):

- Cli gains #[command(subcommand)] command: Option<Command>, with two
  jobs that are useful in any build: 'themes' (the themes it can draw)
  and 'paths' (where it keeps its files). Command::run(out) dispatches
  with no wildcard arm.
- main() takes the command right after parsing and runs it headless,
  before the single-instance check so a job can run beside an open
  window. A failure goes to stderr only, with no dialog. Paired with the
  console attach from #15, a release build prints to the terminal.
- tests/cli.rs covers both paths: a bare run means the window, a
  subcommand parses and runs against a buffer, an unknown one is refused.

The interactive Crates step offers 'Window only' / 'Subcommands' for
desktop kinds too.

Closes #17

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W2BaQmV2uiGiqUHSfS6KUH
Review follow-up to the #15 fix. main() attached whenever it had
arguments, so 'app --theme nebula' from a terminal opened a window tied
to that console: closing the terminal, or Ctrl+C in it, closed the app.

main() now parses with try_parse() first and calls borrow_console() only
when there is output: clap's help, version and usage errors (exit codes
as clap's exit() gives them), the hand-rolled parser's equivalents, and a
headless subcommand. Opening the window never attaches. A window-start
failure in a release build is therefore reported by the dialog alone,
not twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W2BaQmV2uiGiqUHSfS6KUH
The previous commit put borrow_console() before the headless run; the
test's regex predated it. It now also checks that main() never attaches
just because there are arguments. The main.rs docs mention headless jobs
only when subcommands are on.

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

@lnorton89 lnorton89 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Code review

Reviewed origin/main...87fccb3 line by line, then for removed behaviour and for callers of the changed functions. Two findings, both fixed:

Finding Severity Outcome
main() attached to the parent console whenever it had arguments, so app --theme x from a terminal tied the window to that console. Closing the terminal or pressing Ctrl+C there would close the app (Windows sends close and Ctrl+C events to every attached process). important Fixed in e589df2: parse with try_parse() and attach only to print (help, version, usage errors, headless jobs). Opening the window never attaches.
A start-up failure from a terminal launch would be reported twice: on stderr, then in a blocking dialog. nit Fixed by the same change: a window launch no longer attaches, so in a release build the dialog is the only report.

e589df2 was pushed with one Node test still expecting the old dispatch shape. That's why the Node jobs on that commit are red. 073fcd4 updates the test, which now also asserts that main() never attaches merely because there are arguments.

CI: 32/32 green on 073fcd4, including the Windows scaffold jobs that compile src/win/console.rs and run the generated tests.


Generated by Claude Code

@lnorton89
lnorton89 merged commit db3693d into main Nov 19, 2026
32 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.

2 participants