@@ -43,7 +43,22 @@ class _ClosedSidebarViewState extends ConsumerState<ClosedSidebarView> {
4343 // Guard for the live-sync listener below: the set of active session ids the
4444 // last snapshot carried, so routine activity/status churn doesn't trigger a
4545 // reload — only an actual close/reopen (which adds/removes an id) does.
46- Set <String >? _lastActiveIds;
46+ //
47+ // Seeded in [initState] rather than left null, for the same reason the mobile
48+ // ClosedScreen seeds it: the listener only fires on a *change*, so an unseeded
49+ // baseline swallows the FIRST one — close a session from a chat pane with this
50+ // view open and the list stayed stale until a manual toggle. Seeding it *empty*
51+ // is not enough either, or the next snapshot always looks like a change and
52+ // reloads for nothing, so it starts from what the store already holds.
53+ late Set <String > _lastActiveIds;
54+
55+ @override
56+ void initState () {
57+ super .initState ();
58+ _lastActiveIds = {
59+ for (final s in ref.read (sessionsProvider).sessions) s.id,
60+ };
61+ }
4762
4863 void _refresh () {
4964 if (! mounted) return ;
@@ -83,8 +98,7 @@ class _ClosedSidebarViewState extends ConsumerState<ClosedSidebarView> {
8398 ref.listen <SessionsState >(sessionsProvider, (_, next) {
8499 final ids = {for (final s in next.sessions) s.id};
85100 final prev = _lastActiveIds;
86- if (prev != null &&
87- (ids.length != prev.length || ! ids.containsAll (prev))) {
101+ if (ids.length != prev.length || ! ids.containsAll (prev)) {
88102 _refresh ();
89103 }
90104 _lastActiveIds = ids;
0 commit comments