Skip to content

feat(server): add optional sessionId and cwd to ServerOptions/ServerResult#751

Open
buihongduc132 wants to merge 1 commit into
backnotprop:mainfrom
buihongduc132:upstream/feat-session-id-option
Open

feat(server): add optional sessionId and cwd to ServerOptions/ServerResult#751
buihongduc132 wants to merge 1 commit into
backnotprop:mainfrom
buihongduc132:upstream/feat-session-id-option

Conversation

@buihongduc132
Copy link
Copy Markdown

What

Two new optional fields on ServerOptions that get passed through to ServerResult:

  • sessionId — optional string, auto-generates a UUID if omitted
  • cwd — optional string, defaults to process.cwd()

Why

I'm building a Pi coding agent extension that runs plannotator as a long-lived server with multiple concurrent sessions. Right now there's no way to identify which session a server belongs to, or what working directory it was started from.

These two fields are the foundation for session isolation without changing any existing behavior. Down the line they enable:

  • Draft storage scoped per session (instead of global)
  • Decision tracking per session
  • Remote clients managing multiple sessions

Changes

ServerOptions (input)

sessionId?: string;  // auto-generated UUID if omitted
cwd?: string;        // falls back to process.cwd()

ServerResult (output)

sessionId: string;   // always present — provided or generated
cwd: string;         // always present — provided or process.cwd()

Testing

4 tests covering:

  • Custom sessionId passed through
  • Auto-generated sessionId (UUID format)
  • Custom cwd passed through
  • Default cwd (process.cwd())

Backwards Compatibility

100% — both fields are optional on input, and adding non-optional fields to the output interface is safe since the interface was already being constructed internally.

…esult

Adds two optional fields that enable future session isolation without
breaking any existing callers:

- sessionId: optional string, auto-generates UUID if omitted
- cwd: optional string, defaults to process.cwd()

Both fields appear on the returned ServerResult so callers can
reference the session and working directory after server startup.

This is a foundation for:
- Concurrent sessions with isolated storage and decisions
- Draft scoping per session
- Remote client session management

Zero behavior change for existing callers.
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