[fix]: Make elicitation form keyboard shortcuts work on appearance#5307
[fix]: Make elicitation form keyboard shortcuts work on appearance#5307ashrafchowdury wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 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:
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web/oss/src/components/AgentChatSlice/components/clientTools/ElicitationWidget.tsx (1)
126-127: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten inline comments to comply with coding guidelines.
Several comments span multiple lines, which conflicts with the guideline to keep in-code comments to one short line maximum unless a genuinely surprising constraint requires a brief exception. Please consider shortening these comments to maintain consistency with the project standards. As per coding guidelines: "Keep in-code comments to one short line maximum unless a genuinely surprising constraint requires a brief exception."
web/oss/src/components/AgentChatSlice/components/clientTools/ElicitationWidget.tsx#L126-L127: Shorten to a single line, e.g.,// Track focus inside the widget to conditionally show the ⌘↵ shortcut hint.web/oss/src/components/AgentChatSlice/components/clientTools/ElicitationWidget.tsx#L347-L348: Shorten to{/* Show ⌘↵ when focused or in a stepper; paging/pick hints are stepper-only. */}web/packages/agenta-entity-ui/src/gatewayTool/components/SchemaForm.tsx#L125-L126: Shorten to// Focus the answer surface on step change so advertised shortcuts work immediately.web/packages/agenta-entity-ui/src/gatewayTool/components/SchemaForm.tsx#L857-L858: Shorten to// Jump into the input on Enter/Space, ignoring keys bubbling up from the input itself.web/packages/agenta-entity-ui/src/gatewayTool/components/SchemaForm.tsx#L897-L898: Shorten to// Prevent the stepper's Enter-advance from firing on a chip commit.web/packages/agenta-entity-ui/src/gatewayTool/components/SchemaForm.tsx#L902-L904: Shorten to// Trim and auto-advance for single-select parity with listed cards.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: efc4f27e-74db-4675-99c6-cbc301a28f90
📒 Files selected for processing (4)
web/oss/src/components/AgentChatSlice/components/clientTools/ElicitationWidget.tsxweb/oss/tests/playwright/acceptance/agent-chat/assets/elicitationStream.tsweb/oss/tests/playwright/acceptance/agent-chat/index.tsweb/packages/agenta-entity-ui/src/gatewayTool/components/SchemaForm.tsx
Railway Preview Environment
|
Context
In the agent playground, when a "request input" form appeared, the keyboard shortcuts it advertised did nothing until you clicked into the form. Focus stayed on the chat composer, so digits, arrows, and Enter never reached the form. Three smaller issues rode along: the hints always showed the Mac
⌘glyph even on Windows/Linux, there was no way to submit or advance with the keyboard at all, and in a choice-card question Enter selected a normal option but was a dead key on the free-text "Other" option.Root cause of the main bug: the stepper's focus effect seeded its "did the step change?" ref to the current step, so its own guard skipped the very first run. The form never claimed focus when it mounted.
Changes
Focus on appearance. The stepper focus effect now seeds
prevStepRefto-1so it fires when the stepper first becomes active, moving focus onto the answer surface. Keystrokes land with no extra click. This is scoped to stepper mode; otherSchemaFormconsumers are untouched.Platform-correct modifier. A new
useModifierKeyhook renders⌘on macOS andCtrlelsewhere. The hints read⌘ ↵/Ctrl ↵accordingly instead of a hardcoded⌘.Submit and advance from the keyboard.
⌘/Ctrl + Enternow runs the primary action (Next in a stepper, Accept otherwise). A capture handler on the widget root also stops that combo from reaching the chat composer's send, and guards against key-repeat.Hints shown only when they work. The shortcut row appears when the shortcut can actually fire: in a stepper (auto-focused on appear) or in any form once the user focuses it. Before, the row was gated on stepper-only state, so a plain form never advertised its accept shortcut.
Before: hints hidden until you happened to focus a stepper;
⌘shown on every platform.After: hints appear the moment the form owns focus, labeled with the right modifier key.
"Other" option parity. In a choice-card question the "Other" tile now matches a normal card. Enter or Space on the focused Other card jumps into its text input, and Enter inside the single-select Other input confirms the typed value the same way picking a listed card does. Previously the Other card had no key handler and the single-select input wired
onPressEnteronly for multi-select, so Enter did nothing.Tests / notes
STEPPER_ELICITATION_PAYLOAD) that drives a choice-card stepper end to end: focus on appear, digit pick,⌘/Ctrl →paging, and⌘/Ctrl + Enterthrough to submit.pnpm lint-fixpasses clean across the web workspace.⌘/Ctrl + Enteror⌘/Ctrl + →.What to QA
⌘/Ctrl + →to page forward and⌘/Ctrl + Enterto advance and finally submit. The answers post back to the chat.Ctrl ..., not⌘ ....Ctrl/⌘ ↵ acceptappears.Preview
https://jam.dev/c/01645eb8-1b53-43b0-a272-bc2f90efb007