Skip to content

Bug: Project path incorrectly reconstructed when username contains underscores — causes "Failed to send prompt" #465

Description

@mikesmichal

Bug Description

When a system username contains an underscore (e.g. michal_mikes), opcode reconstructs project paths incorrectly, causing "Failed to send prompt" on every prompt submission in the Projects view.

Root Cause

Claude CLI encodes project paths into directory names under ~/.claude/projects/ by replacing both / and _ with -. For example:

/home/michal_mikes/projects  →  -home-michal-mikes-projects

When opcode reads this directory name and reconstructs the original path, it only performs the reverse of / → -, yielding:

-home-michal-mikes-projects  →  /home/michal/mikes/projects   ❌

The underscore in the username is lost, producing a path that does not exist on disk. Claude CLI then fails to start because the working directory is invalid, and opcode surfaces this as "Failed to send prompt".

The correct path should be /home/michal_mikes/projects ✅

Steps to Reproduce

  1. Use a Linux/macOS system where the username contains an underscore (e.g. john_doe)
  2. Open opcode and navigate to the Projects tab
  3. Select any project
  4. Type any prompt and press Enter

Result: "Failed to send prompt" error immediately.

Workaround

Manually fix the corrupted projectPath values in opcode's localStorage SQLite database:

~/.local/share/opcode.asterisk.so/localstorage/tauri_localhost_0.localstorage

Values are UTF-16LE encoded JSON. Replace occurrences of /home/john/doe/ with /home/john_doe/ in the projectPath fields.

Expected Behavior

The path reconstruction from the Claude project directory name should either:

  • Read the cwd field directly from the session .jsonl files inside the project directory (which contain the correct original path), or
  • Use a reversible encoding that distinguishes / from _ (e.g. encode only / as - and leave _ as-is, or use a different separator)

Environment

  • OS: Ubuntu 22.04 LTS
  • opcode version: 0.2.0
  • Claude Code version: 2.1.139
  • Username: contains underscore

Related Issues

Activity

  1. mikesmichal commented on May 12, 2026

    @mikesmichal
    Author

    Follow-up investigation — bug is broader than the username case

    After further testing I found the root cause affects any project whose path contains a dash, not just usernames with underscores. The problem is that opcode converts every - in the Claude project directory name back to /, while Claude CLI originally encoded both / path separators and - dashes in directory names as -.

    Full encoding ambiguity

    Claude CLI creates project directory names by replacing / with - (and also _ with -).
    Example:

    /home/michal_mikes/projects/teamio-acnas  →  -home-michal-mikes-projects-teamio-acnas
    

    Opcode reverses this naively (- → /), producing:

    -home-michal-mikes-projects-teamio-acnas  →  /home/michal/mikes/projects/teamio/acnas  ❌
    

    Correct path: /home/michal_mikes/projects/teamio-acnas ✅

    On a system with 22 Claude projects, all 22 had wrong paths after reconstruction. Every project with a dash in its name is broken (teamio-acnas, alma-career-api-docs, advertplatform-advert-model, …).

    Why the localStorage workaround doesn't hold

    Opcode rebuilds project paths from directory names every time it starts (the list_projects command runs on startup). Any manual fix to the localStorage SQLite DB is overwritten within seconds.

    The session files already have the answer

    Each project directory under ~/.claude/projects/<encoded-name>/ contains .jsonl session files. Every session line that has a cwd field contains the original, correct path. The code already has a path for this — the log message "Failed to get project path from sessions for , falling back to decode" confirms it tries session files first. However, newer Claude session files begin with last-prompt or permission-mode entries (no cwd), so the lookup fails and the broken decode is used as fallback.

    Fix suggestion: when reading a session file to extract cwd, scan beyond the first line until a line with a non-empty cwd is found (or scan all lines in the file), rather than giving up after the first line.

    Minimal reproducible case (no special username needed)

    1. Use any project whose directory name contains a dash, e.g. /home/user/my-project
    2. Claude encodes it as -home-user-my-project
    3. Opcode decodes it as /home/user/my/project — path does not exist → "Failed to send prompt"

    This means the bug affects a large share of Linux/macOS users, not just those with underscores in their username.

  2. amityweb commented on Jun 25, 2026

    @amityweb

    Yes same here, new install of opcode on Mac OS and the Recents show all my projects replacing - with / and it takes the last word after the hyphen/slash as the project name so not very good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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