feat(page-actions): add UI-mode instructions to agent handoff - #411
Conversation
Extend the page-agent-handoff opt-in to accept a mode value: ":page-agent-handoff:" keeps the existing project-editing instructions, ":page-agent-handoff: ui" swaps in an instruction set for console/UI-driven workflows. Defaults to "project" for unset or unrecognized values. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
✅ Deploy Preview for docs-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe change adds project and UI modes to agent handoff prompts. A new helper normalizes the page mode and defaults to Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Page
participant markdownDropdown
participant handleCopyAgent
participant buildAgentHandoffPrompt
Page->>markdownDropdown: render normalized agent handoff mode
markdownDropdown->>handleCopyAgent: pass selected mode
handleCopyAgent->>buildAgentHandoffPrompt: include mode in prompt arguments
buildAgentHandoffPrompt-->>handleCopyAgent: return project or UI prompt
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
micheleRP
left a comment
There was a problem hiding this comment.
Docs-team-standards review
I ran the suite (11 tests, all pass) and diffed prompt output against the post-#408 baseline at 3764dd8d5: the default path is byte-identical to before this change, both with no mode and with explicit mode: 'project'. That compatibility guarantee is the context for suggestion 3 below.
Suggestions
-
A mistyped mode fails silently, in the worst direction. I confirmed that
mode: 'UI'returns a prompt identical to project mode. So a writer who puts:page-agent-handoff: UI(orUi, orconsole) on a console click-through page gets a prompt telling the agent to "Work in the current project," "edit and test local files," and run the project's checks. That is precisely the mismatch this PR exists to prevent, delivered with no warning. Normalizing inagent-handoff-mode.jscosts one line:return String(root.page?.attributes?.['agent-handoff'] || '').trim().toLowerCase() || 'project'
Keeping the fallback for genuinely unknown values is right. It is the near-miss cases that need catching.
-
The prompt's H1 stays project-flavored in UI mode. The heading is still
# Apply this Redpanda documentationwhile the UI intro says "Complete this documented task in the current console, cluster, or account." "Apply this documentation" reads oddly for a click-through task. Since intro and instructions are already keyed by mode, the title should be too. -
No test locks in the byte-identical default. The new tests assert substring matches, so a future mode refactor could drift the default prompt without failing anything. Since byte-identity is the compatibility guarantee for every page already using #408, an equality or snapshot assertion would be cheap insurance.
-
The mode data attribute renders on every page with markdown, including pages that never opted into handoff at all, because the attribute sits on the wrapper
divoutside thehas-agent-handoffguard. Harmless, but it puts a meaninglessdata-agent-handoff-mode="project"on most of the site.
Content review of the UI instruction set
Taking this as the CODEOWNER for the prompt wording, per #408.
The prompt assumes the agent can see a UI. Every instruction ("verify each one against what is on screen," "verify the result in the UI") presumes browser or computer-use access. Most coding agents pasted this prompt have none. Without an escape hatch, the likely outcome is an agent that narrates having clicked through a destructive sequence it never performed, which is the worst failure mode for a prompt whose item 4 is about creating and deleting live resources. Recommend an explicit first instruction: if you cannot see the interface, do not guess. Produce a step-by-step checklist for me to execute, and stop.
The resource enumeration in item 4 is Streaming-shaped. "(clusters, topics, users, ACLs, billing)" will read as wrong on Agentic Data Plane or Connect pages, where the destructive nouns are agents, MCP servers, providers, or pipelines. "Billing" is also an odd member of that list. A generic phrasing ages better than an enumeration that drifts per component.
… fixes Address docs-team-standards review on #411: - Normalize the agent-handoff mode value (case/whitespace) so a mistyped ":page-agent-handoff: UI" doesn't silently fall back to the project instructions. - Key the prompt title by mode, not just the intro/instructions. - Only render data-agent-handoff-mode on pages that opted into agent handoff, instead of on every page with markdown. - Add a byte-identical guard test for the default/project prompt. - UI instruction set: add an explicit escape hatch for agents without UI/computer-use access, and replace the Streaming-shaped resource enumeration with generic wording. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/js/13-agent-handoff.js`:
- Around line 131-133: Update the mode selection in the prompt-building logic to
use an own-property check on PROMPT_TITLES, PROMPT_INTROS, and INSTRUCTION_SETS,
falling back to the project entries for inherited or unrecognized values such as
constructor and toString. Add a regression test covering one of these values and
verify the generated instructions remain the project-mode set.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6bd800df-d559-49c7-9be5-c7277c4779cf
📒 Files selected for processing (7)
preview-src/agent-handoff-ui-test.adocsrc/helpers/agent-handoff-mode.jssrc/js/13-agent-handoff.jssrc/js/14-markdown-dropdown.jssrc/partials/markdown-dropdown.hbstests/markdown-dropdown/agent-handoff.test.jstests/markdown-dropdown/visibility.test.js
CodeRabbit flagged that mode values like "constructor" or "toString" resolve to Object.prototype methods instead of being caught by the falsy-fallback check, since INSTRUCTION_SETS is a plain object literal. buildAgentHandoffPrompt now requires mode to be an own property before using it, falling back to project mode otherwise. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
micheleRP
left a comment
There was a problem hiding this comment.
Follow-up review: impact outside this PR
Re-reviewed after ab28825 and 3ce5536. All four findings from my earlier review are fixed, and I verified them against the code rather than the commit messages: mode normalization (trim().toLowerCase()), mode-keyed PROMPT_TITLES, the byte-exact pinned default prompt with assert.equal, and the data attribute now gated behind has-agent-handoff. Both content items are addressed too — the no-UI-access escape hatch is in as instruction 1, and the Streaming-shaped resource enumeration is gone with a doesNotMatch test pinning its removal. npm run test:markdown-dropdown gives 15/15 and npx gulp lint is clean on my end.
One thing that sits outside this PR:
The :page-agent-handoff: attribute is documented nowhere a writer would look. I checked for a positive answer rather than assuming:
- No mention in any non-source file in
docs-ui(only.github/CODEOWNERS,preview-src/,src/, andtests/reference it). - Not in the page-attribute reference comment block in
docs-site—antora-playbook.yml:184andlocal-antora-playbook.yml:132documentpage-has-markdown, but there's no entry forpage-agent-handoff. - Zero usage across
docs,cloud-docs, andrp-connect-docs.
To be fair to this PR: the attribute was already undocumented after #408, so this isn't a regression introduced here. But it does add a second thing a writer has to know — that the attribute exists and that it takes an optional ui value whose misspellings silently fall back to project instructions. Without a written home for that, the ui mode is discoverable only by reading src/js/13-agent-handoff.js.
Suggest a follow-up issue rather than blocking this PR: add page-agent-handoff (and its ui value) to the attribute reference block in the docs-site playbooks alongside page-has-markdown, so writers have somewhere to look before the docs team enables ui mode on real pages.
micheleRP
left a comment
There was a problem hiding this comment.
left one little suggestion

Summary
:page-agent-handoff:(unset value) keeps today's behavior — project-editing instructions.:page-agent-handoff: uiselects a new instruction set: verify the current UI against the docs, don't invent menu/field/button names, confirm before mutating live resources, verify results after acting.Why
Not all documentation describes something an agent can edit as a "project" (e.g. console click-throughs for creating/deleting resources). The current agent handoff prompt tells the agent to "work in the current project," which doesn't fit those pages. This lets a page opt into UI-appropriate instructions instead, without adding a second attribute for writers to learn.
Implementation
src/helpers/agent-handoff-mode.js(new): reads thepage-agent-handoffattribute value, defaults toproject.src/js/13-agent-handoff.js: intro/instructions are now keyed by mode (PROMPT_INTROS,INSTRUCTION_SETS);buildAgentHandoffPrompttakes amodeparam.src/js/14-markdown-dropdown.js: readsdata-agent-handoff-modeoff the dropdown and threads it through to the prompt builder.src/partials/markdown-dropdown.hbs: rendersdata-agent-handoff-mode.preview-src/agent-handoff-ui-test.adoc(new): preview page with:page-agent-handoff: uifor local testing.Note: the UI instruction wording here is a draft for review, not final copy — #408 assigns ownership of customer-facing prompt wording to the documentation team.
Verification
npm run test:markdown-dropdown(13 tests, including 2 new ones)npx gulp lintui-mode page copies the new intro/instructions and none of the project-mode language; an unmodified default page still copies byte-for-byte the same prompt as before this change.Test plan
:page-agent-handoff:(no value), confirm "Copy agent handoff" still produces the original project-editing prompt.preview-src/agent-handoff-ui-test.adoc(:page-agent-handoff: ui), confirm "Copy agent handoff" produces the UI-mode prompt.uimode on any real page.🤖 Generated with Claude Code