Repository navigation
Add interactive pickers to aitools mcp add and remove - #7552
Conversation
|
Commit: Regression test reportSelected 2 changed tests (limit=20, 0 not selected) 2 tests: regression=2 unreleased=0 coverage=0 failing=0
TestAccept/cmd/aitools/mcp/help: branch ✅ | main (fd2f501) ❌ | latest (v1.27.0) ❌main (fd2f501): latest (v1.27.0): TestAccept/cmd/aitools/mcp/hidden: branch ✅ | main (fd2f501) ❌ | latest (v1.27.0) ❌main (fd2f501): latest (v1.27.0): |
f9ffc67 to
2dd54b7
Compare
✅ Integration test reportCommit: be36588
Top 27 slowest tests (at least 2 minutes):
|
38cdd13 to
1d8e6b3
Compare
2dd54b7 to
a1fd867
Compare
1d8e6b3 to
7b98424
Compare
a1fd867 to
b90afff
Compare
1c6aee6 to
7a9dca9
Compare
0aa2ee4 to
2dbdfe3
Compare
1fff1da to
e9bad5b
Compare
3ed1398 to
8cca61b
Compare
b30caa0 to
43a64fd
Compare
43a64fd to
b12f2bf
Compare
50318b1 to
f46d6a0
Compare
b12f2bf to
1ee83b9
Compare
f46d6a0 to
d049189
Compare
29624cd to
a7c5766
Compare
6955d59 to
84abb41
Compare
52a1885 to
e652cdf
Compare
190f3cb to
fdc9d71
Compare
10594fe to
b4386f3
Compare
201f9a7 to
ffc760f
Compare
b4386f3 to
114dcaf
Compare
| // login hint of each server not signed in, and returns the abort. | ||
| // TestSignedInGivesUpOnAHungCredentialRead checks that a credential read that never answers ends at profileCheckTimeout, | ||
| // so the sign-in question is asked, instead of holding it for the SDK's whole retry budget. | ||
| func TestSignedInGivesUpOnAHungCredentialRead(t *testing.T) { |
There was a problem hiding this comment.
The doc comment for TestSignInInstalledAbortPrintsTheRestOfTheHints (line 2106-2107) is concatenated above TestSignedInGivesUpOnAHungCredentialRead, so godoc ascribes both descriptions to this function. TestSignInInstalledAbortPrintsTheRestOfTheHints at line 2131 ends up with no comment. Split the two blocks to their respective functions.
anton-107
left a comment
There was a problem hiding this comment.
Reviewed the diff against the base merge point (114dcaf5f). It's a two-way door: the command group is hidden, the state format doesn't change, and the only exported addition is cmdio.ErrCtrlC.
I checked the order in runMcpAdd: profile, then CheckProfile/checkBindings, then the agent pick, then the refusals, then connect, the service pick, the post-pick checkBindings, the plan and the writes. Nothing reaches the workspace before the agent and profile refusals, and nothing is written before the post-pick binding check. Unit tests (-race) and TestAccept/cmd/aitools pass locally. I also ran mcp remove in a real PTY (80x24): Esc at the picker and at Proceed? both end with "user aborted", the plan prints before the confirm, and Enter removes only the picked server.
Non-blocking notes:
- In
mcp add, the agent picker is install'sdefaultPromptAgentSelection. It still ignores Esc (huh's default Quit is ctrl+c only) and says "enter to install". The profile, service, location, sign-in and Proceed prompts all cancel on Esc, so one run mixes both behaviours. - Esc in the "Another schema..." location prompt aborts the whole
add, which drops the picks from earlier pages, although the title says "leave empty to stop". profilePickerActive/profilePickerInactiverender[default]throughIsDefault, butpromptProfilenever setsSelectConfig.Default, and the picker only runs when there is no default profile. That branch never runs.- The doc comment on
multiSelectHelp(install.go) says install uses it, but install's agent picker has its own "space to toggle, enter to install". The constant is only used by the mcp pickers, so it could live inmcp_pickers.go.
|
Thanks! All four are in ed5d9ce:
A picker cancelled with Esc also leaves nothing on screen now, as in #7721. |
686894a to
8898daf
Compare
b32f61f to
9cb89d5
Compare
|
Heads-up after the restack onto main. #7721 added its own |
8898daf to
03d0647
Compare
One commit for the restack onto main. The individual commits, up to b32f61f, are in the pull request's history. Co-authored-by: Isaac <no-reply@databricks.com>
9cb89d5 to
be36588
Compare
❌ Integration test reportCommit: ae033ef
778 interesting tests: 745 MISS, 14 RECOVERED, 12 KNOWN, 5 PANIC, 2 FAIL
Top 50 slowest tests (at least 2 minutes):
|
…cks#7804) ## Changes Fix a race in the interactive list pager (`libs/cmdio/pager.go`) that could drop or reorder a page of rows, and the macOS flake it caused in `TestPagedTemplateRespectsLimit`. A non-final page was printed by returning a bare `tea.Println` cmd. bubbletea runs every returned cmd on its own goroutine, so nothing ordered that print before later messages. When ENTER (or SPACE) started the next fetch and that page was the last one, its `tea.Sequence(print, tea.Quit)` could reach the event loop first, and the program quit before the earlier page was printed. In the test (page size 5, limit 7) that leaves only the last 2 rows: `expected: 7, actual: 2`. A non-final page is now followed by a `pagePrintedMsg` in the same `tea.Sequence` as its print. `tea.Sequence` delivers each message before running the next cmd, and `p.Send` is unbuffered, so when `pagePrintedMsg` arrives the page's lines are already queued. Until then a new `printing` flag holds keys back: SPACE is ignored, ENTER sets `drainAll`, and `q`/`esc`/Ctrl+C set `quitPending`. The `pagePrintedMsg` handler then quits or chains the next fetch, replacing the old `Sequence(print, fetch)` branch. `View` is unchanged: the prompt shows as soon as the batch arrives. Also in the tests: `countContentLines` and `TestPagedTemplateMatchesNonPagedForSmallList` now read the output the way a terminal shows it, keeping only the text after each line's last `\r`. tea redraws its spinner and prompt in place, so plain ANSI stripping left that text glued to real rows (`"\r⣽ loading...\r1 1"`). `TestPagedTemplateMatchesNonPagedForSmallList` failed once that way, and `countContentLines` would skip a row that lands on the prompt's line. Introduced with the pager in databricks#5015. ## Why Users can lose rows of `list` output in the pager. It is rare at human typing speed, but it fails CI on unrelated PRs (macOS runners). ## Tests - New `TestPagerModelKeysWaitForPagePrint` and `TestPagerModelQuitWaitsForPagePrint` fail without the fix (SPACE/ENTER fetch, q quits, before the page is printed). `TestPagedTemplateDrainsFullIterator` now checks row order, not just presence. Updated `TestPagerModelBatchPromptsWhenMore` and `TestPagerModelBatchDrainingChainsFetch` to the new message flow. - Reproduced the flake deterministically by adding a 20ms sleep to the page print cmd: before the fix, `TestPagedTemplateDrainsFullIterator` got 18 of 23 rows and `TestPagedTemplateRespectsLimit` 2 of 7. With the fix, every `TestPagedTemplate*` passes with the sleep in place. - `go test -race ./libs/cmdio/ -count=200`, `go test ./libs/cmdio/ -count=1000` and `GOMAXPROCS=1 ... -count=200` pass. ## Dashboard | error / test | failure | |---|---| | [error/3590](http://go/cli/dashboard/error/3590?main=1&pr=1&end=2026-11-19T12:00:00Z&last=7d) | `paged_template_test.go:90: Not equal: expected: 7 actual : 2` (3 failures in 3 days, macOS, PRs databricks#4738, databricks#7552, databricks#7780) | | [libs/cmdio.TestPagedTemplateRespectsLimit](http://go/cli/dashboard/test/libs/cmdio.TestPagedTemplateRespectsLimit?main=1&pr=1&end=2026-11-19T12:00:00Z&last=7d) | same | | [libs/cmdio.TestPagedTemplateMatchesNonPagedForSmallList](http://go/cli/dashboard/test/libs/cmdio.TestPagedTemplateMatchesNonPagedForSmallList?main=1&pr=1&end=2026-11-19T12:00:00Z&last=7d) | `expected: "1 1" actual : "\r⣽ loading...\r1 1"` (1 failure, 2026-11-16, Windows) | This pull request and its description were written by Isaac. --------- Co-authored-by: Isaac <no-reply@databricks.com>
This pull request is part of the stack that adds the hidden
databricks aitools mcpcommand group. It sits on #7595, which adds and removes agent MCP entries through each agent's own CLI.databricks aitools mcp addandremovestopped 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
addasks 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.addhas its own agent picker rather thaninstall's. Like the othermcppickers, Esc cancels it, and its help says enter confirms.(installed), unchecked. "Another schema..." lists another catalog and schema and keeps the checks.[default]mark.add,re-assert(only when the write leaves the entry as it is),updateorreplace. An agent whose config cannot be read is shown with the reason.addasksProceed?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.removewith none of--names,--profileor--allshows the installed servers and asksProceed?before removing the picked ones.add --no-loginskips 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,addalready does not sign in.No servers selected.and exits 0 without writing anything. It used to fail with INVALID_FLAGS.install's picker model, from aitools install: cancel the agent picker on Esc #7721:runPickerruns a built picker,newPickertakes the search func (nil for none), and the model gains anonKeyhook 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
addhas its own agent picker, so the two copies can drift apart.add --namesdoes.--namewithout--namesis refused rather than offered a single-select picker.Tests
mcp_pickers_test.gocovers 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.goruns an interactiveaddthrough 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.TestMcpAddPickerEmptyPickAddsNothingcovers the empty pick, andTestValidateMCPAddFlagsthe--loginand--no-loginconflict.mcp_remove_test.goruns the remove picker end to end, including a declined confirmation../task test-exp-aitoolspasses.go test -race ./cmd/aitools/ ./libs/aitools/... ./libs/cmdio/andGOOS=windowsvet pass.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 movedmultiSelectHelpconstant ininstall.go. Read closely:cmd/aitools/mcp_pickers.go, theaddflow incmd/aitools/mcp_add.go(agent choice at its interactive branch, before the service pick), andcmd/aitools/mcp_remove.go.This pull request and its description were written by Isaac.