Skip to content

Commit fabe0cd

Browse files
committed
Show immediate feedback when submitting review questions
1 parent bfa6578 commit fabe0cd

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎docs/implementation/read-only-review.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,5 @@ The CLI adapter runs without a shell in a fresh temporary directory. Claude uses
7474
Codex options were checked against the installed CLI help and the official [non-interactive documentation](https://learn.chatgpt.com/docs/non-interactive-mode) and [configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference). Both installed providers passed live connection checks. A separate copy of PR #597's review database passed a real Settings → Ask → saved Claude answer browser test; the user's review state and source checkout were unchanged. Native Node startup is covered by enabling TypeScript's erasableSyntaxOnly check after the live test caught an unsupported parameter-property declaration.
7575

7676
Validation: 181 unit/integration tests, 19 browser tests, and typecheck pass. A delayed-initial-review regression reproduced an unresponsive Settings button; binding controls before awaiting the first load fixes it. The restarted PR #597 instance also passed an immediate Settings-open check with both provider options visible.
77+
78+
Single-click submission follow-up: a held `/api/action` browser request reproduced the lack of immediate feedback (the submit button stayed enabled with no saving state). Question/change submission now shows Saving immediately, disables submission while a review action or refresh is in progress, and scrolls the saved note into view. Failures explicitly retain the draft for refresh/retry. The delayed-request regression checks one click produces exactly one stored question and one agent invocation; a lost first click was not independently reproduced.

‎test/browser/review.spec.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,20 @@ test('opens Settings while the initial review is still loading',async({page})=>{
134134
await expect(page.getByLabel('Question agent',{exact:true})).toBeVisible();
135135
} finally {release();}
136136
});
137+
test('acknowledges the first Ask agent click immediately and prevents duplicate submissions',async({page})=>{
138+
const config=app.service.config;await app.close();let calls=0;
139+
app=await startServer(config,0,async()=>{calls++;return 'Single-click answer';});
140+
await page.goto(app.url);await expect(page.getByRole('heading',{name:'Bound exponential retries'})).toBeVisible();
141+
let release!:()=>void;const pending=new Promise<void>(resolve=>{release=resolve;});let submissions=0;
142+
await page.route('**/api/action',async route=>{submissions++;await pending;await route.continue();});
143+
try {
144+
await page.getByLabel('Question about this item').fill('Does one click submit this?');
145+
await page.getByRole('button',{name:'Ask agent',exact:true}).click();
146+
await expect(page.locator('#save-note')).toBeDisabled();
147+
await expect(page.locator('#saved')).toHaveText('Saving question…');
148+
} finally {release();}
149+
await expect(page.getByText('Does one click submit this?',{exact:true})).toBeVisible();
150+
await expect(page.getByText('Single-click answer',{exact:true})).toBeVisible({timeout:10000});
151+
await expect(page.getByRole('button',{name:'Ask agent',exact:true})).toBeEnabled();
152+
expect(submissions).toBe(1);expect(calls).toBe(1);expect(app.service.store.getReviewNotes(config.identity)).toHaveLength(1);
153+
});

‎web/public/app.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ function showFailure(message) {
7575
async function refresh() {
7676
if (busy) return;
7777
busy = true;
78+
renderAttachment();
7879
$("banner").textContent = "Linking changes to plan items…";
7980
try {
8081
rememberDraft();
@@ -89,11 +90,13 @@ async function refresh() {
8990
);
9091
} finally {
9192
busy = false;
93+
renderAttachment();
9294
}
9395
}
9496
async function act(command) {
9597
if (busy || !data) return false;
9698
busy = true;
99+
renderAttachment();
97100
try {
98101
rememberDraft();
99102
data = await api("/api/action", { ...command, token: data.token });
@@ -104,6 +107,7 @@ async function act(command) {
104107
return false;
105108
} finally {
106109
busy = false;
110+
renderAttachment();
107111
}
108112
}
109113
function select(id) {
@@ -355,11 +359,14 @@ $("ask").onclick = () => setMode("question");
355359
$("request").onclick = () => setMode("change");
356360
$("composer").onsubmit = async (event) => {
357361
event.preventDefault();
362+
if (busy || !data) return;
358363
const item = selected,
359364
kind = mode;
360365
const attached = attachments.get(`${item}:${kind}`);
361366
if (attached && (attached.head !== data.snapshot.head || attached.base !== data.snapshot.base)) return;
367+
$("saved").textContent = kind === "change" ? "Saving change request…" : "Saving question…";
362368
if (await act({ action: "note", item, kind, text: $("message").value, ...(attached ? {reference:{key:attached.key,start:attached.start,end:attached.end}} : {}) })) {
369+
$("notes").lastElementChild?.scrollIntoView({ block: "nearest" });
363370
drafts.delete(`${item}:${kind}`);
364371
attachments.delete(`${item}:${kind}`);
365372
renderAttachment();
@@ -368,6 +375,8 @@ $("composer").onsubmit = async (event) => {
368375
kind === "change"
369376
? "Saved for the next revision."
370377
: "Question saved. See agent status in Conversation.";
378+
} else {
379+
$("saved").textContent = "Could not save. Your draft is preserved; refresh and try again.";
371380
}
372381
};
373382
$("conversation-toggle").onclick = () => {
@@ -477,7 +486,7 @@ function renderAttachment() {
477486
$("attachment").hidden = !ref;
478487
const stale = ref && (!data || ref.head !== data.snapshot.head || ref.base !== data.snapshot.base || !data.segments.some(s => s.key === ref.key && s.row === selected));
479488
$("attachment").innerHTML = ref ? `<strong>${esc(referenceLabel(ref))}</strong><small>Commit ${esc(ref.head.slice(0,8))}${stale ? " · ! Outdated — remove and select again" : ""}</small><pre class="snippet-preview">${esc(ref.text)}</pre><button type="button" id="remove-reference">Remove snippet</button>` : "";
480-
$("save-note").disabled = !!stale || !data?.items.some(item=>item.id === selected);
489+
$("save-note").disabled = busy || !!stale || !data?.items.some(item=>item.id === selected);
481490
if (ref) $("remove-reference").onclick = () => {attachments.delete(`${selected}:${mode}`);renderAttachment();};
482491
}
483492
function attachSelection(kind) {

0 commit comments

Comments
 (0)