fix(storage): resolve project paths from session cwd - #45
Merged
Merged
Conversation
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
force-pushed
the
fix/session-cwd-paths
branch
from
August 16, 2026 12:19
5f3cc77 to
641f6ed
Compare
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.
Summary
ExtensionContext.cwdPI_TASKSoverrides from the session workspace/taskscommand reads itProblem
pi-taskscurrently resolves project paths withprocess.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/usermay serve a session whosectx.cwdis/home/user/project. The current code stores session tasks below:instead of:
This can mix task state between workspaces and can produce permission errors when the host's startup directory is not writable.
ExtensionContext.cwdis 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:ctx.cwdand 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_TASKSoverrides retain their existing behavior.Tests
Added regression coverage for:
process.cwd()differing fromctx.cwdPI_TASKSresolutionValidation:
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.