diff --git a/packages/kilo-vscode/tests/fixtures/inline-comment-form.tsx b/packages/kilo-vscode/tests/fixtures/inline-comment-form.tsx index 5e93fad090fc..b8916acbb154 100644 --- a/packages/kilo-vscode/tests/fixtures/inline-comment-form.tsx +++ b/packages/kilo-vscode/tests/fixtures/inline-comment-form.tsx @@ -5,80 +5,31 @@ import type { PRReviewRequest } from "../../src/shared/pr-comment-actions" const { window, root, messages, node, button, input, type, last, respond, wait, mount } = await harness() const { PRCommentForm } = await import("../../webview-ui/agent-manager/pr/PRCommentForm") -const saved: string[] = [] -const sent: string[] = [] let cancelled = 0 let completed = 0 -let reads = 0 -const initial = () => { - reads++ - return "" -} const release = mount(() => ( - <> -
- saved.push(body)} - onSend={(body) => sent.push(body)} - onCancel={() => cancelled++} - onEscape={() => cancelled++} - /> -
-
- completed++} - onCancel={() => cancelled++} - /> -
- +
+ completed++} + onCancel={() => cancelled++} + /> +
)) await wait() -const local = node("#local") const remote = node("#remote") assert.equal(root.querySelector('[data-slot="comment-toolbar"]'), null, "no second toolbar in inline forms") -assert.equal(button("submit", local).textContent, "Save local") -assert.equal(button("send", local).textContent, "Send") -assert.equal(button("send", local).getAttribute("aria-label"), "Send to agent") assert.equal(button("submit", remote).textContent, "Post to GitHub") assert.equal(button("discard", remote).textContent, "Cancel") -const before = reads -type(local, "Preview **this**") -assert.equal(reads, before, "typing in one form does not invalidate unrelated drafts") -button("preview", local).click() -await wait() -assert.match(node('[data-slot="comment-preview"]', local).textContent ?? "", /Preview this/) -button("write", local).click() -assert.equal(document.activeElement, input(local)) -input(local).dispatchEvent(new window.KeyboardEvent("keydown", { key: "Enter", shiftKey: true, bubbles: true })) -assert.equal(saved.length, 0, "Shift+Enter does not submit") -input(local).dispatchEvent(new window.KeyboardEvent("keydown", { key: "Enter", isComposing: true, bubbles: true })) -assert.equal(saved.length, 0, "IME confirmation does not submit") -input(local).dispatchEvent(new window.KeyboardEvent("keydown", { key: "Enter", bubbles: true })) -assert.deepEqual(saved, ["Preview **this**"]) -assert.equal(messages.length, 0, "local save never requests a GitHub write") -type(local, "Send this") -button("send", local).click() -assert.deepEqual(sent, ["Send this"]) type(remote, "Review this line") button("submit", remote).click() const request = last() @@ -92,7 +43,7 @@ assert.match(remote.textContent ?? "", /Snapshot changed/) button("submit", remote).click() respond(last(), {}) assert.equal(completed, 1) -button("cancel", local).click() +button("discard", remote).click() assert.equal(cancelled, 1) release() await window.happyDOM.close() diff --git a/packages/kilo-vscode/webview-ui/agent-manager/pr/PRCommentForm.tsx b/packages/kilo-vscode/webview-ui/agent-manager/pr/PRCommentForm.tsx index 158e412130cc..9aed408887e6 100644 --- a/packages/kilo-vscode/webview-ui/agent-manager/pr/PRCommentForm.tsx +++ b/packages/kilo-vscode/webview-ui/agent-manager/pr/PRCommentForm.tsx @@ -27,29 +27,10 @@ interface Draft { type Props = { projectId?: string worktreeId: string - /** Submit on plain Enter. Diff composers keep their existing Enter-to-send behavior. */ - submitOnEnter?: boolean - /** Called when Escape is pressed in the editor. */ - onEscape?: () => void inline?: boolean } & ( | { action: "reply"; threadId: string } | { action: "create"; prNumber: number; prUrl: string } - | { - projectId?: string - worktreeId: string - action: "local" - file: string - side: "LEFT" | "RIGHT" - startLine: number - endLine: number - selectedText: string - initialBody?: string - onBodyChange?: (body: string) => void - onSubmit: (body: string, selectedText: string) => void - onSend: (body: string, selectedText: string) => void - onCancel: () => void - } | { action: "diff" worktreeId: string @@ -119,7 +100,7 @@ const decisions = [ { event: "REQUEST_CHANGES", action: "review-request-changes", label: "agentManager.pr.review.requestChanges" }, ] as const -// The form supports local, inline, reply, edit, and review actions in one shared UI. +// The form supports diff, inline, reply, edit, and review actions in one shared UI. // eslint-disable-next-line complexity export function PRCommentForm(props: Props) { const { t } = useLanguage() @@ -133,15 +114,9 @@ export function PRCommentForm(props: Props) { props.projectId, props.worktreeId, props.action, - props.action === "reply" - ? props.threadId - : props.action === "local" || props.action === "diff" - ? props.file - : props.prUrl, + props.action === "reply" ? props.threadId : props.action === "diff" ? props.file : props.prUrl, props.action === "edit" ? props.commentId : undefined, - props.action === "local" || props.action === "diff" - ? [props.file, props.side, props.startLine, props.endLine] - : undefined, + props.action === "diff" ? [props.file, props.side, props.startLine, props.endLine] : undefined, props.action === "diff" ? [props.github?.prNumber, props.github?.snapshotId] : undefined, props.action === "line" ? [props.snapshotId, props.path, props.side, props.startLine, props.endLine] : undefined, props.action === "review" ? [props.snapshotId, props.head] : undefined, @@ -153,12 +128,12 @@ export function PRCommentForm(props: Props) { } const state = () => drafts[key()] ?? - ((props.action === "line" || props.action === "local" || props.action === "diff") && props.initialBody + ((props.action === "line" || props.action === "diff") && props.initialBody ? { ...blank, body: props.initialBody } : blank) const [collapsed, setCollapsed] = createSignal() const compact = () => props.action === "reply" || props.action === "create" - const cancellable = () => props.action === "edit" || props.action === "local" || props.action === "diff" || compact() + const cancellable = () => props.action === "edit" || props.action === "diff" || compact() const expanded = () => !!state().pending || state().open || (collapsed() !== key() && !!(state().body || state().error)) const placeholder = () => @@ -169,7 +144,7 @@ export function PRCommentForm(props: Props) { ? t("agentManager.pr.comment.reply") : props.action === "review" ? t("agentManager.pr.review.summary") - : props.action === "create" || props.action === "line" || props.action === "local" || props.action === "diff" + : props.action === "create" || props.action === "line" || props.action === "diff" ? t("agentManager.pr.comment.add") : t("common.edit") const ready = () => @@ -215,7 +190,7 @@ export function PRCommentForm(props: Props) { function cancel() { if (state().pending) return - if (props.action === "local" || props.action === "diff") { + if (props.action === "diff") { patch({ body: "", error: undefined, preview: false, sent: undefined }) props.onCancel() return @@ -281,11 +256,6 @@ export function PRCommentForm(props: Props) { : !ready() ) return - if (props.action === "local") { - patch({ body: "", error: undefined, preview: false, sent: undefined }) - props.onSubmit(body, props.selectedText) - return - } const id = key() const requestId = crypto.randomUUID() const route = { projectId: props.projectId, worktreeId: props.worktreeId } @@ -476,16 +446,10 @@ export function PRCommentForm(props: Props) { disabled={!!state().pending} onChange={(body) => { patch({ body, sent: undefined }) - if (props.action === "line" || props.action === "local" || props.action === "diff") - props.onBodyChange?.(body) + if (props.action === "line" || props.action === "diff") props.onBodyChange?.(body) }} onKeyDown={(event: KeyboardEvent) => { if (event.isComposing || event.keyCode === 229) return - if (event.key === "Escape" && props.onEscape) { - event.preventDefault() - props.onEscape() - return - } if (props.action === "diff") { if (event.key !== "Enter" || event.shiftKey) return // Cmd/Ctrl+Enter saves the comment. Plain Enter sends it to Kilo, @@ -506,10 +470,6 @@ export function PRCommentForm(props: Props) { submit() return } - if (props.submitOnEnter && !event.shiftKey) { - event.preventDefault() - submit() - } }} /> @@ -652,7 +612,7 @@ export function PRCommentForm(props: Props) { - - -