Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

fix(native): require visible composer selection on Enter

yxlyxf91f399802e9
diff --git a/apps/native/components/primitives/PromptBar.tsx b/apps/native/components/primitives/PromptBar.tsx
index be7eaeb1..90862e59 100644
--- a/apps/native/components/primitives/PromptBar.tsx
+++ b/apps/native/components/primitives/PromptBar.tsx
@@ -7,6 +7,7 @@ import layout from "./PromptBar.module.css";
import ModelEffortButtons from "./ModelEffortButtons";
import type { ModelChoice } from "@/lib/acp-client";
import { resolveComposerModel } from "@/lib/composer-model";
+import { shouldPickComposerRow } from "@/lib/composer-keyboard";
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
import ComposerMenu from "./ComposerMenu";
import ComposerAttachments from "./ComposerAttachments";
@@ -488,7 +489,7 @@ export default function PromptBar({
setActive((activeIndex + (event.key === "ArrowDown" ? 1 : rows.length - 1)) % rows.length);
return;
}
- if (!event.shiftKey && (event.key === "Enter" || event.key === "Tab")) {
+ if (shouldPickComposerRow(event.key, event.shiftKey, engaged)) {
event.preventDefault();
event.stopPropagation();
pick(rows[activeIndex]);
diff --git a/apps/native/lib/composer-keyboard.test.ts b/apps/native/lib/composer-keyboard.test.ts
new file mode 100644
index 00000000..ad0fc14a
--- /dev/null
+++ b/apps/native/lib/composer-keyboard.test.ts
@@ -0,0 +1,15 @@
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { shouldPickComposerRow } from "./composer-keyboard.ts";
+
+test("an open composer menu does not capture Enter or Tab before a row is visibly selected", () => {
+ assert.equal(shouldPickComposerRow("Enter", false, false), false);
+ assert.equal(shouldPickComposerRow("Tab", false, false), false);
+});
+
+test("Enter and Tab activate an engaged composer row", () => {
+ assert.equal(shouldPickComposerRow("Enter", false, true), true);
+ assert.equal(shouldPickComposerRow("Tab", false, true), true);
+ assert.equal(shouldPickComposerRow("Enter", true, true), false);
+ assert.equal(shouldPickComposerRow("ArrowDown", false, true), false);
+});
diff --git a/apps/native/lib/composer-keyboard.ts b/apps/native/lib/composer-keyboard.ts
new file mode 100644
index 00000000..a7efecab
--- /dev/null
+++ b/apps/native/lib/composer-keyboard.ts
@@ -0,0 +1,5 @@
+/** A composer menu row is keyboard-activatable only after the user has
+ * visibly selected it by hovering or using the arrow keys. */
+export function shouldPickComposerRow(key: string, shiftKey: boolean, engaged: boolean): boolean {
+ return engaged && !shiftKey && (key === "Enter" || key === "Tab");
+}
diff --git a/apps/native/package.json b/apps/native/package.json
index 42d06619..f1208b8b 100644
--- a/apps/native/package.json
+++ b/apps/native/package.json
@@ -10,7 +10,7 @@
"start": "NEXT_TELEMETRY_DISABLED=1 next start --port 3000",
"mock-serve": "node scripts/mock-serve.mjs",
"lint": "next lint",
- "test": "node --experimental-strip-types --test lib/cite-markup.test.ts lib/graff-events.test.ts lib/acp.test.ts lib/sessions.test.ts lib/session-store.test.ts lib/follow-scroll.test.ts lib/motion-throttle.test.ts lib/prompt-queue.test.ts lib/prompt-queue-steer.test.ts lib/prompt-queue-resume.test.ts lib/streaming-code.test.ts lib/run-traces.test.ts lib/agents.test.ts lib/mermaid-plugin.test.ts lib/prompt-history.test.ts lib/attachments.test.ts lib/queued-attachments.test.ts lib/idle-http.test.ts lib/composer-model-pick.test.ts lib/workspaces.test.ts lib/fuzzy.test.ts lib/folder-picker.test.ts lib/browser/annotations.test.ts lib/browser/url.test.ts lib/extension-bridge.test.ts lib/close-confirm.test.ts components/site/harness-split.test.ts components/site/appearance-panel.test.ts",
+ "test": "node --experimental-strip-types --test lib/cite-markup.test.ts lib/graff-events.test.ts lib/acp.test.ts lib/sessions.test.ts lib/session-store.test.ts lib/follow-scroll.test.ts lib/motion-throttle.test.ts lib/prompt-queue.test.ts lib/prompt-queue-steer.test.ts lib/prompt-queue-resume.test.ts lib/streaming-code.test.ts lib/run-traces.test.ts lib/agents.test.ts lib/mermaid-plugin.test.ts lib/prompt-history.test.ts lib/attachments.test.ts lib/queued-attachments.test.ts lib/idle-http.test.ts lib/composer-model-pick.test.ts lib/composer-keyboard.test.ts lib/workspaces.test.ts lib/fuzzy.test.ts lib/folder-picker.test.ts lib/browser/annotations.test.ts lib/browser/url.test.ts lib/extension-bridge.test.ts lib/close-confirm.test.ts components/site/harness-split.test.ts components/site/appearance-panel.test.ts",
"electron:build": "bash electron/build.sh",
"test:electron": "bun test electron/policy.test.cjs",
"test:webauthn": "node scripts/test-webauthn.mjs",