Skip to content

feat(spec,console): ask_ai action type — focus the in-app assistant on a record - #37215

Draft
os-warren wants to merge 14 commits into
mainfrom
claude/project-thread-1nmo7q
Draft

os-warren wants to merge 14 commits into
mainfrom
claude/project-thread-1nmo7q

Conversation

@os-warren

@os-warren os-warren commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Warren · project thread

Fixes #37142

维护者速读

What changes

ADR-0160 D7 — an action on one record that focuses the in-app assistant on that record and opens it.

Spec (@objectstack/spec)

  • ActionType gains ask_ai. It is outside the target-required set: it takes no target.
  • ActionSchema and InlineActionSchema refuse a target beside it (inline to too) at the target path, and ai.exposed: true at ai.exposed (false parses). body stays script-only.
  • DashboardHeaderActionSchema refuses actionType: 'ask_ai' at actionType: a header runs on no record. WidgetActionTypeSchema stays derived from ActionType.
  • Reference docs regenerated.

Runtime (@objectstack/runtime)

  • isHeadlessInvokableAction answers false for ask_ai, so MCP list_actions skips it and the AI posture of the action door refuses it, whatever a stored row carries beside the type.
  • headlessActionTypeError answers the REST door with a sentence about the in-app assistant instead of the generic "opens its target".

Console

  • @object-ui/core: ActionRunner gets an ask_ai executor that hands { object, id } to the installed AssistantFocusHandler (setAssistantFocusHandler) and nothing else: no registered handler, no fetch, no success toast unless successMessage is declared. The record is the row a row surface stashed (recordIdField honoured), else the page record, else the one selected row. No record, or several selected, is refused before any confirmText; so is a launch with no handler installed. drawsAction() answers whether an action is drawn; ActionEngine.getActionsForLocation and getBulkActions leave undrawn actions out. isAskAiAction reads type and the legacy actionType.
  • @object-ui/react: <ActionProvider onAskAi> installs the handler (the latest one runs; the gate identity changes only when the handler appears or goes) and useDrawsAction() answers for every surface under it; with no provider, ask_ai is not drawn.
  • @object-ui/app-shell: useAskAiHandler returns dock.open({ agent, fresh: true }) + setChatFocus(focus, { follow: true }) only when the layout hosts the chat drawer (useChatDockControl, which is null when the AI surface is off) and an agent in the catalog advertises capabilities.focus (useAiSurfaceEnabled().focusServed); the console action runtime passes it as onAskAi.
  • No single record ⇒ absent. The bulk bar never offers an ask_ai action (the type of a promoted def is read off its actionDef); ActionRunner.bulkRefusal refuses a per-row run over a selection (the grid's per-record bulk dispatch asks it), and ActionEngine.getBulkActions / executeBulk leave it out. A list header draws it only while exactly one row is selected, and leaves it out (not greyed) with none or several. A related list's toolbar leaves it out, because a launch there runs on the parent; its rows still draw it.
  • The conversation it opens. The click opens the drawer on a fresh thread of an agent that declares capabilities.focus (focusAgentName, an ask agent first), so the drawer's pin control, which asks the active agent, is drawn, and pins the record to that thread. setChatFocus(focus, { follow: true }) (new option): a host showing a conversation keeps that conversation's focus and gives this one to the next conversation it shows; the first send carries it onto the id it mints, and an unsent fresh thread creates nothing.
  • resolveAiApiBase moves to hooks/aiApiBase.ts (re-exported from useAiSurface), so useAskAiHandler does not import a module many layout tests mock.
  • Every action surface asks useDrawsAction() beside its existing gates: record header/DeclaredActionsBar, action:bar, action:button, action:icon, action:group, action:menu, element buttons, container action filters, grid row menu and actions column, data-table row actions, related-list toolbar, bulk action bar.

Tests

  • packages/spec/src/ui/action-ask-ai.test.ts: member, parses with no target, refusals at target / ai.exposed (both in one parse), ai.exposed: false accepted, body refused, inline refusals, neighbours keep their rules.
  • packages/spec/src/ui/dashboard-header-ask-ai-37142.test.ts: header refusal, vocabulary still derived, other types still accepted.
  • packages/runtime/src/action-ask-ai-headless.test.ts: not headless-invokable (with or without automation, and for an at-rest row carrying target/body/ai.exposed), REST sentence.
  • ui/packages/core/src/actions/__tests__/ActionRunner.askAi-37142.test.ts: click hands the record once and sends nothing (fetch stub, script handler, toast unspied), row / scoped / selected record readings, refusals before confirm, not drawn without a handler, ActionEngine filtering.
  • ui/packages/react/src/context/__tests__/ActionProvider.askAi-37142.test.tsx: drawn only with onAskAi, gate identity, latest handler runs, no provider.
  • ui/packages/app-shell/src/hooks/__tests__/useAskAiHandler-37142.test.tsx, useAiSurface.test.ts (focusServed), views/__tests__/DeclaredActionsBar.askAi-37142.test.tsx (absent without assistant, drawn and focuses with one; ablation of the filter turns it red).
  • skills/objectstack-ui/SKILL.md: one table row and one sentence (164 → 165 lines); the token ratchet stays under its ceiling.
  • ui/packages/core/src/actions/__tests__/ActionRunner.askAi-37142.test.ts adds bulkRefusal, getBulkActions / executeBulk and page-record recordIdField; plugin-grid/src/__tests__/BulkActionBar.askAi-37142.test.tsx, plugin-detail/src/__tests__/RelatedList.toolbarAskAi-37142.test.tsx, app-shell/src/views/__tests__/objectViewHeaderLaunchGate.askAi-37142.test.tsx pin the three no-single-record surfaces; useAskAiHandler-37142 pins the agent it opens.
  • ui/packages/app-shell/src/layout/__tests__/chatFocus-36999.test.tsx (objectstack#37142 block): the real dock body and focus host under a real useAskAiHandler; a drawer open on another conversation keeps that conversation's focus and the fresh thread's first send carries the record; a drawer on an unsent thread takes it at once. Ablated: without follow, and with open({ agent }) instead of the fresh thread, the first case fails.
  • Updated pins that enumerate ActionType.options (spec row-update, undoable, inline; Studio presets and type-switch pins).

Acceptance notes

  • Studio's action inspector does not offer ask_ai in its Type picker (its option list is hand-written); authoring is code / metadata only for now.
  • params beside ask_ai are not refused (inert); a record-less location such as list_toolbar is not refused at parse — the action is absent there unless exactly one row is selected, and the runner refuses a launch that reaches it anyway.
  • The global ConsoleShell action runtime sits above the chat dock, so ask_ai is absent there; per-view runtimes inside the layout get it. Direct useActionRunner owners get no handler, so ask_ai is absent for them.
  • form.tsx (update-operation actions only) and the managed-by empty state are not gated.
  • The dashboard-header refusal goes beyond the ADR's words; flagged for L2 (judged justified in record 7152689299).
  • The SKILL.md row does not name the dashboard-header refusal (R7): adding it puts the file 14 tokens over its ratchet ceiling, so it is left to 37142 跟进:AI 技能文档教作者放「问 AI」按钮(ask_ai 动作) #37217.

Verification

  • @objectstack/spec: full suite 892 files / 28329 tests pass.
  • @objectstack/runtime: typecheck pass; ask_ai + declarative-update tests pass.
  • @object-ui/core 4789, @object-ui/react 1601, @object-ui/components 4966, @object-ui/plugin-grid 2783, @object-ui/plugin-detail 3941 tests pass; type-check passes on all six ui packages.
  • @object-ui/app-shell: hooks, console, metadata-admin, studio-design and DeclaredActionsBar tests pass (1204 files after the two pin fixes).
  • Review round (R1–R6) and the three CI failures at 076ed686: @object-ui/core 248 files / 4792 pass; plugin-grid __tests__ + components 272 files pass; plugin-detail RelatedList / RecordRelatedListRenderer 73 files pass; app-shell layout + hooks + console/home 311 files pass, views 220 files pass; @objectstack/example-showcase 49 files / 554 pass; type-check passes on core, plugin-grid, plugin-detail, app-shell. New tests each turn red when their fix is removed (list header 3/3, bulk bar 1/1, related-list toolbar 1/1, and the two CI-red AppHeader files fail again with the old import).
  • Gates derived by scripts/pm/dispatch-gates.mjs --commands for this change set (131 commands): all pass except three that could not measure in this container — check-plugin-teardown-shape --self-test (needs an unshallow clone), check:dual-build-cjs-loads (needs every package's dist/); check:skill-examples passed on a re-run once the spec build had finished. CI runs them in full.
  • ESLint on every changed source and test file: 0 errors.

Clause-②: yes
Metadata-protocol: added
Skills-docs: follow-up #37217

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

…n a record

ADR-0160 D7. The spec member and the console executor in one change:
ActionType gains ask_ai (no target, refused at parse beside a target or
ai.exposed: true); the runtime keeps it out of every headless door; the
console executor pins the record through setChatFocus and opens the
drawer, and the action is absent where the console has no assistant
that honours a focus.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbZNHwt6dj15KeoAPMP
…ard headers

Gate action:button, action:icon, action:group and action:menu members with
useDrawsAction, refuse `actionType: 'ask_ai'` on a dashboard header (it runs
on no record), carry `focusServed` in the AI surface fixtures, and teach the
two Studio pin tests that `ask_ai` takes no target. Changeset for #37142.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbZNHwt6dj15KeoAPMP
skills/objectstack-ui/SKILL.md's Action Types table is registered exhaustive
over ActionType (check:skill-identifier-liveness), so it gains the ask_ai row
and the "requires target" sentence names its second exception. Three edited
test files take module-top side-effect imports so the dependency load is
paid during collection (check:test-source-alias).

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbZNHwt6dj15KeoAPMP
@os-warren os-warren self-assigned this Nov 25, 2026
@github-actions github-actions Bot added size/xl documentation Improvements or additions to documentation protocol:ui tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/runtime, @objectstack/spec, touching 13 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/spec/src/ui/component.zod.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

15 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/automation/flows.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/deployment/troubleshooting.mdx (via ActionSchema (symbol, a top-level const))
  • content/docs/deployment/validating-metadata.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/frontend/architecture-overview.mdx (via ActionSchema (symbol, a top-level const))
  • content/docs/frontend/layout.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/frontend/quick-start.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/frontend/schema-rendering.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/frontend/troubleshooting.mdx (via ActionSchema (symbol, a top-level const))
  • content/docs/getting-started/build-with-claude-code.mdx (via record_header (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/getting-started/quick-reference.mdx (via ActionType (symbol, a top-level const object))
  • content/docs/protocol/objectui/actions.mdx (via ActionSchema (symbol, a top-level const), ask_ai (literal, a string literal in ActionType; a string literal in TARGETLESS_TYPES; a string literal in headlessActionTypeError; a string literal in refuseAskAiContradictions; a string literal in refuseRecordlessAskAi), record_header (literal, a string literal in refuseRecordlessAskAi), record_more (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/protocol/objectui/layout-dsl.mdx (via record_header (literal, a string literal in refuseRecordlessAskAi), record_more (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/ui/actions.mdx (via ask_ai (literal, a string literal in ActionType; a string literal in TARGETLESS_TYPES; a string literal in headlessActionTypeError; a string literal in refuseAskAiContradictions; a string literal in refuseRecordlessAskAi), record_header (literal, a string literal in refuseRecordlessAskAi), record_more (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/ui/create-vs-edit-form.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/ui/pages.mdx (via record_header (literal, a string literal in refuseRecordlessAskAi), record_more (literal, a string literal in refuseRecordlessAskAi))

⛔ 11 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v15.mdx (via record_more (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/releases/v16.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/releases/v17/17-0.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/releases/v17/17-1.mdx (via ActionSchema (symbol, a top-level const))
  • content/docs/releases/v17/17-3.mdx (via ActionSchema (symbol, a top-level const))
  • content/docs/releases/v17/17-6.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/releases/v17/17-7.mdx (via actionType (literal, a string literal in refuseRecordlessAskAi))
  • content/docs/releases/v17/index.mdx (via ActionSchema (symbol, a top-level const))
  • content/docs/releases/v18/18-2.mdx (via ActionSchema (symbol, a top-level const))
  • content/docs/releases/v18/18-3.mdx (via ActionSchema (symbol, a top-level const), InlineActionSchema (symbol, a top-level const))
  • content/docs/releases/v18/18-4.mdx (via ActionSchema (symbol, a top-level const), InlineActionSchema (symbol, a top-level const), record_header (literal, a string literal in refuseRecordlessAskAi), record_more (literal, a string literal in refuseRecordlessAskAi))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/spec/src/ui/component.zod.ts) — pages documenting those are invisible to this run
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 181 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 8032d958f2f2892d02e7e4b3cb13da2242f747bb → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 01f4b0175f121659106e6394910aa0e69af9613f — the merge of head 76f9cdab6ad3334c1e5438da6740969d1f202845 into base 8032d958f2f2892d02e7e4b3cb13da2242f747bb, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 01f4b0175f121659106e6394910aa0e69af9613f && git checkout 01f4b0175f121659106e6394910aa0e69af9613f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8032d958f2f2892d02e7e4b3cb13da2242f747bb 76f9cdab6ad3334c1e5438da6740969d1f202845 && git checkout -B drift-repro 8032d958f2f2892d02e7e4b3cb13da2242f747bb && git merge --no-ff 76f9cdab6ad3334c1e5438da6740969d1f202845

node scripts/docs-audit/affected-docs.mjs --json 8032d958f2f2892d02e7e4b3cb13da2242f747bb

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 8032d958f2f2892d02e7e4b3cb13da2242f747bb → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

Contract-review-claim: session_01JQwxbZeHNsF3RWcWpj7rGj · head 076ed68 · 2026-11-25T04:10Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 076ed68671c72dfd944d9b365b4d4f6c3b1fd590
Local-runs: none
Scope: packages/spec/src/ui/action.zod.ts, packages/spec/src/ui/component.zod.ts, packages/spec/src/ui/dashboard.zod.ts, skills/objectstack-ui/SKILL.md + packages/runtime/src/action-execution.ts, ui/packages/core/src/actions/ActionRunner.ts, ui/packages/core/src/actions/ActionEngine.ts, ui/packages/react/src/context/ActionContext.tsx, ui/packages/app-shell/src/hooks/{useAskAiHandler,useAiSurface,surfaceAgent}.ts, ui/packages/app-shell/src/hooks/useConsoleActionRuntime.tsx, ui/packages/app-shell/src/views/DeclaredActionsBar.tsx, ui/packages/app-shell/src/console/ConsoleShell.tsx, the twelve renderer files under ui/packages/components, plugin-grid and plugin-detail, .changeset/37142-ask-ai-action-type.md; read as context, not in the diff: objectViewHeaderLaunchGate.tsx, RelatedRecordActionsBridge.tsx, ObjectGrid.tsx bulk dispatch, resolveBulkActions.ts, chatFocus.ts, AiChatPage.tsx, pr-automation.yml level rule
Security-touching: yes
Rule-change-verified: none

① Derived judgments

  • Spec member: met. ask_ai is outside TARGET_REQUIRED_TYPES, through the new TARGETLESS_TYPES. refuseAskAiContradictions refuses target at target, and ai.exposed: true at ai.exposed, on both ActionSchema and InlineActionSchema. The member and its executor land in one PR.
  • Headless: met. isHeadlessInvokableAction falls through to false for ask_ai, so list_actions, run_action and the action_ family do not serve it.
  • No message, no server call: met. executeAskAi only calls the installed handler, which is setChatFocus plus dock.open(). Nothing posts to the chat endpoint or starts a flow.
  • Absent without the assistant: met. Every surface that reads isActionSwitchedOff also reads the draw gate, except form.tsx and managedByEmptyState.ts, which the PR names. With no handler, the action is not drawn, rather than drawn disabled.
  • "No single record ⇒ absent": not met. See R1 and R2.
  • Dashboard header refusal: justified. A header has no record and no selection, so every click would be refused. It follows the refuseUnopenableHeaderActionUrl precedent, and it narrows nothing, because on main the enum already rejected ask_ai.
  • SQL push-down: n/a.

② Semver level

  • Clause-②: yes (widening) and Metadata-protocol: added are correct.
  • spec, core, react and app-shell are minor; runtime, components, plugin-grid and plugin-detail are patch. The patch packages gain no export and no authorable key.
  • Check Changeset is green.

③ Boundary flags

  • Security. The focus { object, id } comes from a row, page record or selection the client already holds. It is advisory: per ADR-0160 D6, the server re-reads the record as the caller. No path widens what a user can read.
  • MCP. No headless surface serves the action, and ai.exposed: true is refused at parse.
  • Generated artifacts. Only content/docs/references/** moves. The regeneration gates are still running.
  • SKILL.md. One row added (+138 bytes). The token ratchet is not finished.
  • CI. 66 check-runs: 19 success, 9 skipped, 38 in progress, 0 failed. The verdict rests on R1 and R2, not on CI.

④ Design judgment

The spec half and the absent-not-disabled draw gate are sound and well tested. The gap is on the three surfaces that hold no single record. There the action is drawn, and then it is disabled, behaves wrongly without saying so, or points at the parent record.

Findings

  • R1 (must-fix): multi-select pins a record instead of being absent. ui/packages/plugin-grid/src/components/BulkActionBar.tsx:111-115, ui/packages/core/src/actions/ActionRunner.ts:3051-3068.
    • A list view's bulkActions may name an ask_ai action. The per-record bulk dispatcher runs it once per selected row, with _rowRecord set.
    • askAiFocus reads that row, so the "several selected" refusal is never reached. The handler fires N times, the last row stays pinned, and the result panel counts N successes.
    • Fix: leave ask_ai out of the bulk item set, refuse a bulk dispatch in the runner, and add a test.
  • R2 (must-fix): list_toolbar draws it disabled, not absent. ActionRunner.ts:2044-2051, via objectViewHeaderLaunchGate.tsx:47-57. With zero or several rows selected, the list header shows the button greyed out with a reason. The card's acceptance says absent, and the maintainer's note of 2026-11-25 added that line. Make it absent wherever no single record is held.
  • R3 (should-fix): the draw gate is wider than the pin control's. surfaceAgent.ts:100-102, useAskAiHandler.ts:38. The gate holds when any catalog agent has capabilities.focus, but the pin control (AiChatPage.tsx:2070) asks the active agent. D7 draws the action "only under the condition it draws the pin control".
  • R4 (should-fix): a related-list toolbar ask_ai focuses the parent record. RelatedRecordActionsBridge.tsx:713-716. This is another surface with no single record, as in R2.
  • R5 (should-fix): Skills-docs line form. It now reads follow-up owed — …. The card is filed as 37142 跟进:AI 技能文档教作者放「问 AI」按钮(ask_ai 动作) #37217, so the line should read Skills-docs: follow-up #37217 in the PR body and in the changeset.
  • R6 (nit). recordIdField is honoured on the row and selected-row paths but not the page-record path (ActionRunner.ts:3058-3066).
  • R7 (nit). The SKILL.md row (:151) omits the dashboard-header refusal. Optional.

Implemented-by: session_01JQwxbZNHwt6dj15KeoAPMP
Reviewed-by: session_01JQwxbZeHNsF3RWcWpj7rGj

VERDICT: FAIL

Review round on #37215. The bulk bar never offers an ask_ai action (its type
is on a promoted def's actionDef), ActionRunner.bulkRefusal refuses a per-row
run over a selection, and ActionEngine.getBulkActions / executeBulk leave it
out. A list header draws it only while exactly one row is selected, rather
than greyed out with a reason. A related list's toolbar leaves it out (its
rows still draw it). The click opens the drawer on an agent that declares
capabilities.focus, so the drawer's pin control is drawn on the record. The
page-record path reads recordIdField too.

resolveAiApiBase moves to its own module so useAskAiHandler does not import
useAiSurface, which layout tests replace with a mock. The showcase app gains
an ask_ai action, as its coverage test requires every ActionType.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbZNHwt6dj15KeoAPMP
…write

The list header ask_ai test assigned a module variable inside a component,
which the React compiler lint refuses (Lint UI, app-shell).

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbZNHwt6dj15KeoAPMP
@objectstack-fleet

Copy link
Copy Markdown
Contributor

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 159f98ccad82bdd78a29192d98776670634c57ec
Local-runs: none
Scope: delta from 076ed68, the PR's own commits f003d0e, c0f9417, 15af54a, 6740772, 7a6b50d, 159f98c; plus the PR face of the first review's Scope files across merges 15513b8 and 5671abd; read as context: ui/packages/app-shell/src/layout/chatFocus.ts
Security-touching: yes
Rule-change-verified: none

2026-11-25T09:58Z — delta read after the FAIL at 076ed686. All six earlier findings are met, but the R3 fix introduces one new must-fix (N1).

Prior findings

  • R1 — met. BulkActionBar.tsx:117-118 leaves ask_ai out of the bulk set. ObjectGrid.tsx:2933-2934 refuses it through the new ActionRunner.bulkRefusal. ActionEngine.ts:317 and :367-369 exclude it as well. Covered by BulkActionBar.askAi-37142.test.tsx.
  • R2 — met. objectViewHeaderLaunchGate.tsx:55-58 draws the button only when exactly one row is selected. Covered by its test.
  • R3 — met as asked. The handler opens the drawer on a capabilities.focus agent, with ask first (surfaceAgent.ts:111-114, useAskAiHandler.ts:46-47). See N1.
  • R4 — met. RelatedList.tsx:1587 filters ask_ai out of the toolbar. record-related-list.tsx feeds the same prop, so it is covered too. Covered by RelatedList.toolbarAskAi-37142.test.tsx.
  • R5 — met. The PR body and the changeset both read Skills-docs: follow-up #37217.
  • R6 — met. The page-record path in askAiFocus now reads recordIdField.
  • R7 — deferred to 37142 跟进:AI 技能文档教作者放「问 AI」按钮(ask_ai 动作) #37217. Accepted: it was a nit.

Merge sanity

Across both merges, the PR face of the first review's Scope files is unchanged: 19 files, +248 −35. The added and removed lines hash the same at 076ed686 and 159f98cc.

Findings in the delta

  • N1 (must-fix): with the drawer open on another conversation, the click pins the conversation being left. useAskAiHandler.ts:46-47.
    • The handler calls setChatFocus and then open({ agent }).
    • When the mounted host already shows a conversation id, handOff (chatFocus.ts:242) sets no carry. The focus is therefore written to the conversation on screen.
    • open({ agent }) then moves the drawer to the agent's own conversation. useConversationFocus (chatFocus.ts:190-200) reads that conversation's stored focus, which is empty.
    • The result: no chip, no focus on the turn, and a stray pin left on the conversation the user moved away from.
    • This happens whenever the open drawer shows something other than the target agent's conversation, for example the app-bound build thread.
    • The fix order is to switch the agent first and then hand off, or to hand the focus to open itself. Add a test with a mounted host on another conversation; the current test mocks both sides, so it cannot see this.
  • N2 (nit). The Skills-docs line dropped "updated here", but skills/objectstack-ui/SKILL.md still changes in this PR.
  • N3 (nit). bulkRefusal refuses on type alone, ignoring a host-registered ask_ai handler. refusalBeforeInput steps aside for one. No effect today, because the console registers none.
  • No finding: the showcase action showcase_ask_about_task (record_header, no target, no ai block), the ActionEngine narrowing, and the two action-type tables.

Declarations and CI

Clause-②: yes, Metadata-protocol: added and the changeset levels are unchanged and still correct. CI on 159f98cc: 61 success, 9 skipped, 0 failed, 0 pending.

Implemented-by: session_01JQwxbZNHwt6dj15KeoAPMP
Reviewed-by: session_01JQwxbZeHNsF3RWcWpj7rGj

VERDICT: FAIL

…, not the one on screen

With the drawer already open on another conversation, the click pinned the
record to that conversation and then switched away from it: the thread the
drawer moved to had no focus, and the one left behind kept a stray pin.

The handler now opens a fresh thread of the focus-honouring agent first and
pins the record with `setChatFocus(focus, { follow: true })`: a host showing
a conversation keeps that conversation's focus and gives this one to the next
conversation it shows (carried onto the id the first send mints). Pinned
against the real dock body and focus host, with both halves ablated.

bulkRefusal's docblock now says why it reads the type alone.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbZNHwt6dj15KeoAPMP

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:ui size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

记录 AI 问询 6:「问 AI」动作类型 ask_ai(spec 与控制台执行器同一 PR)

2 participants