Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ReviewDisposable, ReviewNotification } from "../common/reviewProto

export function showReviewNotification(
notifications: Pick<INotificationService, "notify">,
{ kind, text, actions, onClose }: ReviewNotification,
{ kind, text, actions, closeAfterMs, onClose }: ReviewNotification,
): ReviewDisposable {
const handle = notifications.notify({
severity: kind === "error" ? Severity.Error : Severity.Info,
Expand All @@ -14,6 +14,10 @@ export function showReviewNotification(
? { primary: actions.map((action, index) => toAction({ id: `review.notification.${index}`, label: action.label, run: () => action.run() })) }
: undefined,
});
if (closeAfterMs !== undefined) {
const timer = setTimeout(() => handle.close(), closeAfterMs);
Event.once(handle.onDidClose)(() => clearTimeout(timer));
}
if (onClose) Event.once(handle.onDidClose)(onClose);
return { dispose: () => handle.close() };
}
1 change: 1 addition & 0 deletions packages/review-protocol/src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ export interface ReviewNotification {
kind: "success" | "error";
text: string;
actions?: readonly { label: string; run(): void }[];
closeAfterMs?: number;
onClose?(): void;
}

Expand Down
1 change: 1 addition & 0 deletions packages/review/app/src/agent-selection.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ it("copies only on click or Shift+Cmd+C, reports failures, and clears on revisio
expect(notify).toHaveBeenLastCalledWith({
kind: "success",
text: expect.stringContaining("copied to clipboard"),
closeAfterMs: 5_000,
});
expect(container.querySelector('[role="status"]')).toBeNull();
await act(async () => {
Expand Down
1 change: 1 addition & 0 deletions packages/review/app/src/agent-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export function AgentSelectionProvider({
notify({
kind: "success",
text: "Selection copied to clipboard. Paste into your agent to chat about it.",
closeAfterMs: 5_000,
});
} catch {
setCopiedSelection(null);
Expand Down
1 change: 1 addition & 0 deletions packages/review/app/src/ask-setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function AskSetup({
notify({
kind: "success",
text: "Selection copied to clipboard. Paste into your agent to chat about it.",
closeAfterMs: 5_000,
});
} catch {
notify({
Expand Down
1 change: 1 addition & 0 deletions packages/review/app/src/bug-report-dialog.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ describe("BugReportControl", () => {
expect(notify).toHaveBeenCalledWith({
kind: "success",
text: "Bug report was sent.",
closeAfterMs: 5_000,
});
expect(container.querySelector("dialog")).toBeNull();
});
Expand Down
1 change: 1 addition & 0 deletions packages/review/app/src/bug-report-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export function BugReportControl({
notify({
kind: "success",
text: "Bug report was sent.",
closeAfterMs: 5_000,
});
reset();
setOpen(false);
Expand Down
1 change: 1 addition & 0 deletions packages/review/app/src/onboarding/draw-flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function DrawFlow({
? {
kind: "success",
text: "Prompt copied. Paste it into your agent.",
closeAfterMs: 5_000,
}
: {
kind: "error",
Expand Down
1 change: 1 addition & 0 deletions packages/review/app/src/review-home-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ function ReviewHomeBody({
? {
kind: "success",
text: "Copied 'founders@dev.fast' to clipboard",
closeAfterMs: 5_000,
}
: { kind: "error", text: "Couldn't copy email. Please try again." },
);
Expand Down
Loading