Skip to content

Commit 544a946

Browse files
feat(app-shell): the assistant's entry is an outlined Ask AI button at the end of every page's top-right group (#37885)
repo:objectstack#3 · os-tesla · session_01L9qibwhwiMRQSuaJ1wVVcU <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoVZq3vnWX7teQJ8M5nj9ENi)_ Fixes #37858 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:所有用户在每个页面右上角看到带文字的「问 AI」描边按钮(页头、记录页、Home 顶栏),手机上是 44px 图标;没有页头的页面在内容右上角也有这个按钮(从右到左的语言在左上角)。 - 为什么做:问 AI 入口改造专题里的入口按钮这一张,解决用户找不到问 AI 入口、只看到一个很小的透明机器人图标的问题。 - 出错会怎样:本轮之前兜底按钮会盖住报表编辑器右上角的「保存」「放弃」和收件箱的「全部标为已读」并抢走点击;现在这两处把按钮放进自己的页头,浏览器实测无遮挡。最坏仍是页头很窄时只剩图标,或今后新加的无页头页面在同一角放了自己的按钮;直接撤回这次改动即可恢复原来的机器人图标。 - 要你做什么:无。 ## What changes The assistant's one standing entry (`AssistantTopBarButton`) is now an outlined button with a chat-bubble icon and the words 「问 AI」 / "Ask AI", replacing the 32 px transparent robot named only by its tooltip. Card items, as written on the card: 1. **Button.** `variant="outline" size="sm"`, `h-8`, chat-bubble icon plus the words; pressed style and the amber plan-pending dot kept. The words come from the existing `home.askAI` string (see Acceptance notes: no new key, so no locale pack changes). Mobile is the icon alone at `size-11`. 2. **Placement.** Last in the page's button group (comments, help, Ask AI), so it ends the console page header's row and the record page's navigation row; after help in the app bar (Home and the phone's bar). 3. **Width.** The console page header measures its own width (the same ResizeObserver plus after-render pass its fold already uses) and hides the words first: before its title is cut and, on a page that offers the folded actions, before those actions fold. The words come back once the cluster's lost width fits again, after any fold has opened, so the states cannot flip-flop. Decided by measured content, never a breakpoint. It reaches the group through one new optional slot prop, `assistantIconOnly`. 4. **Routes with no shell header.** `ShellAssistantFallback`, built like `ShellSidebarExpandFallback`: the scope counts the button groups actually drawn under it, and where none is, the same button sits over the content's empty top end corner (`end-2`: top-right, top-left in a right-to-left language) (never on a phone, never with the group turned off, never without AI). Counting drawn groups rather than routes means a page that draws a header through its children is counted correctly. The routes whose page module draws none of the shell headers today (static reading of the route table and each page module at the base commit): `search`, `component/:ns/:name/*`, `inbox` and `inbox/:tab`, `system/marketplace/:packageId`, `reports/new`, `create-app`, `edit-app/:name`, `design/dashboard/:name`, and the not-found route. The report builder's host and the inbox page keep their own controls in that corner, so they draw the group at the end of their own top bar through the slot (`ReportBuilder` takes an optional `headerEnd`, drawn after Save), which also counts it for the fallback. The marketplace package's error-state Back button is sized to its words (`self-start`), as on the loaded page. 5. **Home.** Home's 「Ask AI」 now opens the drawer through `useAskAiEntry`, the entry hook whose no-target arm is the button's own toggle; it still asks the `ask` agent, as it did. 6. **Accessibility.** With its words shown, the words are the accessible name (no `aria-label`); icon only, `aria-label` carries the same words. The marker's words stay the button's description and are kept out of its name. On a Mac the tooltip shows ⌘⇧I and the button declares `aria-keyshortcuts="Meta+Shift+I"`; elsewhere no shortcut is shown or declared (with the words shown and no shortcut to add, there is no tooltip at all). 7. **The objectstack#34827 pin** stays green; see Acceptance notes for the note to objectstack#37860. 8. Apps cannot rename the button: the words are the platform's string, no app input reads them. Visibility rules unchanged (AI surface gate). ## Tests New pins: - `AssistantTopBarButton.askAi-37858.test.tsx`: both faces and their names (zh 「问 AI」, en "Ask AI"), no `aria-label` on the text face, icon-only `aria-label`, phone 44 px, pressed style and toggle, link face without a drawer host, marker as description not name, Mac `aria-keyshortcuts` plus ⌘⇧I tooltip, no shortcut elsewhere, every built-in pack carries the words. - `ShellPageActions.askAi-37858.test.tsx`: group order ending in Ask AI; icon-only through the slot; corner fallback drawn on a group-less route, gone beside a group, absent on a phone, with the group off and without AI; the header's words-first collapse against a width model (words go before the fold, fold opens before the words return, no flip-flop, a no-fold page keeps the words while only its description is cut, no layout keeps the words). - `HomePage.askAiEntry-37858.test.tsx`: Home's button goes through the entry, on the ask agent, navigating nowhere. - `ReportBuilderHost.askAiEntry-37858.test.tsx` (round 1): inside the shell there is no corner fallback and exactly one Ask AI, in the builder header after Discard and Save; a bare mount ends with Save. - `InboxPage-36741.test.tsx`, two cases added (round 1): the header row ends with unread-only, mark-all-read, divider, shell group; no divider outside the shell. Edited: the objectstack#34827 pin (transition halves), and the two layout harnesses that mounted a bare button beside a header-less page (objectstack#34608, objectstack#26470) now drive the layout's own corner entry; the three edited dock harnesses pay the chat body's grid load at collection, as `check:test-source-alias` prescribes. Ablation: the header's answer forced to "words shown" turns the three collapse cases red (3 failed / 6 passed), restored from the commit. Round 1: the host's `headerEnd` disabled on disk turns the new report-builder pin red (1 failed / 1 passed), restored. <details><summary>Readings</summary> - Related app-shell and console suite (every test file naming the group, the button, `ConsoleLayout`, `PageHeader`, `AppHeader`, `ShellPageActions` or `HomePage`): 249 files / 2903 tests passed at 190b03b; the eight edited/new files re-run at 49369e9: 8 files / 63 tests passed. - `pnpm --filter @object-ui/app-shell run type-check` (src and `tsconfig.test.json`, which reaches the tests): exit 0, 0 TS errors, after building the dependency closure. - eslint on the changed files: 0 errors. - Round 1 at 5f8012f: plugin-report, app-shell layout, Report views, inbox, marketplace and home: 332 files / 2872 passed, 7 skipped. Type-check for plugin-report and app-shell: exit 0; the reverse check (an unknown prop) went red, exit 2. - Button width per locale (headless Chrome, this container's system font, 14 px medium, 16 px icon, 6 px gap, 10 px padding): ar 179, es 149, fr 144, pt-BR 134, ru 130, ko 117, ja 103, de 101, en 84, zh-Hans 75, zh-Hant 75 px. </details> ## Acceptance notes - **No new key; `Clause-②: no`.** The card asked for a new `topbar.askAi` key reusing `home.askAI`'s translations. Adding it in the eleven packs made `overlap-check` answer exit 1 against objectstack#37676 (it shares those packs). The conflicting hunk is objectstack#37676 against current main, not these lines, but the gate counts any conflict on a file the branch changed. The dispatch allows reusing an existing key, so the button reads `home.askAI` itself: the eleven packs are untouched, and the one entry has one string, which Home's button (now the same entry) already carries. - **Record page "before ✕".** Since objectstack#36557 ✕ is the navigation row's first control, at its left. The group sits at the row's right end, so Ask AI, now the group's last button, is the row's top-right control. The record view itself is unchanged. The record row does not measure: it has no page actions to push out, and its stepper's view name truncates first. The widest words (ar, 179 px) take 147 px more than the icon. That squeeze is not measured in a browser. - **For objectstack#37860 (card item 7).** C3 lands first. The objectstack#34827 pin now holds two halves: the drawer title still equals `topbar.aiAssistant` in every pack, and the standing entry reads `home.askAI` beside it. So until C4 the drawer is titled 「AI 助手」 while the button says 「问 AI」. C4 rewrites that pin to "drawer title = conversation title, 「新会话」 before the first send". - **ui ADR-0057 amendment A3** calls the entry "the top-bar robot". It is not edited here (governed); the wording line is the landing seat's after merge. - **Not touched, still "AI Assistant" with the robot.** The record pane and record drawer bars' own assistant buttons (`record-pane-open-assistant`, in the list's record drawer and in the record drawer stack) are outside this card's file surface. Carrier: objectstack#37860 or the seat. - **File surface.** One file outside the claim's list: `shellPageActionsSlot.ts`, one optional prop. It is the header-to-group channel, and a header must not import the group. Two existing layout harnesses were also edited (objectstack#34608, objectstack#26470), as described under Tests. - **Corner fallback, measured in a browser (round 1).** 1280 px, en and ar, every group-less route; before the fix 9 route/locale pairs had a page control under the fallback, after it 0 of 22: | locale | route | before (49369e9): page controls under the fallback | after (5f8012f): where Ask AI is drawn | after: page controls under it | page's own top control nearest the end edge | |---|---|---|---|---|---| | en | search | none | fallback 1186..1272 y8..40 | none | task 344..1192 y76..120 | | en | component-recycle-bin | none | group in page header 1170..1256 y17..49 | none | shell-page-actions-help 1132..1164 y17..49 | | en | component-access-directory | none | fallback 1186..1272 y8..40 | none | View all issues (10) 929..1107 y110..146 | | en | inbox | inbox-page-mark-all-read | group in page header 1170..1256 y14..46 | none | inbox-detail-open-full 1165..1256 y73..109 | | en | inbox-detail | none | group in page header 1170..1256 y14..46 | none | inbox-detail-open-full 1095..1256 y71..107 | | en | marketplace-package | Back to marketplace | fallback 1186..1272 y8..40 | none | Back to marketplace 272..459 y24..60 | | en | reports-new | report-builder-discard, report-builder-save | group in page header 1178..1264 y14..46 | none | report-builder-type-trigger 977..1264 y129..165 | | en | create-app | none | fallback 1186..1272 y8..40 | none | wizard-step-branding 957..1024 y57..117 | | en | edit-app | none | fallback 1186..1272 y8..40 | none | wizard-step-branding 957..1024 y57..117 | | en | design-dashboard | none | fallback 1186..1272 y8..40 | none | dashboard-widget-remove-table_spend 2015..2033 y137..155 | | en | not-found | none | fallback 1186..1272 y8..40 | none | - | | ar | search | رجوع | fallback 8..186 y8..40 | none | رجوع 885..936 y28..48 | | ar | component-recycle-bin | none | group in page header 28..206 y17..49 | none | تصفية الكائنات 757..987 y104..136 | | ar | component-access-directory | none | fallback 8..186 y8..40 | none | 520..1000 y108..148 | | ar | inbox | inbox-page-tab-notifications | group in page header 503..680 y64..96 | none | inbox-page-needs-you 640..1007 y119..161 | | ar | inbox-detail | inbox-page-tab-notifications | group in page header 266..444 y14..46 | none | inbox-page-row 624..1023 y55..120 | | ar | marketplace-package | العودة إلى السوق | fallback 8..186 y8..40 | none | العودة إلى السوق 845..1000 y24..60 | | ar | reports-new | report-builder-close, report-builder-name | group in page header 20..198 y14..46 | none | report-builder-close 976..1008 y14..46 | | ar | create-app | none | fallback 8..186 y8..40 | none | wizard-step-basic 671..786 y57..117 | | ar | edit-app | none | fallback 8..186 y8..40 | none | wizard-step-basic 671..786 y57..117 | | ar | design-dashboard | dashboard-design-back | fallback 8..186 y8..40 | none | dashboard-design-back 972..1000 y12..40 | | ar | not-found | none | fallback 8..186 y8..40 | none | - | In ar the end edge is the left, and the x 8..206 positions there sit under the sidebar panel. That is a pre-existing RTL sidebar defect, the same for every page-header group, and is listed in out_of_scope_findings. The inbox detail was opened from the activity tab's first row (detail header present in both locales). During a lazy route's load it shows until the page's header mounts, which is the expand fallback's behaviour too. - **App bar (Home, organization pages).** It does not measure; it has room for the words at desktop widths. On a phone the button is always the icon. ## Verification Read first, by risk: 1. `ui/packages/app-shell/src/layout/PageHeader.tsx`, the words-first block inside `useActionsFold` and `titleOverflow`: the ordering against the fold. 2. `ui/packages/app-shell/src/views/ReportBuilderHost.tsx`, the `headerEnd` wiring. 3. `ui/packages/app-shell/src/layout/ShellPageActions.tsx`, `ShellAssistantFallback` and the drawn-group counter. 4. `ui/packages/app-shell/src/layout/AssistantTopBarButton.tsx`, the two faces and the Mac-only shortcut. Two-minute check: `pnpm --dir ui exec vitest run packages/app-shell/src/layout/__tests__/ShellPageActions.askAi-37858.test.tsx`. Expected: 9 passed. Then open any list page in the Console at 1280 px: the header ends with an outlined 「问 AI」 button. Narrow the window and the words go before the page's own buttons fold. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibwhwiMRQSuaJ1wVVcU)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3eb778d commit 544a946

21 files changed

Lines changed: 1194 additions & 86 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/plugin-report': patch
4+
---
5+
6+
feat(app-shell): the assistant's entry is an outlined 「Ask AI」 button at the end of every page's top-right group, and a route with no page header gets it in its corner
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The assistant's one standing entry was a 32 px transparent robot icon named only by its tooltip. It is now an outlined button with a chat-bubble icon and the words 「Ask AI」 (「问 AI」 in Chinese), read from the string Home's own 「Ask AI」 button already carries in every built-in pack (`home.askAI`), so no language pack changes. The words are the platform's; no app renames them.
12+
13+
- **Where it sits.** Last in the page's top-right button group (comments, help, Ask AI), so it ends the page header's row and the record page's navigation row; after help on Home's bar and in the phone's top bar. A route whose page draws no button group (search results, a component page, the app editor) gets the same button over the empty top end corner of its content (top-right; top-left in a right-to-left language), and loses it as soon as its page draws a group. A page that keeps its own controls in that corner draws the group in its own top bar instead, so the button never covers them: the report builder (a new report, and a report's Edit) ends its header with Discard, Save, help, Ask AI, and the inbox ends its header row with its own buttons, help, Ask AI.
14+
- **When the header runs out of room.** The console page header now measures whether its title (and, on a page that offers the folded actions, its description) still fits beside the words; when it does not, the words are hidden first and the icon stays, before the page's own actions fold and before the title is cut. They come back once there is room again, after any fold has opened. The decision reads the header's own width, never a breakpoint, so a longer translation hides its words sooner.
15+
- **Phone.** The icon alone, a 44 px target.
16+
- **Accessibility.** With its words shown the words are the button's accessible name; with the icon alone `aria-label` carries the same words. On a Mac the tooltip shows ⌘⇧I and the button declares `aria-keyshortcuts="Meta+Shift+I"`; on other platforms, where Ctrl+Shift+I opens the browser's developer tools, no shortcut is shown or declared.
17+
- **Home.** Home's 「Ask AI」 opens the drawer through the same entry hook as the page's button (`useAskAiEntry`), still on the ask agent.
18+
19+
`useShellPageActionsSlot()`'s render function takes one more optional prop, `assistantIconOnly`, which a header that measures its own width passes; a header that passes nothing gets the button with its words, as before. `ReportBuilder` (`@object-ui/plugin-report`) takes an optional `headerEnd`, drawn after Save at the end of its header; without it the header ends with Save, as before. The drawer keeps its title for now.

‎ui/packages/app-shell/src/console/home/HomePage.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ import { fetchPackages } from '../../views/studio-design/packages-io.js';
9191
import { resolveAiApiBase } from '../../hooks/useAiSurface.js';
9292
import { isAiStudioEnabled, isMarketplaceEnabled } from '../../runtime-config.js';
9393
import { useNewPackageDoorPath } from '../../hooks/useNewPackageDoorPath.js';
94-
import { useOpenAssistant } from '../../layout/chatDockControl.js';
94+
import { useAskAiEntry } from '../../layout/AssistantTopBarButton.js';
9595
import { isProductApp } from '../../utils/homePath.js';
9696
import { useAddAppEntries, useMayAddApp } from '../../hooks/useAddAppEntries.js';
9797
import { catalogServesBuild } from '../../hooks/surfaceAgent.js';
@@ -454,9 +454,11 @@ export { readRecentObjects, type RecentObjectReading };
454454
export function HomePage({ checklist }: HomePageProps = {}) {
455455
const navigate = useNavigate();
456456
// objectstack#34608 — the Home AI buttons open the same right-side drawer
457-
// every console page has (in place, no navigation).
458-
const openAssistant = useOpenAssistant();
459-
const openHomeAssistant = (agent: 'ask') => openAssistant({ agent });
457+
// every console page has (in place, no navigation). objectstack#37858 —
458+
// through the Ask AI entry the top bar's button opens it with, so the two
459+
// change together when opening comes to mean a new conversation.
460+
const askAi = useAskAiEntry();
461+
const openHomeAssistant = (agent: 'ask') => askAi({ agent });
460462
const { t, language } = useObjectTranslation();
461463
const metadata = useMetadata();
462464
const { apps, loading } = metadata;
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#37858 — Home's 「Ask AI」 opens the assistant through the same
5+
* entry as the page's Ask AI button (`useAskAiEntry`), so when opening comes
6+
* to mean "a new conversation" the two change together. Today it still asks
7+
* the `ask` agent, as it did.
8+
*
9+
* Real subject: `HomePage`, with the stand-ins of
10+
* `HomePage.phoneTapTargets-29147.test.tsx` (the catalog moves the way the
11+
* real `useAgents` does); the entry is observed, not run.
12+
*/
13+
14+
import '@testing-library/jest-dom/vitest';
15+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
16+
import React from 'react';
17+
import { render, screen, cleanup, fireEvent } from '@testing-library/react';
18+
19+
const navigateMock = vi.fn();
20+
21+
const state = vi.hoisted(() => ({
22+
apps: [] as Array<Record<string, unknown>>,
23+
/** The catalog's answer, once it has answered. */
24+
agents: [] as Array<{ name: string }>,
25+
askAgent: false,
26+
buildAgent: false,
27+
/** Set once the stand-in has drawn the catalog's answer (objectstack#37227). */
28+
answered: false,
29+
}));
30+
31+
vi.mock('react-router-dom', async () => {
32+
const { createElement } = await import('react');
33+
return {
34+
useNavigate: () => navigateMock,
35+
Link: ({ to, ...rest }: { to: string } & Record<string, unknown>) =>
36+
createElement('a', { ...rest, href: to }),
37+
};
38+
});
39+
40+
vi.mock('@object-ui/i18n', async (importOriginal) => ({
41+
...(await importOriginal<Record<string, unknown>>()),
42+
useObjectTranslation: () => ({ t: (key: string) => `«${key}»`, language: 'en' }),
43+
useObjectLabel: () => {
44+
const label = (x: { name?: string; label?: string }) => String(x?.label || x?.name || '');
45+
return {
46+
appLabel: label,
47+
objectLabel: label,
48+
objectPluralLabel: label,
49+
dashboardLabel: label,
50+
pageLabel: label,
51+
reportLabel: label,
52+
viewLabel: (_object: string, _view: string, fallback?: string) => fallback ?? '',
53+
};
54+
},
55+
}));
56+
57+
vi.mock('@object-ui/auth', async (importOriginal) => ({
58+
...(await importOriginal<Record<string, unknown>>()),
59+
useAuth: () => ({ user: { id: 'u1', name: 'Dev Admin', email: 'dev.admin@example.com' } }),
60+
useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }),
61+
}));
62+
63+
// The catalog moves the way the real `useAgents` does: an empty first frame,
64+
// then loading, then the answer.
65+
vi.mock('@object-ui/plugin-chatbot/core', async (importOriginal) => {
66+
const { useEffect, useState } = await import('react');
67+
return {
68+
...(await importOriginal<typeof import('@object-ui/plugin-chatbot/core')>()),
69+
useAgents: () => {
70+
const [phase, setPhase] = useState<'idle' | 'loading' | 'answered'>('idle');
71+
useEffect(() => {
72+
if (phase === 'idle') setPhase('loading');
73+
else if (phase === 'loading') setPhase('answered');
74+
}, [phase]);
75+
if (phase === 'answered') state.answered = true;
76+
return { agents: phase === 'answered' ? state.agents : [], isLoading: phase === 'loading' };
77+
},
78+
isAskAgent: () => state.askAgent,
79+
agentHasCapability: () => state.buildAgent,
80+
};
81+
});
82+
83+
vi.mock('../../../providers/MetadataProvider', () => ({
84+
useMetadata: () => ({ apps: state.apps, objects: [], dashboards: [], pages: [], reports: [], loading: false }),
85+
}));
86+
vi.mock('../../../context/NavigationContext', () => ({
87+
useNavigationContext: () => ({ currentAppName: 'crm' }),
88+
}));
89+
vi.mock('../../../hooks/useCanAuthorMetadata', () => ({
90+
useCanAuthorMetadata: () => true,
91+
useCanReadPendingDrafts: () => true,
92+
}));
93+
vi.mock('../../../runtime-config', () => ({
94+
getRuntimeConfig: () => ({ branding: { productName: 'ObjectStack' } }),
95+
isMarketplaceEnabled: () => true,
96+
isAiStudioEnabled: () => true,
97+
}));
98+
99+
const now = new Date().toISOString();
100+
vi.mock('../../../hooks/useHomeInbox', () => ({
101+
useHomeInbox: () => ({
102+
pendingApprovals: [{ id: 'apr_1', processLabel: 'Discount approval', recordTitle: 'QUO-0007', createdAt: now }],
103+
pendingApprovalsCount: 1,
104+
pendingApprovalsStatus: 'ready',
105+
pendingApprovalsReadable: true,
106+
notifications: [{ id: 'n1', title: 'Lead assigned', createdAt: now }],
107+
unreadTopicCount: 1,
108+
notificationsStatus: 'ready',
109+
notificationsReadable: true,
110+
activity: {
111+
value: [{ id: 'a1', user: 'Ada', description: 'updated a lead', timestamp: now, objectName: 'crm_lead' }],
112+
status: 'ready',
113+
readable: true,
114+
},
115+
}),
116+
}));
117+
vi.mock('../../../hooks/useRecentItems', () => ({
118+
useRecentItems: () => ({
119+
recentItems: [{ id: 'object:crm_lead', type: 'object', name: 'crm_lead', href: '/apps/crm/crm_lead', visitedAt: now }],
120+
}),
121+
}));
122+
vi.mock('../../../hooks/useFavorites', () => ({ useFavorites: () => ({ favorites: [] }) }));
123+
vi.mock('../../../hooks/useAiSurface', () => ({ resolveAiApiBase: () => '' }));
124+
vi.mock('../../../preview/usePendingDrafts', () => ({
125+
usePendingDrafts: () => ({ count: 1, entries: [{ name: 'crm_lead', label: 'Lead' }] }),
126+
}));
127+
vi.mock('../../../preview/usePublishAllDrafts', () => ({
128+
usePublishAllDrafts: () => ({ publishAll: async () => ({ ok: true }), publishing: false }),
129+
}));
130+
vi.mock('../../../hooks/useInboxBell', () => ({ useInboxBell: () => ({ markRead: vi.fn() }) }));
131+
vi.mock('../../../layout/ActivityObjectLabel', () => ({ ActivityObjectLabel: () => null }));
132+
133+
// objectstack#37858 — the entry the top bar's Ask AI button opens the drawer
134+
// through, observed: Home's button must reach the drawer by the same door.
135+
const askAiEntry = vi.hoisted(() => ({ calls: [] as unknown[] }));
136+
vi.mock('../../../layout/AssistantTopBarButton', async (importOriginal) => ({
137+
...(await importOriginal<Record<string, unknown>>()),
138+
useAskAiEntry: () => (target?: unknown) => {
139+
askAiEntry.calls.push(target);
140+
},
141+
}));
142+
143+
// The deployment notice reads its own state from the server for an administrator
144+
// (objectstack#30120); its fetch, its gate and its copy are pinned in
145+
// `deployment-notice/__tests__/DeploymentNotice.test.tsx`, so it is stubbed here
146+
// like every other source this page reads.
147+
vi.mock('../../deployment-notice/DeploymentNotice', () => ({ DeploymentNotice: () => null }));
148+
149+
// The page reaches `capabilityLint`'s dynamic `@objectstack/lint` import; its
150+
// first load is paid here, at collection, never inside a case's clock
151+
// (`check:test-source-alias`).
152+
import '@objectstack/lint';
153+
import { HomePage } from '../HomePage';
154+
155+
beforeEach(() => {
156+
navigateMock.mockReset();
157+
askAiEntry.calls = [];
158+
state.apps = [{ name: 'crm', label: 'CRM', icon: 'Box' }];
159+
state.agents = [{ name: 'ask' }];
160+
state.askAgent = true;
161+
state.buildAgent = false;
162+
state.answered = false;
163+
});
164+
165+
afterEach(() => {
166+
cleanup();
167+
});
168+
169+
describe("Home's Ask AI opens the assistant's one entry (objectstack#37858)", () => {
170+
it('a click goes through the entry, on the ask agent, and navigates nowhere', async () => {
171+
render(<HomePage />);
172+
fireEvent.click(await screen.findByTestId('home-ask-ai'));
173+
expect(askAiEntry.calls).toEqual([{ agent: 'ask' }]);
174+
expect(navigateMock).not.toHaveBeenCalled();
175+
});
176+
});

‎ui/packages/app-shell/src/console/marketplace/MarketplacePackagePage.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,9 @@ function MarketplacePackagePageBody() {
14641464
if (error || !data) {
14651465
return (
14661466
<div className="mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6">
1467-
<Button variant="ghost" size="sm" onClick={() => navigate(`${basePath}/system/marketplace`)}>
1467+
{/* Sized to its words, as on the loaded page: stretched across the
1468+
row it would run under the shell's corner Ask AI button. */}
1469+
<Button variant="ghost" size="sm" className="self-start -ml-2 text-muted-foreground hover:text-foreground" onClick={() => navigate(`${basePath}/system/marketplace`)}>
14681470
<ArrowLeft className="h-4 w-4 mr-1.5" aria-hidden="true" />
14691471
{t('marketplace.back')}
14701472
</Button>

‎ui/packages/app-shell/src/layout/AppHeader.tsx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -988,11 +988,6 @@ export function AppHeader({
988988
*/}
989989
{!phoneTab && <InboxBell activities={activities} />}
990990

991-
{/* AI Assistant — only when the runtime serves AI (hidden on
992-
Community Edition so it can't dead-end on an agent-less chat).
993-
objectstack#34608: it opens and closes the drawer in place. */}
994-
{aiEnabled && <AssistantTopBarButton />}
995-
996991
{/* Help & Documentation — the shared 「?」 menu (objectstack#36111:
997992
the page's button group draws the same component). The
998993
left-sidebar already links the hub, so this entry point earns
@@ -1002,6 +997,13 @@ export function AppHeader({
1002997
appPackageId={currentAppPackageId}
1003998
triggerClassName="h-8 w-8 hidden md:flex shrink-0"
1004999
/>
1000+
1001+
{/* Ask AI — only when the runtime serves AI (hidden on Community
1002+
Edition so it can't dead-end on an agent-less chat).
1003+
objectstack#34608: it opens and closes the drawer in place.
1004+
objectstack#37858: after help, as in the page's button group;
1005+
with its words on Home's bar, its icon alone (44 px) on a phone. */}
1006+
{aiEnabled && <AssistantTopBarButton className="md:ml-1" />}
10051007
</div>
10061008

10071009
{/* Group 3: Account (theme + lang moved into avatar dropdown) */}

0 commit comments

Comments
 (0)