Repository navigation
Commit 544a946
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
File tree
- .changeset
- ui/packages
- app-shell/src
- console
- home
- __tests__
- marketplace
- layout
- __tests__
- views
- inbox
- __tests__
- plugin-report/src/builder
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
457 | | - | |
458 | | - | |
459 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
460 | 462 | | |
461 | 463 | | |
462 | 464 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1464 | 1464 | | |
1465 | 1465 | | |
1466 | 1466 | | |
1467 | | - | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
1468 | 1470 | | |
1469 | 1471 | | |
1470 | 1472 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
991 | | - | |
992 | | - | |
993 | | - | |
994 | | - | |
995 | | - | |
996 | 991 | | |
997 | 992 | | |
998 | 993 | | |
| |||
1002 | 997 | | |
1003 | 998 | | |
1004 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
1005 | 1007 | | |
1006 | 1008 | | |
1007 | 1009 | | |
| |||
0 commit comments