Skip to content

Commit 8fefabf

Browse files
committed
some more qol
1 parent a05b7df commit 8fefabf

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

apps/twig/src/renderer/features/sidebar/components/HistoryView.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ function HistoryTaskItem({
5959
worktreeName={workspace?.worktreeName ?? undefined}
6060
worktreePath={workspace?.worktreePath ?? workspace?.folderPath}
6161
workspaceMode={taskState?.workspaceMode}
62+
mainRepoPath={workspace?.folderPath}
63+
branchName={workspace?.branchName ?? undefined}
6264
lastActivityAt={task.lastActivityAt}
6365
isGenerating={task.isGenerating}
6466
isUnread={task.isUnread}
@@ -102,6 +104,8 @@ function PinnedTaskItem({
102104
worktreeName={workspace?.worktreeName ?? undefined}
103105
worktreePath={workspace?.worktreePath ?? workspace?.folderPath}
104106
workspaceMode={taskState?.workspaceMode}
107+
mainRepoPath={workspace?.folderPath}
108+
branchName={workspace?.branchName ?? undefined}
105109
lastActivityAt={task.lastActivityAt}
106110
isGenerating={task.isGenerating}
107111
isUnread={task.isUnread}

apps/twig/src/renderer/features/sidebar/components/items/TaskItem.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,29 @@ function useCurrentBranch(repoPath?: string, worktreeName?: string) {
2828
});
2929
}
3030

31+
function useMainRepoBranch(mainRepoPath?: string) {
32+
return useQuery({
33+
queryKey: ["main-repo-branch", mainRepoPath],
34+
queryFn: () => {
35+
if (!mainRepoPath) throw new Error("mainRepoPath is required");
36+
return trpcVanilla.git.getCurrentBranch.query({
37+
directoryPath: mainRepoPath,
38+
});
39+
},
40+
enabled: !!mainRepoPath,
41+
staleTime: 0,
42+
});
43+
}
44+
3145
interface TaskItemProps {
3246
id: string;
3347
label: string;
3448
isActive: boolean;
3549
worktreeName?: string;
3650
worktreePath?: string;
3751
workspaceMode?: WorkspaceMode;
52+
mainRepoPath?: string;
53+
branchName?: string;
3854
lastActivityAt?: number;
3955
isGenerating?: boolean;
4056
isUnread?: boolean;
@@ -135,6 +151,8 @@ export function TaskItem({
135151
worktreeName,
136152
worktreePath,
137153
workspaceMode,
154+
mainRepoPath,
155+
branchName,
138156
lastActivityAt,
139157
isGenerating,
140158
isUnread,
@@ -145,8 +163,10 @@ export function TaskItem({
145163
onTogglePin,
146164
}: TaskItemProps) {
147165
const { data: currentBranch } = useCurrentBranch(worktreePath, worktreeName);
166+
const { data: mainRepoBranch } = useMainRepoBranch(mainRepoPath);
148167

149168
const isCloudTask = workspaceMode === "cloud";
169+
const isWatching = !!(branchName && mainRepoBranch === branchName);
150170

151171
const activityText = isGenerating
152172
? "Generating..."
@@ -159,6 +179,8 @@ export function TaskItem({
159179
<Cloud size={10} />
160180
<span>Cloud</span>
161181
</span>
182+
) : isWatching ? (
183+
<span style={{ color: "var(--blue-11)" }}>Watching</span>
162184
) : (
163185
(worktreeName ?? currentBranch)
164186
);
@@ -181,7 +203,7 @@ export function TaskItem({
181203
) : isPinned ? (
182204
<PushPin size={12} className="text-accent-11" />
183205
) : (
184-
<GitBranchIcon size={12} />
206+
<GitBranchIcon size={12} className={isWatching ? "text-blue-11" : ""} />
185207
);
186208

187209
const endContent = useMemo(

apps/twig/src/renderer/features/workspace/components/FocusWorkspaceButton.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CrosshairIcon, CrosshairSimpleIcon } from "@phosphor-icons/react";
22
import { Button, Spinner, Text, Tooltip } from "@radix-ui/themes";
33
import { trpcReact } from "@renderer/trpc";
4+
import { useQueryClient } from "@tanstack/react-query";
45
import { toast } from "@utils/toast";
56
import { useCallback } from "react";
67
import { selectWorkspace, useWorkspaceStore } from "../stores/workspaceStore";
@@ -12,6 +13,7 @@ interface FocusWorkspaceButtonProps {
1213
export function FocusWorkspaceButton({ taskId }: FocusWorkspaceButtonProps) {
1314
const workspace = useWorkspaceStore(selectWorkspace(taskId));
1415
const utils = trpcReact.useUtils();
16+
const queryClient = useQueryClient();
1517

1618
// Query current branch of main repo - this is the source of truth
1719
const { data: currentBranch, isLoading: isBranchLoading } =
@@ -23,6 +25,7 @@ export function FocusWorkspaceButton({ taskId }: FocusWorkspaceButtonProps) {
2325
const enableFocus = trpcReact.focus.enable.useMutation({
2426
onSuccess: (result) => {
2527
utils.git.getCurrentBranch.invalidate();
28+
queryClient.invalidateQueries({ queryKey: ["main-repo-branch"] });
2629
if (result.success) {
2730
toast.success(
2831
<>
@@ -53,6 +56,7 @@ export function FocusWorkspaceButton({ taskId }: FocusWorkspaceButtonProps) {
5356
const disableFocus = trpcReact.focus.disable.useMutation({
5457
onSuccess: (result) => {
5558
utils.git.getCurrentBranch.invalidate();
59+
queryClient.invalidateQueries({ queryKey: ["main-repo-branch"] });
5660
if (result.success) {
5761
toast.success(
5862
<>

0 commit comments

Comments
 (0)