Skip to content

fix(modules): watch getSessionsDir() so XDG sessions reach the sidebar (rework of #303) - #551

Merged
kahme247 merged 2 commits into
mainfrom
rework-pr-303-2026-11-23
Nov 23, 2026
Merged

kahme247 merged 2 commits into
mainfrom
rework-pr-303-2026-11-23

Conversation

@kahme247

@kahme247 kahme247 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

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
  • npm run typecheck (tsc --noEmit): clean
  • npx eslint lib/session-watcher.ts lib/session-reader.test.mjs: clean

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.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: gzaripov, andrebrait

Merge Risk: Minimal · up to a7ce0

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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed 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 Passed 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

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 1
  • Waived: $0.25 (charged $0.00)
  • View usage details

Note

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.

@kahme247
kahme247 merged commit 46f54cc into main Nov 23, 2026
5 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.

1 participant