File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,12 @@ export const SessionListCommand = cmd({
5252 describe : "limit to N most recent sessions" ,
5353 type : "number" ,
5454 } )
55+ . option ( "all" , {
56+ alias : "a" ,
57+ describe : "show sessions from all directories in the project" ,
58+ type : "boolean" ,
59+ default : false ,
60+ } )
5561 . option ( "format" , {
5662 describe : "output format" ,
5763 type : "string" ,
Original file line number Diff line number Diff line change @@ -708,7 +708,8 @@ export namespace Server {
708708 "/session" ,
709709 describeRoute ( {
710710 summary : "List sessions" ,
711- description : "Get a list of all OpenCode sessions, sorted by most recently updated." ,
711+ description :
712+ "Get a list of OpenCode sessions. By default, returns sessions from the current directory. Use ?all=true to include every session in the project." ,
712713 operationId : "session.list" ,
713714 responses : {
714715 200 : {
@@ -729,14 +730,15 @@ export namespace Server {
729730 . optional ( )
730731 . meta ( { description : "Filter sessions updated on or after this timestamp (milliseconds since epoch)" } ) ,
731732 search : z . string ( ) . optional ( ) . meta ( { description : "Filter sessions by title (case-insensitive)" } ) ,
733+ all : z . string ( ) . optional ( ) . meta ( { description : "When 'true', returns all sessions regardless of directory" } ) ,
732734 limit : z . coerce . number ( ) . optional ( ) . meta ( { description : "Maximum number of sessions to return" } ) ,
733735 } ) ,
734736 ) ,
735737 async ( c ) => {
736738 const query = c . req . valid ( "query" )
737739 const term = query . search ?. toLowerCase ( )
738740 const sessions : Session . Info [ ] = [ ]
739- for await ( const session of Session . list ( ) ) {
741+ for await ( const session of Session . list ( { all : query . all === "true" } ) ) {
740742 if ( query . start !== undefined && session . time . updated < query . start ) continue
741743 if ( term !== undefined && ! session . title . toLowerCase ( ) . includes ( term ) ) continue
742744 sessions . push ( session )
Original file line number Diff line number Diff line change @@ -302,10 +302,23 @@ export namespace Session {
302302 } ,
303303 )
304304
305- export async function * list ( ) {
305+ export interface ListOptions {
306+ /**
307+ * When true, returns all sessions for the project regardless of directory.
308+ * When false (default), only returns sessions created in the current directory.
309+ */
310+ all ?: boolean
311+ }
312+
313+ export async function * list ( options ?: ListOptions ) {
306314 const project = Instance . project
315+ const currentDirectory = Instance . directory
307316 for ( const item of await Storage . list ( [ "session" , project . id ] ) ) {
308- yield Storage . read < Info > ( item )
317+ const session = await Storage . read < Info > ( item )
318+ if ( options ?. all !== true && session . directory !== currentDirectory ) {
319+ continue
320+ }
321+ yield session
309322 }
310323 }
311324
You can’t perform that action at this time.
0 commit comments