Skip to content

Commit 42a9ecb

Browse files
committed
fix(mobile): use live git status for the workspace badge
Count each staged or unstaged path once, including edits that cancel against HEAD. Reuse the existing status subscription instead of loading and parsing another full diff.
1 parent 5e9100d commit 42a9ecb

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

‎apps/mobile/src/features/workspace/ThreadWorkspaceScreen.tsx‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { resolveFilesystemReadAccess } from "@t3tools/client-runtime/state/filesystem";
22
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
33
import type { StaticScreenProps } from "@react-navigation/native";
4-
import { useMemo, useState } from "react";
4+
import { useState } from "react";
55
import { View } from "react-native";
66
import { SegmentedControl } from "../../components/SegmentedControl";
77
import { useEnvironmentQuery } from "../../state/query";
88
import { useEnvironmentPresentation } from "../../state/presentation";
9-
import { reviewEnvironment } from "../../state/review";
9+
import { vcsEnvironment } from "../../state/vcs";
1010
import { environmentSession } from "../../state/session";
1111
import { useSelectedThreadWorktree } from "../../state/use-selected-thread-worktree";
1212
import { ThreadFilesTreeScreen, ThreadFileScreen } from "../files/ThreadFilesRouteScreen";
1313
import { ReviewSheet } from "../review/ReviewSheet";
14-
import { getCachedReviewParsedDiff } from "../review/reviewState";
1514

1615
type Props = StaticScreenProps<{
1716
readonly environmentId: string;
@@ -35,22 +34,14 @@ function ThreadWorkspaceScreen(props: Props & { readonly initialTab: "files" | "
3534
session: session.data,
3635
sessionError: session.error,
3736
});
38-
const preview = useEnvironmentQuery(
37+
const status = useEnvironmentQuery(
3938
access.canReadFiles && cwd !== null
40-
? reviewEnvironment.diffPreview({ environmentId, input: { cwd } })
39+
? vcsEnvironment.status({ environmentId, input: { cwd } })
4140
: null,
4241
);
43-
const source = preview.data?.sources.find((item) => item.kind === "working-tree");
44-
const count = useMemo(() => {
45-
if (!source) return undefined;
46-
if (source.files) return source.files.length;
47-
const parsed = getCachedReviewParsedDiff({
48-
threadKey: `${environmentId}:${threadId}`,
49-
sectionId: "working-tree",
50-
diff: source.diff,
51-
});
52-
return parsed.kind === "files" ? parsed.files.length : 0;
53-
}, [environmentId, threadId, source]);
42+
// Status counts each changed path once, including edits that cancel between
43+
// the index and working tree, and updates through the existing Git subscription.
44+
const count = status.data?.workingTree?.files.length;
5445
const tabs = (
5546
<View className="border-b border-border-subtle bg-sheet px-3 py-2">
5647
<SegmentedControl

0 commit comments

Comments
 (0)