Skip to content

Conversation

@neverbiasu
Copy link

  • use configDir instead of XDG env vars

BREAKING CHANGE: Test harness now provides configDir instead of setting XDG_CONFIG_HOME/XDG_STATE_HOME

  • Remove XDG_CONFIG_HOME and XDG_STATE_HOME environment variable pollution
  • Add fs.mkdirSync() to create isolated configDir for tests
  • Export configDir from test harness for tests to use
  • Update session.test.ts to use harness-provided configDir
  • Each test now has explicit, isolated configuration directory via SessionConfig.configDir
  • Prevents mixing SDK sessions with CLI app sessions
  • Eliminates global environment pollution

Fixes: Resolves TODO comment about SDK configuration isolation

…ad of XDG env vars

BREAKING CHANGE: Test harness now provides configDir instead of setting XDG_CONFIG_HOME/XDG_STATE_HOME

- Remove XDG_CONFIG_HOME and XDG_STATE_HOME environment variable pollution
- Add fs.mkdirSync() to create isolated configDir for tests
- Export configDir from test harness for tests to use
- Update session.test.ts to use harness-provided configDir
- Each test now has explicit, isolated configuration directory via SessionConfig.configDir
- Prevents mixing SDK sessions with CLI app sessions
- Eliminates global environment pollution

Fixes: Resolves TODO comment about SDK configuration isolation
@neverbiasu neverbiasu requested a review from a team as a code owner February 13, 2026 00:59
Copilot AI review requested due to automatic review settings February 13, 2026 00:59
Copy link
Contributor

Copilot AI left a comment

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 refactors the Node.js SDK test harness to provide explicit configDir instead of setting XDG environment variables, aiming to resolve a TODO comment about preventing SDK test sessions from mixing with actual CLI app sessions.

Changes:

  • Remove XDG_CONFIG_HOME and XDG_STATE_HOME environment variable pollution from test harness
  • Create and export isolated configDir for tests to use via SessionConfig
  • Update one test to use the harness-provided configDir

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
nodejs/test/e2e/harness/sdkTestContext.ts Creates isolated configDir and exports it instead of setting XDG env vars
nodejs/test/e2e/session.test.ts Destructures configDir and uses it in the "custom config dir" test

const customConfigDir = `${homeDir}/custom-config`;
const session = await client.createSession({
configDir: customConfigDir,
configDir: configDir,
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is supposed to verify that a custom config directory can be used, but it's now passing the same configDir that the test harness creates by default. This means it's not actually testing custom configuration directory functionality. Consider either:

  1. Creating a different directory like join(homeDir, "custom-config") to truly test custom config dirs, or
  2. Renaming this test to reflect that it's testing the harness-provided config dir explicitly

Copilot uses AI. Check for mistakes.
Comment on lines 10 to 11
it("should create and destroy sessions", async () => {
const session = await client.createSession({ model: "fake-test-model" });
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO comment that was removed warned about mixing SDK sessions with CLI app sessions. While configDir is now exported from the harness, it's not being used in most test session creations in this file. Without XDG environment variables and without passing configDir explicitly, sessions may use the system's default config location (typically ~/.config), potentially mixing with actual CLI app sessions - the exact scenario the TODO warned against. Consider updating all session creations to pass configDir: configDir for proper isolation.

Copilot uses AI. Check for mistakes.
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