[codex] Improve desktop startup shell loading#241
Conversation
|
@codex please review |
There was a problem hiding this comment.
💡 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".
| 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}"); | ||
| } | ||
| }); |
There was a problem hiding this comment.
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 👍 / 👎.
desktop/src/app/AppShell.tsx
Outdated
| const { markChannelRead, unreadChannelIds } = useUnreadChannels( | ||
| channels, | ||
| activeChannel, | ||
| activeReadAt, | ||
| undefined, |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
app/focused on shell coordination while moving feature screens and channel-specific UI/hooks into their owning feature modulesAgents (0)state until the agent query has actually loadedRoot Cause
Startup had regressed because the app was doing too much work on the critical path:
What Changed
ChannelPane,useActiveChannelHeader, anduseChannelPaneHandlersintofeatures/channelsAgents (0)while the deferred query is still loadingImpact
AppShellValidation
cargo checkindesktop/src-tauripnpm typecheckpnpm checkpnpm buildFollow-up
ChannelPaneis still a very large lazy chunk, so the next startup performance pass should focus on further code-splitting inside the channel/message stack