@@ -44,6 +44,7 @@ export interface TaskData {
4444 isGenerating ?: boolean ;
4545 isUnread ?: boolean ;
4646 isPinned ?: boolean ;
47+ needsPermission ?: boolean ;
4748}
4849
4950export interface HistoryTaskData extends TaskData {
@@ -196,7 +197,7 @@ function buildHistoryData(
196197 lastViewedAt : Record < string , number > ,
197198 localActivityAt : Record < string , number > ,
198199 pinnedTaskIds : Set < string > ,
199- activeTaskId : string | null ,
200+ _activeTaskId : string | null ,
200201 visibleCount : number ,
201202) : HistoryData {
202203 const getSessionForTask = ( taskId : string ) : AgentSession | undefined => {
@@ -218,11 +219,8 @@ function buildHistoryData(
218219 : apiUpdatedAt ;
219220
220221 const taskLastViewedAt = lastViewedAt [ task . id ] ;
221- const isCurrentlyViewing = activeTaskId === task . id ;
222222 const isUnread =
223- ! isCurrentlyViewing &&
224- taskLastViewedAt !== undefined &&
225- lastActivityAt > taskLastViewedAt ;
223+ taskLastViewedAt !== undefined && lastActivityAt > taskLastViewedAt ;
226224
227225 return {
228226 id : task . id ,
@@ -232,20 +230,21 @@ function buildHistoryData(
232230 isGenerating : session ?. isPromptPending ?? false ,
233231 isUnread,
234232 isPinned : pinnedTaskIds . has ( task . id ) ,
233+ needsPermission : ( session ?. pendingPermissions ?. size ?? 0 ) > 0 ,
235234 folderName : folder ?. name ,
236235 } ;
237236 } ) ;
238237
239238 // Filter out pinned tasks - they will be shown in their own section
240239 const unpinnedTasks = historyTasks . filter ( ( t ) => ! pinnedTaskIds . has ( t . id ) ) ;
241240
242- // Partition into active (unread) and inactive tasks
241+ // Partition into active (unread or needs permission ) and inactive tasks
243242 const activeTasks = unpinnedTasks
244- . filter ( ( t ) => t . isUnread )
243+ . filter ( ( t ) => t . isUnread || t . needsPermission )
245244 . sort ( ( a , b ) => ( b . lastActivityAt ?? 0 ) - ( a . lastActivityAt ?? 0 ) ) ;
246245
247246 const inactiveTasks = unpinnedTasks
248- . filter ( ( t ) => ! t . isUnread )
247+ . filter ( ( t ) => ! t . isUnread && ! t . needsPermission )
249248 . sort ( ( a , b ) => b . createdAt - a . createdAt ) ;
250249
251250 // Apply pagination to inactive tasks only (active always shown)
@@ -267,7 +266,7 @@ function buildPinnedData(
267266 lastViewedAt : Record < string , number > ,
268267 localActivityAt : Record < string , number > ,
269268 pinnedTaskIds : Set < string > ,
270- activeTaskId : string | null ,
269+ _activeTaskId : string | null ,
271270) : PinnedData {
272271 const getSessionForTask = ( taskId : string ) : AgentSession | undefined => {
273272 return Object . values ( sessions ) . find ( ( s ) => s . taskId === taskId ) ;
@@ -287,11 +286,8 @@ function buildPinnedData(
287286 : apiUpdatedAt ;
288287
289288 const taskLastViewedAt = lastViewedAt [ task . id ] ;
290- const isCurrentlyViewing = activeTaskId === task . id ;
291289 const isUnread =
292- ! isCurrentlyViewing &&
293- taskLastViewedAt !== undefined &&
294- lastActivityAt > taskLastViewedAt ;
290+ taskLastViewedAt !== undefined && lastActivityAt > taskLastViewedAt ;
295291
296292 return {
297293 id : task . id ,
@@ -300,6 +296,7 @@ function buildPinnedData(
300296 isGenerating : session ?. isPromptPending ?? false ,
301297 isUnread,
302298 isPinned : true ,
299+ needsPermission : ( session ?. pendingPermissions ?. size ?? 0 ) > 0 ,
303300 } ;
304301 } ) ;
305302
@@ -370,7 +367,6 @@ export function useSidebarData({
370367
371368 const tasksWithActivity = folderTasks . map ( ( task ) => {
372369 const session = getSessionForTask ( task . id ) ;
373- // Use max of task.updated_at and local activity timestamp for accurate ordering
374370 const apiUpdatedAt = new Date ( task . updated_at ) . getTime ( ) ;
375371 const localActivity = localActivityAt [ task . id ] ;
376372 const lastActivityAt = localActivity
@@ -382,6 +378,7 @@ export function useSidebarData({
382378 lastActivityAt,
383379 isGenerating : session ?. isPromptPending ?? false ,
384380 isPinned,
381+ needsPermission : ( session ?. pendingPermissions ?. size ?? 0 ) > 0 ,
385382 } ;
386383 } ) ;
387384
@@ -399,12 +396,15 @@ export function useSidebarData({
399396 name : folder . name ,
400397 path : folder . path ,
401398 tasks : tasksWithActivity . map (
402- ( { task, lastActivityAt, isGenerating, isPinned } ) => {
399+ ( {
400+ task,
401+ lastActivityAt,
402+ isGenerating,
403+ isPinned,
404+ needsPermission,
405+ } ) => {
403406 const taskLastViewedAt = lastViewedAt [ task . id ] ;
404- const isCurrentlyViewing = activeTaskId === task . id ;
405- // Only show unread if: user has viewed it before AND there's new activity since
406407 const isUnread =
407- ! isCurrentlyViewing &&
408408 taskLastViewedAt !== undefined &&
409409 lastActivityAt > taskLastViewedAt ;
410410
@@ -415,6 +415,7 @@ export function useSidebarData({
415415 isGenerating,
416416 isUnread,
417417 isPinned,
418+ needsPermission,
418419 } ;
419420 } ,
420421 ) ,
@@ -427,7 +428,6 @@ export function useSidebarData({
427428 localActivityAt ,
428429 pinnedTaskIds ,
429430 lastViewedAt ,
430- activeTaskId ,
431431 ] ) ;
432432
433433 const historyData = useMemo (
0 commit comments