You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(modules): watch getSessionsDir() so XDG sessions reach the sidebar (rework of #303) - #551
Maintainer rework of #303 (by kahme247): "fix(modules): watch getSessionsDir() so XDG sessions reach the sidebar".
The original PR's only blockers were a rebase onto current main and its
source-spelling test. This rework is rebased onto current main
(5d7232a) and replaces the source-spelling
test with a behavioral test.
Fix
lib/session-watcher.ts: the watcher derived its directory from join(getAgentDir(), "sessions"), i.e. ~/.omp/agent/sessions, while the
session lister reads getSessionsDir(), which honors the XDG layout
($XDG_DATA_HOME/omp/sessions when that opt-in exists). Under XDG the
watcher therefore watched a directory the lister never reads, so external
session changes never reached the sidebar (or it retried a nonexistent
directory forever). The watcher now watches getSessionsDir() — the same
directory the lister reads.
Test
Replaces the original lib/session-watcher.test.mjs source-text assertions
with a behavioral test in lib/session-reader.test.mjs, next to the existing
native watcher tests:
"native watcher follows the XDG sessions dir so external changes reach the
sidebar" sets up a real XDG layout ($XDG_DATA_HOME/omp/sessions with the
opt-in marker directory, default agent dir), writes a session file there,
asserts listAllSessions() sees it (the sidebar listing reads the XDG dir),
subscribes to the watcher, appends entries to the file, and asserts the
listener is notified with that session id and the appended entries become
visible after invalidation.
Negative control: the test times out (15 s, no notification ever arrives) on
the pre-fix code, and passes in under 1 s with the fix.
Tests run
bun test --parallel lib/session-reader.test.mjs: 52 pass, 0 fail
Supersedes #303; please close#303 once this is verified.
Summary by CodeRabbit
Bug Fixes
Native session-file notifications now follow changes in the configured sessions directory, including the opt-in XDG sessions layout. Updates to a session are reflected in its parsed contents.
Tests
Added integration coverage verifying that sessions in the XDG layout are listed, their IDs resolve, and file changes trigger notifications and expose appended entries.
No actionable comments were generated in the recent review.
Walkthrough
The session watcher now monitors the directory returned by getSessionsDir(). An integration test checks session discovery, watcher notifications, parse-cache invalidation, and appended entries with the XDG layout.
Changes: Session watcher
Layer / File(s)
Summary
Watch the configured sessions directory lib/session-watcher.ts, lib/session-reader.test.mjs
ensureWatcher now watches getSessionsDir(). The integration test verifies XDG session discovery and resolution, watcher notifications after file changes, parse-cache invalidation, and access to appended entries.
The session watcher now watches the same sessions directory the session list reads, so XDG-layout session changes reach the sidebar. No actionable merge-blocking risk is evident, and a Unix-only integration test covers the new behavior.
Architecture risk: Low · up to a7ce0
The change affects 1 system.
Changed systems:lib
Architecture concerns
No architecture-level concerns identified.
Review details
Systems and components
observed — lib (service) was modified; 2 changed files map to changed impact.
Before / after behavior
observed — Modified behavior in lib/session-watcher.ts: The session-reader import no longer includes getAgentDir; getSessionsDir is imported from ./omp/paths.
observed — Modified behavior in lib/session-watcher.ts: ensureWatcher now watches getSessionsDir() instead of join(getAgentDir(), "sessions"); the old path derivation is removed.
observed — Modified behavior in lib/session-reader.test.mjs: Adds a Windows-skipped integration test that sets XDG_DATA_HOME without PI_CODING_AGENT_DIR, confirms the session is listed, and checks that native watcher notifications follow appends and invalidate the changed file’s parse cache. It restores both environment variables, invalidates the list cache, and removes the temporary XDG directory in cleanup.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: session-watcher.ts now watches getSessionsDir() so XDG-layout sessions reach the sidebar. The raw summary confirms the switch from getAgentDir to getSessionsDir in lib…
Linked Issues check
The only directly linked issue, #303, is closed. Per the assessment rules, it supplies historical context only, so no active linked-issue coding requirements apply. The reviewed head also contains the…
Out of Scope Changes check
The whole-PR change set (merge base 5d7232a to head a7ce01e) touches two files. (1) lib/session-watcher.ts: the diff removes the getAgentDir import and adds the getSessionsDir import. It also changes …
Full details: Title check
Explanation
The title names the main change: session-watcher.ts now watches getSessionsDir() so XDG-layout sessions reach the sidebar. The raw summary confirms the switch from getAgentDir to getSessionsDir in lib/session-watcher.ts, and the objectives describe the same fix. The '(rework of #303)' reference is extra context and does not affect the match.
Full details: Linked Issues check
Explanation
The only directly linked issue, #303, is closed. Per the assessment rules, it supplies historical context only, so no active linked-issue coding requirements apply. The reviewed head also contains the change #303 describes. In lib/session-watcher.ts, ensureWatcher() now watches getSessionsDir() (imported from ./omp/paths) instead of join(getAgentDir(), "sessions"). This matches the directory the session lister reads. The added behavioral test in lib/session-reader.test.mjs covers the XDG path. These points are supporting evidence only, not requirements.
Full details: Out of Scope Changes check
Explanation
The whole-PR change set (merge base 5d7232a to head a7ce01e) touches two files. (1) lib/session-watcher.ts: the diff removes the getAgentDir import and adds the getSessionsDir import. It also changes the watched directory in ensureWatcher() and adds a comment. This is the fix described by #303 and by the PR description. (2) lib/session-reader.test.mjs (about +73/-0, per the summary): a Unix-only behavioral test for the native watcher under the XDG layout. It checks that the lister sees the session, that an append notifies the watcher, and that the entries become visible after invalidation. The test supports the fix and is in scope. No change found falls outside the watcher fix or its test. The test-file hunks were not read directly; this conclusion relies on the summary for that file.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: c49e3c6a-45b1-410b-a746-05e9bde289c7
Commits
Reviewing files that changed from the base of the PR and between 19e612c and a7ce01e.
Files selected for processing: 1
lib/session-reader.test.mjs
Limit details: You’ve used all 10 included reviews currently available.
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
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.
Maintainer rework of #303 (by kahme247): "fix(modules): watch getSessionsDir() so XDG sessions reach the sidebar".
The original PR's only blockers were a rebase onto current main and its
source-spelling test. This rework is rebased onto current main
(5d7232a) and replaces the source-spelling
test with a behavioral test.
Fix
lib/session-watcher.ts: the watcher derived its directory fromjoin(getAgentDir(), "sessions"), i.e.~/.omp/agent/sessions, while thesession lister reads
getSessionsDir(), which honors the XDG layout(
$XDG_DATA_HOME/omp/sessionswhen that opt-in exists). Under XDG thewatcher therefore watched a directory the lister never reads, so external
session changes never reached the sidebar (or it retried a nonexistent
directory forever). The watcher now watches
getSessionsDir()— the samedirectory the lister reads.
Test
Replaces the original
lib/session-watcher.test.mjssource-text assertionswith a behavioral test in
lib/session-reader.test.mjs, next to the existingnative watcher tests:
"native watcher follows the XDG sessions dir so external changes reach the
sidebar" sets up a real XDG layout (
$XDG_DATA_HOME/omp/sessionswith theopt-in marker directory, default agent dir), writes a session file there,
asserts
listAllSessions()sees it (the sidebar listing reads the XDG dir),subscribes to the watcher, appends entries to the file, and asserts the
listener is notified with that session id and the appended entries become
visible after invalidation.
Negative control: the test times out (15 s, no notification ever arrives) on
the pre-fix code, and passes in under 1 s with the fix.
Tests run
bun test --parallel lib/session-reader.test.mjs: 52 pass, 0 failnpm run typecheck(tsc --noEmit): cleannpx eslint lib/session-watcher.ts lib/session-reader.test.mjs: cleanSupersedes #303; please close #303 once this is verified.
Summary by CodeRabbit