Skip to content

Commit 6ddf827

Browse files
feat(app-shell): Connect an Agent asks which AI client you use and shows only its steps (#30943)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao4R5vgzn4JR1Ewtt4rWD5cr)_ Fixes #30896 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:「连接智能体」页不再一次铺开七张卡片。端点与 SKILL.md 下载仍在最上方;其下先问「你用的是哪个 AI 助手?」(Claude、Codex、Cursor、WorkBuddy、豆包工作、千问办公),只显示所选那一个的步骤,切换一次点击,本浏览器记住选择;API 密钥表单移到底部折叠的「高级:脚本与 CI」。 - 为什么改:一个人只用一个客户端,原来要翻过另外六个客户端的说明才找到自己的步骤,API 密钥卡还混在客户端中间。实测页面主体从 1604 px 降到 664 px 高。 - 风险与回滚:只动这一个页面组件和新增的三条文案;选择存在本地浏览器(`os:pref:connect.client`),读不到时回到 Claude。密钥签发逻辑原样未改。回滚即 revert 本 PR。 - 先看:`ui/packages/app-shell/src/console/connect/ConnectAgentWidget.tsx`(Tabs 与 Collapsible 两处)、`connectClientPreference.ts`、测试文件末尾新增的 describe。 - 两分钟验证:打开 设置 → Connect an Agent,点「Codex」,刷新页面仍停在 Codex;点「高级:脚本与 CI」才出现 API 密钥表单。 - 需要你做的:无,席位落地。 - **席位意见**:ui 席 2 对照 head `953cfc49` 的 diff 复核:14 个文件、+448 / −207,无受治理路径。各客户端步骤、片段与提示文字原样搬进 `Tabs`,只渲染所选一个;选择经控制台既有的偏好存储(`user` 范围,`os:pref:connect.client`)保存,读不到或已不提供的客户端回到 Claude;API 密钥卡整体移入默认折叠的「高级:脚本与 CI」,签发与确认逻辑未改,签发结果状态在父组件,折叠不会丢失。席位核对时更正了 changeset 里新增文案的条数(三条),此外无改动。CI 全绿,Clause-② no,不欠契约复审。同意落地。 ## What changes - `ConnectAgentWidget.tsx`: under the endpoint card (URL, copy, SKILL.md download — unchanged, on top for everyone), a card asks "Which AI assistant do you use?" and holds a `Tabs` picker from `@object-ui/components` with the six clients in the order the page offered them. Only the chosen client's steps render; every client's steps, snippets and hints are the same text as before. The API key card moves into a `Collapsible` "Advanced: scripts and CI" at the bottom, closed by default; its mint/confirm logic is unchanged. - `connectClientPreference.ts` (new): the client ids and the reader's choice, declared through the console's one preference store (`utils/workspacePreference.ts`, imported, not edited), `user` scope, stored as `{"client":"CLIENT_ID","v":1}` under `os:pref:connect.client`. A stored id the page no longer offers, an unreadable record, or storage that throws reads as no choice → Claude. The store already wraps every storage access in try/catch. - i18n: three new keys (`connectAgent.client.title`, `connectAgent.client.hint`, `connectAgent.advanced.title`) in all ten console packs. PR #30902 is not on `main`, so they sit in today's `zh.ts` / `pt.ts`. - Root changeset `.changeset/30896-connect-agent-client-picker.md` (`@object-ui/app-shell`, `@object-ui/i18n`: patch). ## Tests `ConnectAgentWidget.keyName-13355.test.tsx` (the component's one harness file): - the three key-name cases open the Advanced section first, then assert as before; - the Chinese-clients block now walks the picker: tab order, each client's body + hint on pick, each client's transport spelling; - new top-level describe: endpoint + SKILL.md on top, Claude only with no choice, key form collapsed until opened; one click switches and the choice is stored and read back after remount; an unknown stored client reads as Claude. ## Acceptance notes - With no stored choice the picker opens on Claude rather than on an empty state; the card asks the question in the card heading and shows the first client's steps. - The Chinese clients' hints still say "(create a key below)"; the key form is below, now behind the Advanced trigger. #30898 rewrites this copy. - No widget heading follows the #30895 rename: the widget has none, the page title is metadata. - Three `no-explicit-any` lint warnings in the file are pre-existing lines that moved. ## Verification Head `6111073f` (my commit `181fd4df` + merge of `origin/main` `33043bd8`, no overlap with this diff). <details><summary>Live measure on a local deployment (showcase with the fresh flag, console Vite dev), admin and member</summary> Widget body height at a 1004 px wide pane: - before (`main` 0e88208 source): admin 1604 px, member 1604 px. Endpoint card, the Claude card, then Codex, Cursor, WorkBuddy, Doubao Work, QwenWork and the API key card, all open. - after: admin 664 px, member 664 px. Endpoint card, the picker card showing Claude's steps, the closed "Advanced: scripts and CI" trigger. - member click-through: pick Codex → Codex steps shown, `claude mcp add` gone, `localStorage['os:pref:connect.client']` = `{"client":"codex","v":1}`; reload → Codex still selected; API key name input absent until Advanced is opened, present after. </details> <details><summary>Local tests and gates</summary> - `pnpm --dir ui exec vitest run packages/app-shell/src/console/connect/` → 9/9 passed (on 181fd4d and again on 6111073) - `pnpm --dir ui exec vitest run packages/i18n/` → 97 files, 1521 passed, 13 skipped - `pnpm --dir ui exec vitest run packages/app-shell/src/__tests__/product-neutral-renderer.ratchet.test.ts` → 32/32 - `pnpm --filter @object-ui/i18n run type-check && pnpm --filter @object-ui/app-shell run type-check` → exit 0 - eslint on the three changed widget files → 0 errors; `pnpm check:new-line-citations` → 0 new - `dispatch-gates --commands` derived 36 commands on 181fd4d; all 36 exit 0 (incl. `node scripts/check-sdui-manifest.mjs`, `pnpm --dir ui exec vitest run scripts/` 170 files passed); `--ran` reconciliation: 36 run, 0 NOT-MEASURED, 0 UNRUN. </details> <!-- signed: domain:ui#2 · os-tesla · session_01L9qibw7DekEe3wx5f3zphf --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c571165 commit 6ddf827

14 files changed

Lines changed: 448 additions & 207 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(app-shell): Connect an Agent asks which AI client you use and shows only that client's steps
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The Connect an Agent page no longer lays out every client at once. Under the endpoint and the SKILL.md download, which stay on top for everyone, the page asks which AI assistant you use (Claude, Codex, Cursor, WorkBuddy, Doubao Work, QwenWork) and shows that one's steps; switching is one click, and this browser remembers your choice (`os:pref:connect.client` in the console's workspace preference store). The API key form for scripts and CI moves out of the client list into a collapsed "Advanced: scripts and CI" section at the bottom. The three new strings ship in all ten console languages.

‎ui/packages/app-shell/src/console/connect/ConnectAgentWidget.keyName-13355.test.tsx‎

Lines changed: 112 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
* - §3 confirming posts exactly the typed (trimmed) name, never a default, and
1818
* the key is revealed once.
1919
*
20+
* The key form lives in the collapsed "Advanced: scripts and CI" section, so
21+
* those cases open it first. The last block holds the page's shape: the
22+
* endpoint and SKILL.md on top, a picker that shows one client's steps and
23+
* remembers the choice on this browser, and the key form collapsed.
24+
*
2025
* `fetch` is stubbed by path; `t` echoes the KEY (with the `name` option
2126
* appended when one is passed), as the sibling suites do, so the assertions
2227
* read which string the widget asked for and with which name.
@@ -49,6 +54,7 @@ function keyPosts(): unknown[] {
4954
}
5055

5156
beforeEach(() => {
57+
window.localStorage.clear();
5258
fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
5359
const url = String(input);
5460
if (url.includes('/api/v1/discovery')) {
@@ -74,11 +80,35 @@ afterEach(() => {
7480
vi.unstubAllGlobals();
7581
});
7682

83+
/** Render and wait for discovery to settle: the client picker is up. */
84+
async function renderPage() {
85+
const view = render(<ConnectAgent />);
86+
await screen.findByRole('tablist');
87+
return view;
88+
}
89+
90+
/** The API key form sits in the collapsed Advanced section; open it and return its name box. */
7791
async function renderSettled() {
78-
render(<ConnectAgent />);
92+
await renderPage();
93+
fireEvent.click(screen.getByRole('button', { name: /«connectAgent\.advanced\.title»/ }));
7994
return screen.findByPlaceholderText('«connectAgent.apiKey.namePlaceholder»');
8095
}
8196

97+
/** Pick a client in the picker (Radix tabs activate on mouse-down). */
98+
function pickClient(label: string) {
99+
fireEvent.mouseDown(screen.getByRole('tab', { name: label }), { button: 0 });
100+
}
101+
102+
const PICKER_LABELS = [
103+
'Claude',
104+
'Codex',
105+
'Cursor',
106+
'WorkBuddy',
107+
// Product names a pack may write in its own script (zh: 豆包工作 / 千问办公).
108+
'«connectAgent.doubao.title»',
109+
'«connectAgent.qwenwork.title»',
110+
];
111+
82112
const createButton = () => screen.getByRole('button', { name: '«connectAgent.apiKey.mint»' });
83113

84114
describe('Connect an Agent mints a key only under a typed, confirmed name (objectui#13355)', () => {
@@ -143,53 +173,48 @@ describe('Connect an Agent offers the Chinese clients after the international on
143173
const copyable = () =>
144174
Array.from(document.querySelectorAll('code, dd')).map((el) => el.textContent ?? '');
145175

146-
it('renders one card list, international clients first, then WorkBuddy, Doubao Work and QwenWork', async () => {
147-
await renderSettled();
148-
const order = [
149-
// One Claude card carries both ways in: the connector, then the CLI.
150-
'Claude',
151-
'claude.ai / Claude Desktop',
152-
'Claude Code',
153-
'Codex',
154-
'Cursor',
155-
'WorkBuddy',
156-
// Product names a pack may write in its own script (zh: 豆包工作 / 千问办公).
157-
'«connectAgent.doubao.title»',
158-
'«connectAgent.qwenwork.title»',
159-
].map((title) => screen.getByText(title));
160-
for (let i = 1; i < order.length; i++) {
161-
const follows = order[i - 1].compareDocumentPosition(order[i]) & Node.DOCUMENT_POSITION_FOLLOWING;
162-
expect(follows, `${order[i].textContent} renders after ${order[i - 1].textContent}`).toBeTruthy();
163-
}
164-
// One list: no group headings split the cards.
165-
expect(document.querySelectorAll('h3')).toHaveLength(0);
176+
it('offers one picker, international clients first, then WorkBuddy, Doubao Work and QwenWork', async () => {
177+
await renderPage();
178+
expect(screen.getAllByRole('tab').map((tab) => tab.textContent)).toEqual(PICKER_LABELS);
166179
for (const dropped of ['DuMate', 'VS Code / Copilot']) {
167180
expect(screen.queryByText(dropped)).not.toBeInTheDocument();
168181
}
169-
for (const key of ['codex', 'workbuddy', 'doubao', 'qwenwork']) {
170-
expect(screen.getByText(`«connectAgent.${key}.body»`)).toBeInTheDocument();
182+
// Claude carries both ways in: the connector, then the CLI.
183+
const desktop = screen.getByText('claude.ai / Claude Desktop');
184+
const code = screen.getByText('Claude Code');
185+
expect(desktop.compareDocumentPosition(code) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
186+
for (const [label, key] of [
187+
['Codex', 'codex'],
188+
['WorkBuddy', 'workbuddy'],
189+
['«connectAgent.doubao.title»', 'doubao'],
190+
['«connectAgent.qwenwork.title»', 'qwenwork'],
191+
]) {
192+
pickClient(label);
193+
expect(await screen.findByText(`«connectAgent.${key}.body»`)).toBeInTheDocument();
171194
expect(screen.getByText(`«connectAgent.${key}.hint»`)).toBeInTheDocument();
172195
}
173196
});
174197

175198
it('hands each client its own transport spelling for this deployment\'s MCP URL', async () => {
176-
await renderSettled();
177-
const values = copyable();
199+
await renderPage();
178200
const json = (type: string) =>
179201
JSON.stringify({ mcpServers: { objectstack: { type, url: MCP_URL } } }, null, 2);
180202
// WorkBuddy's mcp.json and QwenWork's JSON import spell Streamable HTTP differently.
181-
expect(values).toContain(json('streamableHttp'));
182-
expect(values).toContain(json('streamable-http'));
183-
// The Codex app and Doubao Work are dialog forms: name, transport and URL, each copyable.
184-
expect(values.filter((v) => v === 'objectstack')).toHaveLength(2);
185-
expect(values).toContain('Streamable HTTP');
186-
expect(values).toContain('HTTP');
187-
expect(values.filter((v) => v === MCP_URL).length).toBeGreaterThanOrEqual(4);
188-
// The Codex card describes the app's form, not a config.toml snippet.
189-
expect(values.some((v) => v.includes('[mcp_servers.objectstack]'))).toBe(false);
203+
pickClient('WorkBuddy');
204+
await waitFor(() => expect(copyable()).toContain(json('streamableHttp')));
205+
pickClient('«connectAgent.qwenwork.title»');
206+
await waitFor(() => expect(copyable()).toContain(json('streamable-http')));
207+
// The Codex app and Doubao Work are dialog forms: name, transport and URL, each copyable
208+
// (after the endpoint's own URL on top).
209+
pickClient('Codex');
210+
await waitFor(() => expect(copyable()).toEqual([MCP_URL, 'objectstack', 'Streamable HTTP', MCP_URL]));
211+
// The Codex steps describe the app's form, not a config.toml snippet.
212+
expect(copyable().some((v) => v.includes('[mcp_servers.objectstack]'))).toBe(false);
213+
pickClient('«connectAgent.doubao.title»');
214+
await waitFor(() => expect(copyable()).toEqual([MCP_URL, 'objectstack', 'HTTP', MCP_URL]));
190215
});
191216

192-
it('reveals a minted key in the Authorization: Bearer form the cards point to', async () => {
217+
it('reveals a minted key in the Authorization: Bearer form the steps point to', async () => {
193218
const input = await renderSettled();
194219
fireEvent.change(input, { target: { value: 'ci-agent' } });
195220
fireEvent.click(createButton());
@@ -202,3 +227,55 @@ describe('Connect an Agent offers the Chinese clients after the international on
202227
expect(screen.getByText(`x-api-key: ${MINTED_KEY}`)).toBeInTheDocument();
203228
});
204229
});
230+
231+
describe('Connect an Agent asks which client the person uses and shows only those steps', () => {
232+
const PREFERENCE_KEY = 'os:pref:connect.client';
233+
const CLAUDE_CODE = /^claude mcp add --transport http objectstack /;
234+
235+
it('§1 the endpoint and SKILL.md stay on top; one client\'s steps show; the API key form is collapsed', async () => {
236+
await renderPage();
237+
// On top, for everyone: the endpoint and the skill download.
238+
const endpoint = screen.getByText('«connectAgent.url.title»');
239+
const picker = screen.getByText('«connectAgent.client.title»');
240+
expect(endpoint.compareDocumentPosition(picker) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
241+
expect(screen.getByRole('link', { name: /«connectAgent\.url\.downloadSkill»/ })).toHaveAttribute(
242+
'download',
243+
'SKILL.md',
244+
);
245+
// A person who never chose sees Claude, and only Claude.
246+
expect(screen.getByRole('tab', { name: 'Claude' })).toHaveAttribute('aria-selected', 'true');
247+
expect(screen.getByText(CLAUDE_CODE)).toBeInTheDocument();
248+
for (const key of ['codex', 'cursor', 'workbuddy', 'doubao', 'qwenwork']) {
249+
expect(screen.queryByText(`«connectAgent.${key}.body»`)).not.toBeInTheDocument();
250+
}
251+
// Scripts and CI: the API key form waits behind the collapsed Advanced section, after the picker.
252+
const advanced = screen.getByRole('button', { name: /«connectAgent\.advanced\.title»/ });
253+
expect(advanced).toHaveAttribute('aria-expanded', 'false');
254+
expect(picker.compareDocumentPosition(advanced) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
255+
expect(screen.queryByText('«connectAgent.apiKey.title»')).not.toBeInTheDocument();
256+
expect(screen.queryByPlaceholderText('«connectAgent.apiKey.namePlaceholder»')).not.toBeInTheDocument();
257+
fireEvent.click(advanced);
258+
expect(advanced).toHaveAttribute('aria-expanded', 'true');
259+
expect(await screen.findByText('«connectAgent.apiKey.title»')).toBeInTheDocument();
260+
});
261+
262+
it('§2 one click switches clients, and this browser remembers the choice', async () => {
263+
const first = await renderPage();
264+
pickClient('Cursor');
265+
expect(await screen.findByText('«connectAgent.cursor.body»')).toBeInTheDocument();
266+
expect(screen.queryByText(CLAUDE_CODE)).not.toBeInTheDocument();
267+
expect(JSON.parse(window.localStorage.getItem(PREFERENCE_KEY) ?? 'null')).toEqual({ client: 'cursor', v: 1 });
268+
269+
first.unmount();
270+
await renderPage();
271+
expect(screen.getByRole('tab', { name: 'Cursor' })).toHaveAttribute('aria-selected', 'true');
272+
expect(screen.getByText('«connectAgent.cursor.body»')).toBeInTheDocument();
273+
});
274+
275+
it('§3 a stored client the page does not offer reads as no choice', async () => {
276+
window.localStorage.setItem(PREFERENCE_KEY, JSON.stringify({ client: 'copilot', v: 1 }));
277+
await renderPage();
278+
expect(screen.getByRole('tab', { name: 'Claude' })).toHaveAttribute('aria-selected', 'true');
279+
expect(screen.getByText(CLAUDE_CODE)).toBeInTheDocument();
280+
});
281+
});

0 commit comments

Comments
 (0)