Skip to content

refactor: unify event names + centralize them in DEVFRAME_EVENTS / HUB_EVENTS maps - #258

Merged
antfu merged 2 commits into
mainfrom
docs/hub-events-reference
Aug 18, 2026
Merged

refactor: unify event names + centralize them in DEVFRAME_EVENTS / HUB_EVENTS maps#258
antfu merged 2 commits into
mainfrom
docs/hub-events-reference

Conversation

@antfubot

@antfubot antfubot commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

What & why

Two related cleanups to how devframe names its events.

1. Unify inconsistent internal event names. ctx.docks.events emitted dock:activate while its wire counterpart broadcasts devframe:docks:activate — the internal bus was the only place using a singular subject. Renamed the internal EventEmitter events to the plural subsystem vocabulary used everywhere else, so each internal event lines up with its wire counterpart:

  • dock:activatedocks:activate, dock:entry:updateddocks:entry:updated
  • terminal:session:updatedterminals:session:updated
  • message:*messages:*, command:*commands:*

2. Centralize every event name in one source-of-truth map per package, so names stop living as scattered string literals ("no magic event names"):

  • packages/devframe/src/events.tsDEVFRAME_EVENTS (agent host bus events, client connection events, server→client broadcasts). Re-exported from devframe/constants.
  • packages/hub/src/events.tsHUB_EVENTS (docks/terminals/messages/commands bus events, hub: RPC methods, devframe: broadcasts, shared-state keys, channels). Re-exported from @devframes/hub/constants.

Call sites across both packages — plus @devframes/hub-ui and the messages dev harness — now reference DEVFRAME_EVENTS.* / HUB_EVENTS.* instead of literals. The only literals left are unavoidable type-position keys (the EventEmitter<…> maps and the RPC augmentation interfaces), which mirror the maps. @devframes/plugin-terminals keeps a local literal by design — it models the hub bridge structurally and takes no hub dependency.

Docs & guardrail

  • New Events Reference docs page (docs/guide/events.md) tables every channel: the hub's three channels (internal node bus, hub: server RPC, devframe: broadcasts/shared state) and the core devframe channels (agent bus, client connection events, broadcasts). Wired into the sidebar under Hub.
  • The page states that HUB_EVENTS / DEVFRAME_EVENTS back it, and an AGENTS.md rule now requires the maps and the page to move together and forbids magic event names.

Scope & compatibility

Wire names (hub:*, devframe:*) are public API and unchanged. The internal .events names are @internal. Public constant types are preserved (DOCK_RENDERERS_STATE_KEY, FRAME_NAV_CHANNEL, DEVFRAME_REMOTE_ASSETS_ERROR_MESSAGE_TYPE stay string), so the tsnapi snapshot delta is purely the additive HUB_EVENTS / DEVFRAME_EVENTS exports.

Verification

pnpm build, full vitest (104 files / 1163 tests), pnpm knip, docs build, and typecheck for devframe / @devframes/hub / @devframes/hub-ui all pass; lint clean. (A pre-existing devframe/utils/get-port typecheck error in some plugin test utils is unrelated and present on the base branch.)

This PR was created with the help of an agent.

Rename the internal EventEmitter events on the subsystem hosts to the
plural subsystem vocabulary already used across every wire name, so the
bus lines up with its RPC/broadcast/shared-state counterparts:

- dock:activate           -> docks:activate
- dock:entry:updated      -> docks:entry:updated
- terminal:session:updated -> terminals:session:updated
- message:*               -> messages:*
- command:*               -> commands:*

Add a dedicated Hub Events Reference docs page tabling the three event
channels (internal node bus, hub: server RPC, devframe: broadcasts and
shared state) and their scope/flow.

Wire names (hub:*, devframe:*) are public API and stay unchanged.
@netlify

netlify Bot commented Aug 18, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 591cd68
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a83ead63536c30008a94c60
😎 Deploy Preview https://deploy-preview-258--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Introduce one source-of-truth event map per package and reference it from
every call site, so event/broadcast/shared-state/channel names stop living
as scattered string literals:

- packages/devframe/src/events.ts (DEVFRAME_EVENTS) — agent host bus events,
  client connection events, and server->client broadcasts; re-exported from
  devframe/constants.
- packages/hub/src/events.ts (HUB_EVENTS) — the docks/terminals/messages/
  commands bus events, hub: RPC methods, devframe: broadcasts, shared-state
  keys, and channels; re-exported from @devframes/hub/constants.

Call sites across both packages (plus hub-ui and the messages dev harness)
now reference the maps instead of literals. The unavoidable type-position
keys (EventEmitter<...> maps, RPC augmentation interfaces) mirror the maps.

Document the core devframe channels in the Events Reference and note that
the two maps back the page; add an AGENTS.md rule requiring the maps and
events.md to move together and forbidding magic event names.

Public constant types are preserved (DOCK_RENDERERS_STATE_KEY,
FRAME_NAV_CHANNEL, DEVFRAME_REMOTE_ASSETS_ERROR_MESSAGE_TYPE stay `string`);
the snapshot change is purely the additive HUB_EVENTS / DEVFRAME_EVENTS.
@antfubot antfubot changed the title refactor(hub): unify internal event names and add Hub Events Reference docs refactor: unify event names + centralize them in DEVFRAME_EVENTS / HUB_EVENTS maps Aug 18, 2026
@antfu
antfu merged commit f9577fd into main Aug 18, 2026
12 checks passed
@antfu
antfu deleted the docs/hub-events-reference branch August 18, 2026 05:22
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