Skip to content

Commit cd10d6a

Browse files
feat(console): a new chat conversation is about the record on the page until its first send, shown as a chip in the composer (#38230)
repo:objectstack#3 · os-tesla · session_01L9qibwivzADop4jGmFZ81y Fixes #37861 Clause-②: yes (widening) — `@object-ui/plugin-chatbot` `ChatbotEnhanced` gains the optional `promptInputHeaderSlot`; `@object-ui/app-shell` `UseChatConversationReturn` gains `conversationMetadata` and `createdConversationId` Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:在记录页打开问 AI 时,输入框行首直接显示一个「正在问的记录」标签(图标、名称、×),换页会跟着换,第一次发送后固定下来;原来的图钉和「改为问另一条记录?」提示去掉了。 - 为什么做:「问 AI」入口改造专题的第五张卡,让一个会话问的是哪条记录一目了然,且不用用户手动钉。 - 出错会怎样:最坏是会话带错或没带上记录上下文,用户可点 × 去掉、或新开会话;不支持该能力的助手完全不变,直接撤回这次改动即恢复原样。 - 要你做什么:无。 ## What changes Framework ADR-0160 D6, seventh amendment ("The focus of a conversation"), on the client. Only where the agent declares `capabilities.focus: true`; without it nothing changes (no chip, no `focus` key, the page chip where it was). 1. **State `{ focus, dismissed }`** (`layout/chatFocus.ts`, rewritten). A conversation with no id yet is about the page's record (`surfaceRecord()`, moved here from the row), unless dismissed, and follows the page with no prompt. The first send fixes it: the id that send's own create mints (`useChatConversation`'s new `createdConversationId`) takes the focus it had at that moment, in the same render, so the first turn already carries `context.focus`. The mark keeps the `createdConversationId` the hook held when the send was made, and only a newer one takes it. No other arriving id takes it: a thread a send made during the resolve joins, and a history row opened while the create is on the wire, keep their own fixed or dismissed entry, including a thread this dock created at an earlier send. After that, navigation no longer moves it. A conversation sent without one never takes one. 2. **× removes it, and nothing adds it again** in that conversation, before or after the first send. Another dock target while unsent is another conversation, so × does not carry over. 3. **Restore.** A conversation opened again restores its own focus: this tab's `sessionStorage` copy first, else its row's `metadata.focus` (cloud#5113 shape: an array like `context.focus`, `raw[0]` under a string object/id guard, label trimmed; the client applies no length cap and the chip truncates in CSS; absent or malformed means none). `useChatConversation` now returns `conversationMetadata`, the `metadata` of the row it holds, and `createdConversationId`, the row its own create minted last. The request body stays the authority. 4. **The chip sits inside the composer's frame at the start of the line** (`ChatbotEnhanced.promptInputHeaderSlot`, new, drawn in place of the `surfaceContextLabel` chip when given): object icon, record name (else the metadata label, else `object · id`), and ×. × shows on hover, on focus-within, always on a coarse pointer, and has a 24px hit area. Logical margins, so it sits on the right in RTL. With no focus the page chip 「正在看:X」 shows, with no ×. 5. **Removed:** `setChatFocus` callers are already gone with C1 (#37924); this removes the pin, the 「改为问《X》?」 offer, `declined`, and the four locale keys `console.ai.focus.pin/switchPrompt/switchAccept/switchDecline` from every pack (they shipped only in 19 prereleases; named on their own line in the changeset). `console.ai.focus.pinned` now names the chip for assistive technology, `.remove` labels ×. 6. **Spec:** the `ToolExecutionContext.focus` docblock and the `capabilities.focus` description no longer speak of a pin; no key, type or gate change (`protocol.mdx` regenerated). ## Tests - `layout/__tests__/chatFocus-36999.test.tsx`, rewritten (25 cases): `surfaceRecord`; `chatFocusFromMetadata` (array, absent, malformed); the dock before the first send following the page, × before and after the send, a list start, a target change resetting ×; restore from `sessionStorage`, from metadata in a new tab (with label), absent/malformed metadata, × in this tab beating metadata, a failed create; a send during the resolve joining a found thread that keeps its ×; a history row opened while the create is on the wire keeping its own focus; the same two paths on a thread this dock itself created earlier, keeping its ×; the × reachability classes; the full page (no record, metadata restore); no-capability agents; the no-flag frame chip. - `plugin-chatbot/__tests__/ChatbotEnhanced.promptInputHeaderSlot-37861.test.tsx` (3): the slot sits inside the input group before the textarea and replaces the surface chip. - `i18n/__tests__/de-quote-pairing-3876.test.ts`: count 129 to 128 for the removed key. Ablations (on disk, restored from the commit): metadata restore plus the unsent rule removed → 10 red; carry plus origin removed → 5 red; `markSending` a no-op → 5 red. At `2a9ab800`: the newer-than-at-send check removed → the two cases on a dock-created thread red (2 of 25); that check and the created-id match both removed → 4 of 25 red. The per-target epoch from the previous round is removed: the held send marks again after a target change, so no case could turn on it. <details><summary>Readings</summary> - Head `37dccd4c` (the second review fix `2a9ab800`, then main merged, 18 behind, no conflict): every test file under app-shell `layout`, `console/ai` and `hooks`, plus `plugin-chatbot` and `i18n`: 505 files, 5413 passed, 13 skipped, 2 failed in `designModeMenuSave-36363` under the shared box, as on every earlier head (it passed alone, 47/47, at `fdb5e405`). The diff does not touch design mode. - `pnpm run type-check` in `@object-ui/app-shell`, `@object-ui/plugin-chatbot` and `@object-ui/i18n`: exit 0 each, after building the dependency closure with declarations. - eslint on `chatFocus.ts` and `useChatConversation.ts`: 0 errors. `chatFocus.ts` has one `react-hooks/refs` warning, for the first-send mark read where an id arrives (main had two in this file). - `overlap-check.mjs` at `37dccd4c`: clean. - `dispatch-gates --ran` at `00f98e0c`: 116 accounted, 115 run, 1 NOT-MEASURED (exit 3, built-output prerequisite). - CI at `fdb5e405`: 74 check runs, 0 failure. </details> ## Acceptance notes - **Conflicts with C1 resolved in favour of this branch** in `chatFocus.ts`, its test and `ChatDockConversation.tsx` (C1 had trimmed the same setter and carry code this rewrite replaces). The second main merge (`00f98e0c`) had no conflict. The file surface is unchanged from the claim. - **Review fixes (L1 R1 = L2 S1, then R2).** The first-send mark goes only to an id the hook created after that send; the two paths the review named have a case each on a thread the dock never created and on one it created earlier, red without the fix. - **Metadata label.** The chip prefers the record's own title (read as before); the metadata label stands in only until that read answers, or when it cannot. - **A sent conversation in another tab** with no stored copy and no `metadata.focus` shows the page chip, not a focus: the server row is the only witness there. - Ships in the same release as C4 (#37970), per the card. ## Verification Read first, by risk: 1. `ui/packages/app-shell/src/layout/chatFocus.ts`: `nextFocusState` (which arrival of an id takes the first send's mark) and `useConversationFocus`'s effective focus. 2. `ui/packages/app-shell/src/hooks/useChatConversation.ts`: `heldMetadata` and when it is set. 3. `ui/packages/app-shell/src/console/ai/ChatFocusRow.tsx`: the chip and the × classes. Two-minute check: `pnpm --dir ui exec vitest run packages/app-shell/src/layout/__tests__/chatFocus-36999.test.tsx`. Expected: 21 passed. In the Console, with an agent that declares `capabilities.focus`: open a record, open 问 AI, the composer line starts with the record's chip; open another record, the chip follows; send, then navigate away, the chip stays. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibwivzADop4jGmFZ81y)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4997cae commit cd10d6a

27 files changed

Lines changed: 900 additions & 358 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@objectstack/spec': patch
3+
'@object-ui/plugin-chatbot': patch
4+
'@object-ui/app-shell': patch
5+
'@object-ui/i18n': patch
6+
---
7+
8+
feat(console): a new chat conversation is about the record on the page until its first send, shown as a chip at the start of the composer's line; the pin and the offer to switch records are gone
9+
10+
Clause-②: yes (widening) — `@object-ui/plugin-chatbot` `ChatbotEnhanced` gains the optional `promptInputHeaderSlot`; `@object-ui/app-shell` `UseChatConversationReturn` gains `conversationMetadata` and `createdConversationId`
11+
Metadata-protocol: none
12+
Removed locale keys (`@object-ui/i18n`, every pack): `console.ai.focus.pin`, `console.ai.focus.switchPrompt`, `console.ai.focus.switchAccept`, `console.ai.focus.switchDecline` — shipped only in 19 prereleases.
13+
14+
Framework ADR-0160 D6, seventh amendment ("The focus of a conversation"). Where the agent the chat runs declares `capabilities.focus: true`:
15+
16+
- **A conversation that has sent nothing is about the record on the page** (a record page, or a record open in a list's drawer). It follows the page with no prompt: another record is that record, and a list or a dashboard is no record, so the composer shows the page chip ("Viewing: X") there.
17+
- **The chip sits inside the composer's frame, at the start of the line** (the right in Arabic): the object's icon, the record's name, and ×. × shows while the composer has focus or the pointer is over the chip, always on a touch screen, and has a 24px hit area. A record whose name cannot be read shows `object · id`.
18+
- **× removes the focus and nothing adds it again** in that conversation, before or after the first send; the composer falls back to the page chip.
19+
- **The first send fixes the focus**: that turn and every later one send it as `context.focus`, and navigation no longer changes it. A conversation sent without one never takes one. Only the conversation that send creates takes it: a thread a send made during the resolve joins, and a history row opened while the create is under way, keep their own.
20+
- **A conversation opened again restores its own focus**: from this tab, or, in another tab or from history, from the `metadata.focus` its server row stores. The request body stays the authority.
21+
- **Removed**: the pin on the page chip and the 「改为问《X》?」 offer to ask about another record, with their four locale keys (listed above). `console.ai.focus.pinned` now names the chip for assistive technology, and `.remove` labels ×.
22+
23+
Where the agent does not declare the flag, nothing changes: no chip, no `focus` key, and the page chip stays where it was.
24+
25+
`@object-ui/plugin-chatbot`: `ChatbotEnhanced` gains `promptInputHeaderSlot`, a row drawn inside the input's frame at the start of the line, in place of the `surfaceContextLabel` chip when given. `@object-ui/app-shell`: `useChatConversation` returns `conversationMetadata`, the `metadata` of the row it holds, and `createdConversationId`, the id of the row its own create minted last. `@objectstack/spec`: the `ToolExecutionContext.focus` docblock and the `capabilities.focus` description no longer speak of a pin; no key, type or gate changes.

‎content/docs/references/api/protocol.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const result = AiAgentCapabilitiesSchema.parse(data);
3232
| **canvas** | `boolean` | ✅ | Drives the Live Canvas split view (ADR-0037) |
3333
| **debug** | `boolean` | ✅ | Exposes the build-doctor debug drawer |
3434
| **resume** | `boolean` | ✅ | Turns resume durable multi-step runs (ADR-0013) |
35-
| **focus** | `boolean` | optional | Honours a conversation focus: the chat request's `context.focus`, the record the user pinned the conversation to (`ToolExecutionContext.focus`). A client draws the pin and sends the key only when this is true; absent reads as false. |
35+
| **focus** | `boolean` | optional | Honours a conversation focus: the chat request's `context.focus`, the record the conversation is about (`ToolExecutionContext.focus`). A client draws the focus chip and sends the key only when this is true; absent reads as false. |
3636

3737

3838
---
@@ -77,7 +77,7 @@ const result = AiAgentCapabilitiesSchema.parse(data);
7777
| **canvas** | `boolean` | ✅ | Drives the Live Canvas split view (ADR-0037) |
7878
| **debug** | `boolean` | ✅ | Exposes the build-doctor debug drawer |
7979
| **resume** | `boolean` | ✅ | Turns resume durable multi-step runs (ADR-0013) |
80-
| **focus** | `boolean` | optional | Honours a conversation focus: the chat request's `context.focus`, the record the user pinned the conversation to (`ToolExecutionContext.focus`). A client draws the pin and sends the key only when this is true; absent reads as false. |
80+
| **focus** | `boolean` | optional | Honours a conversation focus: the chat request's `context.focus`, the record the conversation is about (`ToolExecutionContext.focus`). A client draws the focus chip and sends the key only when this is true; absent reads as false. |
8181

8282

8383
---

‎packages/spec/src/api/protocol.zod.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4729,8 +4729,8 @@ export const AiAgentCapabilitiesSchema = lazySchema(() => z.object({
47294729
debug: z.boolean().describe('Exposes the build-doctor debug drawer'),
47304730
resume: z.boolean().describe('Turns resume durable multi-step runs (ADR-0013)'),
47314731
focus: z.boolean().optional().describe(
4732-
'Honours a conversation focus: the chat request\'s `context.focus`, the record the user pinned the '
4733-
+ 'conversation to (`ToolExecutionContext.focus`). A client draws the pin and sends the key only when '
4732+
'Honours a conversation focus: the chat request\'s `context.focus`, the record the conversation is '
4733+
+ 'about (`ToolExecutionContext.focus`). A client draws the focus chip and sends the key only when '
47344734
+ 'this is true; absent reads as false.',
47354735
),
47364736
}));

‎packages/spec/src/contracts/ai-service.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,12 +1263,14 @@ export interface ToolExecutionContext {
12631263
mode?: string;
12641264
};
12651265
/**
1266-
* The record(s) the conversation is pinned to — the conversation's FOCUS,
1266+
* The record(s) the conversation is about — the conversation's FOCUS,
12671267
* as the client reports it on every turn (`context.focus` in the chat
1268-
* request body), beside the page in view ({@link surfaceContext}). Unlike
1269-
* the surface, a focus does not follow navigation: the user pinned it, and
1270-
* it stays until they remove or replace it, so "this policy" keeps meaning
1271-
* the pinned record while they browse elsewhere.
1268+
* request body), beside the page in view ({@link surfaceContext}). Until
1269+
* the conversation's first send, its focus is the record on the page
1270+
* unless the user removed it; the first send fixes it. Unlike the
1271+
* surface, a focus then does not follow navigation: it stays until the
1272+
* user removes it, so "this policy" keeps meaning the focused record
1273+
* while they browse elsewhere.
12721274
*
12731275
* Client-reported and advisory, exactly like {@link surfaceContext}:
12741276
* NEVER an access decision. A consumer that reads the record re-reads it

‎ui/packages/app-shell/src/console/ai/AiChatPage.tsx‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ export function AiChatPage({ apiBase: apiBaseProp, defaultAgent: defaultAgentPro
213213
initialMessages,
214214
ensureConversation,
215215
createError: conversationCreateError,
216+
conversationMetadata,
217+
createdConversationId,
216218
} = useChatConversation({
217219
// Gate resolution on the agent being known: resolving while `activeAgent`
218220
// is still undefined (catalog loading) would bind a SCOPELESS conversation
@@ -250,10 +252,20 @@ export function AiChatPage({ apiBase: apiBaseProp, defaultAgent: defaultAgentPro
250252
const [selectedModelId, setSelectedModelId] = useState<string | undefined>(undefined);
251253
// objectstack#36999 — the conversation's focus, held here for the same
252254
// reason: the keyed pane remounts when the first send mints the id, and that
253-
// first turn must still carry the record the user pinned.
254-
const conversationFocus = useConversationFocus(paneConversationId, conversationCreateError);
255-
// A first send creates the conversation: the id it mints takes the focus
256-
// pinned before it (and no other arriving id does).
255+
// first turn must still carry the conversation's record. This page shows no
256+
// record of its own, so a new conversation here has none (ADR-0160 D6,
257+
// seventh amendment); one opened from history restores its own from this
258+
// tab or from its row's metadata (objectstack#37861).
259+
const conversationFocus = useConversationFocus(
260+
paneConversationId,
261+
conversationCreateError,
262+
null,
263+
scopeMatched ? conversationMetadata : undefined,
264+
undefined,
265+
createdConversationId,
266+
);
267+
// A first send creates the conversation: the id its create mints takes the
268+
// focus the conversation had at that send (and no other arriving id does).
257269
const { markSending: markFocusSending } = conversationFocus;
258270
const ensureConversationForSend = useCallback(() => {
259271
// With no user there is nothing to create: no mark, so no id that
Lines changed: 71 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
22

33
/**
4-
* objectstack#36999 — the composer's context row while the agent honours a
5-
* conversation focus (`capabilities.focus` on its catalog row).
4+
* objectstack#36999 / objectstack#37861 — the composer's context chip while
5+
* the agent honours a conversation focus (`capabilities.focus` on its catalog
6+
* row), drawn inside the input's frame at the start of the line.
67
*
7-
* It takes the place of the page chip the composer draws today
8-
* (`console.ai.discussing`), in the pane's in-flow composer row: the page chip
9-
* with a pin on it when the page shows one record, or — once a record is
10-
* pinned — the focus chip, naming the record by its display name, with a
11-
* remove control. Opening another record while one is pinned asks once
12-
* 「改为问《X》?」; a decline is remembered for the conversation.
8+
* Framework ADR-0160 D6 (seventh amendment): with a focus, the chip names the
9+
* record (the object's icon and the record's name) with × to remove it; ×
10+
* shows while the composer has focus or the pointer is over the chip, and
11+
* always on a touch screen. Without a focus — a list or a dashboard, a
12+
* conversation sent without one, or after × — it is the page chip
13+
* 「正在看:X」 (`console.ai.discussing`), with no ×. There is no pin and no
14+
* offer to switch records: an unsent conversation follows the page on its
15+
* own, and a sent one keeps the record it was sent with.
1316
*
1417
* The record's name is read client-side, as the user: the object definition
15-
* and one `findOne`, through the same seams the record page reads with. A
18+
* and one `findOne`, through the same seams the record page reads with. Until
19+
* that answers, the label the conversation's metadata stored stands in; a
1620
* record the user cannot read keeps its `object · id` pair.
1721
*/
1822

1923
import * as React from 'react';
20-
import { Pin, X } from 'lucide-react';
24+
import { X } from 'lucide-react';
25+
import { ObjectIconTile } from '@object-ui/components';
2126
import { useObjectTranslation } from '@object-ui/i18n';
2227
import { useMetadataItem } from '@object-ui/react';
2328
import { useAdapter } from '../../providers/AdapterProvider.js';
2429
import { getRecordDisplayName } from '../../utils/index.js';
25-
import type { ChatSurfaceContext } from '../../layout/chatSurfaceContext.js';
26-
import { sameChatFocus, type ChatFocus, type ConversationFocus } from '../../layout/chatFocus.js';
30+
import type { ChatFocus, ConversationFocus } from '../../layout/chatFocus.js';
2731

28-
/** The record a surface shows on its own (a record page, a record open in a list's drawer), or null. */
29-
export function surfaceRecord(surface: ChatSurfaceContext | undefined): ChatFocus | null {
30-
const object = surface?.artifact?.type === 'object' ? surface.artifact.name : undefined;
31-
const id = surface?.selection?.kind === 'record' ? surface.selection.id : undefined;
32-
return object && id ? { object, id } : null;
32+
/** What the chip shows of a record: its display name and its object's icon and colour. */
33+
export interface ChatRecordFace {
34+
/** The display name, undefined while it loads and when the record or its definition cannot be read. */
35+
title?: string;
36+
icon?: string;
37+
color?: string;
3338
}
3439

35-
/**
36-
* The display name of `record`, read as the user: undefined while it loads,
37-
* and when the record or its definition cannot be read.
38-
*/
39-
export function useChatRecordTitle(record: ChatFocus | null): string | undefined {
40+
/** The face of `record`, read as the user. */
41+
export function useChatRecordFace(record: ChatFocus | null): ChatRecordFace {
4042
const dataSource = useAdapter() as { findOne?: (object: string, id: string) => unknown } | null;
4143
const { item: objectDef } = useMetadataItem('object', record?.object ?? null);
4244
const object = record?.object;
@@ -67,103 +69,75 @@ export function useChatRecordTitle(record: ChatFocus | null): string | undefined
6769
};
6870
}, [object, id, canRead, dataSource]);
6971

70-
if (!record || !answer || answer.key !== key || !answer.row || !objectDef) return undefined;
72+
const def = record ? (objectDef as { icon?: unknown; color?: unknown } | undefined) : undefined;
73+
const icon = typeof def?.icon === 'string' ? def.icon : undefined;
74+
const color = typeof def?.color === 'string' ? def.color : undefined;
75+
if (!record || !answer || answer.key !== key || !answer.row || !objectDef) return { icon, color };
7176
const title = getRecordDisplayName(objectDef, answer.row, { fallback: '' });
72-
return title || undefined;
77+
return { title: title || undefined, icon, color };
7378
}
7479

7580
const CHIP =
76-
'inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground';
77-
const CHIP_BUTTON =
78-
'inline-flex shrink-0 items-center justify-center rounded-full p-0.5 hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring';
81+
'group/focus-chip inline-flex min-w-0 max-w-full items-center gap-1 rounded-full border bg-muted/40 py-0.5 text-[11px] text-muted-foreground';
82+
/**
83+
* × — a 24px hit area around a 12px glyph (WCAG 2.5.8). Revealed while the
84+
* pointer is over the chip, while anything in the composer has focus (the
85+
* frame is the `group/input-group`), on its own keyboard focus, and always on
86+
* a coarse pointer, where there is no hover.
87+
*/
88+
const REMOVE =
89+
'-my-1 -me-1 inline-flex size-6 shrink-0 items-center justify-center rounded-full opacity-0 transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover/focus-chip:opacity-100 group-focus-within/input-group:opacity-100 pointer-coarse:opacity-100';
7990

8091
export interface ChatFocusRowProps {
8192
/** The host's focus state for the conversation on screen. */
8293
focus: ConversationFocus;
83-
/** The page in view (`context.surface`). */
84-
surface?: ChatSurfaceContext;
8594
/** The page chip's text, as the composer draws it today; absent → no page chip. */
8695
surfaceLabel?: string;
8796
/** The page chip's tooltip (the internal `type · name` pair). */
8897
surfaceTitle?: string;
8998
}
9099

91-
export function ChatFocusRow({ focus, surface, surfaceLabel, surfaceTitle }: ChatFocusRowProps) {
100+
export function ChatFocusRow({ focus, surfaceLabel, surfaceTitle }: ChatFocusRowProps) {
92101
const { t } = useObjectTranslation();
93-
const pinned = focus.focus;
94-
const pageRecord = surfaceRecord(surface);
95-
const offerSwitch = Boolean(pinned && pageRecord && !sameChatFocus(pinned, pageRecord) && !focus.declined);
96-
const pinnedTitle = useChatRecordTitle(pinned);
97-
const pageTitle = useChatRecordTitle(offerSwitch ? pageRecord : null);
102+
const record = focus.focus;
103+
const face = useChatRecordFace(record);
98104

99-
if (pinned) {
100-
const pair = `${pinned.object} · ${pinned.id}`;
105+
if (record) {
106+
const pair = `${record.object} · ${record.id}`;
107+
const name = face.title || focus.label || pair;
108+
const described = t('console.ai.focus.pinned', { defaultValue: 'Asking about: {{target}}', target: name });
101109
return (
102-
<div className="flex min-w-0 flex-1 flex-col items-start gap-1 px-3" data-testid="chat-focus-row">
103-
<span className={CHIP} title={pair} data-testid="chat-focus-chip">
104-
<Pin className="size-3 shrink-0" aria-hidden="true" />
105-
<span className="truncate">
106-
{t('console.ai.focus.pinned', { defaultValue: 'Asking about: {{target}}', target: pinnedTitle || pair })}
107-
</span>
108-
<button
109-
type="button"
110-
className={CHIP_BUTTON}
111-
onClick={() => focus.setFocus(null)}
112-
aria-label={t('console.ai.focus.remove', { defaultValue: 'Stop asking about this record' })}
113-
title={t('console.ai.focus.remove', { defaultValue: 'Stop asking about this record' })}
114-
data-testid="chat-focus-remove"
115-
>
116-
<X className="size-3" aria-hidden="true" />
117-
</button>
110+
<span
111+
className={`${CHIP} ps-1 pe-2`}
112+
role="group"
113+
aria-label={described}
114+
title={`${described} (${pair})`}
115+
data-testid="chat-focus-chip"
116+
data-focus-object={record.object}
117+
data-focus-id={record.id}
118+
>
119+
<ObjectIconTile icon={face.icon} color={face.color} size="xs" className="shrink-0" />
120+
<span className="truncate text-foreground/90" data-testid="chat-focus-name">
121+
{name}
118122
</span>
119-
{offerSwitch && pageRecord ? (
120-
<div className="flex min-w-0 max-w-full flex-wrap items-center gap-1.5 text-[11px]" role="group" data-testid="chat-focus-switch">
121-
<span className="min-w-0 truncate text-muted-foreground">
122-
{t('console.ai.focus.switchPrompt', {
123-
defaultValue: 'Ask about "{{target}}" instead?',
124-
target: pageTitle || `${pageRecord.object} · ${pageRecord.id}`,
125-
})}
126-
</span>
127-
<button
128-
type="button"
129-
className="rounded px-1.5 py-0.5 font-medium text-foreground hover:bg-muted"
130-
onClick={() => focus.setFocus(pageRecord)}
131-
data-testid="chat-focus-switch-accept"
132-
>
133-
{t('console.ai.focus.switchAccept', { defaultValue: 'Switch' })}
134-
</button>
135-
<button
136-
type="button"
137-
className="rounded px-1.5 py-0.5 text-muted-foreground hover:bg-muted hover:text-foreground"
138-
onClick={focus.decline}
139-
data-testid="chat-focus-switch-decline"
140-
>
141-
{t('console.ai.focus.switchDecline', { defaultValue: 'Keep' })}
142-
</button>
143-
</div>
144-
) : null}
145-
</div>
123+
<button
124+
type="button"
125+
className={REMOVE}
126+
onClick={focus.dismiss}
127+
aria-label={t('console.ai.focus.remove', { defaultValue: 'Stop asking about this record' })}
128+
title={t('console.ai.focus.remove', { defaultValue: 'Stop asking about this record' })}
129+
data-testid="chat-focus-remove"
130+
>
131+
<X className="size-3" aria-hidden="true" />
132+
</button>
133+
</span>
146134
);
147135
}
148136

149137
if (!surfaceLabel) return null;
150138
return (
151-
<div className="flex min-w-0 flex-1 px-3" data-testid="chat-focus-row">
152-
<span className={CHIP} title={surfaceTitle} data-testid="surface-context-chip">
153-
<span className="truncate">{surfaceLabel}</span>
154-
{pageRecord ? (
155-
<button
156-
type="button"
157-
className={CHIP_BUTTON}
158-
onClick={() => focus.setFocus(pageRecord)}
159-
aria-label={t('console.ai.focus.pin', { defaultValue: 'Keep asking about this record' })}
160-
title={t('console.ai.focus.pin', { defaultValue: 'Keep asking about this record' })}
161-
data-testid="chat-focus-pin"
162-
>
163-
<Pin className="size-3" aria-hidden="true" />
164-
</button>
165-
) : null}
166-
</span>
167-
</div>
139+
<span className={`${CHIP} px-2`} title={surfaceTitle} data-testid="surface-context-chip">
140+
<span className="truncate">{surfaceLabel}</span>
141+
</span>
168142
);
169143
}

0 commit comments

Comments
 (0)