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
2 changes: 0 additions & 2 deletions apps/mobile/src/features/files/ZipArchiveView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,6 @@ function ZipEntryView(props: {
() => {
if (controller.signal.aborted) return;
setBusy(null);
if (kind === "attach")
Dialog.alert("Added to chat", `${entry.name} is attached to your message.`);
},
(cause: unknown) => {
if (controller.signal.aborted) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ function ConfiguredSettingsNotificationsRouteScreen() {
}
if (result.value.type === "granted") {
setNotificationStatus("enabled");
if (agentAwarenessNotificationsReady()) {
Dialog.alert("Notifications enabled", "Agent notifications are enabled for this device.");
} else {
if (!agentAwarenessNotificationsReady()) {
Dialog.alert(
"Couldn't finish enabling notifications",
"Notification access was granted, but this device could not be registered with T3 Connect. Notifications will start once registration succeeds.",
Expand Down
10 changes: 1 addition & 9 deletions apps/web/src/components/BranchToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,7 @@ function showWorkspaceContextMenu(event: ReactMouseEvent, workspacePath: string)
if (action !== "copy-path") return;
const clipboardPath = formatFilePathForClipboard(workspacePath);
void writeTextToClipboard(clipboardPath, "workspace path").then(
(didCopy) => {
if (didCopy) {
toastManager.add({
type: "success",
title: "Path copied",
description: clipboardPath,
});
}
},
undefined,
(error: unknown) => {
toastManager.add(
stackedThreadToast({
Expand Down
28 changes: 9 additions & 19 deletions apps/web/src/components/BranchToolbarBranchSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,25 +364,15 @@ export function BranchToolbarBranchSelector({
: null;

const copyBranchName = (branchName: string) => {
void writeTextToClipboard(branchName, "branch name").then(
(didCopy) => {
if (!didCopy) return;
toastManager.add({
type: "success",
title: "Branch name copied",
description: branchName,
});
},
(error: unknown) => {
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to copy branch name",
description: toBranchActionErrorMessage(error),
}),
);
},
);
void writeTextToClipboard(branchName, "branch name").then(undefined, (error: unknown) => {
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to copy branch name",
description: toBranchActionErrorMessage(error),
}),
);
});
};

const handleBranchContextMenu = (event: ReactMouseEvent, branchName: string | null) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ it("explains a denied clipboard write and lets the same path be copied again", a
await page.getByRole("button", { name: "Dismiss notification" }).click();
await copy.click();

await expect.element(page.getByText("Copied!", { exact: true })).toBeVisible();
await expect.element(page.getByText("Copied!", { exact: true })).not.toBeInTheDocument();
expect(write).toHaveBeenCalledTimes(2);
expect(write).toHaveBeenLastCalledWith("apps/web/src/index.ts");
});
7 changes: 1 addition & 6 deletions apps/web/src/components/DiffFilePathCopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { CheckIcon, CopyIcon } from "lucide-react";
import { useRef } from "react";
import { useCopyToClipboard } from "../hooks/useCopyToClipboard";
import {
ANCHORED_COPY_TOAST_TIMEOUT_MS,
showAnchoredCopyErrorToast,
showAnchoredCopySuccessToast,
} from "./ui/anchoredCopyToast";
import { ANCHORED_COPY_TOAST_TIMEOUT_MS, showAnchoredCopyErrorToast } from "./ui/anchoredCopyToast";
import { Button } from "./ui/button";
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";

export function DiffFilePathCopyButton({ filePath }: { filePath: string }) {
const ref = useRef<HTMLButtonElement>(null);
const { copyToClipboard, isCopied } = useCopyToClipboard<void>({
onCopy: () => showAnchoredCopySuccessToast(ref),
onError: (error) => showAnchoredCopyErrorToast(ref, error),
timeout: ANCHORED_COPY_TOAST_TIMEOUT_MS,
});
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/components/KeybindingsUpdateToast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function keybindingsUpdated(issues: ReadonlyArray<unknown>): ServerConfigStreamE
}

describe("startKeybindingsUpdateToasts", () => {
it("toasts reloads the server reports after start", () => {
it("only toasts invalid reloads the server reports after start", () => {
const stop = startKeybindingsUpdateToasts();
try {
appAtomRegistry.set(mocks.state, { latestEvent: keybindingsUpdated([]) });
Expand All @@ -55,7 +55,6 @@ describe("startKeybindingsUpdateToasts", () => {
});

expect(mocks.addToast.mock.calls.map(([toast]) => toast.title)).toEqual([
"Keybindings updated",
"Invalid keybindings configuration",
]);
} finally {
Expand Down
10 changes: 1 addition & 9 deletions apps/web/src/components/KeybindingsUpdateToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ import { KeybindingsConfigWarning } from "./KeybindingsConfigWarning";
import { createKeybindingsUpdateToastController } from "./KeybindingsUpdateToast.logic";
import { stackedThreadToast, toastManager } from "./ui/toast";

/** Toasts each keybindings reload the primary server reports. */
export function startKeybindingsUpdateToasts(): () => void {
const controller = createKeybindingsUpdateToastController({});
return subscribeAtomChanges(primaryServerConfigEventAtom, (event) => {
const decision = controller.handle(event);
if (!decision) return;

if (decision._tag === "Success") {
toastManager.add({
type: "success",
title: "Keybindings updated",
description: "Keybindings configuration reloaded successfully.",
});
return;
}
if (decision._tag === "Success") return;

const serverConfig = appAtomRegistry.get(primaryServerConfigAtom);
toastManager.add(
Expand Down
21 changes: 0 additions & 21 deletions apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -942,13 +942,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
reportFailure: false,
});
const { copyToClipboard: copyPathToClipboard } = useCopyToClipboard<{ path: string }>({
onCopy: ({ path }) => {
toastManager.add({
type: "success",
title: "Path copied",
description: path,
});
},
onError: (error) => {
toastManager.add(
stackedThreadToast({
Expand All @@ -961,13 +954,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
});
const { copyToClipboard: copyBranchToClipboard } = useCopyToClipboard<{ branch: string }>({
target: "branch name",
onCopy: ({ branch }) => {
toastManager.add({
type: "success",
title: "Branch copied",
description: branch,
});
},
onError: (error) => {
toastManager.add(
stackedThreadToast({
Expand All @@ -979,13 +965,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
},
});
const { copyToClipboard: copyThreadIdToClipboard } = useCopyToClipboard<{ threadId: ThreadId }>({
onCopy: ({ threadId }) => {
toastManager.add({
type: "success",
title: "Thread ID copied",
description: threadId,
});
},
onError: (error) => {
toastManager.add(
stackedThreadToast({
Expand Down
35 changes: 13 additions & 22 deletions apps/web/src/components/chat/MarkdownFileLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,28 +220,19 @@ export const MarkdownFileLink = memo(function MarkdownFileLink({
}),
])
: value.then((text) => navigator.clipboard.writeText(text));
void Promise.all([write, value]).then(
([, text]) => {
toastManager.add({
type: "success",
title: `${title} copied`,
description: text,
});
},
(error) => {
reportMarkdownActionFailure(
{ operation: "copy-file-path", target: targetPath, copyTarget: title },
error,
);
toastManager.add(
stackedThreadToast({
type: "error",
title: `Failed to copy ${title.toLowerCase()}`,
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
},
);
void Promise.all([write, value]).catch((error) => {
reportMarkdownActionFailure(
{ operation: "copy-file-path", target: targetPath, copyTarget: title },
error,
);
toastManager.add(
stackedThreadToast({
type: "error",
title: `Failed to copy ${title.toLowerCase()}`,
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
});
};

const showFileContextMenu = async (position: { x: number; y: number }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ it("explains a denied clipboard write and lets the same message be copied again"
await page.getByRole("button", { name: "Dismiss notification" }).click();
await copy.click();

await expect.element(page.getByText("Copied!", { exact: true })).toBeVisible();
await expect.element(page.getByText("Copied!", { exact: true })).not.toBeInTheDocument();
await expect.element(copy).toBeDisabled();
});
2 changes: 0 additions & 2 deletions apps/web/src/components/chat/MessageCopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
import {
ANCHORED_COPY_TOAST_TIMEOUT_MS,
showAnchoredCopyErrorToast,
showAnchoredCopySuccessToast,
} from "../ui/anchoredCopyToast";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";

Expand All @@ -28,7 +27,6 @@ export const MessageCopyButton = memo(function MessageCopyButton({
}) {
const ref = useRef<HTMLButtonElement>(null);
const { copyToClipboard, isCopied } = useCopyToClipboard<void>({
onCopy: () => showAnchoredCopySuccessToast(ref),
onError: (error: Error) => showAnchoredCopyErrorToast(ref, error),
timeout: ANCHORED_COPY_TOAST_TIMEOUT_MS,
...(extraFlavors ? { extraFlavors } : {}),
Expand Down
27 changes: 9 additions & 18 deletions apps/web/src/components/chat/useRightPanelActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,24 +262,15 @@ export function useRightPanelActions(input: RightPanelActionsInput) {
relativePath,
resolvePathLinkTarget(relativePath, gitCwd ?? activeProjectCwd ?? ""),
);
void navigator.clipboard.writeText(clipboardPath).then(
() => {
toastManager.add({
type: "success",
title: "Path copied",
description: clipboardPath,
});
},
(error) => {
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to copy path",
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
},
);
void navigator.clipboard.writeText(clipboardPath).then(undefined, (error) => {
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to copy path",
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
});
};
const copyRightPanelFilePathStable = useStableCallback(copyRightPanelFilePath);
const addPullRequestSurface = () => {
Expand Down
5 changes: 0 additions & 5 deletions apps/web/src/components/files/FileBrowserPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ export default function FileBrowserPanel({
if (clicked === "copy-mention") {
try {
await writeTextToClipboard(mention);
toastManager.add({
type: "success",
title: "Mention copied",
description: relativePath,
});
} catch (error) {
toastManager.add({
type: "error",
Expand Down
9 changes: 1 addition & 8 deletions apps/web/src/components/media/MediaActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ export function MediaActions({
const clipboardText =
reference?.kind === "file" ? formatFilePathForClipboard(text, reference.path) : text;
await writeTextToClipboard(clipboardText, reference?.kind === "file" ? "file path" : "URL");
toastManager.add({
type: "success",
title: action === "copy-url" ? "URL copied" : "Path copied",
});
} else if (action === "open-file") {
assertCanReadMedia();
source.onOpenFile?.();
Expand All @@ -186,10 +182,7 @@ export function MediaActions({
title: action === "save" ? `Preparing ${noun} download…` : "Copying image…",
});
await (action === "save" ? save() : copyImage());
toastManager.update(progressToast, {
type: "success",
title: action === "save" ? "Download started" : "Image copied",
});
toastManager.close(progressToast);
}
});
if (AsyncResult.isFailure(result)) {
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/components/promptLinks/copyPromptLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export function composerPromptLink(input: {

export async function copyPromptLink(link: string): Promise<void> {
try {
if (!(await writeTextToClipboard(link))) return;
toastManager.add({ type: "success", title: "Prompt link copied" });
await writeTextToClipboard(link);
} catch (error) {
toastManager.add(
stackedThreadToast({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ export function PullRequestDetailPanel({
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
const { copyToClipboard: copyReference } = useCopyToClipboard<string>({
target: `${terminology.singular} reference`,
onCopy: (label) => toastManager.add({ type: "success", title: `${label} copied` }),
onError: (error, label) =>
toastManager.add({
type: "error",
Expand Down
24 changes: 7 additions & 17 deletions apps/web/src/components/pullRequest/PullRequestsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1443,23 +1443,13 @@ export function PullRequestsPage() {
const { shortLabel, singular } = (
sourceControlClients.findByChangeRequestUrl(url) ?? sourceControlClients.get(undefined)
).changeRequest;
void writeTextToClipboard(url, `${singular} link`).then(
(didCopy) => {
if (didCopy)
toastManager.add({
type: "success",
title: `${shortLabel} link copied`,
description: url,
});
},
(error) => {
toastManager.add({
type: "error",
title: `Failed to copy ${shortLabel} link`,
description: error instanceof Error ? error.message : "An error occurred.",
});
},
);
void writeTextToClipboard(url, `${singular} link`).then(undefined, (error) => {
toastManager.add({
type: "error",
title: `Failed to copy ${shortLabel} link`,
description: error instanceof Error ? error.message : "An error occurred.",
});
});
});
const closeActiveSurfaceFromShortcut = useEffectEvent((event: KeyboardEvent) => {
if (activePullRequestSurface === null) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { APP_VERSION } from "../../branding";
import { AnchoredToastProvider } from "../ui/toast";
import { AboutVersionTitle } from "./AboutVersionTitle";

it("shows copy confirmation when the version is clicked without waiting for a hover tooltip", async () => {
it("copies the version without a notification", async () => {
await using screen = await render(
<AnchoredToastProvider>
<AboutVersionTitle />
Expand All @@ -17,5 +17,5 @@ it("shows copy confirmation when the version is clicked without waiting for a ho
await screen.getByRole("button", { name: `Copy version ${APP_VERSION}` }).click();

expect(write).toHaveBeenCalledWith(APP_VERSION);
await expect.element(page.getByText(/^Copied!?$/)).toBeVisible();
await expect.element(page.getByText(/^Copied!?$/)).not.toBeInTheDocument();
});
Loading
Loading