@@ -24,8 +24,7 @@ import { AppText as Text } from "../../components/AppText";
2424import { EmptyState } from "../../components/EmptyState" ;
2525import type { WorkspaceState } from "../../state/workspaceModel" ;
2626import type { SavedRemoteConnection } from "../../lib/connection" ;
27- import { scopedProjectKey , scopedThreadKey } from "../../lib/scopedEntities" ;
28- import { useArchivedThreadSnapshots } from "../archive/useArchivedThreadSnapshots" ;
27+ import { scopedProjectKey } from "../../lib/scopedEntities" ;
2928import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass" ;
3029import { mobilePreferencesAtom , updateMobilePreferencesAtom } from "../../state/preferences" ;
3130import type { PendingNewTask } from "../../state/use-pending-new-tasks" ;
@@ -291,15 +290,9 @@ export function HomeScreen(props: HomeScreenProps) {
291290
292291 // Thread List v2 (beta): one flat list in creation order, no grouping.
293292 // Settled threads collapse into a recency tail below the card block.
294- // Settle = archive in the client-only model, and the live shell stream
295- // drops archived threads — merge them back from the archived snapshot so
296- // they render as the settled tail. Live shells win on overlap.
297- const archivedEnvironmentIds = useMemo (
298- ( ) =>
299- threadListV2Enabled ? props . environments . map ( ( environment ) => environment . environmentId ) : [ ] ,
300- [ props . environments , threadListV2Enabled ] ,
301- ) ;
302- const { snapshots : archivedSnapshots } = useArchivedThreadSnapshots ( archivedEnvironmentIds ) ;
293+ // Settled threads stay in the live shell stream (settled ≠ archived), so
294+ // the partition works directly off live shells — no snapshot merging or
295+ // optimistic holds.
303296 // PR states stream in per-row (rows own the VCS subscriptions); a merged or
304297 // closed PR auto-settles its thread on the next partition (mirrors web).
305298 const [ changeRequestStateByKey , setChangeRequestStateByKey ] = useState <
@@ -320,84 +313,14 @@ export function HomeScreen(props: HomeScreenProps) {
320313 } ,
321314 [ ] ,
322315 ) ;
323- // Bridge the gap between the live stream dropping a just-settled thread
324- // and the archived snapshot returning it: hold the shell we settled,
325- // marked archived, until the snapshot carries it. Held explicitly at
326- // settle time so deleted threads are never resurrected.
327- const [ settledHolds , setSettledHolds ] = useState < ReadonlyMap < string , EnvironmentThreadShell > > (
328- ( ) => new Map ( ) ,
329- ) ;
330316 const handleSettleThread = useCallback (
331317 ( thread : EnvironmentThreadShell ) => {
332- const threadKey = scopedThreadKey ( thread . environmentId , thread . id ) ;
333- // An existing hold means a settle for this thread is already in flight
334- // (or done and awaiting its snapshot). Re-triggering would fail the
335- // executor's in-flight check and the rollback below would strip the
336- // first settle's hold, flickering the row out of the settled tail.
337- if ( settledHolds . has ( threadKey ) ) {
338- return ;
339- }
340- setSettledHolds ( ( current ) =>
341- new Map ( current ) . set ( threadKey , {
342- ...thread ,
343- archivedAt : thread . archivedAt ?? new Date ( ) . toISOString ( ) ,
344- } ) ,
345- ) ;
346- void ( async ( ) => {
347- // Roll the optimistic hold back if the settle was blocked or failed —
348- // otherwise a never-archived thread would render settled forever.
349- const succeeded = await props . onSettleThread ( thread ) ;
350- if ( ! succeeded ) {
351- setSettledHolds ( ( current ) => {
352- const next = new Map ( current ) ;
353- next . delete ( threadKey ) ;
354- return next ;
355- } ) ;
356- }
357- } ) ( ) ;
318+ void props . onSettleThread ( thread ) ;
358319 } ,
359- [ props . onSettleThread , settledHolds ] ,
320+ [ props . onSettleThread ] ,
360321 ) ;
361- // Delete and un-settle both invalidate any hold for the thread.
362- const dropSettledHold = useCallback ( ( thread : EnvironmentThreadShell ) => {
363- setSettledHolds ( ( current ) => {
364- const threadKey = scopedThreadKey ( thread . environmentId , thread . id ) ;
365- if ( ! current . has ( threadKey ) ) return current ;
366- const next = new Map ( current ) ;
367- next . delete ( threadKey ) ;
368- return next ;
369- } ) ;
370- } , [ ] ) ;
371- const handleDeleteThread = useCallback (
372- ( thread : EnvironmentThreadShell ) => {
373- dropSettledHold ( thread ) ;
374- props . onDeleteThread ( thread ) ;
375- } ,
376- [ dropSettledHold , props . onDeleteThread ] ,
377- ) ;
378- const handleUnsettleThread = useCallback (
379- ( thread : EnvironmentThreadShell ) => {
380- dropSettledHold ( thread ) ;
381- props . onUnsettleThread ( thread ) ;
382- } ,
383- [ dropSettledHold , props . onUnsettleThread ] ,
384- ) ;
385- useEffect ( ( ) => {
386- if ( settledHolds . size === 0 ) return ;
387- const covered = new Set < string > ( ) ;
388- for ( const { environmentId, snapshot } of archivedSnapshots ) {
389- for ( const thread of snapshot . threads ) {
390- covered . add ( scopedThreadKey ( environmentId , thread . id ) ) ;
391- }
392- }
393- if ( [ ...settledHolds . keys ( ) ] . some ( ( threadKey ) => covered . has ( threadKey ) ) ) {
394- setSettledHolds ( ( current ) => {
395- const next = new Map ( current ) ;
396- for ( const threadKey of covered ) next . delete ( threadKey ) ;
397- return next ;
398- } ) ;
399- }
400- } , [ archivedSnapshots , settledHolds ] ) ;
322+ const handleDeleteThread = props . onDeleteThread ;
323+ const handleUnsettleThread = props . onUnsettleThread ;
401324 // The settled tail renders in pages; expansion resets when the filter
402325 // context changes so environment/search flips never inherit a deep page.
403326 const [ settledVisibleCount , setSettledVisibleCount ] = useState (
@@ -424,21 +347,10 @@ export function HomeScreen(props: HomeScreenProps) {
424347 } , [ threadListV2Enabled ] ) ;
425348 const threadListV2Layout = useMemo ( ( ) => {
426349 if ( ! threadListV2Enabled ) return { items : [ ] , hiddenSettledCount : 0 } ;
427- const merged = new Map < string , EnvironmentThreadShell > ( ) ;
428- for ( const { environmentId, snapshot } of archivedSnapshots ) {
429- for ( const thread of snapshot . threads ) {
430- merged . set ( scopedThreadKey ( environmentId , thread . id ) , { ...thread , environmentId } ) ;
431- }
432- }
433- for ( const thread of props . threads ) {
434- merged . set ( scopedThreadKey ( thread . environmentId , thread . id ) , thread ) ;
435- }
436- for ( const [ threadKey , shell ] of settledHolds ) {
437- if ( merged . has ( threadKey ) ) continue ;
438- merged . set ( threadKey , shell ) ;
439- }
350+ // Settled threads are live shells; archived threads keep their original
351+ // "hidden from lists" meaning.
440352 return buildThreadListV2Items ( {
441- threads : [ ... merged . values ( ) ] ,
353+ threads : props . threads . filter ( ( thread ) => thread . archivedAt === null ) ,
442354 environmentId : props . selectedEnvironmentId ,
443355 searchQuery : props . searchQuery ,
444356 changeRequestStateByKey,
@@ -448,9 +360,7 @@ export function HomeScreen(props: HomeScreenProps) {
448360 } , [
449361 changeRequestStateByKey ,
450362 nowMinute ,
451- settledHolds ,
452363 settledVisibleCount ,
453- archivedSnapshots ,
454364 props . searchQuery ,
455365 props . selectedEnvironmentId ,
456366 props . threads ,
@@ -591,17 +501,12 @@ export function HomeScreen(props: HomeScreenProps) {
591501 const keyExtractor = useCallback ( ( item : HomeListItem ) => item . key , [ ] ) ;
592502
593503 /* Empty states */
594- // v2 shows archived threads as its settled tail, so an archived-only
595- // workspace still has a list to render there. The signal must ignore the
596- // search/environment filters: an active query that matches nothing needs
597- // the in-list "No results" state, not the full-page "No threads yet" .
504+ // The signal must ignore the search/environment filters: an active query
505+ // that matches nothing needs the in- list "No results" state, not the
506+ // full-page "No threads yet". Settled threads are unarchived live shells,
507+ // so the v1 check already covers v2 .
598508 const hasAnyThreads =
599- props . threads . some ( ( thread ) => thread . archivedAt === null ) ||
600- props . pendingTasks . length > 0 ||
601- ( threadListV2Enabled &&
602- ( props . threads . length > 0 ||
603- settledHolds . size > 0 ||
604- archivedSnapshots . some ( ( { snapshot } ) => snapshot . threads . length > 0 ) ) ) ;
509+ props . threads . some ( ( thread ) => thread . archivedAt === null ) || props . pendingTasks . length > 0 ;
605510 const hasResults = projectGroups . length > 0 ;
606511 const selectedEnvironmentLabel =
607512 props . selectedEnvironmentId === null
0 commit comments