Skip to content

fix: improve startup reliability, repo validation, and toasts#4

Merged
iHildy merged 8 commits into
mainfrom
fix/startup-reliability-and-toasts
Dec 31, 2025
Merged

fix: improve startup reliability, repo validation, and toasts#4
iHildy merged 8 commits into
mainfrom
fix/startup-reliability-and-toasts

Conversation

@iHildy

@iHildy iHildy commented Dec 31, 2025

Copy link
Copy Markdown
Owner

Summary

Improves startup reliability by deferring startup tasks until the UI is ready, validating repository configuration before syncing, and enhancing toast notifications for resilience.

Changes

  • Delay startupSync invocation in src/index.ts by 1 second to ensure the TUI is connected
  • In startup path, validate config presence and repo configuration before running startup tasks; show informative toasts if missing
  • Add pre-check in runStartup to determine if the local repo is cloned; if not cloned, verify repo exists on GitHub before attempting to clone
  • Startup becomes more robust: errors during startup show a toast instead of blocking startup
  • Extend showToast to support an optional title and handle UI toast failures gracefully
  • README: add note suggesting opencodesync as a CLI alternative

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @iHildy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the application's startup reliability and user experience by making the initial synchronization process more robust. It ensures that startup tasks are deferred until the UI is ready, validates repository configurations upfront, and provides clearer, non-blocking feedback through enhanced toast notifications when issues occur. These changes contribute to a more stable and informative application launch.

Highlights

  • Startup Delay: Introduced a 1-second delay for the startupSync operation to ensure the Text User Interface (TUI) is fully connected before critical synchronization tasks begin, improving initial reliability.
  • Configuration Validation: Enhanced the startup process to rigorously validate the presence and correctness of the repository configuration (e.g., repo.url or repo.owner/repo.name) before attempting any synchronization, providing informative toasts if misconfigured.
  • Repository Pre-check: Added a pre-check within runStartup to determine if the repository is already cloned locally. If not, it verifies the repository's existence on GitHub before attempting to clone, silently skipping if the remote repo doesn't exist to prevent blocking startup.
  • Robust Error Handling: Implemented more robust error handling during the startup phase, ensuring that any errors encountered are caught and displayed as informative toast notifications rather than causing the application to block or crash.
  • Enhanced Toast Notifications: Extended the showToast utility to support an optional title for notifications and added a try...catch block to gracefully handle potential failures when displaying toasts, especially if the TUI is not yet fully connected.
  • CLI Alternative Mention: Updated the README.md file to suggest opencodesync as a potential command-line interface (CLI) alternative for users.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request significantly improves the startup reliability and user experience of the plugin. The changes to defer startup tasks, validate repository configuration, and make toast notifications more resilient are all excellent additions. My review focuses on further enhancing this reliability. I've identified a potential race condition with the use of setTimeout and suggest exploring a more deterministic, event-based approach for startup synchronization. Additionally, I've provided suggestions to make error messages more specific for better usability and to improve debuggability by logging errors that are intentionally caught and suppressed.

Comment thread src/index.ts
Comment on lines +145 to +147
setTimeout(() => {
void service.startupSync();
}, 1000);

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.

high

Using a fixed setTimeout to delay an operation is often a sign of a race condition and can be unreliable. On a slow system or under heavy load, the TUI might take longer than 1 second to connect, causing startupSync to fail. Conversely, on a fast system, this introduces an unnecessary delay.

A more robust solution would be to use an event-driven approach. Please investigate if the plugin's context or lifecycle provides a mechanism to know when the TUI is ready, such as an onReady callback or an event listener. This would eliminate the guesswork and make the startup process more reliable.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Addressed in 11d417b. Replaced the fixed setTimeout with an event-driven approach using the server.connected event listener. Added a guard flag and a fallback timer to ensure reliable, single-execution startup.

Comment thread src/sync/service.ts Outdated
Comment on lines +72 to +75
if (!config.repo || (!config.repo.url && (!config.repo.owner || !config.repo.name))) {
await showToast(ctx, 'Run /sync-init to set up config sync.', 'info');
return;
}

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.

medium

The validation checks for a missing configuration file and a malformed repository configuration both display the same generic toast message. For a better user experience, consider providing a more specific message for this case to inform the user precisely what is wrong with their configuration.

          await showToast(ctx, 'Repository details are missing or incomplete in config. Run /sync-init to fix.', 'info');
          return;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 11d417b. Added a specific error message for malformed repository configurations to provide better guidance to the user.

Comment thread src/sync/service.ts Outdated
Comment on lines +451 to +453
} catch {
// Toast failed - TUI might not be connected yet
}

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.

medium

This empty catch block swallows errors, which can make debugging difficult if toasts fail for reasons other than the TUI not being connected. While it's correct not to block the startup process for a failed toast, logging the error to the console would be beneficial for development and troubleshooting without impacting the user.

} catch (error) {
    // Toast failed - TUI might not be connected yet
    console.error('[opencode-synced] Failed to show toast:', error);
  }

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Done in 11d417b. Added console error logging to the catch block to improve debuggability while maintaining non-blocking behavior.

- Replace fixed setTimeout with event-driven 'server.connected' listener
- Add guard flag to ensure startupSync runs exactly once
- Provide specific toast message for malformed repo config
- Log showToast errors to console for better debuggability
@iHildy iHildy changed the title Improve startup reliability, repo validation, and toasts fix: improve startup reliability, repo validation, and toasts Dec 31, 2025
@iHildy iHildy merged commit 4fc999b into main Dec 31, 2025
3 checks passed
@iHildy iHildy deleted the fix/startup-reliability-and-toasts branch December 31, 2025 03:57
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