@@ -1639,7 +1639,7 @@ test("opening a session from the inbox keeps the list's scroll position and rows
16391639 id : `ses_inbox_${ String ( index ) . padStart ( 2 , "0" ) } ` ,
16401640 title : `Inbox session ${ index } ` ,
16411641 directory : index === 14 ? "C:/OpenCode/Inbox/worktrees/unopened" : "C:/OpenCode/Inbox" ,
1642- time : { created : T0 , updated : T0 + 100 - index , idle : T0 + index } ,
1642+ time : { created : T0 , updated : T0 + 100 - index , idle : T0 + index , viewed : T0 + 100 } ,
16431643 } ) )
16441644
16451645 await mockWorkspace ( page , {
@@ -1774,13 +1774,21 @@ test("sessions opened from Home and Search get a temporary Current session row w
17741774 await mockWorkspace ( page , {
17751775 name : "CurrentInbox" ,
17761776 sessions : [
1777- { id : "ses_current_home" , title : "Older Home session" , time : { created : T0 , updated : T0 , idle : T0 } } ,
1778- { id : "ses_current_search" , title : "Older Search session" , time : { created : T0 , updated : T0 , idle : T0 } } ,
1779- { id : "ses_current_recent" , title : "Recent inbox session" , time : { created : T0 , updated : T0 + 2 , idle : T0 + 2 } } ,
1777+ { id : "ses_current_home" , title : "Older Home session" , time : { created : T0 , updated : T0 , idle : T0 , viewed : T0 } } ,
1778+ {
1779+ id : "ses_current_search" ,
1780+ title : "Older Search session" ,
1781+ time : { created : T0 , updated : T0 , idle : T0 , viewed : T0 } ,
1782+ } ,
1783+ {
1784+ id : "ses_current_recent" ,
1785+ title : "Recent inbox session" ,
1786+ time : { created : T0 , updated : T0 + 2 , idle : T0 + 2 , viewed : T0 + 2 } ,
1787+ } ,
17801788 ...Array . from ( { length : 9 } , ( _ , index ) => ( {
17811789 id : `ses_current_extra_${ index } ` ,
17821790 title : `Other recent session ${ index } ` ,
1783- time : { created : T0 , updated : T0 + 3 + index , idle : T0 + 3 + index } ,
1791+ time : { created : T0 , updated : T0 + 3 + index , idle : T0 + 3 + index , viewed : T0 + 3 + index } ,
17841792 } ) ) ,
17851793 ] ,
17861794 seed : {
@@ -1823,3 +1831,136 @@ test("sessions opened from Home and Search get a temporary Current session row w
18231831 await expectPath ( page , "/" )
18241832 await expect ( rows ) . toHaveCount ( 10 )
18251833} )
1834+
1835+ test ( "the inbox keeps every unread result separate from expandable Recent, including never-run sessions" , async ( {
1836+ page,
1837+ } ) => {
1838+ await mockWorkspace ( page , {
1839+ name : "InboxSections" ,
1840+ sessions : [
1841+ ...Array . from ( { length : 12 } , ( _ , index ) => ( {
1842+ id : `ses_unread_${ index } ` ,
1843+ title : `Unread result ${ index } ` ,
1844+ outcome : index === 0 ? "failed" : "succeeded" ,
1845+ time : { created : T0 , updated : T0 + index , idle : T0 + index } ,
1846+ } ) ) ,
1847+ ...Array . from ( { length : 12 } , ( _ , index ) => ( {
1848+ id : `ses_read_${ index } ` ,
1849+ title : index === 0 ? "Never-run session" : `Read session ${ index } ` ,
1850+ time : { created : T0 , updated : T0 + 100 - index , idle : index ? T0 + 100 - index : undefined , viewed : T0 + 200 } ,
1851+ } ) ) ,
1852+ ] ,
1853+ seed : { settings : { appearance : { tabLayout : "inbox" } } , tabs : [ ] } ,
1854+ } )
1855+ await page . goto ( "/" )
1856+
1857+ const inbox = page . locator ( '[data-slot="sidebar-inbox"]' )
1858+
1859+ const unread = inbox . getByRole ( "group" , { name : "Unread" , exact : true } ) . locator ( '[data-slot="sidebar-inbox-item"]' )
1860+
1861+ const recent = inbox . getByRole ( "group" , { name : "Recent" , exact : true } ) . locator ( '[data-slot="sidebar-inbox-item"]' )
1862+
1863+ await expect ( unread ) . toContainText ( Array . from ( { length : 12 } , ( _ , index ) => `Unread result ${ 11 - index } ` ) )
1864+ await expect ( unread . filter ( { hasText : "Unread result 0" } ) ) . toHaveAttribute ( "data-status" , "failed" )
1865+ await expect ( recent ) . toContainText ( [
1866+ "Never-run session" ,
1867+ ...Array . from ( { length : 9 } , ( _ , index ) => `Read session ${ index + 1 } ` ) ,
1868+ ] )
1869+ await expect ( recent ) . toHaveCount ( 10 )
1870+ await expect ( inbox . locator ( '[data-slot="sidebar-inbox-item"][tabindex="0"]' ) ) . toHaveCount ( 1 )
1871+
1872+ await unread . filter ( { hasText : "Unread result 11" } ) . focus ( )
1873+ await page . keyboard . press ( "ArrowDown" )
1874+ await expect ( unread . filter ( { hasText : "Unread result 10" } ) ) . toBeFocused ( )
1875+ await page . keyboard . press ( "End" )
1876+ await expect ( recent . filter ( { hasText : "Read session 9" } ) ) . toBeFocused ( )
1877+ await page . keyboard . press ( "Home" )
1878+ await expect ( unread . filter ( { hasText : "Unread result 11" } ) ) . toBeFocused ( )
1879+
1880+ await inbox . getByRole ( "button" , { name : "Show more" , exact : true } ) . click ( )
1881+ await expect ( recent ) . toHaveCount ( 12 )
1882+ await expect ( recent . filter ( { hasText : "Read session 11" } ) ) . toHaveCount ( 1 )
1883+ await expect ( unread ) . toHaveCount ( 12 )
1884+ await page . reload ( )
1885+ await expect ( recent ) . toHaveCount ( 12 )
1886+ await inbox . getByRole ( "button" , { name : "Show less" , exact : true } ) . click ( )
1887+ await expect ( recent ) . toHaveCount ( 10 )
1888+ await expect ( unread ) . toHaveCount ( 12 )
1889+ } )
1890+
1891+ test ( "the inbox waits for initial requests and orders attention by waiting age rather than last update" , async ( {
1892+ page,
1893+ } ) => {
1894+ await page . clock . install ( { time : T0 + 10 * 60_000 } )
1895+
1896+ const workspace = await mockWorkspace ( page , {
1897+ name : "InboxWaiting" ,
1898+ sessions : [
1899+ {
1900+ id : "ses_waiting_old" ,
1901+ title : "Oldest waiting session" ,
1902+ time : { created : T0 , updated : T0 + 60_000 , busy : T0 } ,
1903+ } ,
1904+ {
1905+ id : "ses_waiting_new" ,
1906+ title : "Newer waiting session" ,
1907+ time : { created : T0 , updated : T0 + 9 * 60_000 , busy : T0 + 5 * 60_000 } ,
1908+ } ,
1909+ {
1910+ id : "ses_waiting_live" ,
1911+ title : "New live question" ,
1912+ time : { created : T0 , updated : T0 + 2 * 60_000 , busy : T0 + 60_000 } ,
1913+ } ,
1914+ ] ,
1915+ sessionStatus : {
1916+ ses_waiting_old : { type : "running" } ,
1917+ ses_waiting_new : { type : "running" } ,
1918+ ses_waiting_live : { type : "running" } ,
1919+ } ,
1920+ sessionPermissions : {
1921+ ses_waiting_old : [ { id : "perm_inbox_old" , sessionID : "ses_waiting_old" , action : "shell" , resources : [ "build" ] } ] ,
1922+ ses_waiting_new : [ { id : "perm_inbox_new" , sessionID : "ses_waiting_new" , action : "shell" , resources : [ "test" ] } ] ,
1923+ } ,
1924+ seed : { settings : { appearance : { tabLayout : "inbox" } } , tabs : [ ] } ,
1925+ } )
1926+
1927+ const pending = await holdRoute ( page , / \/ a p i \/ s e s s i o n \/ s e s _ w a i t i n g _ o l d \/ p e r m i s s i o n (?: \? | $ ) / )
1928+
1929+ await page . goto ( "/" )
1930+ await pending . arrived
1931+
1932+ const inbox = page . locator ( '[data-slot="sidebar-inbox"]' )
1933+
1934+ await expect ( inbox ) . toHaveAttribute ( "aria-busy" , "true" )
1935+ await expect ( inbox . getByText ( "Sessions you work on will appear here" , { exact : true } ) ) . toHaveCount ( 0 )
1936+ pending . release ( )
1937+
1938+ const needs = inbox
1939+ . getByRole ( "group" , { name : "Needs attention" , exact : true } )
1940+ . locator ( '[data-slot="sidebar-inbox-item"]' )
1941+
1942+ await expect ( needs ) . toContainText ( [ "Oldest waiting session" , "Newer waiting session" ] )
1943+ await expect ( inbox ) . toHaveAttribute ( "aria-busy" , "false" )
1944+ await expect ( inbox . getByRole ( "status" ) ) . toBeEmpty ( )
1945+ workspace . push ( [
1946+ {
1947+ id : "evt_inbox_question" ,
1948+ type : "form.created" ,
1949+ created : T0 + 8 * 60_000 ,
1950+ location : { directory : workspace . directory } ,
1951+ data : {
1952+ form : {
1953+ id : "form_inbox_question" ,
1954+ sessionID : "ses_waiting_live" ,
1955+ title : "Choose a library" ,
1956+ metadata : { kind : "question" } ,
1957+ fields : [ { key : "library" , type : "string" , title : "Library" } ] ,
1958+ } ,
1959+ } ,
1960+ } satisfies Extract < OpenCodeEvent , { type : "form.created" } > ,
1961+ ] )
1962+ await expect ( needs ) . toContainText ( [ "Oldest waiting session" , "Newer waiting session" , "New live question" ] )
1963+ await expect ( needs . filter ( { hasText : "New live question" } ) ) . toContainText ( "2m" )
1964+ await expect ( inbox . getByRole ( "status" ) ) . toHaveText ( "New live question has a question." )
1965+ await expect ( inbox . getByRole ( "status" ) ) . toHaveCount ( 1 )
1966+ } )
0 commit comments