@@ -86,6 +86,9 @@ import type {
8686 SuggestedReviewersArtefact ,
8787 SuggestedReviewerWriteEntry ,
8888 Task ,
89+ TaskActivityMarkReadResult ,
90+ TaskActivityPage ,
91+ TaskActivityReadMarker ,
8992 TaskChannel ,
9093 TaskMention ,
9194 TaskRun ,
@@ -2506,6 +2509,53 @@ export class PostHogAPIClient {
25062509 return ( await response . json ( ) ) as TaskMention [ ] ;
25072510 }
25082511
2512+ // Tasks the current user is involved in (created, mentioned, or messaged),
2513+ // one row per task, newest activity first.
2514+ async getTaskActivity ( options ?: {
2515+ before ?: string ;
2516+ beforeId ?: string ;
2517+ } ) : Promise < TaskActivityPage > {
2518+ const teamId = await this . getTeamId ( ) ;
2519+ const urlPath = `/api/projects/${ teamId } /task_activity/` ;
2520+ const url = new URL ( `${ this . api . baseUrl } ${ urlPath } ` ) ;
2521+ if ( options ?. before && options . beforeId ) {
2522+ url . searchParams . set ( "before" , options . before ) ;
2523+ url . searchParams . set ( "before_id" , options . beforeId ) ;
2524+ }
2525+ const response = await this . api . fetcher . fetch ( {
2526+ method : "get" ,
2527+ url,
2528+ path : urlPath ,
2529+ } ) ;
2530+ if ( ! response . ok ) {
2531+ throw new Error ( `Failed to fetch task activity: ${ response . statusText } ` ) ;
2532+ }
2533+ return ( await response . json ( ) ) as TaskActivityPage ;
2534+ }
2535+
2536+ // Read state is per task, so callers name the tasks the user has seen rather than
2537+ // clearing the whole feed.
2538+ async markTaskActivityRead (
2539+ activities : TaskActivityReadMarker [ ] ,
2540+ ) : Promise < TaskActivityMarkReadResult > {
2541+ const teamId = await this . getTeamId ( ) ;
2542+ const urlPath = `/api/projects/${ teamId } /task_activity/mark_read/` ;
2543+ const response = await this . api . fetcher . fetch ( {
2544+ method : "post" ,
2545+ url : new URL ( `${ this . api . baseUrl } ${ urlPath } ` ) ,
2546+ path : urlPath ,
2547+ overrides : {
2548+ body : JSON . stringify ( { activities } ) ,
2549+ } ,
2550+ } ) ;
2551+ if ( ! response . ok ) {
2552+ throw new Error (
2553+ `Failed to mark task activity read: ${ response . statusText } ` ,
2554+ ) ;
2555+ }
2556+ return ( await response . json ( ) ) as TaskActivityMarkReadResult ;
2557+ }
2558+
25092559 async getTaskThreadMessages ( taskId : string ) : Promise < TaskThreadMessage [ ] > {
25102560 const teamId = await this . getTeamId ( ) ;
25112561 const urlPath = `/api/projects/${ teamId } /tasks/${ taskId } /thread_messages/` ;
0 commit comments