Skip to content

[FEATURE]: Expose worktree lifecycle events (created, removed, reset) to plugins #15680

Description

@kldzj

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Right now, plugins are completely blind to worktree operations (create, remove, reset). Because these operations only emit directly to GlobalBus instead of going through Bus.publish(), they successfully reach SSE clients and the TUI, but entirely bypass plugin subscriptions.

This creates a few major roadblocks for plugin authors:

  • Leaked external resources: If a plugin spins up a dev server, Docker container, or DB branch for a worktree, it has no signal to tear it down when the worktree is removed (or provision it on create).
  • Stale cache data: Plugins that maintain local state per worktree (like indexed context or build artifacts) end up holding onto dead data because they don't know when a worktree is deleted or hard-reset.

Proposed events

Three new events emitted via Bus.publish() so they reach both plugins (via Bus.subscribeAll) and existing SSE/TUI consumers (via GlobalBus):

Event Payload When
worktree.created { info: { name, branch, directory } } After git worktree add and sandbox registration succeed, before async bootstrap
worktree.removed { directory } After worktree directory cleanup and branch deletion
worktree.reset { directory } After git reset --hard, git clean, and submodule update complete

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions