Skip to content

[BUG] [v0.0.7] cortex sessions cwd filter hides sessions when session cwd is a symlink path (must use --all) #48554

@Ashishpan321

Description

@Ashishpan321

Project

cortex

Description

cortex sessions filters sessions by current working directory unless --all is passed. If a session was created while the shell was in a symlinked directory, the session stores the symlink string in cwd, but std::env::current_dir() resolves to the real path. The strict path equality check fails, so the session is hidden and sessions --json returns [] even though the user is “in the same directory”.

Error Message

Debug Logs

System Information

linux

Screenshots

Image

Steps to Reproduce

cd cortex
bin=/home/im8/bounty-challenge/cortex/target/debug/Cortex
tmp="$(mktemp -d)"

root="$tmp/root"
real="$root/real"
link="$root/link"
mkdir -p "$real"
ln -s "$real" "$link"

Create a minimal session rollout with cwd stored as the symlink path

mkdir -p "$tmp/.cortex/sessions"
cat >"$tmp/.cortex/sessions/symlinked.jsonl" <<EOF
{"timestamp":"2026-04-06T00:00:00Z","type":"session_meta","payload":{"id":"symlinked","parent_id":null,"fork_point":null,"timestamp":"2026-04-06T00:00:00Z","cwd":"$link","model":"gpt-4o","cli_version":"0.0.7","instructions":null}}
EOF

Run from inside the symlinked directory

cd "$link"
pwd -L
pwd -P
readlink -f .

HOME="$tmp" "$bin" sessions --json; echo "exit=$?"
HOME="$tmp" "$bin" sessions --json --all; echo "exit=$?"

Expected Behavior

Without --all, cortex sessions should still show sessions for “this directory”, even if the directory is entered via a symlink path.

Actual Behavior

Without --all, output is [] (session is hidden). With --all, the session appears.

Additional Context

Code Evidence

src/cortex-cli/src/cli/handlers.rs: list_sessions() filters by strict equality: if !all ... && s.cwd != *cwd { return false; } (no canonicalization).
src/cortex-engine/src/session/lifecycle.rs: list_sessions() sets cwd = PathBuf::from(&meta.cwd) using the stored string verbatim.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingideIssues related to IDEvalidValid issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions