@@ -31,14 +31,18 @@ function compactThinValue(value: unknown): unknown {
3131 return value ;
3232}
3333
34+ function displayItems ( items : unknown [ ] , hideDone : boolean ) : unknown [ ] {
35+ return hideDone ? items . filter ( row => ! dict ( row ) || row . status !== "done" ) : items ;
36+ }
37+
3438export function compactTodoReadSummary ( summary : JsonObject , role : string , limit : number | null ) : JsonObject {
3539 const result : JsonObject = { } , lanes : JsonObject = { } ;
3640 let omittedLanes = 0 , omittedDicts = 0 ;
3741 for ( const [ key , value ] of Object . entries ( summary ) ) {
3842 if ( Array . isArray ( value ) ) {
3943 const cap = limit ?? ( layout . _RETAINED_LANE_LIMITS as Record < string , number > ) [ key ] ;
4044 if ( cap === undefined ) { omittedLanes += Number ( nonempty ( value ) ) ; continue ; }
41- const retained = limit === null && key === "items" ? value . filter ( row => ! dict ( row ) || row . status !== "done" ) : value ;
45+ const retained = displayItems ( value , limit === null && key === "items" ) ;
4246 result [ key ] = retained . slice ( 0 , cap ) . map ( row => compactItem ( row ) ) ;
4347 if ( retained . length > cap ) lanes [ key ] = { shown : cap , total : retained . length } ;
4448 } else if ( dict ( value ) ) {
@@ -114,3 +118,36 @@ export function compactThinTodoReadSummary(summary: JsonObject, details: {
114118 omitted_nonempty_dict_count : omittedDicts , full_detail_cold_path : "todo list without --thin or active state" } ;
115119 return fields ;
116120}
121+
122+ /** An opt-in queue overview; selection, full requirements and admission stay upstream. */
123+ export function compactTodoQueueSummary ( payload : JsonObject , hot : boolean ) : JsonObject {
124+ const limit = Math . min ( 8 , typeof payload . explicit_limit === "number" ? payload . explicit_limit : 8 ) ;
125+ const projection = dict ( payload . todo_list_projection ) ? payload . todo_list_projection : { } ;
126+ const matched = Number ( projection . matched_todo_count ?? payload . todo_count ?? 0 ) ;
127+ const todos : JsonObject [ ] = [ ] ;
128+ for ( const role of [ "user" , "agent" ] ) {
129+ const group = payload [ `${ role } _todos` ] ;
130+ if ( ! dict ( group ) || ! Array . isArray ( group . items ) ) continue ;
131+ for ( const row of displayItems ( group . items , hot ) . filter ( dict ) . slice ( 0 , limit ) ) {
132+ const full = stripPythonWhitespace ( String ( row . title || row . text || "" ) ) ;
133+ todos . push ( { todo_id : row . todo_id , role, title : compactText ( full ) , status : row . status ,
134+ priority : row . priority ?? null , claimed_by : row . claimed_by ?? null ,
135+ title_truncated : Array . from ( full ) . length > 180 } ) ;
136+ }
137+ }
138+ const authority = dict ( payload . authority_read ) ? payload . authority_read : { } ;
139+ return { ok : payload . ok , dry_run : payload . dry_run , read_only : payload . read_only ,
140+ command : payload . command , goal_id : payload . goal_id , role : payload . role ,
141+ status_filter : payload . status_filter , source : payload . source ,
142+ ...( payload . agent_id_filter === undefined ? { } : { agent_id_filter : payload . agent_id_filter } ) ,
143+ ...( payload . unfiltered_todo_count === undefined ? { } : { unfiltered_todo_count : payload . unfiltered_todo_count } ) ,
144+ todo_count : matched , matched_todo_count : matched , returned_todo_count : todos . length ,
145+ omitted_todo_count : Math . max ( 0 , matched - todos . length ) , summary : true , todos,
146+ authority_read : { source_authority : authority . source_authority , provider_revision : authority . provider_revision ,
147+ cursor : authority . cursor , decision_read_from_provider : authority . decision_read_from_provider ,
148+ legacy_fallback_used : authority . legacy_fallback_used } ,
149+ todo_list_summary_projection : { schema_version : "todo_list_summary_v0" , item_limit_per_role : limit ,
150+ item_text_limit : 180 , counts_cover_full_match : true ,
151+ full_detail_cold_paths : [ "todo list --goal-id <goal-id> --todo-id <todo-id>" , "todo list without --summary" ] ,
152+ readback : "Queue overview only. Read the exact Todo for complete requirements; quota owns execution admission." } } ;
153+ }
0 commit comments