Skip to content

feat(hub): expose panel session lifecycle events - #281

Open
dvcolomban wants to merge 3 commits into
devframes:mainfrom
dvcolomban:codex/feat-panel-session-lifecycle
Open

feat(hub): expose panel session lifecycle events#281
dvcolomban wants to merge 3 commits into
devframes:mainfrom
dvcolomban:codex/feat-panel-session-lifecycle

Conversation

@dvcolomban

Copy link
Copy Markdown
Contributor

Review diff

This PR depends on #276, whose branch also lives in the contributor fork. GitHub therefore includes both layers in the normal Files changed view until #276 merges.

Review the lifecycle layer only

After #276 merges, this branch will be rebased onto main and the standard PR diff will contain only this layer.

Summary

  • expose live connected, changed, and disconnected events for each reporting viewer, using server-minted RPC session IDs
  • add reportDockPanelState() and report restored initial state plus later open-state transitions from both built-in clients
  • deduplicate reports per connection and remove tracked state through the existing RPC disconnect lifecycle
  • document the bus and RPC names and update public API snapshots

The existing $bindState and on.change contract already supports consumer-owned tab persistence through RPC actions, so this PR makes no tabs API changes.

Testing

  • pnpm lint
  • pnpm knip
  • pnpm test
  • pnpm typecheck
  • pnpm build

Part of #229.

@dvcolomban
dvcolomban force-pushed the codex/feat-panel-session-lifecycle branch from 42b2944 to 2900b4a Compare August 22, 2026 10:49
@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

@dvcolomban is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@dvcolomban
dvcolomban marked this pull request as ready for review August 22, 2026 10:49
Copilot AI lite review requested due to automatic review settings August 22, 2026 10:49

Copilot AI 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.

Pull request overview

This PR adds a hub-level, per-RPC-connection lifecycle signal for dock panel open/close state so Node-side hub consumers can observe when a given viewer connects, changes open state, or disconnects, keyed by the server-minted RPC session id.

Changes:

  • Introduces docks:panel:state as a typed hub bus event (connected/changed/disconnected) backed by server-tracked state per RPC session id.
  • Adds the internal RPC method hub:docks:panel-state plus a client helper reportDockPanelState() and wires reporting from both the headless hub client host and hub-ui viewer.
  • Adds unit/integration coverage and updates events documentation + public API snapshots.

Reviewed changes

Copilot reviewed 18 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/snapshots/tsnapi/@devframes/hub/types.snapshot.d.ts Snapshot: exports DevframeDockPanelStateEvent.
tests/snapshots/tsnapi/@devframes/hub/node.snapshot.js Snapshot: exports hubDocksPanelState.
tests/snapshots/tsnapi/@devframes/hub/node.snapshot.d.ts Snapshot: adds typed hubDocksPanelState RPC definition.
tests/snapshots/tsnapi/@devframes/hub/index.snapshot.d.ts Snapshot: adds docks:panel:state event + DevframeDockPanelStateEvent type.
tests/snapshots/tsnapi/@devframes/hub/constants.snapshot.d.ts Snapshot: adds HUB_EVENTS.bus.docksPanelState + HUB_EVENTS.rpc.docksPanelState.
tests/snapshots/tsnapi/@devframes/hub/client.snapshot.js Snapshot: exports reportDockPanelState.
tests/snapshots/tsnapi/@devframes/hub/client.snapshot.d.ts Snapshot: types reportDockPanelState(rpc, open).
packages/hub/src/types/docks.ts Extends docks host event surface and introduces DevframeDockPanelStateEvent.
packages/hub/src/node/rpc-builtins.ts Adds hub:docks:panel-state RPC builtin and registers it.
packages/hub/src/node/panel-state.ts Implements per-docks-host tracking + dedup + disconnect cleanup + event emission.
packages/hub/src/node/initiate.ts Hooks RPC peer disconnect to emit disconnected and clear tracked state.
packages/hub/src/node/context.ts Adds module augmentation for hub:docks:panel-state (internal RPC).
packages/hub/src/node/tests/rpc-builtins.test.ts Verifies session id derivation via handler context.
packages/hub/src/node/tests/initiate.test.ts Integration test for per-connection tracking + disconnect semantics.
packages/hub/src/node/tests/host-docks.test.ts Unit tests for dedupe, independent sessions, and disconnect behavior.
packages/hub/src/events.ts Adds centralized bus + RPC names for panel state reporting.
packages/hub/src/client/panel-state.ts Adds client helper for reporting open/close state to hub.
packages/hub/src/client/index.ts Re-exports the new client helper.
packages/hub/src/client/host.ts Reports initial state and subsequent panel.session.open changes from the headless client host.
packages/hub/src/client/tests/host.test.ts Tests initial report and later open-state assignments.
packages/hub-ui/src/client/state/context.ts Reports restored initial state and subsequent open transitions from hub-ui viewer after initialization.
packages/hub-ui/src/client/state/context.test.ts Tests restored state report and later transitions.
docs/content/1.guide/20.events.md Documents the new bus event and RPC method.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 22, 2026 11:10

Copilot AI 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.

Pull request overview

Copilot reviewed 18 out of 23 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 22, 2026 11:22

Copilot AI 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.

Pull request overview

Copilot reviewed 18 out of 23 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

packages/hub-ui/src/client/state/context.ts:670

  • reportPanelStateAfterInitialization() awaits restoreAfterInitialization() without handling rejection. If the restore path throws (e.g. a restored dock’s executeSetupScript() fails), the promise rejects, the watch() is never installed, and the hub will stop receiving panel-state reports for that viewer connection (plus this becomes an unhandled promise rejection).
  const reportPanelStateAfterInitialization = async (): Promise<void> => {
    await restoreAfterInitialization()
    watch(
      () => sessionStore.value.open,
      open => void reportDockPanelState(rpc, open).catch(() => {}),

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