Skip to content

fix(tabs): non-active restored tabs no longer require manual refresh#1025

Merged
datlechin merged 1 commit intomainfrom
fix/restore-tab-lazy-load
May 6, 2026
Merged

fix(tabs): non-active restored tabs no longer require manual refresh#1025
datlechin merged 1 commit intomainfrom
fix/restore-tab-lazy-load

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

  • After reopening the app and reconnecting, only the last-active tab loaded data; other tabs (in additional native window-tabs) showed an empty grid until the user pressed Refresh
  • Affects: any connection with multiple persisted tabs spread across native window tabs

Root cause

handleConnectionStatusChange only triggers a query when coordinator.needsLazyLoad == true. The flag is set in two places:

  • handleRestoreOrDefault for the first restored tab when the session is not yet connected
  • lazyLoadCurrentTabIfNeeded when a .task(id: TabLoadKey) fires before the session is ready

For non-first restored tabs, the new window opens with intent=.openContent skipAutoExecute=true and MainContentView+Setup returns early without setting needsLazyLoad. There's also a race: connectionStatusDidChange can fire before handleRestoreOrDefault sets the flag, after which the lazy-load path is wedged because no further notifications fire. Either way, the only path that runs the query is the user pressing Refresh.

Fix

handleConnectionStatusChange now also calls coordinator.lazyLoadCurrentTabIfNeeded() when the session is connected, in addition to its existing needsLazyLoad branch. lazyLoadCurrentTabIfNeeded already guards against double-execution:

  • skips if tab.execution.isExecuting
  • skips if rows are already present and not evicted
  • skips if tab.execution.lastExecutedAt != nil
  • skips if there are pending edits

So the extra call is idempotent — it triggers the query when needed and is a no-op otherwise. The needsLazyLoad flag becomes a fast-path hint rather than a hard gate, and the bug class around timing races / non-first-tab restoration goes away.

Test plan

  • Open a connection, open 2-3 table tabs, quit
  • Reopen app: all tabs reappear, all show data without needing Refresh
  • Open a connection, switch to a different tab via native window tab: grid populates without Refresh (already worked, regression check)
  • Disconnect and reconnect a connection: current tab re-loads automatically
  • swiftlint --strict on changed file: 0 violations
  • xcodebuild Debug arm64: BUILD SUCCEEDED

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit bb77ecc into main May 6, 2026
2 checks passed
@datlechin datlechin deleted the fix/restore-tab-lazy-load branch May 6, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant