Skip to content

Conversation

@Raviguntakala
Copy link
Contributor

@Raviguntakala Raviguntakala commented Nov 22, 2025

Problem

  1. Upgrade toast notifications weren't showing because upgrade() was called in worker initialization before any clients connected to the event stream
  2. When auto-update is disabled, users weren't notified that updates are available

Solution

  1. Added checkUpgrade() RPC method to worker that calls upgrade() in proper Instance context
  2. TUI thread triggers checkUpgrade() via RPC after TUI starts, ensuring Instance is bootstrapped
  3. Added Installation.Event.UpdateAvailable to notify users when auto-update is disabled without auto-updating them
  4. Added toast notification handler in TUI to display manual update prompt when updates are available but auto-update is off

Testing

  • Verified auto-update complete toast notification appears when auto-update is enabled
  • Verified manual update available toast notification appears when auto-update is disabled
  • Both notifications display the correct version information

Files Changed

  • packages/opencode/src/cli/cmd/tui/worker.ts - Added checkUpgrade() RPC method with Instance.provide()
  • packages/opencode/src/cli/cmd/tui/thread.ts - Call checkUpgrade() RPC after TUI starts
  • packages/opencode/src/installation/index.ts - Added UpdateAvailable event definition
  • packages/opencode/src/cli/upgrade.ts - Modified to publish UpdateAvailable event when auto-update is disabled
  • packages/opencode/src/cli/cmd/tui/app.tsx - Added toast handler for UpdateAvailable event
  • packages/sdk/js/src/gen/types.gen.ts - Regenerated SDK types to include UpdateAvailable event

IMG_8329

Screenshot 2025-11-22 at 12 56 56 PM

Move upgrade() from TUI worker initialization to /event endpoint handler.
The upgrade check now runs 1 second after a client connects to the event
stream, ensuring proper delivery of upgrade notifications.
@rekram1-node
Copy link
Collaborator

To address that issue do you think we could update upgrade function to notify the user of an update if there is one but NOT auto update them (may need to create a new event for it)

Comment on lines 1988 to 1989
setTimeout(() => {
upgrade()
Copy link
Collaborator

@rekram1-node rekram1-node Nov 22, 2025

Choose a reason for hiding this comment

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

hm this probably isn't the best spot for this tbh. The server is used in several types of environments (some people spawn these servers and connect multiple clients to it). Ideally we could have some setup w/ worker + tui thread so that once the tui is booted we run this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use worker + TUI thread approach instead. Added checkUpgrade() RPC method to worker that's called from TUI thread after startup. This ensures it only runs once per TUI session and doesn't affect other server environments.

@Raviguntakala
Copy link
Contributor Author

To address that issue do you think we could update upgrade function to notify the user of an update if there is one but NOT auto update them (may need to create a new event for it)

Yes, I've added Installation.Event.UpdateAvailable that publishes when auto-update is disabled. It notifies users of the available version and prompts them to run opencode upgrade manually.
Screenshot 2025-11-22 at 12 56 56 PM

Call upgrade() via worker.checkUpgrade() RPC from TUI thread instead of in server /event endpoint. This ensures upgrade runs in proper Instance context and avoids running on every client connection.
@rekram1-node rekram1-node merged commit b92e851 into anomalyco:dev Nov 22, 2025
3 checks passed
rekram1-node pushed a commit that referenced this pull request Nov 23, 2025
Co-authored-by: Dax Raad <[email protected]>
Co-authored-by: opencode <[email protected]>
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.

3 participants