Skip to content

Commit f9bb507

Browse files
authored
fix: Fix unread notifications marking (#215)
1 parent 54be0a8 commit f9bb507

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

apps/array/src/renderer/features/task-detail/components/TaskLogsPanel.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "@features/workspace/stores/workspaceStore";
1010
import { Box } from "@radix-ui/themes";
1111
import { logger } from "@renderer/lib/logger";
12+
import { useNavigationStore } from "@renderer/stores/navigationStore";
1213
import type { Task } from "@shared/types";
1314
import { useCallback, useEffect, useRef } from "react";
1415

@@ -29,6 +30,7 @@ export function TaskLogsPanel({ taskId, task }: TaskLogsPanelProps) {
2930
const sendPrompt = useSessionStore((state) => state.sendPrompt);
3031
const cancelPrompt = useSessionStore((state) => state.cancelPrompt);
3132
const markActivity = useTaskViewedStore((state) => state.markActivity);
33+
const markAsViewed = useTaskViewedStore((state) => state.markAsViewed);
3234

3335
const isRunning =
3436
session?.status === "connected" || session?.status === "connecting";
@@ -60,14 +62,25 @@ export function TaskLogsPanel({ taskId, task }: TaskLogsPanelProps) {
6062
const handleSendPrompt = useCallback(
6163
async (text: string) => {
6264
try {
63-
markActivity(taskId);
65+
markAsViewed(taskId);
66+
6467
const result = await sendPrompt(taskId, text);
6568
log.info("Prompt completed", { stopReason: result.stopReason });
69+
70+
markActivity(taskId);
71+
72+
// if we are currently viewing this task by the end of the prompt, mark it as viewed
73+
const view = useNavigationStore.getState().view;
74+
const isViewingTask =
75+
view?.type === "task-detail" && view?.data?.id === taskId;
76+
if (isViewingTask) {
77+
markAsViewed(taskId);
78+
}
6679
} catch (error) {
6780
log.error("Failed to send prompt", error);
6881
}
6982
},
70-
[taskId, sendPrompt, markActivity],
83+
[taskId, sendPrompt, markActivity, markAsViewed],
7184
);
7285

7386
const handleCancelPrompt = useCallback(async () => {

0 commit comments

Comments
 (0)