Skip to content

feat: attach client_session_id to requests and set the CLI session env var - #1074

Open
aqandrew wants to merge 3 commits into
aqandrew/devex-661-session-loggerfrom
aqandrew/devex-661-session-id-requests
Open

feat: attach client_session_id to requests and set the CLI session env var#1074
aqandrew wants to merge 3 commits into
aqandrew/devex-661-session-loggerfrom
aqandrew/devex-661-session-id-requests

Conversation

@aqandrew

@aqandrew aqandrew commented Aug 11, 2026

Copy link
Copy Markdown

What

Propagate the session ID from Phase 1 to outbound API requests and to the CLI,
so server-side logs, telemetry, and the spawned coder ssh process can all be
correlated with the extension's session.

This is Phase 2 of 3 for
DEVEX-661. It builds on
#1073.

Changes

  • Requests (RFC req 3): add a sessionId argument to CoderApi.create and
    attach the session ID to every request via the W3C baggage header using the
    client_session_id key (baggage: client_session_id=<hex>), on both the REST
    default headers and the WebSocket handshake headers. Threaded through all
    CoderApi.create call sites, including the pre-auth OAuth/login/deployment
    clients, so every request carries it.
  • Telemetry (RFC req 4.2): already satisfied — the shared ID is the
    telemetry sessionId, which ships on every event's context.
  • CLI (RFC reqs 5.2/5.3): extend applySshEnvironment to also set
    CODER_TRACE_SESSION_ID on both process.env and the terminal environment
    collection, so the spawned coder ssh ProxyCommand reuses the plugin's
    session ID instead of generating its own.

Testing

  • pnpm typecheck, targeted pnpm lint, full pnpm test:extension (2108
    passing).
  • New tests: baggage: client_session_id=<hex> present/absent on CoderApi;
    CODER_TRACE_SESSION_ID applied to process.env and the terminal collection
    and restored on dispose.

🤖 Generated by Coder Agents.

@linear-code

linear-code Bot commented Aug 11, 2026

Copy link
Copy Markdown

DEVEX-661

@aqandrew aqandrew changed the title feat: propagate the session ID to requests and the CLI feat: propagate the session ID to requests and CLI invocations Aug 11, 2026
Attach the session ID to every API request via the W3C baggage header
(session_id=<id>) so the server can correlate requests with the
session's logs and telemetry, threading it through CoderApi.create at
all call sites.

Set CODER_TRACE_SESSION_ID on both process.env and the terminal
environment collection so the spawned `coder ssh` ProxyCommand reuses
the plugin's session ID instead of generating its own.
@aqandrew
aqandrew force-pushed the aqandrew/devex-661-session-id-requests branch from f2f6512 to e6e52cc Compare August 12, 2026 22:00
@aqandrew
aqandrew requested review from EhabY and code-asher August 12, 2026 22:31
Align with the updated RFC: the session ID baggage key changes from
session_id to client_session_id.
@aqandrew
aqandrew force-pushed the aqandrew/devex-661-session-id-requests branch from 0baf84a to 8d98780 Compare August 13, 2026 00:40
@aqandrew aqandrew changed the title feat: propagate the session ID to requests and CLI invocations feat: attach client_session_id to requests and set the CLI session env var Aug 13, 2026
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.

1 participant