Skip to content

fix(storage): resolve project paths from session cwd - #45

Merged
tintinweb merged 1 commit into
tintinweb:masterfrom
yeyaowei:fix/session-cwd-paths
Aug 16, 2026
Merged

tintinweb merged 1 commit into
tintinweb:masterfrom
yeyaowei:fix/session-cwd-paths

Conversation

@yeyaowei

@yeyaowei yeyaowei commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve session- and project-scoped task stores from ExtensionContext.cwd
  • load and save project task configuration relative to the active session workspace
  • resolve relative PI_TASKS overrides from the session workspace
  • initialize the store before the /tasks command reads it
  • track store targets by their effective identity so same-workspace sessions remain isolated while in-memory stores survive cwd changes

Problem

pi-tasks currently resolves project paths with process.cwd(). That works in the regular terminal host, where the process cwd normally matches the active workspace, but it breaks in long-lived hosts that serve sessions from another directory.

For example, a host started in /home/user may serve a session whose ctx.cwd is /home/user/project. The current code stores session tasks below:

/home/user/.pi/tasks/

instead of:

/home/user/project/.pi/tasks/

This can mix task state between workspaces and can produce permission errors when the host's startup directory is not writable.

ExtensionContext.cwd is the session-scoped workspace, so project-owned paths should be resolved from it rather than from the host process cwd.

Implementation

The extension factory does not have an ExtensionContext, so initialization now happens in two stages:

  1. Load global defaults and create only stores whose identity is context-independent.
  2. On the first context-bearing lifecycle event, merge project configuration from ctx.cwd and select the effective store target.

Store targets have stable identities for memory, named, absolute, relative, project, and session stores. This also ensures that different session IDs in the same workspace use different files, while an in-memory store is not discarded merely because a context reports another cwd.

Absolute and named PI_TASKS overrides retain their existing behavior.

Tests

Added regression coverage for:

  • process.cwd() differing from ctx.cwd
  • project scope loaded from the session workspace
  • relative PI_TASKS resolution
  • different session IDs in the same workspace
  • in-memory stores across cwd changes
  • cwd-aware global/project config merging

Validation:

npm run lint       passed
npm run typecheck  passed
npm test           196 passed
npm run build      passed

Related to #29.
Follow-up to #34, which fixed the session lifecycle/rehydration portion described there; this PR addresses the remaining cwd-aware path resolution.

Use ExtensionContext.cwd for task storage, project configuration, and relative PI_TASKS overrides so long-lived hosts do not use their process startup directory.

Related to tintinweb#29 and tintinweb#34.
@tintinweb
tintinweb force-pushed the fix/session-cwd-paths branch from 5f3cc77 to 641f6ed Compare August 16, 2026 12:19
@tintinweb
tintinweb merged commit 556435a into tintinweb:master Aug 16, 2026
3 checks passed
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