Repository navigation
Commit 1afb6d4
fix(console): on a phone, a page the assistant opens closes its sheet (#37571)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg8JRuu4biowMGgDVcNVcsSp)_
Fixes #37556
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:在手机上用应用内 AI,点回答下方的引用后,AI 对话面板自动收起,直接看到被标出的那一段;再打开 AI
面板,还是原来的对话。电脑上面板照旧留在页面旁边。
- 为什么做:记录 AI 问询专题里引用条的跟进,原先手机上点引用像没反应,要手动关面板才看得到。
- 出错会怎样:手机上点 AI 里的链接后面板该收不收或不该收时收起;对话和数据不受影响,撤回本次合并即可恢复原样。
- 要你做什么:无。
## What changes
- `ui/packages/app-shell/src/layout/useConsoleChatDock.tsx`: on a phone
(the drawer is a bottom sheet over the page), the host closes the sheet
when the location moves by a PUSH or POP away from the history entry
(`location.key`) the sheet was shown open on. A PUSH onto the same URL
counts (a second click on the same citation chip carries fresh section
state to the same URL). A REPLACE never closes it: a page rewriting its
own query, the host's handoff hand-over, and an old `/ai…` link landing
with the drawer armed open all stay as they were.
- The entry the sheet was shown on is kept per tab in sessionStorage
(`ai-chat-dock-sheet-shown-at`, cleared whenever the sheet is closed),
not in the hook: a chip in a sheet opened over Home lands on an app's
record through another layout, which mounts a new dock host that never
saw the navigation (found by the first booted check). Where
sessionStorage throws, a module copy stands in, so the rule still works
for the life of the page.
- Review rework (contract review 7195408408, seat REWORK 7195422188):
- S1: the move away is noted on the navigation itself, before the phone
check. `useIsMobile` answers `false` on a host's first render; an app
named by its alias lands through `AppContent`, which REPLACEs the
address on mount, so a rule judged only once the flag settled saw that
REPLACE and kept the sheet open.
- N1: at a desktop width (read off the window, since `useIsMobile`'s
first-render `false` cannot tell) the entry is dropped, so turning a
tablet portrait, landscape, portrait does not close the drawer on the
turn.
- S2: a POP case is pinned. N3: the storage-failure jsdoc is corrected
and the in-memory fallback added. N2 and N4 accepted as they are.
- The rule lives in the host, not at the chip: every navigation the chat
makes on a phone (citation chip, `open_record`, list link, open-form)
now reveals the page; the chip's click path is not touched.
- The conversation is kept: closing only collapses the sheet; the dock
target is untouched, so reopening shows the same thread. Desktop rail
and the full-window rule are unchanged.
- Changeset `.changeset/37556-phone-dock-closes-on-citation.md` (patch,
`@object-ui/app-shell`).
Read first: `useConsoleChatDock.tsx`, the effect under the full-window
one and the storage helpers above `hasHandoff`.
## Tests
-
`ui/packages/app-shell/src/layout/__tests__/useConsoleChatDock.phoneCollapseOnNavigate-37556.test.tsx`
(9): the real host, `useChatDockState` and router; `useIsMobile` is a
stand-in with the real hook's timing (`false` on the first render,
measured in its mount effect, again on resize); stand-in sheet/rail.
Cases: a phone chip click (PUSH) closes the sheet and reopening with no
target shows the same conversation; a same-URL re-click closes it; Back
(POP) closes it; a chip from Home into an app (two layouts, two hosts)
closes it and reopening shows the same thread; the alias landing (a
parent `AppContent`-shaped redirect REPLACEs on mount while the new
host's flag is held back one task) closes it; with
`window.sessionStorage` throwing, a chip click closes it; a same-page
REPLACE leaves it open; a tablet turn to landscape, a chip click there,
and a turn back leaves the drawer open; CONTROL: at desktop width the
rail stays open after a chip click.
- The new tests against the previous head's hook (b220ce8): 3 failed
(alias landing, storage throwing, tablet turn), 6 passed.
- Ablation (the `collapse()` call replaced by a no-op): 6 failed, 3
passed (every closing case red; the REPLACE case, the tablet turn and
the desktop control green); restored 9/9.
## Acceptance notes
- Acceptance 1 (test): above.
- Acceptance 2 (booted-console phone check): see Verification.
## Verification
- Local on e4692c3: the new test 9/9; `@object-ui/app-shell`
`type-check` exit 0; derived gate families: see the report. The
package's whole suite is left to CI's `Test UI` (test-run scope, not a
Clause-② narrowing).
- Two-minute check: `pnpm --dir ui exec vitest run
packages/app-shell/src/layout/__tests__/useConsoleChatDock.phoneCollapseOnNavigate-37556.test.tsx`,
expected 9 passed.
- Booted-console phone check (iPhone 13 profile). Showcase app
(`objectstack dev --seed-admin`) with the `ui/` console dev server
pointed at it, on `main` (which now carries PR #37539, so history draws
chips) merged with this branch. **Injected, not produced**: no producer
emits the citations part before cloud 10c, so the run serves the
conversation-history read with an answer carrying a
`data-record-citations` part, and a one-agent catalog because the boot
has no model.
- Package address: the old `/ai/ask/CONVERSATION` link lands on Home
with the sheet open and 3 chips. Chip click:
`/apps/com.example.showcase/showcase_field_zoo/record/ID?section=contractor-scope`,
sheet gone (0 in the DOM), the marked heading `Contractor scope` at top
45 px, in view. Reopening: the same 3 chips. The same chip again: sheet
gone, heading in view.
- Alias path (S1): the object read is served with the app's NAME
(`showcase_app`) as its package, so the chip lands on
`/apps/showcase_app/…` and the app shell REPLACEs it with
`/apps/com.example.showcase/…`. Sheet gone, heading at top 45 px, in
view; reopening shows the same chips; the same chip again closes it
again.
- Screenshots: `objectstack-seat5/ai-36996/shots-37556/` in the project
files (`phone-dock-*.png` and `phone-alias-dock-*.png`, four each, plus
the script).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CXDoFxnz75MqdAxLSW)_
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CXDoFxnz75MqdAxLSW -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent bebc2cf commit 1afb6d4
3 files changed
Lines changed: 390 additions & 2 deletions
File tree
- .changeset
- ui/packages/app-shell/src/layout
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 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 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
0 commit comments