Remove git status refresh on menu open
- Rely on the existing watcher instead of resubscribing when the menu opens - Drop the obsolete refresh helper and its test
This commit is contained in:
1 parent
8b9304ca7c
commit
60b9b6c54f
3 files changed
+2
-38
No files matched your search
@@ -46,7 +46,7 @@ import {
|
||||
gitPullMutationOptions,
|
||||
gitRunStackedActionMutationOptions,
|
||||
} from "~/lib/gitReactQuery";
|
||||
import { refreshGitStatus, useGitStatus } from "~/lib/gitStatusState";
|
||||
import { useGitStatus } from "~/lib/gitStatusState";
|
||||
import { newCommandId, randomUUID } from "~/lib/utils";
|
||||
import { resolvePathLinkTarget } from "~/terminal-links";
|
||||
import { readNativeApi } from "~/nativeApi";
|
||||
@@ -798,11 +798,7 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
|
||||
</Button>
|
||||
)}
|
||||
<GroupSeparator className="hidden @3xl/header-actions:block" />
|
||||
<Menu
|
||||
onOpenChange={(open) => {
|
||||
if (open) refreshGitStatus(gitCwd);
|
||||
}}
|
||||
>
|
||||
<Menu>
|
||||
<MenuTrigger
|
||||
render={<Button aria-label="Git action options" size="icon-xs" variant="outline" />}
|
||||
disabled={isGitActionRunning}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
getGitStatusSnapshot,
|
||||
refreshGitStatus,
|
||||
resetGitStatusStateForTests,
|
||||
watchGitStatus,
|
||||
} from "./gitStatusState";
|
||||
@@ -76,21 +75,4 @@ describe("gitStatusState", () => {
|
||||
releaseB();
|
||||
expect(gitStatusListeners.size).toBe(0);
|
||||
});
|
||||
|
||||
it("restarts the live stream when explicitly refreshed", () => {
|
||||
const release = watchGitStatus("/repo", gitClient);
|
||||
|
||||
emitGitStatus(BASE_STATUS);
|
||||
refreshGitStatus("/repo");
|
||||
|
||||
expect(gitClient.onStatus).toHaveBeenCalledTimes(2);
|
||||
expect(getGitStatusSnapshot("/repo")).toEqual({
|
||||
data: BASE_STATUS,
|
||||
error: null,
|
||||
cause: null,
|
||||
isPending: true,
|
||||
});
|
||||
|
||||
release();
|
||||
});
|
||||
});
|
||||
@@ -76,20 +76,6 @@ export function watchGitStatus(
|
||||
return () => unwatchGitStatus(cwd);
|
||||
}
|
||||
|
||||
export function refreshGitStatus(cwd: string | null): void {
|
||||
if (cwd === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const watched = watchedGitStatuses.get(cwd);
|
||||
if (!watched) {
|
||||
return;
|
||||
}
|
||||
|
||||
watched.unsubscribe();
|
||||
watched.unsubscribe = subscribeToGitStatus(cwd);
|
||||
}
|
||||
|
||||
export function resetGitStatusStateForTests(): void {
|
||||
for (const watched of watchedGitStatuses.values()) {
|
||||
watched.unsubscribe();
|
||||
|
||||
Reference in new issue
Block a user