Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be2bb4f4c3 | ||
|
|
3907e5e8c5 | ||
|
|
c8989287d3 | ||
|
|
8ec1958540 | ||
|
|
86650a03bb | ||
|
|
2742cd8a0c | ||
|
|
79affb0e06 | ||
|
|
74dbb98a40 |
No files matched your search
@@ -11,4 +11,3 @@ packages/*/dist
|
||||
build/
|
||||
.logs/
|
||||
release/
|
||||
.t3
|
||||
@@ -65,7 +65,6 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
|
||||
{ key: "mod+d", command: "terminal.split", when: "terminalFocus" },
|
||||
{ key: "mod+n", command: "terminal.new", when: "terminalFocus" },
|
||||
{ key: "mod+w", command: "terminal.close", when: "terminalFocus" },
|
||||
{ key: "mod+d", command: "diff.toggle", when: "!terminalFocus" },
|
||||
{ key: "mod+n", command: "chat.new", when: "!terminalFocus" },
|
||||
{ key: "mod+shift+o", command: "chat.new", when: "!terminalFocus" },
|
||||
{ key: "mod+shift+n", command: "chat.newLocal", when: "!terminalFocus" },
|
||||
|
||||
@@ -91,7 +91,6 @@ import { Menu, MenuItem, MenuPopup, MenuShortcut, MenuTrigger } from "./ui/menu"
|
||||
import { CursorIcon, Icon } from "./Icons";
|
||||
import { cn, isMacPlatform, isWindowsPlatform } from "~/lib/utils";
|
||||
import { Badge } from "./ui/badge";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
|
||||
import { Command, CommandInput, CommandItem, CommandList } from "./ui/command";
|
||||
import { decodeProjectScriptKeybindingRule } from "~/lib/projectScriptKeybindings";
|
||||
import ProjectScriptsControl, { type NewProjectScriptInput } from "./ProjectScriptsControl";
|
||||
@@ -616,21 +615,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
() => shortcutLabelForCommand(keybindings, "terminal.close"),
|
||||
[keybindings],
|
||||
);
|
||||
const diffPanelShortcutLabel = useMemo(
|
||||
() => shortcutLabelForCommand(keybindings, "diff.toggle"),
|
||||
[keybindings],
|
||||
);
|
||||
const onToggleDiff = useCallback(() => {
|
||||
void navigate({
|
||||
to: "/$threadId",
|
||||
params: { threadId },
|
||||
replace: true,
|
||||
search: (previous) => {
|
||||
const rest = stripDiffSearchParams(previous);
|
||||
return diffOpen ? rest : { ...rest, diff: "1" };
|
||||
},
|
||||
});
|
||||
}, [diffOpen, navigate, threadId]);
|
||||
|
||||
const envLocked = Boolean(
|
||||
activeThread &&
|
||||
@@ -1163,13 +1147,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (command === "diff.toggle") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onToggleDiff();
|
||||
return;
|
||||
}
|
||||
|
||||
const scriptId = projectScriptIdFromCommand(command);
|
||||
if (!scriptId || !activeProject) return;
|
||||
const script = activeProject.scripts.find((entry) => entry.id === scriptId);
|
||||
@@ -1191,7 +1168,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
runProjectScript,
|
||||
splitTerminal,
|
||||
keybindings,
|
||||
onToggleDiff,
|
||||
toggleTerminalVisibility,
|
||||
]);
|
||||
|
||||
@@ -1636,6 +1612,16 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
const onExpandTimelineImage = useCallback((image: ExpandedImagePreview) => {
|
||||
setExpandedImage(image);
|
||||
}, []);
|
||||
const onToggleDiff = useCallback(() => {
|
||||
void navigate({
|
||||
to: "/$threadId",
|
||||
params: { threadId },
|
||||
search: (previous) => {
|
||||
const rest = stripDiffSearchParams(previous);
|
||||
return diffOpen ? rest : { ...rest, diff: "1" };
|
||||
},
|
||||
});
|
||||
}, [diffOpen, navigate, threadId]);
|
||||
const onOpenTurnDiff = useCallback(
|
||||
(turnId: TurnId, filePath?: string) => {
|
||||
void navigate({
|
||||
@@ -1706,7 +1692,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
|
||||
activeProject ? (lastInvokedScriptByProjectId[activeProject.id] ?? null) : null
|
||||
}
|
||||
keybindings={keybindings}
|
||||
diffToggleShortcutLabel={diffPanelShortcutLabel}
|
||||
gitCwd={gitCwd}
|
||||
diffOpen={diffOpen}
|
||||
onRunProjectScript={(script) => {
|
||||
@@ -2058,7 +2043,6 @@ interface ChatHeaderProps {
|
||||
activeProjectScripts: ProjectScript[] | undefined;
|
||||
preferredScriptId: string | null;
|
||||
keybindings: ResolvedKeybindingsConfig;
|
||||
diffToggleShortcutLabel: string | null;
|
||||
gitCwd: string | null;
|
||||
diffOpen: boolean;
|
||||
onRunProjectScript: (script: ProjectScript) => void;
|
||||
@@ -2074,7 +2058,6 @@ const ChatHeader = memo(function ChatHeader({
|
||||
activeProjectScripts,
|
||||
preferredScriptId,
|
||||
keybindings,
|
||||
diffToggleShortcutLabel,
|
||||
gitCwd,
|
||||
diffOpen,
|
||||
onRunProjectScript,
|
||||
@@ -2113,27 +2096,16 @@ const ChatHeader = memo(function ChatHeader({
|
||||
<OpenInPicker keybindings={keybindings} activeThreadId={activeThreadId} />
|
||||
)}
|
||||
{activeProjectName && <GitActionsControl gitCwd={gitCwd} activeThreadId={activeThreadId} />}
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Toggle
|
||||
className="shrink-0"
|
||||
pressed={diffOpen}
|
||||
onPressedChange={onToggleDiff}
|
||||
aria-label="Toggle diff panel"
|
||||
variant="outline"
|
||||
size="xs"
|
||||
>
|
||||
<DiffIcon className="size-3" />
|
||||
</Toggle>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="bottom">
|
||||
{diffToggleShortcutLabel
|
||||
? `Toggle diff panel (${diffToggleShortcutLabel})`
|
||||
: "Toggle diff panel"}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
<Toggle
|
||||
className="shrink-0"
|
||||
pressed={diffOpen}
|
||||
onPressedChange={onToggleDiff}
|
||||
aria-label="Toggle diff panel"
|
||||
variant="outline"
|
||||
size="xs"
|
||||
>
|
||||
<DiffIcon className="size-3" />
|
||||
</Toggle>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type GitStatusResult, type GitStackedAction, type ThreadId } from "@t3tools/contracts";
|
||||
import { useIsMutating, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react";
|
||||
import { GitHubIcon } from "./Icons";
|
||||
@@ -33,7 +33,6 @@ import { toastManager } from "~/components/ui/toast";
|
||||
import {
|
||||
gitBranchesQueryOptions,
|
||||
gitInitMutationOptions,
|
||||
gitMutationKeys,
|
||||
gitPullMutationOptions,
|
||||
gitRunStackedActionMutationOptions,
|
||||
gitStatusQueryOptions,
|
||||
@@ -169,10 +168,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
|
||||
);
|
||||
const pullMutation = useMutation(gitPullMutationOptions({ cwd: gitCwd, queryClient }));
|
||||
|
||||
const isRunStackedActionRunning =
|
||||
useIsMutating({ mutationKey: gitMutationKeys.runStackedAction(gitCwd) }) > 0;
|
||||
const isPullRunning = useIsMutating({ mutationKey: gitMutationKeys.pull(gitCwd) }) > 0;
|
||||
const isGitActionRunning = isRunStackedActionRunning || isPullRunning;
|
||||
const isGitActionRunning = runImmediateGitActionMutation.isPending || pullMutation.isPending;
|
||||
const isDefaultBranch = useMemo(() => {
|
||||
const branchName = gitStatusForActions?.branch;
|
||||
if (!branchName) return false;
|
||||
|
||||
@@ -281,17 +281,7 @@ export default function Sidebar() {
|
||||
async (threadId: ThreadId, position: { x: number; y: number }) => {
|
||||
const api = readNativeApi();
|
||||
if (!api) return;
|
||||
const clicked = await api.contextMenu.show(
|
||||
[
|
||||
{ id: "mark-unread", label: "Mark unread" },
|
||||
{ id: "delete", label: "Delete" },
|
||||
],
|
||||
position,
|
||||
);
|
||||
if (clicked === "mark-unread") {
|
||||
dispatch({ type: "MARK_THREAD_UNREAD", threadId });
|
||||
return;
|
||||
}
|
||||
const clicked = await api.contextMenu.show([{ id: "delete", label: "Delete" }], position);
|
||||
if (clicked !== "delete") return;
|
||||
|
||||
const thread = state.threads.find((t) => t.id === threadId);
|
||||
@@ -390,7 +380,6 @@ export default function Sidebar() {
|
||||
},
|
||||
[
|
||||
appSettings.confirmThreadDelete,
|
||||
dispatch,
|
||||
navigate,
|
||||
removeWorktreeMutation,
|
||||
routeThreadId,
|
||||
|
||||
@@ -24,6 +24,7 @@ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
||||
const SIDEBAR_WIDTH = "16rem";
|
||||
const SIDEBAR_WIDTH_MOBILE = "calc(100vw - var(--spacing(3)))";
|
||||
const SIDEBAR_WIDTH_ICON = "3rem";
|
||||
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
||||
const SIDEBAR_RESIZE_DEFAULT_MIN_WIDTH = 16 * 16;
|
||||
|
||||
type SidebarContextProps = {
|
||||
@@ -128,6 +129,19 @@ function SidebarProvider({
|
||||
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
||||
}, [isMobile, setOpen]);
|
||||
|
||||
// Adds a keyboard shortcut to toggle the sidebar.
|
||||
React.useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
||||
event.preventDefault();
|
||||
toggleSidebar();
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [toggleSidebar]);
|
||||
|
||||
// We add a state so that we can do data-state="expanded" or "collapsed".
|
||||
// This makes it easier to style the sidebar with Tailwind classes.
|
||||
const state = open ? "expanded" : "collapsed";
|
||||
|
||||
@@ -41,10 +41,8 @@ export function showContextMenuFallback<T extends string>(
|
||||
const btn = document.createElement("button");
|
||||
btn.type = "button";
|
||||
btn.textContent = item.label;
|
||||
const isDeleteAction = item.id === "delete";
|
||||
btn.className = isDeleteAction
|
||||
? "flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-destructive hover:bg-accent cursor-default"
|
||||
: "flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-popover-foreground hover:bg-accent cursor-default";
|
||||
btn.className =
|
||||
"flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-destructive hover:bg-accent cursor-default";
|
||||
btn.addEventListener("click", () => cleanup(item.id));
|
||||
menu.appendChild(btn);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
formatShortcutLabel,
|
||||
isChatNewShortcut,
|
||||
isChatNewLocalShortcut,
|
||||
isDiffToggleShortcut,
|
||||
isOpenFavoriteEditorShortcut,
|
||||
isTerminalClearShortcut,
|
||||
isTerminalCloseShortcut,
|
||||
@@ -92,11 +91,6 @@ const DEFAULT_BINDINGS = compile([
|
||||
command: "terminal.close",
|
||||
whenAst: whenIdentifier("terminalFocus"),
|
||||
},
|
||||
{
|
||||
shortcut: modShortcut("d"),
|
||||
command: "diff.toggle",
|
||||
whenAst: whenNot(whenIdentifier("terminalFocus")),
|
||||
},
|
||||
{ shortcut: modShortcut("o", { shiftKey: true }), command: "chat.new" },
|
||||
{ shortcut: modShortcut("n", { shiftKey: true }), command: "chat.newLocal" },
|
||||
{ shortcut: modShortcut("o"), command: "editor.openFavorite" },
|
||||
@@ -236,7 +230,6 @@ describe("shortcutLabelForCommand", () => {
|
||||
|
||||
it("returns labels for non-terminal commands", () => {
|
||||
assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "chat.new", "MacIntel"), "⇧⌘O");
|
||||
assert.strictEqual(shortcutLabelForCommand(DEFAULT_BINDINGS, "diff.toggle", "Linux"), "Ctrl+D");
|
||||
assert.strictEqual(
|
||||
shortcutLabelForCommand(DEFAULT_BINDINGS, "editor.openFavorite", "Linux"),
|
||||
"Ctrl+O",
|
||||
@@ -283,21 +276,6 @@ describe("chat/editor shortcuts", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("matches diff.toggle shortcut outside terminal focus", () => {
|
||||
assert.isTrue(
|
||||
isDiffToggleShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
|
||||
platform: "MacIntel",
|
||||
context: { terminalFocus: false },
|
||||
}),
|
||||
);
|
||||
assert.isFalse(
|
||||
isDiffToggleShortcut(event({ key: "d", metaKey: true }), DEFAULT_BINDINGS, {
|
||||
platform: "MacIntel",
|
||||
context: { terminalFocus: true },
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("cross-command precedence", () => {
|
||||
|
||||
@@ -198,14 +198,6 @@ export function isTerminalCloseShortcut(
|
||||
return matchesCommandShortcut(event, keybindings, "terminal.close", options);
|
||||
}
|
||||
|
||||
export function isDiffToggleShortcut(
|
||||
event: ShortcutEventLike,
|
||||
keybindings: ResolvedKeybindingsConfig,
|
||||
options?: ShortcutMatchOptions,
|
||||
): boolean {
|
||||
return matchesCommandShortcut(event, keybindings, "diff.toggle", options);
|
||||
}
|
||||
|
||||
export function isChatNewShortcut(
|
||||
event: ShortcutEventLike,
|
||||
keybindings: ResolvedKeybindingsConfig,
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { QueryClient } from "@tanstack/react-query";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
gitMutationKeys,
|
||||
gitPullMutationOptions,
|
||||
gitRunStackedActionMutationOptions,
|
||||
} from "./gitReactQuery";
|
||||
|
||||
describe("gitMutationKeys", () => {
|
||||
it("scopes stacked action keys by cwd", () => {
|
||||
expect(gitMutationKeys.runStackedAction("/repo/a")).not.toEqual(
|
||||
gitMutationKeys.runStackedAction("/repo/b"),
|
||||
);
|
||||
});
|
||||
|
||||
it("scopes pull keys by cwd", () => {
|
||||
expect(gitMutationKeys.pull("/repo/a")).not.toEqual(gitMutationKeys.pull("/repo/b"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("git mutation options", () => {
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
it("attaches cwd-scoped mutation key for runStackedAction", () => {
|
||||
const options = gitRunStackedActionMutationOptions({ cwd: "/repo/a", queryClient });
|
||||
expect(options.mutationKey).toEqual(gitMutationKeys.runStackedAction("/repo/a"));
|
||||
});
|
||||
|
||||
it("attaches cwd-scoped mutation key for pull", () => {
|
||||
const options = gitPullMutationOptions({ cwd: "/repo/a", queryClient });
|
||||
expect(options.mutationKey).toEqual(gitMutationKeys.pull("/repo/a"));
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { GitStackedAction } from "@t3tools/contracts";
|
||||
import { mutationOptions, queryOptions, type QueryClient } from "@tanstack/react-query";
|
||||
import { ensureNativeApi } from "../nativeApi";
|
||||
import { ensureNativeApi } from "~/nativeApi";
|
||||
|
||||
const GIT_STATUS_STALE_TIME_MS = 5_000;
|
||||
const GIT_STATUS_REFETCH_INTERVAL_MS = 15_000;
|
||||
@@ -13,15 +13,6 @@ export const gitQueryKeys = {
|
||||
branches: (cwd: string | null) => ["git", "branches", cwd] as const,
|
||||
};
|
||||
|
||||
export const gitMutationKeys = {
|
||||
init: (cwd: string | null) => ["git", "mutation", "init", cwd] as const,
|
||||
checkout: (cwd: string | null) => ["git", "mutation", "checkout", cwd] as const,
|
||||
createBranchAndCheckout: (cwd: string | null) =>
|
||||
["git", "mutation", "create-branch-and-checkout", cwd] as const,
|
||||
runStackedAction: (cwd: string | null) => ["git", "mutation", "run-stacked-action", cwd] as const,
|
||||
pull: (cwd: string | null) => ["git", "mutation", "pull", cwd] as const,
|
||||
};
|
||||
|
||||
export function invalidateGitQueries(queryClient: QueryClient) {
|
||||
return queryClient.invalidateQueries({ queryKey: gitQueryKeys.all });
|
||||
}
|
||||
@@ -60,7 +51,6 @@ export function gitBranchesQueryOptions(cwd: string | null) {
|
||||
|
||||
export function gitInitMutationOptions(input: { cwd: string | null; queryClient: QueryClient }) {
|
||||
return mutationOptions({
|
||||
mutationKey: gitMutationKeys.init(input.cwd),
|
||||
mutationFn: async () => {
|
||||
const api = ensureNativeApi();
|
||||
if (!input.cwd) throw new Error("Git init is unavailable.");
|
||||
@@ -77,7 +67,6 @@ export function gitCheckoutMutationOptions(input: {
|
||||
queryClient: QueryClient;
|
||||
}) {
|
||||
return mutationOptions({
|
||||
mutationKey: gitMutationKeys.checkout(input.cwd),
|
||||
mutationFn: async (branch: string) => {
|
||||
const api = ensureNativeApi();
|
||||
if (!input.cwd) throw new Error("Git checkout is unavailable.");
|
||||
@@ -94,7 +83,6 @@ export function gitCreateBranchAndCheckoutMutationOptions(input: {
|
||||
queryClient: QueryClient;
|
||||
}) {
|
||||
return mutationOptions({
|
||||
mutationKey: gitMutationKeys.createBranchAndCheckout(input.cwd),
|
||||
mutationFn: async (branch: string) => {
|
||||
const api = ensureNativeApi();
|
||||
if (!input.cwd) throw new Error("Git branch creation is unavailable.");
|
||||
@@ -112,7 +100,6 @@ export function gitRunStackedActionMutationOptions(input: {
|
||||
queryClient: QueryClient;
|
||||
}) {
|
||||
return mutationOptions({
|
||||
mutationKey: gitMutationKeys.runStackedAction(input.cwd),
|
||||
mutationFn: async ({
|
||||
action,
|
||||
commitMessage,
|
||||
@@ -136,7 +123,6 @@ export function gitRunStackedActionMutationOptions(input: {
|
||||
|
||||
export function gitPullMutationOptions(input: { cwd: string | null; queryClient: QueryClient }) {
|
||||
return mutationOptions({
|
||||
mutationKey: gitMutationKeys.pull(input.cwd),
|
||||
mutationFn: async () => {
|
||||
const api = ensureNativeApi();
|
||||
if (!input.cwd) throw new Error("Git pull is unavailable.");
|
||||
@@ -165,7 +151,6 @@ export function gitCreateWorktreeMutationOptions(input: { queryClient: QueryClie
|
||||
if (!cwd) throw new Error("Git worktree creation is unavailable.");
|
||||
return api.git.createWorktree({ cwd, branch, newBranch, path: path ?? null });
|
||||
},
|
||||
mutationKey: ["git", "mutation", "create-worktree"] as const,
|
||||
onSettled: async () => {
|
||||
await invalidateGitQueries(input.queryClient);
|
||||
},
|
||||
@@ -179,7 +164,6 @@ export function gitRemoveWorktreeMutationOptions(input: { queryClient: QueryClie
|
||||
if (!cwd) throw new Error("Git worktree removal is unavailable.");
|
||||
return api.git.removeWorktree({ cwd, path, force });
|
||||
},
|
||||
mutationKey: ["git", "mutation", "remove-worktree"] as const,
|
||||
onSettled: async () => {
|
||||
await invalidateGitQueries(input.queryClient);
|
||||
},
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
import { ProjectId, ThreadId } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { reducer, type AppState } from "./store";
|
||||
import { DEFAULT_THREAD_TERMINAL_HEIGHT, DEFAULT_THREAD_TERMINAL_ID, type Thread } from "./types";
|
||||
|
||||
function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
return {
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
codexThreadId: null,
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
model: "gpt-5-codex",
|
||||
terminalOpen: false,
|
||||
terminalHeight: DEFAULT_THREAD_TERMINAL_HEIGHT,
|
||||
terminalIds: [DEFAULT_THREAD_TERMINAL_ID],
|
||||
runningTerminalIds: [],
|
||||
activeTerminalId: DEFAULT_THREAD_TERMINAL_ID,
|
||||
terminalGroups: [
|
||||
{
|
||||
id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
|
||||
terminalIds: [DEFAULT_THREAD_TERMINAL_ID],
|
||||
},
|
||||
],
|
||||
activeTerminalGroupId: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
|
||||
session: null,
|
||||
messages: [],
|
||||
turnDiffSummaries: [],
|
||||
activities: [],
|
||||
error: null,
|
||||
createdAt: "2026-02-13T00:00:00.000Z",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function makeState(thread: Thread): AppState {
|
||||
return {
|
||||
projects: [
|
||||
{
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
name: "Project",
|
||||
cwd: "/tmp/project",
|
||||
model: "gpt-5-codex",
|
||||
expanded: true,
|
||||
scripts: [],
|
||||
},
|
||||
],
|
||||
threads: [thread],
|
||||
threadsHydrated: true,
|
||||
runtimeMode: "full-access",
|
||||
};
|
||||
}
|
||||
|
||||
describe("store reducer", () => {
|
||||
it("marks a completed thread as unread by moving lastVisitedAt before completion", () => {
|
||||
const latestTurnCompletedAt = "2026-02-25T12:30:00.000Z";
|
||||
const initialState = makeState(
|
||||
makeThread({
|
||||
latestTurnCompletedAt,
|
||||
lastVisitedAt: "2026-02-25T12:35:00.000Z",
|
||||
}),
|
||||
);
|
||||
|
||||
const next = reducer(initialState, {
|
||||
type: "MARK_THREAD_UNREAD",
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
});
|
||||
|
||||
const updatedThread = next.threads[0];
|
||||
expect(updatedThread).toBeDefined();
|
||||
expect(updatedThread?.lastVisitedAt).toBe("2026-02-25T12:29:59.999Z");
|
||||
expect(Date.parse(updatedThread?.lastVisitedAt ?? "")).toBeLessThan(
|
||||
Date.parse(latestTurnCompletedAt),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not change a thread without a completed turn", () => {
|
||||
const initialState = makeState(
|
||||
makeThread({
|
||||
latestTurnCompletedAt: undefined,
|
||||
lastVisitedAt: "2026-02-25T12:35:00.000Z",
|
||||
}),
|
||||
);
|
||||
|
||||
const next = reducer(initialState, {
|
||||
type: "MARK_THREAD_UNREAD",
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
});
|
||||
|
||||
expect(next).toEqual(initialState);
|
||||
});
|
||||
});
|
||||
@@ -33,7 +33,6 @@ import {
|
||||
type Action =
|
||||
| { type: "SYNC_SERVER_READ_MODEL"; readModel: OrchestrationReadModel }
|
||||
| { type: "MARK_THREAD_VISITED"; threadId: ThreadId; visitedAt?: string }
|
||||
| { type: "MARK_THREAD_UNREAD"; threadId: ThreadId }
|
||||
| { type: "TOGGLE_PROJECT"; projectId: Project["id"] }
|
||||
| { type: "TOGGLE_THREAD_TERMINAL"; threadId: ThreadId }
|
||||
| { type: "SET_THREAD_TERMINAL_OPEN"; threadId: ThreadId; open: boolean }
|
||||
@@ -505,29 +504,6 @@ export function reducer(state: AppState, action: Action): AppState {
|
||||
};
|
||||
}
|
||||
|
||||
case "MARK_THREAD_UNREAD": {
|
||||
return {
|
||||
...state,
|
||||
threads: updateThread(state.threads, action.threadId, (thread) => {
|
||||
if (!thread.latestTurnCompletedAt) {
|
||||
return thread;
|
||||
}
|
||||
const latestTurnCompletedAtMs = Date.parse(thread.latestTurnCompletedAt);
|
||||
if (Number.isNaN(latestTurnCompletedAtMs)) {
|
||||
return thread;
|
||||
}
|
||||
const unreadVisitedAt = new Date(latestTurnCompletedAtMs - 1).toISOString();
|
||||
if (thread.lastVisitedAt === unreadVisitedAt) {
|
||||
return thread;
|
||||
}
|
||||
return {
|
||||
...thread,
|
||||
lastVisitedAt: unreadVisitedAt,
|
||||
};
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
case "TOGGLE_PROJECT":
|
||||
return {
|
||||
...state,
|
||||
|
||||
@@ -35,12 +35,6 @@ it.effect("parses keybinding rules", () =>
|
||||
});
|
||||
assert.strictEqual(parsedClose.command, "terminal.close");
|
||||
|
||||
const parsedDiffToggle = yield* decode(KeybindingRule, {
|
||||
key: "mod+d",
|
||||
command: "diff.toggle",
|
||||
});
|
||||
assert.strictEqual(parsedDiffToggle.command, "diff.toggle");
|
||||
|
||||
const parsedLocal = yield* decode(KeybindingRule, {
|
||||
key: "mod+shift+n",
|
||||
command: "chat.newLocal",
|
||||
|
||||
@@ -14,7 +14,6 @@ export const STATIC_KEYBINDING_COMMANDS = [
|
||||
"terminal.split",
|
||||
"terminal.new",
|
||||
"terminal.close",
|
||||
"diff.toggle",
|
||||
"chat.new",
|
||||
"chat.newLocal",
|
||||
"editor.openFavorite",
|
||||
|
||||
Reference in new issue
Block a user