Skip to content

feat(telemetry): central command dispatcher (#902)#934

Open
EhabY wants to merge 2 commits intotelemetry/local-jsonl-sinkfrom
telemetry/command-dispatcher
Open

feat(telemetry): central command dispatcher (#902)#934
EhabY wants to merge 2 commits intotelemetry/local-jsonl-sinkfrom
telemetry/command-dispatcher

Conversation

@EhabY
Copy link
Copy Markdown
Collaborator

@EhabY EhabY commented May 5, 2026

Closes #902. Adds CommandManager so every coder.* command emits command.invoked (durationMs + success/error) via TelemetryService.trace.

  • src/core/commandManager.tsregister(id, handler): Disposable. CoderCommandId is a string-literal union; a unit test pins it to package.json so drift breaks CI.
  • src/extension.ts — migrates all 25 coder.* registrations. The manager owns disposal via ServiceContainer, disposed before TelemetryService so in-flight events still flush.
  • eslint.config.mjs — blocks direct registerCommand of coder.* ids (carve-out for commandManager.ts).
  • package.json — declares coder.openDevContainer (was registered but never declared).

Builds on #921; merge target is telemetry/local-jsonl-sink, not main.

Introduce CommandManager so every coder.* registration funnels through
one place and inherits command.invoked instrumentation (durationMs +
result) via TelemetryService.trace, no per-command wrapping. CoderCommandId
is a string-literal union derived from a static array; a unit test pins
it to package.json's contributes.commands so drift breaks CI.

Wire CommandManager into ServiceContainer so its dispose runs before
TelemetryService dispose, letting in-flight events flush. Migrate all
25 vscode.commands.registerCommand("coder.*", ...) sites in extension.ts
to commandManager.register(...). Returns are not pushed onto
ctx.subscriptions because the manager owns its registrations and is
itself disposed via the service container chain.

Add a no-restricted-syntax ESLint rule blocking direct registerCommand
of coder.* ids, with commandManager.ts carved out, mirroring the
existing setContext guard.

Declare coder.openDevContainer in package.json contributes.commands
(commandPalette when:false to preserve current behavior). It was
registered in code but never declared, which the new manifest-parity
test would have flagged.
@EhabY EhabY force-pushed the telemetry/command-dispatcher branch from 4b4c555 to 0e6d1a1 Compare May 5, 2026 13:57
@EhabY EhabY requested a review from DanielleMaywood May 6, 2026 10:50
Comment thread src/core/commandManager.ts Outdated
Comment thread src/extension.ts Outdated
Comment thread src/extension.ts Outdated
Comment thread test/unit/core/commandManager.test.ts Outdated
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