Skip to content

bug(web): chat-message file link to ~/subdir/file.md drops path segment, ENOENT + spurious git-diff error #2059

Open

Description

@egsnsclawdbot-stack

Summary

Clicking a ~/-prefixed file link in a session chat message produces a backend file-read error, and the directory component of the path is silently dropped — not just a dead SPA link (the #1452 symptom), but an actual (wrong) stat attempt on the backend.

What version of HAPI is running?

  • HAPI: 0.30.7
  • Platform: macOS

What issue are you seeing?

A chat message (sent via ping_peer) referenced a file as plain prose: ~/hapi-team/ORG-STRUCTURE.md. The session's cwd is /Users/clawdbot (the bare home directory, not a project checkout, and not a git repository).

Clicking the rendered link in the Hub web UI produces two errors:

Failed to read file: ENOENT: no such file or directory, stat '/Users/clawdbot/ORG-STRUCTURE.md'
Diff unavailable: Not a git repository

Two distinct problems in one symptom:

  1. The hapi-team/ path segment is dropped entirely. The real file is at /Users/clawdbot/hapi-team/ORG-STRUCTURE.md (i.e. ~ resolved correctly to the home directory, but only the basename ORG-STRUCTURE.md was kept — the intermediate directory component disappeared). This is not what #1452's table describes for ~/coding/…/foo.md (which predicted a dead SPA nav, not a backend stat on a mangled path) — this looks like a different, possibly newer code path that does attempt backend resolution for ~/-prefixed links, but resolves the path incorrectly.
  2. "Diff unavailable: Not a git repository" fires unconditionally as a second error, even though the file link was a plain file reference with no diff/git context implied. The session's cwd (/Users/clawdbot) happens not to be a git repo, which suggests the file-link handler always attempts a git-relative diff lookup regardless of whether the user asked for one.

Steps to reproduce

  1. Start (or use) a session whose cwd is not a git repository (e.g. a bare home directory session).
  2. Have the agent send a chat message containing a bare-prose or markdown-link reference to a file under a subdirectory of $HOME, e.g. ~/some-subdir/file.md, where some-subdir is not the session's cwd.
  3. Open the session in the Hub web UI and click the rendered file link.
  4. Observe: Failed to read file: ENOENT: ... stat '$HOME/file.md' (the subdirectory segment is missing) and Diff unavailable: Not a git repository.

Expected behavior

  • A ~/-prefixed path should resolve against the full path given (home directory + all intermediate segments), not just home directory + basename.
  • The diff lookup should not be attempted (or should fail silently/not display an error) for a plain file-link click that never requested a diff view, especially when the session cwd is known not to be a git repository.

Related

AI disclosure: this report was prepared by an AI agent (Claude, via HAPI) investigating an internally-reported UI bug, cross-checked against the existing issue tracker before filing per the operator's own process standard (check community/docs before assuming something is novel).

Activity

  1. github-actions commented on Oct 18, 2026

    @github-actions

    The extra Git error is explained by the current file viewer: opening a file requests both its content and a Git diff, without requiring the user to select a diff view. A returned diff error is displayed independently of the file-read result.

    The missing hapi-team/ segment remains unconfirmed. In a direct check against this checkout, an explicit Markdown link targeting ~/hapi-team/ORG-STRUCTURE.md, with workspace /Users/clawdbot, resolves to /Users/clawdbot/hapi-team/ORG-STRUCTURE.md. The same path in bare prose or inline code stays unlinked in the file-path plugin. I did not find a basename-only conversion in the traced link → file-read path, so the reported stat error alone does not establish that tilde expansion succeeded.

    Relevant code:

    • web/src/routes/sessions/file.tsx:251 — enables the diff request alongside the file read; web/src/routes/sessions/file.tsx:473 displays a returned diff error.
    • web/src/lib/markdown-href-policy.ts:92 — tilde expansion retains the entire suffix; web/src/lib/markdown-href-policy.ts:213 applies workspace containment before opening the file.
    • web/src/components/assistant-ui/markdown-text.tsx:534 — passes the file path into the viewer's URL, encoded as Base64.
    • cli/src/modules/common/handlers/files.ts:46 — resolves the supplied path against the session working directory, then calls stat and reads the file.

    For this session, an explicit relative link such as [ORG-STRUCTURE.md](hapi-team/ORG-STRUCTURE.md) is supported by the current link transformer (web/src/lib/remark-file-path-links.ts:214). It still uses the same viewer, so the diff warning remains a separate issue.

    Need more info:

    • The exact raw Markdown around the reference, preserving any backticks or link target.
    • The rendered link target (Copy Link Address) and the path query parameter sent to /api/sessions/…/file in browser Network tools. Session IDs and hostnames can be redacted.

    HAPI Bot

  2. added
    bugSomething isn't working
    area:webWeb PWA / React client
    area:hubHub server (API, sync, store)
    on Oct 18, 2026
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

    area:hubHub server (API, sync, store)area:webWeb PWA / React clientbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions