Repository navigation
refactor(cli): resolve runtime config once and thread ui.IO - #122
Merged
Merged
Conversation
P1 foundation (PR-1.4) of the CLI UX overhaul — the merge pass. Resolve the full runtime config exactly once in the root PersistentPreRunE and cache it, the single ui.IO, the logger, and outputExplicit on commandContext. Delete the ten per-command loadRuntimeConfig re-calls (up/down/exec/info/install/list/run/ connect/wallet/target) in favour of cc.runtimeConfig. loadRuntimeConfig now takes (cmd, vp): precedence values come from viper, the flag-only session knobs (-v/-q/--non-interactive/--color/--no-color) come straight off cmd.Flags(), -v raises the resolved --log-level, and --color/ --no-color fold into a ui.ColorMode. resolveUX turns the requested policy into final color/non-interactive verdicts from the raw injected streams (NO_COLOR supreme; the latch one-way). The signature change is atomic with the re-call deletions because resolveWallet and rejectExplicitTarget have no cmd in scope. The ui.IO seam replaces the ad-hoc logger and JSON toggle: ctx.io.NewSlogLogger (DiscardHandler under -q) supersedes newLogger, and list/info/wallet read cc.io.JSON() instead of the viper-backed outputJSON() helper (both removed). The global flags are extracted into addGlobalFlags so tests can drive loadRuntimeConfig directly. ui gains an exported IsTerminalReader for the latch. No user-visible behaviour change: the resolved values and output bytes are identical; resolution simply happens once. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jmgilman
force-pushed
the
feat/cli-ux-p1-merge-context
branch
from
June 8, 2026 14:50
67cbd42 to
cc50a75
Compare
This was referenced Jun 8, 2026
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.
Summary
P1 / PR-1.4 of the CLI UX overhaul — the merge pass that makes the foundation real. No user-visible behavior change: the resolved values and output bytes are identical; resolution simply happens once.
What's here
PersistentPreRunEresolves the fullRuntimeConfigand caches it, the singleui.IO, the logger, andoutputExplicitoncommandContext. The ten per-commandloadRuntimeConfigre-calls (up/down/exec/info/install/list/run/connect/wallet/target) becomecc.runtimeConfig.loadRuntimeConfig(cmd, vp): precedence values from viper; the flag-only session knobs (-v/-q/--non-interactive/--color/--no-color) straight offcmd.Flags()(env-immune);-vraises the resolved--log-level;--color/--no-colorfold into aui.ColorMode. The signature change is atomic with the re-call deletions becauseresolveWallet/rejectExplicitTargethave nocmdin scope (deviation from the 063 plan, which mistakenly put the signature change in PR-1.2).resolveUX: turns the requested color policy + interactivity into final verdicts from the raw injected streams —NO_COLORsupreme, the non-interactive latch one-way.ui.IOseam:ctx.io.NewSlogLogger(DiscardHandler under-q) replacesnewLogger;list/info/walletreadcc.io.JSON()instead of the viper-backedoutputJSON()helper. Both removed.addGlobalFlagsextracts the persistent-flag registration so tests driveloadRuntimeConfigdirectly;uigains an exportedIsTerminalReaderfor the latch.ConfigFromRuntimetakes aui-localRuntimeView(via aRuntimeConfig.view()adapter) souinever importscli(no cycle; keeps charm-banned deps out ofui's graph).Testing
gofmt/go vet/go buildclean;golangci-lint0 issues;moon run root:check+moon run root:test(full envtest gate) green;git diff --checkclean.slogLevel,resolveColorMode(incl.--no-color/explicit-color precedence),resolveUX(non-TTY → plain + non-interactive;--color=alwaysforces color off-TTY),loadRuntimeConfigflag resolution (-vvraise,-q,--non-interactive, viper output) + unknown-color rejection. Existing per-command tests pass unchanged through the new single resolution (the byte-neutrality net); thenewLogger/outputJSONunit tests are dropped (their behavior moved touiand is covered there).Part of the P1 foundation series (1.1 #119, 1.2 #120, 1.3 #121 merged → 1.4 → 1.5 → 1.6).
🤖 Generated with Claude Code