Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
26 changes: 15 additions & 11 deletions apps/web/src/components/BranchToolbarBranchSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
ComboboxStatus,
ComboboxTrigger,
} from "./ui/combobox";
import { toastManager } from "./ui/toast";
import { stackedThreadToast, toastManager } from "./ui/toast";

interface BranchToolbarBranchSelectorProps {
environmentId: EnvironmentId;
Expand Down Expand Up @@ -351,11 +351,13 @@ export function BranchToolbarBranchSelector({
setThreadBranch(nextBranchName, selectionTarget.nextWorktreePath);
} catch (error) {
setOptimisticBranch(previousBranch);
toastManager.add({
type: "error",
title: "Failed to checkout branch.",
description: toBranchActionErrorMessage(error),
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to checkout branch.",
description: toBranchActionErrorMessage(error),
}),
);
}
});
};
Expand All @@ -381,11 +383,13 @@ export function BranchToolbarBranchSelector({
setThreadBranch(createBranchResult.branch, activeWorktreePath);
} catch (error) {
setOptimisticBranch(previousBranch);
toastManager.add({
type: "error",
title: "Failed to create and checkout branch.",
description: toBranchActionErrorMessage(error),
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to create and checkout branch.",
description: toBranchActionErrorMessage(error),
}),
);
}
});
};
Expand Down
38 changes: 22 additions & 16 deletions apps/web/src/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { defaultUrlTransform } from "react-markdown";
import remarkGfm from "remark-gfm";
import { VscodeEntryIcon } from "./chat/VscodeEntryIcon";
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
import { toastManager } from "./ui/toast";
import { stackedThreadToast, toastManager } from "./ui/toast";
import { openInPreferredEditor } from "../editorPreferences";
import { resolveDiffThemeName, type DiffThemeName } from "../lib/diffRendering";
import { fnv1a32 } from "../lib/diffRendering";
Expand Down Expand Up @@ -351,21 +351,25 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
}

void openInPreferredEditor(api, targetPath).catch((error) => {
toastManager.add({
type: "error",
title: "Unable to open file",
description: error instanceof Error ? error.message : "An error occurred.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Unable to open file",
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
});
}, [targetPath]);

const handleCopy = useCallback((value: string, title: string) => {
if (typeof window === "undefined" || !navigator.clipboard?.writeText) {
toastManager.add({
type: "error",
title: `Failed to copy ${title.toLowerCase()}`,
description: "Clipboard API unavailable.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: `Failed to copy ${title.toLowerCase()}`,
description: "Clipboard API unavailable.",
}),
);
return;
}

Expand All @@ -378,11 +382,13 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
});
},
(error) => {
toastManager.add({
type: "error",
title: `Failed to copy ${title.toLowerCase()}`,
description: error instanceof Error ? error.message : "An error occurred.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: `Failed to copy ${title.toLowerCase()}`,
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
},
);
}, []);
Expand Down
54 changes: 32 additions & 22 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
import ThreadTerminalDrawer from "./ThreadTerminalDrawer";
import { ChevronDownIcon } from "lucide-react";
import { cn, randomUUID } from "~/lib/utils";
import { toastManager } from "./ui/toast";
import { stackedThreadToast, toastManager } from "./ui/toast";
import { decodeProjectScriptKeybindingRule } from "~/lib/projectScriptKeybindings";
import { type NewProjectScriptInput } from "./ProjectScriptsControl";
import {
Expand Down Expand Up @@ -1556,7 +1556,7 @@
);

const focusComposer = useCallback(() => {
composerRef.current?.focusAtEnd();

Check warning on line 1559 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
}, []);
const scheduleComposerFocus = useCallback(() => {
window.requestAnimationFrame(() => {
Expand All @@ -1564,7 +1564,7 @@
});
}, [focusComposer]);
const addTerminalContextToDraft = useCallback((selection: TerminalContextSelection) => {
composerRef.current?.addTerminalContext(selection);

Check warning on line 1567 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
}, []);
const setTerminalOpen = useCallback(
(open: boolean) => {
Expand Down Expand Up @@ -1855,11 +1855,13 @@
title: `Deleted action "${deletedName ?? "Unknown"}"`,
});
} catch (error) {
toastManager.add({
type: "error",
title: "Could not delete action",
description: error instanceof Error ? error.message : "An unexpected error occurred.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Could not delete action",
description: error instanceof Error ? error.message : "An unexpected error occurred.",
}),
);
}
},
[activeProject, persistProjectScripts],
Expand Down Expand Up @@ -2233,7 +2235,7 @@
const shortcutContext = {
terminalFocus: isTerminalFocused(),
terminalOpen: Boolean(terminalState.terminalOpen),
modelPickerOpen: composerRef.current?.isModelPickerOpen() ?? false,

Check warning on line 2238 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useEffect has a missing dependency: 'composerRef.current'
};

const command = resolveShortcutCommand(event, keybindings, {
Expand Down Expand Up @@ -2426,11 +2428,13 @@
expiredTerminalContextCount,
"empty",
);
toastManager.add({
type: "warning",
title: toastCopy.title,
description: toastCopy.description,
});
toastManager.add(
stackedThreadToast({
type: "warning",
title: toastCopy.title,
description: toastCopy.description,
}),
);
}
return;
}
Expand Down Expand Up @@ -2512,11 +2516,13 @@
expiredTerminalContextCount,
"omitted",
);
toastManager.add({
type: "warning",
title: toastCopy.title,
description: toastCopy.description,
});
toastManager.add(
stackedThreadToast({
type: "warning",
title: toastCopy.title,
description: toastCopy.description,
}),
);
}
promptRef.current = "";
clearComposerDraftContent(composerDraftTarget);
Expand Down Expand Up @@ -2766,7 +2772,7 @@
};
});
promptRef.current = "";
composerRef.current?.resetCursorState({ cursor: 0 });

Check warning on line 2775 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
},
[activePendingProgress?.activeQuestion, activePendingUserInput],
);
Expand All @@ -2793,7 +2799,7 @@
),
},
}));
const snapshot = composerRef.current?.readSnapshot();

Check warning on line 2802 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
if (
snapshot?.value !== value ||
snapshot.cursor !== nextCursor ||
Expand Down Expand Up @@ -2856,7 +2862,7 @@
return;
}

const sendCtx = composerRef.current?.getSendContext();

Check warning on line 2865 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
if (!sendCtx) {
return;
}
Expand Down Expand Up @@ -2991,7 +2997,7 @@
return;
}

const sendCtx = composerRef.current?.getSendContext();

Check warning on line 3000 in apps/web/src/components/ChatView.tsx

View workflow job for this annotation

GitHub Actions / Format, Lint, Typecheck, Test, Browser Test, Build

eslint-plugin-react-hooks(exhaustive-deps)

React Hook useCallback has a missing dependency: 'composerRef.current'
if (!sendCtx) {
return;
}
Expand Down Expand Up @@ -3082,12 +3088,16 @@
threadId: nextThreadId,
})
.catch(() => undefined);
toastManager.add({
type: "error",
title: "Could not start implementation thread",
description:
err instanceof Error ? err.message : "An error occurred while creating the new thread.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Could not start implementation thread",
description:
err instanceof Error
? err.message
: "An error occurred while creating the new thread.",
}),
);
})
.then(finish, finish);
}, [
Expand Down
62 changes: 36 additions & 26 deletions apps/web/src/components/CommandPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ import {
} from "./ui/command";
import { Button } from "./ui/button";
import { Kbd, KbdGroup } from "./ui/kbd";
import { toastManager } from "./ui/toast";
import { stackedThreadToast, toastManager } from "./ui/toast";
import { ComposerHandleContext, useComposerHandleContext } from "../composerHandleContext";
import type { ChatComposerHandle } from "./chat/ChatComposer";

Expand Down Expand Up @@ -605,11 +605,13 @@ function OpenCommandPaletteDialog() {

const environmentId = defaultAddProjectEnvironmentId;
if (!environmentId) {
toastManager.add({
type: "error",
title: "Unable to browse projects",
description: "No environment is available.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Unable to browse projects",
description: "No environment is available.",
}),
);
return;
}

Expand Down Expand Up @@ -724,20 +726,24 @@ function OpenCommandPaletteDialog() {
if (!api) return;

if (isUnsupportedWindowsProjectPath(rawCwd.trim(), browseEnvironmentPlatform)) {
toastManager.add({
type: "error",
title: "Failed to add project",
description: "Windows-style paths are only supported on Windows.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to add project",
description: "Windows-style paths are only supported on Windows.",
}),
);
return;
}

if (isExplicitRelativeProjectPath(rawCwd.trim()) && !currentProjectCwdForBrowse) {
toastManager.add({
type: "error",
title: "Failed to add project",
description: "Relative paths require an active project.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to add project",
description: "Relative paths require an active project.",
}),
);
return;
}

Expand Down Expand Up @@ -790,11 +796,13 @@ function OpenCommandPaletteDialog() {
}).catch(() => undefined);
setOpen(false);
} catch (error) {
toastManager.add({
type: "error",
title: "Failed to add project",
description: error instanceof Error ? error.message : "An error occurred.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to add project",
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
}
},
[
Expand Down Expand Up @@ -934,11 +942,13 @@ function OpenCommandPaletteDialog() {
}

void item.run().catch((error: unknown) => {
toastManager.add({
type: "error",
title: "Unable to run command",
description: error instanceof Error ? error.message : "An unexpected error occurred.",
});
toastManager.add(
stackedThreadToast({
type: "error",
title: "Unable to run command",
description: error instanceof Error ? error.message : "An unexpected error occurred.",
}),
);
});
}

Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/GitActionsControl.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ vi.mock("~/components/ui/toast", () => ({
promise: toastPromiseSpy,
update: toastUpdateSpy,
},
stackedThreadToast: vi.fn((options: unknown) => options),
}));

vi.mock("~/editorPreferences", () => ({
Expand Down
Loading
Loading