Skip to content

Standalone CLI derives wrong agent labels from the encoded project dir #381

Description

@McGars

Version: pixel-agents@1.4.0 (standalone CLI, macOS, Node 25.9)

Summary

In standalone CLI mode, the label shown above a character is derived by splitting Claude Code's
encoded project-directory name on - and taking the last segment. That encoding is lossy — Claude
Code replaces both / and _ with - — so the last segment is frequently not the folder name.

Result: several unrelated projects render with the same meaningless label.

Reproduce

  1. Have Claude Code sessions in folders whose names contain _ or -, e.g.
    ~/work/acme/mobile_client_new.
  2. Run pixel-agents --port 3100, enable Settings → Watch All Sessions.
  3. Enable Always show labels.

Observed

encoded project dir label shown actual folder
-Users-<u>-personal-ai-work work personal_ai_work
-Users-<u>-work-acme-mobile-client-new new mobile_client_new
-Users-<u>-workflow-my-openclaw openclaw my-openclaw
-Users-<u>-workflow-my-openclaw-skills-report-subagent subagent report-subagent

Three concurrent sessions from the same repo all render as new, so characters are
indistinguishable.

Root cause

dist/cli.js:

function fs(t){ let e = t.replace(/^-+/,"").split("-"); return e[e.length-1] || t }

It is used only as the fallback branch of a resolver hook that the VS Code adapter supplies:

let h = Rt?.({ cwd: n, projectDir: u }) ?? fs(w.basename(u));

In standalone mode Rt is undefined, so the lossy fallback is always taken. The information needed
to undo the encoding is not present in the directory name — but it is present in the transcript:
every .jsonl record carries the real cwd.

$ head -1 ~/.claude/projects/-Users-<u>-work-acme-mobile-client-new/<session>.jsonl | jq -r .cwd
/Users/<u>/work/acme/mobile_client_new

Suggested fix

Provide an Rt implementation for standalone that reads cwd from the newest .jsonl in the
project dir and returns path.basename(cwd), falling back to the current behaviour on any error.
The first call site already has cwd in scope and could pass it straight through.

I verif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions