Compare commits

..
18 Commits
Author SHA1 Message Date
Julius Marminge 0d4a38f079 kewl 2026-02-14 23:33:58 -08:00
Julius Marminge f3b65dbedf Polish action button icons and hover tooltips
- Standardize quick action icon sizing and label spacing in chat and git controls
- Replace manual popover hover state handling with `openOnHover` triggers
- Add reusable terminal action button wrapper with hover tooltips for split/new/close controls
2026-02-14 23:31:20 -08:00
Julius Marminge 38667d323c Add inline branch creation to branch picker search
- let users create a new local branch directly from the branch combobox search
- remove separate "New branch" form/button flow in `BranchToolbar`
- add `inputClassName` support to `ComboboxInput` for native input styling control
2026-02-14 23:20:45 -08:00
Julius Marminge e829f971ce Use action maps for Git dialog title and description
- Replace nested conditional strings with action-to-copy lookup objects
- Keep commit/push/create PR dialog text centralized and easier to maintain
2026-02-14 23:08:05 -08:00
Julius Marminge 37cd7be09b Close git action toast before triggering follow-up action
- Dismiss the success toast before handling Push/Open PR/Create PR CTA clicks
- Prevent stale result toasts from lingering while starting the next git action
2026-02-14 23:04:34 -08:00
Julius Marminge aa6412c3ba Keep git action success toast visible until dismissed
- set success toast timeout in `GitActionsControl` from `5_000` to `0`
- keeps post-action feedback and push CTA available until user closes it
2026-02-14 23:02:58 -08:00
Julius Marminge 04d86b0559 Skip commit progress stages when no files changed
- Only include commit-related progress steps for stacked actions when there are working tree changes
- Prevents showing "Generating commit message"/"Committing" during pure push or PR flows
2026-02-14 23:02:37 -08:00
Julius Marminge d4447da322 Streamline git action flow and improve changed-files dialog
- Trigger `commit_push` directly from primary Push actions
- Simplify push confirmation copy and dialog descriptions
- Replace 6-file cap with a scrollable full changed-files list plus totals
2026-02-14 23:00:53 -08:00
Julius Marminge 2512721b13 fmt 2026-02-14 22:54:58 -08:00
Julius Marminge 07d5dc1f25 kewl 2026-02-14 22:49:16 -08:00
Julius Marminge 3125dd80a7 Reduce git action success toast duration
- Shorten success notification timeout in `GitActionsControl` from 10s to 5s
2026-02-14 22:47:21 -08:00
Julius Marminge 25579c9942 Prefer upstream branch in push result summary
- show push target as `origin/<branch>` when available
- update summarizeGitResult test expectation accordingly
2026-02-14 22:44:22 -08:00
Julius Marminge 5caae992e3 Refine git action success toasts with contextual summaries
- replace generic success text with action-specific toast titles/descriptions
- include short SHA/branch details for push and commit outcomes
- add tests for PR/commit/push summaries and description truncation
2026-02-14 22:43:27 -08:00
Julius Marminge beb9201f5d Fix disabled git action tooltip hover handling
- Use the quick action button itself as the popover trigger
- Keep hover tooltips working on disabled controls via pointer-events override
- Remove focus/blur tab-stop handlers from disabled tooltip wrappers
2026-02-14 22:38:54 -08:00
Julius Marminge c129be5e21 Improve git status details and streamline quick action flows
- add working-tree file/line stats to git status contracts, server responses, and tests
- refactor web git queries/mutations into shared React Query helpers
- update git quick-action logic/UI to prefer commit/push/PR flows and clearer disabled states
- hide branch toolbar for non-repos and tighten related chat/toolbar behavior
2026-02-14 22:36:16 -08:00
Julius Marminge 5aaae6cb60 git actions 2026-02-14 21:40:42 -08:00
Julius Marminge 8b94f007f2 Use outline styling for Git action buttons
- Change primary Git action button from ghost to outline
- Update Git action options trigger button to outline for consistent affordance
2026-02-14 10:17:14 -08:00
Julius Marminge 80ce01b8e6 Adopt Base UI components and improve editor open behavior
- migrate web UI to shared Base UI primitives (alerts, buttons, combobox, toast, etc.)
- refactor chat and branch toolbars to use new components and cleaner interactions
- add cross-platform file-manager fallback in `openInEditor` server handling
- update model contracts/tests and web dependencies to support new UI flow
2026-02-14 10:16:31 -08:00
10 changed files with 48 additions and 334 deletions

No files matched your search

-134
View File
@@ -239,140 +239,6 @@ describe("git integration", () => {
expect(current!.name).toBe("feature");
});
it("refreshes upstream behind count after checkout when remote branch advanced", async () => {
await using remote = await makeTmpDir();
await using source = await makeTmpDir();
await using clone = await makeTmpDir();
await git(remote.path, "init --bare");
await initRepoWithCommit(source.path);
const defaultBranch = (await listGitBranches({ cwd: source.path })).branches.find(
(branch) => branch.current,
)!.name;
await git(source.path, `remote add origin ${JSON.stringify(remote.path)}`);
await git(source.path, `push -u origin ${defaultBranch}`);
const featureBranch = "feature-behind";
await createGitBranch({ cwd: source.path, branch: featureBranch });
await checkoutGitBranch({ cwd: source.path, branch: featureBranch });
await writeFile(path.join(source.path, "feature.txt"), "feature base\n");
await git(source.path, "add feature.txt");
await git(source.path, "commit -m 'feature base'");
await git(source.path, `push -u origin ${featureBranch}`);
await checkoutGitBranch({ cwd: source.path, branch: defaultBranch });
await git(clone.path, `clone ${JSON.stringify(remote.path)} .`);
await git(clone.path, "config user.email '[email protected]'");
await git(clone.path, "config user.name 'Test'");
await git(clone.path, `checkout -b ${featureBranch} --track origin/${featureBranch}`);
await writeFile(path.join(clone.path, "feature.txt"), "feature from remote\n");
await git(clone.path, "add feature.txt");
await git(clone.path, "commit -m 'remote feature update'");
await git(clone.path, `push origin ${featureBranch}`);
await checkoutGitBranch({ cwd: source.path, branch: featureBranch });
const core = new GitCoreService();
const details = await core.statusDetails(source.path);
expect(details.branch).toBe(featureBranch);
expect(details.aheadCount).toBe(0);
expect(details.behindCount).toBe(1);
});
it("keeps checkout successful when upstream refresh fails", async () => {
await using remote = await makeTmpDir();
await using source = await makeTmpDir();
await git(remote.path, "init --bare");
await initRepoWithCommit(source.path);
const defaultBranch = (await listGitBranches({ cwd: source.path })).branches.find(
(branch) => branch.current,
)!.name;
await git(source.path, `remote add origin ${JSON.stringify(remote.path)}`);
await git(source.path, `push -u origin ${defaultBranch}`);
const featureBranch = "feature-refresh-failure";
await git(source.path, `branch ${featureBranch}`);
await git(source.path, `checkout ${featureBranch}`);
await writeFile(path.join(source.path, "feature.txt"), "feature base\n");
await git(source.path, "add feature.txt");
await git(source.path, "commit -m 'feature base'");
await git(source.path, `push -u origin ${featureBranch}`);
await git(source.path, `checkout ${defaultBranch}`);
class RefreshFailingGitCoreService extends GitCoreService {
refreshFetchAttempts = 0;
override async git(
cwd: string,
args: readonly string[],
allowNonZeroExit = false,
): Promise<void> {
if (args[0] === "fetch") {
this.refreshFetchAttempts += 1;
throw new Error("simulated fetch timeout");
}
await super.git(cwd, args, allowNonZeroExit);
}
}
const core = new RefreshFailingGitCoreService();
await expect(core.checkoutBranch({ cwd: source.path, branch: featureBranch })).resolves.toBe(
undefined,
);
expect(core.refreshFetchAttempts).toBe(1);
expect(await git(source.path, "branch --show-current")).toBe(featureBranch);
});
it("refresh fetch is scoped to the checked out branch upstream refspec", async () => {
await using remote = await makeTmpDir();
await using source = await makeTmpDir();
await git(remote.path, "init --bare");
await initRepoWithCommit(source.path);
const defaultBranch = (await listGitBranches({ cwd: source.path })).branches.find(
(branch) => branch.current,
)!.name;
await git(source.path, `remote add origin ${JSON.stringify(remote.path)}`);
await git(source.path, `push -u origin ${defaultBranch}`);
const featureBranch = "feature/scoped-fetch";
await git(source.path, `checkout -b ${featureBranch}`);
await writeFile(path.join(source.path, "feature.txt"), "feature base\n");
await git(source.path, "add feature.txt");
await git(source.path, "commit -m 'feature base'");
await git(source.path, `push -u origin ${featureBranch}`);
await git(source.path, `checkout ${defaultBranch}`);
class FetchRecordingGitCoreService extends GitCoreService {
fetchArgs: readonly string[] | null = null;
override async git(
cwd: string,
args: readonly string[],
allowNonZeroExit = false,
): Promise<void> {
if (args[0] === "fetch") {
this.fetchArgs = args;
return;
}
await super.git(cwd, args, allowNonZeroExit);
}
}
const core = new FetchRecordingGitCoreService();
await core.checkoutBranch({ cwd: source.path, branch: featureBranch });
expect(await git(source.path, "branch --show-current")).toBe(featureBranch);
expect(core.fetchArgs).toEqual([
"fetch",
"--quiet",
"--no-tags",
"origin",
`+refs/heads/${featureBranch}:refs/remotes/origin/${featureBranch}`,
]);
});
it("throws when branch does not exist", async () => {
await using tmp = await makeTmpDir();
await initRepoWithCommit(tmp.path);
-34
View File
@@ -553,45 +553,11 @@ export class GitCoreService {
});
}
private async refreshCheckedOutBranchUpstream(cwd: string): Promise<void> {
const upstreamRef = trimStdout(
await this.gitStdout(
cwd,
["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}"],
true,
),
);
if (upstreamRef.length === 0 || upstreamRef === "@{upstream}") {
return;
}
const separatorIndex = upstreamRef.indexOf("/");
if (separatorIndex <= 0) {
return;
}
const remoteName = upstreamRef.slice(0, separatorIndex);
const upstreamBranch = upstreamRef.slice(separatorIndex + 1);
if (remoteName.length === 0) {
return;
}
if (upstreamBranch.length === 0) {
return;
}
const refspec = `+refs/heads/${upstreamBranch}:refs/remotes/${upstreamRef}`;
await this.git(cwd, ["fetch", "--quiet", "--no-tags", remoteName, refspec], true);
}
async checkoutBranch(input: GitCheckoutInput): Promise<void> {
await executeGit(input.cwd, ["checkout", input.branch], {
timeoutMs: 10_000,
fallbackErrorMessage: "git checkout failed",
});
try {
await this.refreshCheckedOutBranchUpstream(input.cwd);
} catch {
// Best effort: checkout already succeeded, so avoid surfacing refresh failures.
}
}
async initRepo(input: GitInitInput): Promise<void> {
+2 -7
View File
@@ -1,4 +1,4 @@
import { QueryClient, QueryClientProvider, useQueryClient } from "@tanstack/react-query";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useEffect, useRef } from "react";
import ChatView from "./components/ChatView";
@@ -11,27 +11,22 @@ import { DEFAULT_THREAD_TERMINAL_HEIGHT, DEFAULT_THREAD_TERMINAL_ID } from "./ty
import { onServerWelcome } from "./wsNativeApi";
import { useNativeApi } from "./hooks/useNativeApi";
import { AnchoredToastProvider, ToastProvider } from "./components/ui/toast";
import { invalidateGitQueries } from "./lib/gitReactQuery";
function EventRouter() {
const api = useNativeApi();
const { dispatch } = useStore();
const queryClient = useQueryClient();
const activeAssistantItemRef = useRef<string | null>(null);
useEffect(() => {
if (!api) return;
return api.providers.onEvent((event) => {
if (event.method === "turn/completed") {
void invalidateGitQueries(queryClient);
}
dispatch({
type: "APPLY_EVENT",
event,
activeAssistantItemRef,
});
});
}, [api, dispatch, queryClient]);
}, [api, dispatch]);
useEffect(() => {
if (!api) return;
+7 -18
View File
@@ -19,11 +19,8 @@ import {
useRef,
useState,
} from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
gitBranchesQueryOptions,
gitCreateWorktreeMutationOptions,
} from "~/lib/gitReactQuery";
import { useQuery } from "@tanstack/react-query";
import { gitBranchesQueryOptions } from "~/lib/gitReactQuery";
import { EDITORS, type EditorId } from "@t3tools/contracts";
import { isElectron } from "../env";
@@ -128,8 +125,6 @@ function readFileAsDataUrl(file: File): Promise<string> {
export default function ChatView() {
const { state, dispatch } = useStore();
const api = useNativeApi();
const queryClient = useQueryClient();
const createWorktreeMutation = useMutation(gitCreateWorktreeMutationOptions({ api, queryClient }));
const [prompt, setPrompt] = useState("");
const [composerImages, setComposerImages] = useState<ComposerImageAttachment[]>([]);
const [isDragOverComposer, setIsDragOverComposer] = useState(false);
@@ -314,20 +309,14 @@ export default function ChatView() {
const closeTerminal = useCallback(
(terminalId: string) => {
if (!activeThreadId || !api) return;
const isFinalTerminal = (activeThread?.terminalIds.length ?? 0) <= 1;
const fallbackExitWrite = () =>
api.terminal
.write({ threadId: activeThreadId, terminalId, data: "exit\n" })
.catch(() => undefined);
if ("close" in api.terminal && typeof api.terminal.close === "function") {
void (async () => {
if (isFinalTerminal) {
await api.terminal
.clear({ threadId: activeThreadId, terminalId })
.catch(() => undefined);
}
await api.terminal.close({ threadId: activeThreadId, terminalId, deleteHistory: true });
})().catch(() => fallbackExitWrite());
void api.terminal
.close({ threadId: activeThreadId, terminalId })
.catch(() => fallbackExitWrite());
} else {
void fallbackExitWrite();
}
@@ -338,7 +327,7 @@ export default function ChatView() {
});
setTerminalFocusRequestId((value) => value + 1);
},
[activeThread?.terminalIds.length, activeThreadId, api, dispatch],
[activeThreadId, api, dispatch],
);
const handleRuntimeModeChange = async (mode: "approval-required" | "full-access") => {
@@ -674,7 +663,7 @@ export default function ChatView() {
) {
try {
const newBranch = `codething/${crypto.randomUUID().slice(0, 8)}`;
const result = await createWorktreeMutation.mutateAsync({
const result = await api.git.createWorktree({
cwd: activeProject.cwd,
branch: activeThread.branch,
newBranch,
@@ -1,7 +1,6 @@
import type { GitStatusResult } from "@t3tools/contracts";
import { assert, describe, it } from "vitest";
import {
buildGitActionProgressStages,
buildMenuItems,
requiresDefaultBranchConfirmation,
resolveQuickAction,
@@ -597,33 +596,6 @@ describe("requiresDefaultBranchConfirmation", () => {
});
});
describe("buildGitActionProgressStages", () => {
it("shows only push progress when push-only is forced", () => {
const stages = buildGitActionProgressStages({
action: "commit_push",
hasCustomCommitMessage: false,
hasWorkingTreeChanges: true,
forcePushOnly: true,
pushTarget: "origin/feature/test",
});
assert.deepEqual(stages, ["Pushing to origin/feature/test..."]);
});
it("includes commit stages for commit+push when working tree is dirty", () => {
const stages = buildGitActionProgressStages({
action: "commit_push",
hasCustomCommitMessage: false,
hasWorkingTreeChanges: true,
pushTarget: "origin/feature/test",
});
assert.deepEqual(stages, [
"Generating commit message...",
"Committing...",
"Pushing to origin/feature/test...",
]);
});
});
describe("summarizeGitResult", () => {
it("returns commit-focused toast for commit action", () => {
const result = summarizeGitResult({
@@ -43,30 +43,6 @@ function truncateText(
return `${value.slice(0, Math.max(0, maxLength - 3)).trimEnd()}...`;
}
export function buildGitActionProgressStages(input: {
action: GitStackedAction;
hasCustomCommitMessage: boolean;
hasWorkingTreeChanges: boolean;
forcePushOnly?: boolean;
pushTarget?: string;
}): string[] {
const shouldIncludeCommitStages =
!input.forcePushOnly && (input.action === "commit" || input.hasWorkingTreeChanges);
const commitStages = !shouldIncludeCommitStages
? []
: input.hasCustomCommitMessage
? ["Committing..."]
: ["Generating commit message...", "Committing..."];
const pushStage = input.pushTarget ? `Pushing to ${input.pushTarget}...` : "Pushing...";
if (input.action === "commit") {
return commitStages;
}
if (input.action === "commit_push") {
return [...commitStages, pushStage];
}
return [...commitStages, pushStage, "Creating PR..."];
}
export function summarizeGitResult(result: GitRunStackedActionResult): {
title: string;
description?: string;
@@ -231,7 +207,7 @@ export function resolveQuickAction(
label: "Commit",
disabled: true,
kind: "show_hint",
hint: "Branch is up to date. No action needed.",
hint: "Branch is up to date. Nothing to commit, push, pull, or open as a PR.",
};
}
+32 -35
View File
@@ -4,7 +4,6 @@ import { useCallback, useMemo, useState } from "react";
import { ChevronDownIcon, CloudUploadIcon, GitCommitIcon, InfoIcon } from "lucide-react";
import { GitHubIcon } from "./Icons";
import {
buildGitActionProgressStages,
buildMenuItems,
type GitActionIconName,
type GitActionMenuItem,
@@ -135,6 +134,26 @@ function GitQuickActionIcon({ quickAction }: { quickAction: GitQuickAction }) {
return <InfoIcon className={iconClassName} />;
}
function buildGitActionProgressStages(input: {
action: GitStackedAction;
hasCustomCommitMessage: boolean;
hasWorkingTreeChanges: boolean;
}): string[] {
const shouldIncludeCommitStages = input.action === "commit" || input.hasWorkingTreeChanges;
const commitStages = !shouldIncludeCommitStages
? []
: input.hasCustomCommitMessage
? ["Committing..."]
: ["Generating commit message...", "Committing..."];
if (input.action === "commit") {
return commitStages;
}
if (input.action === "commit_push") {
return [...commitStages, "Pushing..."];
}
return [...commitStages, "Pushing...", "Creating PR..."];
}
export default function GitActionsControl({ api, gitCwd }: GitActionsControlProps) {
const queryClient = useQueryClient();
const [activeDialogAction, setActiveDialogAction] = useState<GitDialogAction | null>(null);
@@ -211,28 +230,14 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
}, [api, gitStatus?.openPr?.url]);
const runGitActionWithToast = useCallback(
async ({
action,
commitMessage,
forcePushOnlyProgress = false,
onConfirmed,
}: {
action: GitStackedAction;
commitMessage?: string;
forcePushOnlyProgress?: boolean;
onConfirmed?: () => void;
}) => {
async ({ action, commitMessage }: { action: GitStackedAction; commitMessage?: string }) => {
const confirmed = await maybeConfirmPushToDefaultBranch(action);
if (!confirmed) return;
onConfirmed?.();
const pushTarget = gitStatus?.branch ? `origin/${gitStatus.branch}` : undefined;
const progressStages = buildGitActionProgressStages({
action,
hasCustomCommitMessage: !!commitMessage?.trim(),
hasWorkingTreeChanges: !!gitStatus?.hasWorkingTreeChanges,
forcePushOnly: forcePushOnlyProgress,
...(pushTarget ? { pushTarget } : {}),
});
const progressToastId = toastManager.add({
type: "loading",
@@ -267,9 +272,9 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
const prUrl = result.pr.url ?? gitStatus?.openPr?.url;
const shouldOfferPushCta = action === "commit" && result.commit.status === "created";
const shouldOfferOpenPrCta =
(action === "commit_push" || action === "commit_push_pr") && !!prUrl && !isDefaultBranch;
(action === "commit_push" || action === "commit_push_pr") && !!prUrl;
const shouldOfferCreatePrCta =
action === "commit_push" && !prUrl && result.push.status === "pushed" && !isDefaultBranch;
action === "commit_push" && !prUrl && result.push.status === "pushed";
const closeResultToast = () => {
toastManager.close(progressToastId);
};
@@ -284,11 +289,8 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
actionProps: {
children: "Push",
onClick: () => {
void runGitActionWithToast({
action: "commit_push",
forcePushOnlyProgress: true,
onConfirmed: closeResultToast,
});
closeResultToast();
void runGitActionWithToast({ action: "commit_push" });
},
},
}
@@ -325,10 +327,8 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
},
[
api,
gitStatus?.branch,
gitStatus?.hasWorkingTreeChanges,
gitStatus?.openPr?.url,
isDefaultBranch,
maybeConfirmPushToDefaultBranch,
runImmediateGitActionMutation,
setActiveDialogAction,
@@ -380,7 +380,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
return;
}
if (item.dialogAction === "push") {
void runGitActionWithToast({ action: "commit_push", forcePushOnlyProgress: true });
void runGitActionWithToast({ action: "commit_push" });
return;
}
if (item.dialogAction) {
@@ -399,12 +399,10 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
? "commit_push"
: "commit_push_pr";
const commitMessage = activeDialogAction === "commit" ? dialogCommitMessage.trim() : "";
const forcePushOnlyProgress = activeDialogAction === "push";
setActiveDialogAction(null);
void runGitActionWithToast({
action,
...(commitMessage ? { commitMessage } : {}),
...(forcePushOnlyProgress ? { forcePushOnlyProgress } : {}),
});
}, [activeDialogAction, dialogCommitMessage, runGitActionWithToast]);
@@ -450,10 +448,10 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
openOnHover
render={
<Button
aria-disabled="true"
className="cursor-not-allowed rounded-e-none border-e-0 opacity-64 before:rounded-e-none"
size="xs"
variant="outline"
size="xs"
disabled={isGitActionRunning || quickAction.disabled}
className="cursor-not-allowed disabled:cursor-not-allowed disabled:pointer-events-auto"
/>
}
>
@@ -487,7 +485,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
>
<ChevronDownIcon aria-hidden="true" className="size-4" />
</MenuTrigger>
<MenuPopup align="end" className="w-full">
<MenuPopup align="end" sideOffset={4}>
{gitActionMenuItems.map((item) => {
const disabledReason = getMenuActionDisabledReason(
item,
@@ -499,10 +497,9 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
<Popover key={`${item.id}-${item.label}`}>
<PopoverTrigger
openOnHover
nativeButton={false}
render={<span className="block w-max cursor-not-allowed" />}
render={<span className="inline-flex w-full cursor-not-allowed" />}
>
<MenuItem className="w-full" disabled>
<MenuItem disabled>
<GitActionItemIcon icon={item.icon} />
{item.label}
</MenuItem>
+2 -6
View File
@@ -1,6 +1,5 @@
import { MonitorIcon, MoonIcon, SunIcon, TerminalIcon } from "lucide-react";
import { useCallback, useEffect, useMemo, useState } from "react";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { isElectron } from "../env";
import { useTheme } from "../hooks/useTheme";
import { DEFAULT_MODEL } from "../model-logic";
@@ -13,7 +12,6 @@ import {
type Thread,
} from "../types";
import { useNativeApi } from "../hooks/useNativeApi";
import { gitRemoveWorktreeMutationOptions } from "../lib/gitReactQuery";
import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "../worktreeCleanup";
const THEME_CYCLE = { system: "light", light: "dark", dark: "system" } as const;
@@ -112,8 +110,6 @@ function terminalStatusIndicator(thread: Thread): TerminalStatusIndicator | null
export default function Sidebar() {
const { state, dispatch } = useStore();
const api = useNativeApi();
const queryClient = useQueryClient();
const removeWorktreeMutation = useMutation(gitRemoveWorktreeMutationOptions({ api, queryClient }));
const { theme, setTheme } = useTheme();
const [addingProject, setAddingProject] = useState(false);
const [newCwd, setNewCwd] = useState("");
@@ -311,7 +307,7 @@ export default function Sidebar() {
}
try {
await removeWorktreeMutation.mutateAsync({
await api.git.removeWorktree({
cwd: threadProject.cwd,
path: orphanedWorktreePath,
});
@@ -319,7 +315,7 @@ export default function Sidebar() {
// Worktree deletion is best-effort and should not block thread deletion.
}
},
[api, dispatch, removeWorktreeMutation, state.projects, state.threads],
[api, dispatch, state.projects, state.threads],
);
useEffect(() => {
+2 -44
View File
@@ -108,7 +108,7 @@ export function gitRunStackedActionMutationOptions(input: {
...(commitMessage ? { commitMessage } : {}),
});
},
onSettled: async () => {
onSuccess: async () => {
await invalidateGitQueries(input.queryClient);
},
});
@@ -124,49 +124,7 @@ export function gitPullMutationOptions(input: {
if (!input.api || !input.cwd) throw new Error("Git pull is unavailable.");
return input.api.git.pull({ cwd: input.cwd });
},
onSettled: async () => {
await invalidateGitQueries(input.queryClient);
},
});
}
export function gitCreateWorktreeMutationOptions(input: {
api: NativeApi | undefined;
queryClient: QueryClient;
}) {
return mutationOptions({
mutationFn: async ({
cwd,
branch,
newBranch,
}: {
cwd: string;
branch: string;
newBranch: string;
}) => {
if (!input.api) {
throw new Error("Git worktree creation is unavailable.");
}
return input.api.git.createWorktree({ cwd, branch, newBranch });
},
onSettled: async () => {
await invalidateGitQueries(input.queryClient);
},
});
}
export function gitRemoveWorktreeMutationOptions(input: {
api: NativeApi | undefined;
queryClient: QueryClient;
}) {
return mutationOptions({
mutationFn: async ({ cwd, path }: { cwd: string; path: string }) => {
if (!input.api) {
throw new Error("Git worktree removal is unavailable.");
}
return input.api.git.removeWorktree({ cwd, path });
},
onSettled: async () => {
onSuccess: async () => {
await invalidateGitQueries(input.queryClient);
},
});
+2 -3
View File
@@ -269,7 +269,6 @@ function closeThreadTerminal(thread: Thread, terminalId: string): Thread {
const remainingTerminalIds = thread.terminalIds.filter((id) => id !== terminalId);
if (remainingTerminalIds.length === 0) {
const nextTerminalGroupId = fallbackGroupId(DEFAULT_THREAD_TERMINAL_ID);
return normalizeThreadTerminals({
...thread,
terminalOpen: false,
@@ -278,11 +277,11 @@ function closeThreadTerminal(thread: Thread, terminalId: string): Thread {
activeTerminalId: DEFAULT_THREAD_TERMINAL_ID,
terminalGroups: [
{
id: nextTerminalGroupId,
id: fallbackGroupId(DEFAULT_THREAD_TERMINAL_ID),
terminalIds: [DEFAULT_THREAD_TERMINAL_ID],
},
],
activeTerminalGroupId: nextTerminalGroupId,
activeTerminalGroupId: fallbackGroupId(DEFAULT_THREAD_TERMINAL_ID),
});
}