mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-08 01:57:31 +01:00
fix(chat): preserve request selection during dismissal save
This commit is contained in:
1 parent
d37c016e6b
commit
b9c03cea65
2 files changed
+26
-3
No files matched your search
@@ -3403,6 +3403,23 @@ describe.each([true, false])("Unanswered question history (conversationMode=%s)"
|
||||
expect(container.querySelector('[role="alert"]')?.textContent).toContain("Dismissal could not be saved");
|
||||
});
|
||||
|
||||
it("keeps the newly opened request visible when an earlier dismissal finishes saving", async () => {
|
||||
const { genericPendingRequestConfirmationInteraction } = await import("@/fixtures/issueThreadInteractionFixtures");
|
||||
const first = { ...genericPendingRequestConfirmationInteraction, id: "first-review", title: "First review" };
|
||||
const second = { ...first, id: "second-review", title: "Second review" };
|
||||
let finishDismiss!: () => void;
|
||||
const onDismissInteraction = vi.fn(() => new Promise<void>(resolve => { finishDismiss = resolve; }));
|
||||
render(<TaskChatThread {...props} comments={[]} interactions={[first, second]} onDismissInteraction={onDismissInteraction} />);
|
||||
await act(async () => container.querySelector<HTMLButtonElement>('[aria-label="Open request: First review"]')!.click());
|
||||
await dismiss();
|
||||
expect(onDismissInteraction).toHaveBeenCalledWith(first);
|
||||
await act(async () => container.querySelector<HTMLButtonElement>('[aria-label="Open request: Second review"]')!.click());
|
||||
expect(takeover()?.textContent).toContain("Second review");
|
||||
await act(async () => finishDismiss());
|
||||
expect(takeover()?.textContent).toContain("Second review");
|
||||
expect(takeover()?.textContent).not.toContain("First review");
|
||||
});
|
||||
|
||||
it("opens the new question but can reopen the exact historical native question", async () => {
|
||||
const nativeOld = { ...old, sourceRunId: "old-run", payload: { ...old.payload, runtimeRequestId: "old-request" } } as IssueThreadInteraction;
|
||||
render(<TaskChatThread {...props} comments={movedOn} interactions={[nativeOld, newer]} />);
|
||||
|
||||
@@ -2591,6 +2591,10 @@ export function TaskChatThread(props: TaskChatThreadProps) {
|
||||
pendingComposerInputs.find((input) => input.key === selectedPendingKey) ??
|
||||
currentPendingInputs[0] ??
|
||||
null;
|
||||
const selectedPendingInputKeyRef = useRef<string | null>(null);
|
||||
useLayoutEffect(() => {
|
||||
selectedPendingInputKeyRef.current = selectedPendingInput?.key ?? null;
|
||||
}, [selectedPendingInput?.key]);
|
||||
const interactionDraftKey = selectedPendingInput
|
||||
? `paperclip:task-input:${issueId ?? "unknown"}:${selectedPendingInput.key}`
|
||||
: undefined;
|
||||
@@ -2870,9 +2874,11 @@ export function TaskChatThread(props: TaskChatThreadProps) {
|
||||
} else {
|
||||
dismissInput(selectedPendingInput.key);
|
||||
}
|
||||
explicitlyOpenedInputRef.current = null;
|
||||
setSelectedPendingKey(null);
|
||||
setTakeoverMode("normal");
|
||||
if (selectedPendingInputKeyRef.current === selectedPendingInput.key) {
|
||||
explicitlyOpenedInputRef.current = null;
|
||||
setSelectedPendingKey(null);
|
||||
setTakeoverMode("normal");
|
||||
}
|
||||
} catch (error) {
|
||||
setDismissError(error instanceof Error ? error.message : "Unable to dismiss this request. Try again.");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user