#15684: fix(telegram): persist relative session transcript paths
stale
size: XS
Cluster:
Session Management Enhancements
## Summary
- fix session-state persistence to store `sessionFile` as a relative filename instead of an absolute path
- normalize both normal and forked-session transcript path assignment via `path.basename(...)`
- prevents Telegram inbound handler failures caused by strict sessions-dir validation rejecting absolute `sessionFile` values
## Verification
- reproduced failure locally with logs showing `Session file path must be within sessions directory` on inbound Telegram messages
- applied equivalent runtime patch and confirmed Telegram responses resumed
- ported fix to source in `src/auto-reply/reply/session.ts`
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adjusts session-state persistence in `src/auto-reply/reply/session.ts` so `sessionEntry.sessionFile` is stored as a relative filename (via `path.basename(...)`) for both newly created sessions and forked sessions. This aligns persisted state with `resolveSessionFilePath(...)` strict containment checks in `src/config/sessions/paths.ts`, avoiding failures when absolute paths would be rejected as “not within sessions directory.”
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is narrowly scoped to session-file persistence and is consistent with the existing path-validation logic (which expects a within-sessions-dir relative path). Repository code confirms transcript paths are simple filenames, so using `path.basename` will not drop required subdirectory information.
- src/auto-reply/reply/session.ts
<sub>Last reviewed commit: 3bd7b82</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#15888: fix: store relative session file paths instead of absolute
by devAnon89 · 2026-02-14
86.2%
#16061: fix(sessions): tolerate invalid sessionFile metadata
by haoyifan · 2026-02-14
85.9%
#17132: fix: filter out invalid session entries with empty sessionFile
by Limitless2023 · 2026-02-15
82.4%
#3410: fix(sessions): always compute session paths from current environment
by sakunsylvi · 2026-01-28
81.0%
#15793: fix(sessions): gracefully handle stale cross-agent session file paths
by lxcong · 2026-02-13
79.5%
#15744: fix: allow cross-agent session path validation
by scottgl9 · 2026-02-13
78.8%
#20188: fix: Update sessionFile path when rolling to new session in cron jobs
by jriff · 2026-02-18
78.0%
#15176: fix(sessions): allow channel-routed session IDs and cross-agent paths
by cathrynlavery · 2026-02-13
77.9%
#18593: fix: resolve symlinks in session path validation (#18553)
by EpaL · 2026-02-16
77.8%
#15493: feat(telegram): session state memory for diagnostic continuity
by tangcruz · 2026-02-13
77.7%