Skip to content

[codex] Improve desktop startup shell loading#241

Merged
wesbillman merged 3 commits intomainfrom
codex/desktop-startup-shell-refactor
Apr 6, 2026
Merged

[codex] Improve desktop startup shell loading#241
wesbillman merged 3 commits intomainfrom
codex/desktop-startup-shell-refactor

Conversation

@wesbillman
Copy link
Copy Markdown
Collaborator

Summary

  • move the desktop app toward a shell-first startup path instead of blocking the initial render on managed agent restore and eagerly mounted screens
  • keep app/ focused on shell coordination while moving feature screens and channel-specific UI/hooks into their owning feature modules
  • defer non-critical sidebar data and hide transient Agents (0) state until the agent query has actually loaded

Root Cause

Startup had regressed because the app was doing too much work on the critical path:

  • managed agent restoration was happening during synchronous Tauri setup
  • the shell was mounting or coordinating too many view-specific concerns up front
  • the main window reveal and first meaningful content were tightly coupled to frontend readiness

What Changed

  • backgrounded managed-agent restore in the Tauri setup path
  • kept window reveal in the frontend after the first React commit
  • split Home, Agents, Workflows, Settings, and Channel into feature-local screen components
  • moved ChannelPane, useActiveChannelHeader, and useChannelPaneHandlers into features/channels
  • introduced a shared view loading fallback and kept lazy boundaries at screen/feature edges
  • deferred sidebar DM metadata and agent count hydration
  • suppressed Agents (0) while the deferred query is still loading

Impact

  • the desktop window should become visible sooner with less startup blocking
  • the app shell architecture is cleaner and easier to extend without piling more startup-specific conditionals into AppShell
  • inactive sections now load more like a normal desktop app: shell first, per-screen loaders as needed, cached data on revisit

Validation

  • cargo check in desktop/src-tauri
  • pnpm typecheck
  • pnpm check
  • pnpm build
  • pre-push hooks also ran: desktop check/build, desktop tauri check, rust fmt, clippy, and unit tests

Follow-up

  • the largest remaining frontend issue is bundle shape, especially the channel/message surface, not screen ownership
  • ChannelPane is still a very large lazy chunk, so the next startup performance pass should focus on further code-splitting inside the channel/message stack

@wesbillman wesbillman marked this pull request as ready for review April 5, 2026 18:14
@wesbillman
Copy link
Copy Markdown
Collaborator Author

@codex please review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f5b4506e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +305 to +309
tauri::async_runtime::spawn_blocking(move || {
if let Err(error) = restore_managed_agents_on_launch(&app_handle) {
eprintln!("sprout-desktop: failed to restore managed agents: {error}");
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid restoring agents after shutdown begins

restore_managed_agents_on_launch is now launched as a detached spawn_blocking task, so it can race with the one-shot shutdown path in run (shutdown_done only allows shutdown_managed_agents once). If the user exits during startup, shutdown can run first and then this background restore task can still acquire the store lock and start local managed agents afterward, leaving agent processes running after the desktop app exits.

Useful? React with 👍 / 👎.

Comment on lines +115 to +118
const { markChannelRead, unreadChannelIds } = useUnreadChannels(
channels,
activeChannel,
activeReadAt,
undefined,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve read position when wiring unread tracking

Passing undefined as activeReadAt causes useUnreadChannels to immediately mark the active channel read at activeChannel.lastMessageAt instead of the latest message actually loaded in the timeline. When channel metadata is newer than cached messages (which happens because message subscription is only active for the selected channel), opening the channel can clear unread state for messages the user has not fetched/viewed yet.

Useful? React with 👍 / 👎.

@wesbillman wesbillman merged commit 53c2223 into main Apr 6, 2026
8 checks passed
@wesbillman wesbillman deleted the codex/desktop-startup-shell-refactor branch April 6, 2026 16:19
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