Repository navigation
aitools install: cancel the agent picker on Esc - #7721
Conversation
Esc did nothing in the agent picker, so only Ctrl+C left it. Esc now cancels the picker as Ctrl+C does, and the run ends with the same "user aborted" error. While the picker searches, the first Esc only leaves the search. The help line now says how to cancel. Enter installs the selected agents, since install runs the plan straight after the picker. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
left a comment
There was a problem hiding this comment.
Requesting changes for one blocker, posted inline: the picker now renders to stdout instead of stderr.
Non-blocking: Esc leaves the picker on screen, while Ctrl+C clears it. huh's Form.View returns "" only after the form sets quitting itself, and the wrapper quits without setting it. After Esc the final View() is 249 bytes; after Ctrl+C it is 0. If pickerModel.View returned "" when p.cancelled is set, both keys would leave the same screen.
Co-authored-by: Isaac <no-reply@databricks.com>
|
The Esc note is in b137472 too: |
anton-107
left a comment
There was a problem hiding this comment.
Approving. The stdout blocker is fixed. In a real terminal, databricks aitools install --scope=global > install.log shows the picker, and install.log stays at 0 bytes after both Esc and Ctrl+C. The program options now match huh's NewForm defaults, and go test ./cmd/aitools passes.
Non-blocking, and a correction to my round-1 note: Ctrl+C doesn't clear the picker either. I measured View(), not the screen. huh cancels with tea.Interrupt, which bubbletea treats as a kill, so it skips the final empty frame (bubbletea v1.3.10 tea.go:722-743). The picker stayed on screen after Ctrl+C in 4 of 4 runs, the same as on main. Esc now clears it in 3 of 3. That makes the new View comment ("both keys leave the same screen") inaccurate. Either reword it, or make Ctrl+C quit with tea.Quit as well (form.CancelCmd = tea.Quit plus a form.State == huh.StateAborted check) if you want the two keys to match.
Co-authored-by: Isaac <no-reply@databricks.com>
|
Thanks for measuring it on screen. I reworded the comment in 6958a6d: Esc leaves no picker on screen, and Ctrl+C interrupts the program, which keeps the last frame, as huh's Run does. I kept Ctrl+C on huh's interrupt path, so it still behaves as it does on main. |
❌ Integration test reportCommit: 83ed6fa
300 interesting tests: 271 MISS, 18 RECOVERED, 4 KNOWN, 4 PANIC, 3 FAIL
Top 50 slowest tests (at least 2 minutes):
|
This pull request is part of the stack that adds the hidden `databricks aitools mcp` command group. It sits on databricks#7595, which adds and removes agent MCP entries through each agent's own CLI. `databricks aitools mcp add` and `remove` stopped in a terminal with "interactive selection is not available yet" when a flag was missing. This PR replaces that stopgap with pickers. Runs without a terminal keep their flags and output. ## Changes - In a terminal, `add` asks for the profile, the services and the agents that the flags do not give. The profile resolves as it does without a terminal, so the picker runs only where that stops with several profiles. - `add` has its own agent picker rather than `install`'s. Like the other `mcp` pickers, Esc cancels it, and its help says enter confirms. - At the catalog and schema prompt, Esc stops listing, as an empty answer does, and keeps the picks of the pages already shown. Ctrl-C still aborts the add. - A picker cancelled with Esc leaves nothing on screen. - A run that picks its services checks the profile and chooses the agents before it connects. A missing profile or no agent is refused without a request. A picked service whose recorded entry points at another host is refused after the pick, before anything is written. - The service picker marks services the profile already has as `(installed)`, unchecked. "Another schema..." lists another catalog and schema and keeps the checks. - The profile picker rows have no `[default]` mark. - The plan says `add`, `re-assert` (only when the write leaves the entry as it is), `update` or `replace`. An agent whose config cannot be read is shown with the reason. - `add` asks `Proceed?` only when a picker made a choice. For each sign-in-required server it installed, it asks "Sign in now?" unless the caller is already signed in. Ctrl-C stops the remaining questions and prints the login command of each server still to sign in. - In a terminal, `remove` with none of `--names`, `--profile` or `--all` shows the installed servers and asks `Proceed?` before removing the picked ones. - `add --no-login` skips the sign-in question that a terminal asks for each sign-in-required server it installed. It cannot be combined with `--login`. Without a terminal, `add` already does not sign in. - An empty pick in the service picker prints `No servers selected.` and exits 0 without writing anything. It used to fail with INVALID_FLAGS. - The pickers share `install`'s picker model, from databricks#7721: `runPicker` runs a built picker, `newPicker` takes the search func (nil for none), and the model gains an `onKey` hook and a search check that allows none. ## Why Choosing servers needs their descriptions and sign-in requirements, which the workspace knows and the flags do not show. ## Decisions to review - Agents are chosen before the services, so a missing agent or a broken profile is reported before any request. Cost: the agent question comes first. - Esc at the catalog and schema prompt stops listing instead of aborting the add, so the picks already shown are kept. Cost: an Esc meant to abort keeps those picks; Ctrl-C aborts. - `add` has its own agent picker, so the two copies can drift apart. - A picked service is checked against its recorded entry only after the pick, so one stale entry of another service does not stop the picker. - Installed services are checkable rows, not disabled rows, because the picker library has no disabled options. Checking one re-asserts its entry, as `add --names` does. - `--name` without `--names` is refused rather than offered a single-select picker. ## Tests - `mcp_pickers_test.go` covers the service and profile pickers, the agent picker's failed check and Esc, the location prompt's Esc, and the remove picker's refusal. `mcp_add_test.go` runs an interactive `add` through the prompt seams: refusals make no request, a changed host is refused after the pick, and a fully specified run asks only the sign-in question. `TestMcpAddPickerEmptyPickAddsNothing` covers the empty pick, and `TestValidateMCPAddFlags` the `--login` and `--no-login` conflict. - `mcp_remove_test.go` runs the remove picker end to end, including a declined confirmation. - `./task test-exp-aitools` passes. `go test -race ./cmd/aitools/ ./libs/aitools/... ./libs/cmdio/` and `GOOS=windows` vet pass. - Not tested: a real terminal and a live workspace. The prompts are covered through their seams. ## How to review Small edits outside the feature, about 15 lines in `libs/cmdio/` (`io.go`, `prompt.go`, `select.go`), `cmd/aitools/mcp.go`, `uninstall.go`, and the moved `multiSelectHelp` constant in `install.go`. Read closely: `cmd/aitools/mcp_pickers.go`, the `add` flow in `cmd/aitools/mcp_add.go` (agent choice at its interactive branch, before the service pick), and `cmd/aitools/mcp_remove.go`. This pull request and its description were written by Isaac. Co-authored-by: Isaac <no-reply@databricks.com>
Changes
Esc now cancels the
aitools installagent picker, the same way Ctrl+C does: the run ends withError: user abortedand exit code 1. Before, Esc did nothing, so only Ctrl+C left the picker.space to toggle, enter to install, esc to cancel. Its "enter to install" was already right, since install runs the plan straight after the picker.Why
Esc is the key people reach for to back out of a terminal prompt, and the picker gave no hint that only Ctrl+C would work.
Decisions to review
esc to cancelduring search too, where Esc leaves the search first. The help text is not switched during search.Tests
TestAgentPickerEscCancelsLikeCtrlCcovers Esc and Ctrl+C reaching the same cancel result, and the help line.TestAgentPickerEscLeavesSearchBeforeCancellingcovers the first Esc leaving the search.TestPickerErrorcovers mapping a cancel tohuh.ErrUserAborted.Error: user abortedand exit 1.go test ./cmd/aitools/...,go test ./acceptance -run TestAccept/cmd/aitools, andGOOS=windows go vet ./cmd/aitools/...pass.This pull request and its description were written by Isaac.