Skip to content

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

Python

Fix GUI prompt and attachment affordances

Pranav Pbad84980abb6
diff --git a/gui/src/components/PromptInputCard.test.tsx b/gui/src/components/PromptInputCard.test.tsx
new file mode 100644
index 00000000..dd01c4c6
--- /dev/null
+++ b/gui/src/components/PromptInputCard.test.tsx
@@ -0,0 +1,58 @@
+import { describe, expect, test } from "bun:test";
+import { renderToStaticMarkup } from "react-dom/server";
+
+import type {
+ CommandDescriptor,
+ PromptSettings,
+} from "@/services/desktop/types/contracts";
+import { PromptInputCard } from "./PromptInputCard";
+
+const longModelName =
+ "claude-4.7-sonnet-super-long-context-reasoning-preview-20260615";
+
+const promptSettings: PromptSettings = {
+ availableModels: [
+ {
+ contextLength: 200000n,
+ modelId: "claude-sonnet-long",
+ modelName: longModelName,
+ providerId: "anthropic",
+ providerName: "Anthropic",
+ reasoningEfforts: ["low", "medium", "high"],
+ supportsReasoning: true,
+ },
+ ],
+ selectedModelId: "claude-sonnet-long",
+ selectedProviderId: "anthropic",
+ selectedReasoningEffort: "medium",
+};
+
+function renderPromptInputCard() {
+ return renderToStaticMarkup(
+ <PromptInputCard
+ canCompose
+ isPlanningMode={false}
+ isRequestActive={false}
+ isSendingPrompt={false}
+ onCommandSelect={(_: CommandDescriptor) => {}}
+ promptDraft="Describe this repo"
+ promptSettings={promptSettings}
+ setPlanningMode={() => {}}
+ setPromptDraft={() => {}}
+ stopPrompt={async () => {}}
+ submitPrompt={async () => {}}
+ updatePromptSettings={async () => {}}
+ workspacePath="/workspace/codegraff"
+ />,
+ );
+}
+
+describe("PromptInputCard", () => {
+ test("constrains long selected model names in the footer", () => {
+ const html = renderPromptInputCard();
+
+ expect(html).toContain("max-w-44");
+ expect(html).toContain("truncate");
+ expect(html).toContain(`title="${longModelName}"`);
+ });
+});
diff --git a/gui/src/components/PromptInputCard.tsx b/gui/src/components/PromptInputCard.tsx
index 09898b78..13e21df2 100644
--- a/gui/src/components/PromptInputCard.tsx
+++ b/gui/src/components/PromptInputCard.tsx
@@ -122,6 +122,8 @@ export function PromptInputCard({
// command. Only active in command mode, so normal prose typing is untouched.
const commandMatch = /^(\/[A-Za-z][\w-]*)([\s\S]*)$/.exec(promptDraft);
const planningThinkingLabel = formatPlanningThinkingLabel();
+ const selectedModelLabel =
+ selectedModel?.modelName ?? selectedModel?.modelId ?? "Model";
function handleSubmit() {
if (isSubmitDisabled) {
@@ -152,7 +154,7 @@ export function PromptInputCard({
items={commandAutocomplete.items}
activeIndex={commandAutocomplete.activeIndex}
onHighlight={commandAutocomplete.setActiveIndex}
- onPick={commandAutocomplete.complete}
+ onPick={commandAutocomplete.pick}
/>
) : null}
<Card
@@ -241,17 +243,14 @@ export function PromptInputCard({
type="button"
variant="outline"
size="sm"
- className="text-muted-foreground hover:bg-transparent hover:text-foreground"
+ className="min-w-0 max-w-44 overflow-hidden text-muted-foreground hover:bg-transparent hover:text-foreground"
disabled={isControlDisabled || !hasAvailableModels}
+ title={selectedModelLabel}
/>
}
>
- <span>
- {selectedModel?.modelName ??
- selectedModel?.modelId ??
- "Model"}
- </span>
- <ChevronDownIcon />
+ <span className="min-w-0 truncate">{selectedModelLabel}</span>
+ <ChevronDownIcon className="shrink-0" />
</DropdownMenuTrigger>
<DropdownMenuContent align="start" className="max-h-80 w-72 pt-0">
<div className="sticky z-10 top-0 bg-popover -mx-1 p-1.5">
diff --git a/gui/src/components/attachments/AttachmentCard.test.tsx b/gui/src/components/attachments/AttachmentCard.test.tsx
new file mode 100644
index 00000000..76861647
--- /dev/null
+++ b/gui/src/components/attachments/AttachmentCard.test.tsx
@@ -0,0 +1,25 @@
+import { describe, expect, test } from "bun:test";
+import { renderToStaticMarkup } from "react-dom/server";
+
+import { AttachmentCard } from "./AttachmentCard";
+import type { Attachment } from "./attachmentTypes";
+
+const attachment: Attachment = {
+ ext: "pdf",
+ id: "attachment-1",
+ kind: "pdf",
+ name: "Design Notes.pdf",
+ path: "/workspace/Design Notes.pdf",
+};
+
+describe("AttachmentCard", () => {
+ test("shows the remove control on keyboard focus", () => {
+ const html = renderToStaticMarkup(
+ <AttachmentCard attachment={attachment} onRemove={() => {}} />,
+ );
+
+ expect(html).toContain("focus-visible:opacity-100");
+ expect(html).toContain("group-focus-within/attachment:opacity-100");
+ expect(html).toContain("Remove Design Notes.pdf");
+ });
+});
diff --git a/gui/src/components/attachments/AttachmentCard.tsx b/gui/src/components/attachments/AttachmentCard.tsx
index ca28176e..7cedc45c 100644
--- a/gui/src/components/attachments/AttachmentCard.tsx
+++ b/gui/src/components/attachments/AttachmentCard.tsx
@@ -78,7 +78,7 @@ export function AttachmentCard({
<button
type="button"
aria-label={`Remove ${attachment.name}`}
- className="absolute top-1 right-1 inline-flex size-5 items-center justify-center rounded-md text-muted-foreground opacity-0 transition hover:bg-muted hover:text-foreground group-hover/attachment:opacity-100"
+ className="absolute top-1 right-1 inline-flex size-5 items-center justify-center rounded-md text-muted-foreground opacity-0 transition hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 group-hover/attachment:opacity-100 group-focus-within/attachment:opacity-100"
onClick={(event) => {
event.stopPropagation();
onRemove(attachment.id);