Repository navigation
GUI: terminal output in release builds, headless subcommands, --without demo, --base - #20
Merged
Merged
Conversation
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
commented
Nov 19, 2026
lnorton89
left a comment
Contributor
Author
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
5ac49d3, refined ine589df2main()parses withtry_parse(). It callsborrow_console()only when there's output: clap's help, version and usage errors (same exit codes as clap'sexit()), the hand-rolled parser's equivalents, and a headless subcommand. That function wrapswin::console::attach_parent(), a one-call safe leaf aroundAttachConsole(ATTACH_PARENT_PROCESS)inside the existingsrc/win/unsafe boundary (plus theWin32_System_Consolefeature). 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.--without demo1a56b30features.demo(default on). Off:Pagehas a singleHomedrawn byhome(); no cards,selected_card, palette or about pages. Pages are now additive in both modes:Ctrl+1…9come from aPAGE_KEYStable zipped withPage::ALL, and the shortcut test checksSHORTCUTSagainstPage::ALL.len()instead of a literal 3.docs/ARCHITECTURE.mdhas a fuller "Adding a page". With the demo on, the only code change is that generic shortcut table.--baseca86f1d--base <id>(or Customize › App) takes any theme in the shippedthemes.toml, read by the newsrc/gen/themes.ts, so the catalog the app compiles in is the single source. The theme's mode, surfaces, text, status colours and span fillsignature_specthroughbase*tokens, and its accent becomesFALLBACK_ACCENT. On a light base the accent retries go darker. The defaultmidnightreproduces the old literals exactly; only comments change. A light base exposed two latent bugs, now fixed:emergency()borrowedFALLBACK_ACCENTfor Midnight surfaces, and a test asserted the signature theme is dark.--with subcommandson GUI kinds87fccb3Cligainscommand: Option<Command>with two jobs that are useful in any build:themesandpaths.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.rscovers both paths. Works forguiandworkspace, and needs clap.Contract changes (CONTRACTS.md updated)
Answers.features.demo(bool, default true) andAnswers.themeBase(a shipped theme id;''without a GUI).features.subcommandsnow applies to GUI kinds too.baseName baseMode baseApp basePanel baseRaised baseHover baseBorder baseText baseTextMuted baseDanger baseWarning baseSuccess baseSpan baseAccentRgb.base_dark/base_light.Test plan
npm run typecheck && npm test && npm run build: 58/58-D warnings, test): minimal, lib, cli, tui, rustaman, strobe--target x86_64-pc-windows-msvc, which is whereconsole.rscompiles--helpexits 0, a usage error exits 2--with subcommandsfor GUI presets (window by default, headless pipeline commands on demand) #17: through the full gate, with Windows clippy:--binthemesandpathsprint correctly.--bin, palette, tray): full gate plus Windows clippy073fcd4🤖 Generated with Claude Code
https://claude.ai/code/session_01W2BaQmV2uiGiqUHSfS6KUH