Skip to content

Polish CLI init: handle plugin replacement and fix formatting#591

Merged
huntercaron merged 7 commits intomainfrom
huntercaron/cli-init-polish
Mar 12, 2026
Merged

Polish CLI init: handle plugin replacement and fix formatting#591
huntercaron merged 7 commits intomainfrom
huntercaron/cli-init-polish

Conversation

@huntercaron
Copy link
Collaborator

@huntercaron huntercaron commented Mar 12, 2026

Description

This PR improves the CLI initialization flow by properly handling plugin tab replacement and fixing generated file formatting.

When a new plugin tab connects, it now cleanly closes the previous connection using a custom close code (CLOSE_CODE_REPLACED = 4001), preventing reconnection attempts. The plugin tab gracefully transitions to a "replaced" state and stops trying to reconnect.

Additionally, package.json files are now generated with 4-space indentation to match the prettier configuration, eliminating the need for reformatting on first edit.

Changelog

  • Add proper cleanup when plugin tabs are replaced by a new connection
  • Add status message for git repository initialization
  • Fix package.json indentation to use 4 spaces (matches prettier config)
  • Add "replaced" mode to display status when connection is superseded

Testing

  • Test CLI init creates properly formatted package.json
    • Run CLI init in a new project
    • Verify generated package.json uses 4-space indentation
  • Test plugin replacement behavior
    • Open plugin in one tab
    • Open plugin in another tab
    • Verify first tab displays "Replaced by another Plugin connection"
    • Verify first tab stops attempting reconnection

@github-actions github-actions bot added the Auto submit to Marketplace on merge Submits the plugin to the marketplace after merging label Mar 12, 2026
@huntercaron huntercaron removed the Auto submit to Marketplace on merge Submits the plugin to the marketplace after merging label Mar 12, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@huntercaron huntercaron force-pushed the huntercaron/cli-init-polish branch 4 times, most recently from 7dd94bf to e0fbf2d Compare March 12, 2026 10:24
- Add CLOSE_CODE_REPLACED for cleanly handling when a new plugin tab replaces the active one
- Add status message when initializing git repository
- Fix package.json indentation to use 4 spaces instead of 2 (matches prettier config)
- Add 'replaced' mode to handle plugin connection replacement state
- Stop reconnecting when a plugin is replaced by another tab
@huntercaron huntercaron force-pushed the huntercaron/cli-init-polish branch from e0fbf2d to 2b68506 Compare March 12, 2026 11:33
Copy link
Member

@niekert niekert left a comment

Choose a reason for hiding this comment

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

LFG

@huntercaron huntercaron added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit d179419 Mar 12, 2026
6 checks passed
@huntercaron huntercaron deleted the huntercaron/cli-init-polish branch March 12, 2026 14:00
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