Repository navigation
Conversation
✅ Integration test reportCommit: febc8ca
Top 3 slowest tests (at least 2 minutes):
|
|
/review |
|
/review |
There was a problem hiding this comment.
Automated review at 034903f. Each finding was verified against the code.
Not ready yet: part of the automated review did not complete.
This PR adds several hidden databricks selftest tui subcommands (keys, profile, colors, pager, table, huh, spinner --duration) for live-terminal testing during the Charm v1→v2 migration. The commands are well-structured with consistent flag validation and cobra wiring. The two new test files cover the non-interactive helpers (runRawKeys, pagerFakeIterator). The remaining findings are convention-level: test package naming and missing test files for three new source files.
| @@ -0,0 +1,26 @@ | |||
| package tui | |||
There was a problem hiding this comment.
[nit] keys_test.go and pager_test.go both declare package tui; .agents/rules/testing.md asks for package tui_test. These tests call unexported symbols (runRawKeys, pagerFakeIterator, buildPagerRows), so switching requires either exporting them or adding an export_test.go bridge. Same issue in pager_test.go:1.
| @@ -0,0 +1,99 @@ | |||
| package tui | |||
There was a problem hiding this comment.
[nice to have] huh.go, profile.go, and table.go are new files with no corresponding _test.go, which .agents/rules/testing.md asks for. The rest of this directory was test-free before this PR, and the files are mostly cobra wiring for interactive commands, so the value is limited — but if any testable logic can be extracted (the way runRawKeys was pulled out of keys.go), a test file would be consistent with the pattern you already set here.
|
/review |
There was a problem hiding this comment.
Automated review at 034903f. Each finding was verified against the code.
No blocking issues found. 4 non-blocking comment(s) below.
This PR adds hidden selftest tui commands (keys, profile, pager, table, huh, plus new flags on colors and spinner) for checking TUI behaviour in a real terminal during the Charm v1→v2 migration. The commands mostly wrap existing cmdio code and look fine. One real bug: keys --raw errors out on Git Bash without ConPTY, which is one of the terminals the description lists. The rest are smaller: a --fail-after value that is silently ignored, plus two pieces of dead code.
| resolved = adaptive.Dark | ||
| } | ||
| cmdio.LogString(ctx, fmt.Sprintf("blurred_button=%s (resolved, default renderer dark_background=%t)", resolved, dark)) | ||
| } else { |
There was a problem hiding this comment.
[nit] AppkitTheme always sets BlurredButton to colorDimmed, which is a lipgloss.AdaptiveColor (libs/apps/prompt/prompt.go:35). The type assertion always succeeds and this else branch is a just-in-case fallback, which AGENTS.md asks to avoid. Assert the type directly and drop the branch?
…atabricks#7884) ## Changes Halve the agent rules: 66 KB → 33 KB of AGENTS.md + `.agents/rules/`. The rules that are always loaded or loaded on every Go edit shrink the most: | Context loaded | Before | After | |---|---|---| | Always (AGENTS.md) | 12.2 KB | 6.1 KB | | Editing a `.go` file (+ style-guide-go, comments) | 23.5 KB | 9.7 KB | | Editing a `_test.go` file (+ testing) | 45.8 KB | 17.5 KB | | Editing acceptance outputs (+ testing, auto-generated-files) | 38.5 KB | 16.4 KB | Skills are unchanged: they load only when invoked. What was removed, and why: - **Already enforced by `./task lint`** (the agent gets the same message from the linter): - integer `range`, builtin `min`/`max` (modernize) - loop-variable capture (copyloopvar) - `os.Getenv`, `sync.Once` (forbidigo) - `context.Background()` (gorules) - `t.Context()` in tests (usetesting) - stdlib `log` (depguard) - `%w` wrapping (errorlint) - error-string punctuation (staticcheck ST1005) - copying `config.Config` (govet copylocks) - **Wrong or stale:** - `errors.As` was recommended, but forbidigo bans it (the tree has 0 `errors.As` calls vs 231 `errors.AsType`). - `isResourceGone` doesn't exist. - `libs/structpath` has moved to `libs/structs/structpath`. - "consult the Makefile": there is no Makefile. - The `out.test.toml` old-format migration rule is dead: 0 files are left in that format. - "Use Python 3.11" also applied to `python/`, which supports `>=3.10`. - The `databricks_template_schema.json` "reference" was an outdated copy of dbt-sql's schema. It described a description convention the real file no longer uses, and it had a typo. It is replaced by pointers to the real templates and to `libs/jsonschema/extension.go`. - template-versions.md hardcoded how many pins each template has. The counts were wrong; the grep in the same rule is what the agent should rely on. - **Rules that produced wrong review feedback:** - "Each source file should have a corresponding test file": 38% of source files have none, and the rule contradicts acceptance-tests-first. The reviewer bot used it to request tests for cobra wiring, and those requests were ignored: databricks#7688 (comment), databricks#7742 (comment) - "Place tests in the same package but with a `_test` suffix": 1050 test files use the internal package and 231 use `_test`. The rule led to an invented `_internal_test.go` convention that the author rejected: databricks#7847 (comment) - "Add `.databricks` to `Ignore`": `acceptance/script.cleanup` already removes it. This produced a wrong `[blocking]` comment: databricks#7846 (comment) - "Define magic strings as named constants, even if short": reviewers push back on single-use constants (databricks#5844 (comment), databricks#6204 (comment), databricks#6149 (comment)). - **Generic guidance current models already follow:** - return early - `switch` vs `if/else` - empty-struct context keys - table-driven tests - shared test constants - Go doc comment format - constructor parameter structs - "don't explain each test case in your responses" - debug prints (pr-checklist already covers them) - the GOOD/BAD preamble - **Repetition:** - `Cloud = true` runs locally too: this was explained 5 times and is now explained once in AGENTS.md and once in testing.md. - `integration/` is deprecated: stated 4 times. - "Don't edit generated outputs": stated 4 times across testing.md and auto-generated-files.md. - The `print_requests.py`/`jq` guidance was 3 overlapping rules and is now 1. - The long GOOD/BAD examples were dropped where the rule sentence already says it. Clarified: - `os.Exit`: the rule now says how `TestMain` should exit. The bot had suggested `os.Exit(m.Run())`, against this same rule: databricks#7595 (comment) - Comments: existing comments may be updated when your change makes them wrong. ## Why The rules were mostly mined from review history in databricks#5078. That PR's follow-up promised a slim-down that never came (databricks#4882), and token cost had already come up in review (databricks#6584). Every byte of AGENTS.md and the Go/test rules is paid on most turns, and rules that are wrong or that the linter already enforces either crowd out the useful ones or become review noise. I checked the 98 comments from review-oss-bot and the human pushback since 2026: the rules that went wrong are the ones removed above. The acceptance-test rules that came from real agent failures (`Cloud`, `EnvMatrix`, TOML dotted keys, `musterr`/`errcode`, `print_requests.py`, testserver over `[[Server]]`, GET-response projection) are kept, just shorter. ## Tests `./task check-agents-setup` and `./task checks` pass. Every path, helper, task and identifier still mentioned was checked against the tree. This pull request and its description were written by Isaac. --------- Co-authored-by: Isaac <no-reply@databricks.com>
034903f to
dea2d9a
Compare
rugpanov
left a comment
There was a problem hiding this comment.
I found no blocking problem. The inline comments have 3 [nice to have] items and 4 [nit] items.
Risk: LOW. All changes are in cmd/selftest/tui/, under the hidden databricks selftest tui command. No production code path changes, and a revert removes the change. CI is green at this head.
[nit] (PR body) .agents/skills/pr-checklist/SKILL.md asks for the agent-help disclosure as a single italic line. Put the last line of the body in _..._.
The open review-oss-bot threads (package tui_test, no tests for huh.go, profile.go and table.go, and the dead else branch in huh.go) still apply. I did not repeat them here.
| // writeLine sends lines without --stream through cmdio.LogString, so the default | ||
| // output and its stderr routing are unchanged. | ||
| func writeLine(ctx context.Context, stream string, w io.Writer, s string) { | ||
| if stream == "" { |
There was a problem hiding this comment.
[nit] cmdio.LogString writes to the cmdio error writer, and initializeIO sets that writer to cmd.ErrOrStderr(). That is the same w that --stream stderr uses. Thus --stream "" and --stream stderr write the same bytes to the same writer.
Remove the "" branch, and make stderr the default value of --stream.
There was a problem hiding this comment.
Keeping both. They are the same on this PR, but they differ from #7738 on: the default goes through cmdio.LogString, which strips styles when stderr cannot show color, and --stream stderr writes the bytes as they are. The default is the path that tests LogString.
dea2d9a to
ee418c4
Compare
|
Thanks for the review. The inline threads have the resolution for each comment; five are fixed in the latest push and two are answered there.
The branch was also rebased onto |
Add hidden `databricks selftest tui` commands that drive the production cmdio, tableview and huh/appkit code paths so their observable behaviour can be checked in a live terminal. They unblock testing while the CLI migrates its Charm TUI libraries to the charm.land v2 modules: the same checks can run on the current v1 build and on the v2 build side by side. - keys: print each key bubbletea decodes; --raw prints raw stdin bytes - profile: print the color, background and env decisions for stdout/stderr - colors: --stream stdout|stderr, --lipgloss adds color depth swatches - pager: cmdio.RenderIterator over a fake iterator with --fail-after - table: tableview.Run over generated rows - huh: one form field with the appkit theme - spinner: --duration sets the total run time Only selftest code changes. No production behaviour changes. Co-authored-by: Isaac <no-reply@databricks.com>
- keys --raw prints CRLF while raw mode is on, so lines start at column 0 - keys and spinner reject negative --timeout and --duration in PreRunE - colors: replace the inline closure with a named helper - huh: document that the field is built here and only the theme is shared - Expected failures in acceptance tests use musterr instead of errcode - Add a --header case to the pager acceptance test - Gate the tui acceptance tests off Windows Co-authored-by: Isaac <no-reply@databricks.com>
- Pin COLORFGBG in the tui acceptance env - pager rejects negative --delay and --delay-first in PreRunE - Tighten the writeLine comment and the --stream help text Co-authored-by: Isaac <no-reply@databricks.com>
The existing selftest tui commands have no acceptance tests, and acceptance/selftest holds the harness's own self-tests. Keep the unit tests for the raw key reader and the fake iterator. Co-authored-by: Isaac <no-reply@databricks.com>
bubbletea puts the terminal in raw mode, which clears OPOST, so the bare "\n" from the keys log staircased across the screen. Use "\r\n" there too, the same way the --raw path already does. The other new commands print outside any tea program: spinner's program has no input, and the table, pager and huh output comes after or outside tea's raw-mode window. Co-authored-by: Isaac <no-reply@databricks.com>
GetForeground returned the static AdaptiveColor, which printed the same Light/Dark pair whatever the terminal was. Print the side lipgloss picks with the default renderer, which is the renderer the theme's styles use. Co-authored-by: Isaac <no-reply@databricks.com>
After #7700 NO_COLOR only turns color off, and TERM=dumb also turns off prompts and spinners. Print cmdio's interactive mode and prompt decision next to the raw env values, so a run under NO_COLOR shows prompts still on. This uses the existing cmdio helpers; libs/cmdio is unchanged. Co-authored-by: Isaac <no-reply@databricks.com>
The huh probe runs its field the way the production prompts do. keys --raw marks stdin as read in the background, so a later line prompt is not asked while its reader can still take the answer. The double Ctrl+C test reads from a pipe that stays open, so EOF can't end the call for it. table prints its result line only on success; the root command prints an error once. Co-authored-by: Isaac <no-reply@databricks.com>
…e on request The huh probe created a second renderer to read the background, which sent its own OSC 11 query after the form had already resolved the same value. It now prints the default renderer's cached answer, the one the form's AdaptiveColors used, and the blurred-button line no longer repeats it. The profile probe queried the background for both streams on every run, so its output carried the terminal's replies. The query now sits behind --query-background; by default the command only prints. Co-authored-by: Isaac <no-reply@databricks.com>
main no longer asks a line prompt after a command (#8135) and removed cmdio.MarkStdinReadInBackground with it, so the unjoined reader has nothing left to protect. Co-authored-by: Isaac <no-reply@databricks.com>
4e2455b to
febc8ca
Compare
Changes
Adds hidden
databricks selftest tuicommands that unblock live-terminal testing while the CLI migrates its Charm TUI libraries (bubbletea, bubbles, lipgloss, huh) from v1 to thecharm.land/*/v2modules. They drive the productioncmdio,tableviewand huh/appkit code paths and print what they decide or receive. That way the same observable checks can run on the current v1 build and on a v2 build side by side, across terminals (Ghostty, Terminal.app, Linux terminals, tmux, Windows Terminal, conhost, Git Bash).New commands and flags:
keys: prints every key message bubbletea decodes (key string, type, runes, alt, paste).--rawskips bubbletea and prints the raw stdin bytes. Lines start at column 0 in a terminal, where bubbletea's raw mode needs\r\n. Exits on two Ctrl+C or after--timeout.profile: prints the interactive mode and prompt support that cmdio decides, the color decision and color profile thatcmdio.NewRendererresolves for stdout and stderr, plus the environment variables that affect them (TERM,COLORTERM,CLICOLOR,CLICOLOR_FORCE,NO_COLOR,CI,TERM_PROGRAM,WT_SESSION,COLORFGBG).--query-backgroundadds the dark-background decision; it sends an OSC 11 query to the terminal, so the default output carries no terminal replies and compares cleanly between builds.colors:--stream stdout|stderrpicks the output stream.--lipglossadds truecolor and 256-color swatches, which make differences in color depth visible.pager: runscmdio.RenderIteratorover a fake iterator with the sametemplate/headerTemplateannotations that list commands get, so the production pager gate applies. Flags:--items,--header,--delay-first,--delay, and--fail-afterto inject an iterator error.table: runstableview.Runover generated rows (--rows,--cols).huh: one huh field (--field input|select|confirm|multiselect) using the appkit theme fromlibs/apps/prompt, run the way the production prompts run a field (no help footer). Prints the answer, the dark-background value the form resolved (lipgloss caches the default renderer's answer, so the probe sends no query of its own) and the resolved blurred-button colour (the Light or Dark side of the appkit theme'sAdaptiveColor).spinner --duration: sets the spinner's total run time.Only
cmd/selftest/tuichanges: nolibs/cmdiochanges and no production behaviour change.profileuses the existing cmdio helpers (GetInteractiveMode,IsPromptSupported,SupportsColor).Not included, because each would need a production change:
--quit-afteronprompt/select, to reproduce fast-quit behaviour:runTUIdoesn't run the program with a context.linkcommand: the only hyperlink helper is unexported incmd/air.Why
The v2 migration changes key decoding, color-profile detection, background detection, and the bytes written when a TUI starts and exits. Our tests run against pipes and a terminal emulator, so they can't show what a user sees in a real terminal. These commands make those behaviours directly observable for each terminal and platform, before and after the swap.
Tests
keys_test.go) and for the fake iterator (pager_test.go).go build,go vet, golangci-lint (./cmd/selftest/...,./libs/cmdio/...) and gofmt all pass. The branch merges cleanly into currentmain(which includes cmdio: gate prompts on MSYS2 pty pipes (no ConPTY), not on Git Bash #7699 and cmdio: make NO_COLOR only affect color #7700); build, vet, lint and tests pass withmainmerged in.selftest tuicommands, these are tools for manual testing in a live terminal.How to use
This pull request and its description were written by Isaac.