feat(telemetry): central command dispatcher (#902)#934
Open
EhabY wants to merge 1 commit intotelemetry/local-jsonl-sinkfrom
Open
feat(telemetry): central command dispatcher (#902)#934EhabY wants to merge 1 commit intotelemetry/local-jsonl-sinkfrom
EhabY wants to merge 1 commit intotelemetry/local-jsonl-sinkfrom
Conversation
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.
4b4c555 to
0e6d1a1
Compare
DanielleMaywood
approved these changes
May 6, 2026
Comment on lines
+43
to
+44
| // `never[]` parameter type lets any concrete handler shape satisfy the | ||
| // constraint, sidestepping function-parameter contravariance. |
Collaborator
There was a problem hiding this comment.
Do we need this comment? Fine with keeping, just want to make sure it adds value
Comment on lines
+223
to
+225
| commandManager.register("coder.tasks.refresh", () => | ||
| tasksPanelProvider.refresh(), | ||
| ); |
Collaborator
There was a problem hiding this comment.
how come we moved this below the secretsManager?
Comment on lines
+254
to
+255
| // Coder commands. The CommandManager owns disposal via ServiceContainer, | ||
| // so registrations do not need to be pushed onto ctx.subscriptions. |
Collaborator
There was a problem hiding this comment.
Do we need this comment?
Comment on lines
+22
to
+24
| return { | ||
| extension: { packageJSON: { version: "1.2.3-test" } }, | ||
| } as unknown as vscodeTypes.ExtensionContext; |
Collaborator
There was a problem hiding this comment.
Just want to check that as unknown as is absolutely required to do what you want? It would be nice for a solution that doesn't require cheating the type system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #902. Introduces
CommandManagerso everycoder.*command goes through one place and getscommand.invokedinstrumentation (durationMs + result) for free viaTelemetryService.trace.src/core/commandManager.ts—register(id, handler): Disposable.CoderCommandIdis a string-literal union derived from a static array. Unknown ids throw at runtime; a unit test pins the array topackage.jsonso drift breaks CI.src/core/container.ts— wiresCommandManagerintoServiceContainerand disposes it beforeTelemetryServiceso any in-flightcommand.invokedevents still flush.src/extension.ts— migrates all 25vscode.commands.registerCommand("coder.*", ...)sites. Returns are not pushed ontoctx.subscriptions: the manager owns its registrations and is itself disposed via the service container chain.eslint.config.mjs— adds ano-restricted-syntaxrule blocking directregisterCommandofcoder.*ids, withcommandManager.tscarved out, mirroring the existingsetContextguard.package.json— declarescoder.openDevContainer(withcommandPalettewhen: falseto preserve current behavior). It was registered in code but never declared, which the new manifest-parity test would have flagged.Builds on top of #921 (
telemetry/local-jsonl-sink); merge target is that branch, notmain.