99} from "@features/workspace/stores/workspaceStore" ;
1010import { Box } from "@radix-ui/themes" ;
1111import { logger } from "@renderer/lib/logger" ;
12+ import { useNavigationStore } from "@renderer/stores/navigationStore" ;
1213import type { Task } from "@shared/types" ;
1314import { 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