Skip to content

fix(renderer): load UI state before Keychain authentication#2104

Open
fbricon wants to merge 1 commit into
openkaiden:mainfrom
fbricon:worktree-GH-2091
Open

fix(renderer): load UI state before Keychain authentication#2104
fbricon wants to merge 1 commit into
openkaiden:mainfrom
fbricon:worktree-GH-2091

Conversation

@fbricon

@fbricon fbricon commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #2091

On macOS initial startup from DMG, UI was not properly initialized until
after Keychain authentication completed. Window showed with black background
and missing navigation labels while waiting for user to authenticate.

Root cause: SafeStorageRegistry.init() was called before ColorRegistry,
ConfigurationRegistry, and their IPC handlers were registered. When the
renderer loaded, critical IPC handlers were unavailable, preventing colors,
configuration properties, and navigation from loading until the entire
initialization sequence completed (including Keychain auth).

Changes:

  • Reordered initialization: ConfigurationRegistry and ColorRegistry now
    initialize before SafeStorageRegistry
  • Registered configuration and color IPC handlers immediately after their
    respective registries initialize
  • Added immediate fetch in EventStores for colors, configuration properties,
    and navigation registry instead of waiting for events
  • Added undefined guard in ColorsStyle for test environments

Result: Colors, configuration, and navigation labels all load immediately
when the renderer starts, before SafeStorageRegistry initialization. The UI
is fully styled and functional even when the Keychain authentication prompt
appears during extension activation.

Screenshot 2026-06-09 at 11 56 28

@fbricon fbricon requested a review from a team as a code owner June 9, 2026 10:18
@fbricon fbricon requested review from benoitf and gastoner and removed request for a team June 9, 2026 10:18
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Main process registers configuration and color IPC handlers immediately after their registries initialize and defers SafeStorageRegistry init. Renderer stores trigger immediate initial fetches for colors, configuration properties, and navigation (with error logging). ColorsStyle guards against falsy color infos before generating styles.

Changes

Early data initialization for renderer startup

Layer / File(s) Summary
Early IPC handler registration in main process
packages/main/src/plugin/index.ts
Registers configuration-registry handlers immediately after ConfigurationRegistry initialization; initializes ColorRegistry earlier and registers colorRegistry handlers; defers SafeStorageRegistry binding/init until after color initialization; replaces later duplicate handler registrations with comments.
Renderer store initial fetches and UI guard
packages/renderer/src/stores/colors.ts, packages/renderer/src/stores/configurationProperties.ts, packages/renderer/src/stores/navigation/navigation-registry.ts, packages/renderer/src/lib/style/ColorsStyle.svelte
Stores perform immediate .fetch() after .setup() to preload colors, configuration properties, and navigation with .catch(...) logging on failure. ColorsStyle.svelte adds an early-return guard when subscribed infos is falsy.

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers:

  • bmahabirbu
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: reordering initialization so UI state (colors, configuration, navigation) loads before Keychain authentication.
Description check ✅ Passed The description clearly explains the root cause, changes made, and expected result, directly addressing the problem described in the linked issue.
Linked Issues check ✅ Passed All changes directly address issue #2091: initialization reordering [2104] prevents Keychain blocking UI state loading, and immediate fetches in EventStores [2104] ensure colors, configuration, and navigation load before SafeStorage initialization.
Out of Scope Changes check ✅ Passed All changes are scoped to the fix: initialization reordering, IPC handler registration timing, and EventStore fetches directly support loading UI state before Keychain authentication.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.83333% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/main/src/plugin/index.ts 46.66% 8 Missing ⚠️
packages/renderer/src/stores/colors.ts 33.33% 2 Missing ⚠️
...ges/renderer/src/stores/configurationProperties.ts 33.33% 2 Missing ⚠️
...derer/src/stores/navigation/navigation-registry.ts 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@gastoner gastoner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Personally I would move the registration of IPC handles to init methods of colorRegistry and configurationRegistry

LGTM otherwise

Comment thread packages/renderer/src/stores/colors.ts Outdated
Comment thread packages/renderer/src/stores/configurationProperties.ts Outdated
@fbricon

fbricon commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Personally I would move the registration of IPC handles to init methods of colorRegistry and configurationRegistry

This indirection idea is sometimes interesting, but here, I'd rather not introduce new couplings to these registries. At least we have a mostly consistent way of registering IPC handles here.

@fbricon fbricon force-pushed the worktree-GH-2091 branch 5 times, most recently from dfd2880 to ab61b96 Compare June 10, 2026 09:19
@fbricon fbricon enabled auto-merge (rebase) June 10, 2026 09:19
Fixes openkaiden#2091

On macOS initial startup from DMG, UI was not properly initialized until
after Keychain authentication completed. Window showed with black background
and missing navigation labels while waiting for user to authenticate.

Root cause: SafeStorageRegistry.init() was called before ColorRegistry,
ConfigurationRegistry, and their IPC handlers were registered. When the
renderer loaded, critical IPC handlers were unavailable, preventing colors,
configuration properties, and navigation from loading until the entire
initialization sequence completed (including Keychain auth).

Changes:
- Reordered initialization: ConfigurationRegistry and ColorRegistry now
  initialize before SafeStorageRegistry
- Registered configuration and color IPC handlers immediately after their
  respective registries initialize
- Added immediate fetch in EventStores for colors, configuration properties,
  and navigation registry instead of waiting for events
- Added undefined guard in ColorsStyle for test environments

Result: Colors, configuration, and navigation labels all load immediately
when the renderer starts, before SafeStorageRegistry initialization. The UI
is fully styled and functional even when the Keychain authentication prompt
appears during extension activation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Fred Bricon <fbricon@gmail.com>
@fbricon fbricon force-pushed the worktree-GH-2091 branch from ab61b96 to 6d5a7bf Compare June 10, 2026 16:22

@benoitf benoitf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is something we inherit from rebasing from Podman Desktop, we should not change any logic only for kaiden

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.

On initial startup, styles are not loaded until after Keychain authentication

3 participants