fix: keep subagent spinners animating with session-scoped dirs#244
fix: keep subagent spinners animating with session-scoped dirs#244NOirBRight wants to merge 3 commits into
Conversation
…IRS mutable container
- ensureAccessibleDir now catches EPERM/EACCES from mkdirSync, attempts
rmSync+retry, and falls back to ${dirPath}-${process.pid} when both fail
- Return type changed from void to string (actual path used)
- DIRS mutable container replaces export const RESULTS_DIR/ASYNC_DIR for
runtime path override propagation
- All 11 consumer module sites migrated to use DIRS.results/DIRS.async
- Backward-compatible RESULTS_DIR/ASYNC_DIR aliases retained in types.ts
- Unit tests for ensureAccessibleDir + DIRS container (9 pass)
Refs: nicobailon/pi-subagents EPERM crash on Windows ACL corruption
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0511a836a1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| state.lastUiContext = ctx; | ||
|
|
||
| // Update DIRS to session-scoped paths to prevent cross-process conflicts | ||
| updateDirsForSession(sessionId); |
There was a problem hiding this comment.
Restart watchers after changing session directories
When session_start mutates DIRS.results, the result watcher created earlier still closes over the pre-session path passed at registration time, so this later primeExistingResults() call continues scanning the old directory while new async runs write completion JSON under the session-scoped DIRS.results. In a normal session, those completions will not emit SUBAGENT_ASYNC_COMPLETE_EVENT, which can leave async notifications/result delivery and widget cleanup stuck; defer watcher creation until after the session directory is chosen or recreate/restart it with the new path.
Useful? React with 👍 / 👎.
| */ | ||
| export function updateDirsForSession(sessionId: string): string { | ||
| // Use first 8 chars of sessionId for a short, unique suffix | ||
| const sessionSuffix = sanitizeTempScopeSegment(sessionId.substring(0, 8)); |
There was a problem hiding this comment.
resolveCurrentSessionId() prefers getSessionFile(), so in normal sessions this argument is a full path like .../sessions/<id>.jsonl; taking the first 8 characters means every session under the same path prefix gets the same suffix after sanitization. That defeats the session-scoped directory isolation for concurrent Pi processes in the same environment; derive the suffix from the basename, actual session id, or a hash of the full identity instead.
Useful? React with 👍 / 👎.
Summary
Verification
Notes
This is intended as the combined upstreamable version of the spinner fix after the fork temporarily pinned session-scoped temp directory work. It supersedes the isolated spinner branch in #237 for users that need both fixes.