Skip to content

Conversation

@code-yeongyu
Copy link
Owner

Summary

  • Remove immediate showToast() calls during plugin initialization
  • Defer config error display to session.created event when TUI is ready
  • Fixes issue where users couldn't see config error toasts

Problem

Config error toasts were shown during plugin initialization (before TUI was ready), causing them to be invisible to users.

Solution

  1. Removed showToast() calls from loadConfigFromPath()
  2. Errors are still stored via addConfigLoadError()
  3. auto-update-checker hook's showConfigErrorsIfAny() displays errors after session.created event

Changes

  • src/index.ts: Removed 27 lines of immediate toast calls

🤖 GENERATED WITH ASSISTANCE OF OhMyOpenCode

Removed showToast calls from loadConfigFromPath() function. Error notifications were not visible during plugin initialization because the TUI was not ready yet.

Changes:
- Removed immediate showToast calls from validation error handler
- Removed immediate showToast calls from file load error handler
- Errors are still captured via addConfigLoadError() for later display
- auto-update-checker hook will display errors via showConfigErrorsIfAny() after session.created event

This ensures error messages are displayed when the TUI is fully ready and able to render them properly.

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
@greptile-apps
Copy link

greptile-apps bot commented Dec 27, 2025

Greptile Summary

This PR fixes a timing issue where config error toasts were invisible to users by deferring their display until the TUI is fully initialized.

Key changes:

  • Removed immediate showToast() calls (27 lines) from loadConfigFromPath() in src/index.ts:129-143
  • Errors are still captured via addConfigLoadError() and stored in memory
  • The auto-update-checker hook now displays accumulated errors after the session.created event fires

How it works:
During plugin initialization (before TUI is ready), config validation/parse errors are silently recorded in memory. Once the session.created event fires (signaling TUI readiness), the auto-update-checker hook's showConfigErrorsIfAny() function retrieves and displays all stored errors as a single toast notification.

This ensures users can actually see config error messages that were previously lost during the initialization phase.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change is a straightforward timing fix that improves user experience without altering core logic. Error handling remains intact (errors are still captured), only the display timing changes. The deferred approach leverages an existing hook pattern and event system that's already in production.
  • No files require special attention

Important Files Changed

Filename Overview
src/index.ts Removed immediate toast calls from config loading, errors now deferred to session.created event

Sequence Diagram

sequenceDiagram
    participant Plugin as OhMyOpenCode Plugin
    participant ConfigLoader as loadConfigFromPath()
    participant ErrorStore as config-errors (memory)
    participant AutoUpdateChecker as auto-update-checker hook
    participant TUI as OpenCode TUI

    Note over Plugin,TUI: Plugin Initialization (TUI not ready)
    Plugin->>ConfigLoader: Load user/project configs
    ConfigLoader->>ConfigLoader: Parse & validate JSON
    alt Config has errors
        ConfigLoader->>ErrorStore: addConfigLoadError(error)
        Note over ErrorStore: Errors stored in memory
        ConfigLoader-->>Plugin: return null
    else Config valid
        ConfigLoader-->>Plugin: return config
    end

    Note over Plugin,TUI: Session Created Event (TUI ready)
    TUI->>AutoUpdateChecker: session.created event
    AutoUpdateChecker->>ErrorStore: getConfigLoadErrors()
    ErrorStore-->>AutoUpdateChecker: Return stored errors
    alt Errors exist
        AutoUpdateChecker->>TUI: showToast(config errors)
        TUI->>TUI: Display error toast to user
    end
    AutoUpdateChecker->>AutoUpdateChecker: Continue with version check
Loading

Ensure config errors are awaited and displayed before the startup spinner toast is shown. Changed showConfigErrorsIfAny(ctx).catch(() => {}) to await showConfigErrorsIfAny(ctx) to guarantee proper error handling order.

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
@code-yeongyu code-yeongyu merged commit c5f5103 into dev Dec 27, 2025
2 checks passed
@code-yeongyu code-yeongyu deleted the notify-invalid-config-toast branch December 27, 2025 15:46
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.

2 participants