Skip to content

desktop: file links to freshly created files stay inactive until the session is reopened #67360

Backlog

Description

@littlemontana

Description

In the Desktop app, a workspace-relative file path written as inline code in an agent's message (agent_work/.../REPORT.md) only becomes a clickable link after an existence check against the workspace file index. That check runs once, when the message block finishes rendering. The ripgrep-backed search index deliberately serves stale data for up to 10 seconds (packages/core/src/filesystem/search.ts, REFRESH_INTERVAL, background rescan introduced by #42348). So when an agent creates a file and immediately finishes with a report linking to it, the check runs inside the stale window, answers "does not exist", and the path stays plain code — until the user opens an older session from history and returns, which re-mounts the timeline and re-runs the check against the now-fresh index.

Markdown links (name) are unaffected because they never pass the existence check — they are always clickable and open fine. Absolute paths are unaffected too, because they are verified by a live parent-directory listing (/api/fs/list) instead of the index.

Measured on a real Windows project: /api/fs/find does not see a freshly created file for 0.3–9 s (typically ~9 s), while /api/fs/list of its folder shows it immediately.

Related but distinct: #65546 (ignored files never enter the index), #55863 (paths with spaces/directories are never linkified). PR #65571's exact-path-on-disk fallback would incidentally fix this case as well.

Plugins

superpowers (git), @nandoblanco/opencode-local-search@1.2.3, ru-hotkeys, search-in-session-local, session-id-copy, session-nav (bug reproduces independently of plugins: it is core path-link behavior; verified via API-level probes without touching the UI).

OpenCode version

Desktop 2.4.3 (V2, Windows x64; bundled CLI 2.4.3). Still present on dev HEAD 259e7cb (2026-11-30).

Steps to reproduce

  1. In any project, have the agent create a file, e.g. test-project/REPORT.md, and immediately finish with a short final message containing the relative path as inline code: test-project/REPORT.md.
  2. Within ~10 seconds of the file's creation, the path renders as plain inline code — not clickable, not styled as a link.
  3. Open any older session from history, then return to the original session: the same path is now a clickable link that opens the file in the side panel.
    API-level repro without the UI (server on 127.0.0.1:):

GET /api/fs/find?query=&type=file&limit=200&location[directory]= immediately after creating the file → data: [].
Repeat for ~9 s → still empty; then it appears (the index refresh completes).
Control: GET /api/fs/list?path=&location[directory]= right after creation → the file is listed immediately.

Expected behavior
A relative path in inline code that names a file the agent just created should become an active link immediately (or within the 5 s negative-TTL window, once any re-render happens) — without reopening the session.

Actual behavior
The path stays plain inline code indefinitely. The negative answer is cached for only 5 s (LINK_EXISTS_NEGATIVE_TTL_MS in packages/gui-plugins/src/file/link-exists-machine.ts), but nothing ever re-asks: markInlineCode (packages/session-ui/src/components/markdown.tsx) checks each completed block once, and a completed message never re-renders its blocks. Opening a session from history re-mounts the timeline and re-runs the checks — by then the index is fresh, so the link "comes alive". This makes the workaround from the user's point of view: links only work after switching sessions.

Suggested fixes (any one is sufficient)
Cheapest: in checkFileLinkExists (packages/gui-plugins/src/file/resolve-link.ts), fall back to files.exists() (live parent-directory listing, already used for absolute paths) when the index search misses for a relative path. PR #65571 implements essentially this for ignored paths.
Invalidate the GUI linkExists cache on filesystem.changed events and re-run checks for already-rendered blocks.
Make FileSystemSearch.find await its pending rescan instead of returning the prior index when the entry is older than REFRESH_INTERVAL.

Screenshot

None; deterministic text repro, no visual state needed.

Operating System

Windows 10 (10.0.19044, x64)

Terminal

Not applicable (Desktop app)

Activity

  1. added
    area/desktop
    type/bug
    version/v2
    on Nov 30, 2026
  2. opencodejr commented on Nov 30, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I reproduced the server side on 2.4.3, and it still happens on the latest dev (acf58399).

    With the ripgrep-backed index, which Windows uses by default:

    • I created test-project/REPORT.md about a second after the index was built.
    • /api/fs/list of the folder showed the file at once.
    • /api/fs/find?query=REPORT.md&type=file returned [] for about 9.2 s before it found the file.

    The script below shows this.

    I couldn't run the Desktop app here, so the rest is from reading the code:

    • Relative inline-code paths are checked only against that index; absolute paths use the live directory listing.
    • A finished message block checks its paths only once, when it stops streaming. So a miss during that window is never asked again, which matches what you saw.

    On Linux and macOS in git projects, the default index has a file watcher, and the file showed up after about 0.5 s. So the long delay mostly affects Windows and folders that aren't git repositories.

    Related: #65546 (ignored files never become links), with open PR #65571, and #55863.

    Reproduction script (repro.sh)
    #!/bin/sh
    # Reproduces #67360: /api/fs/find (used for relative inline-code links) misses a
    # freshly created file for up to ~10 s, while /api/fs/list sees it at once.
    # Usage: OPENCODE="opencode" sh repro.sh   (or OPENCODE="bun ... packages/cli/src/index.ts")
    set -e
    # OPENCODE_DISABLE_FFF=1 selects the ripgrep-backed index, the default on Windows (the reported platform).
    OPENCODE=${OPENCODE:-opencode}
    PORT=${PORT:-4987}
    PROJ=$(mktemp -d)
    cd "$PROJ"; git init -q; echo a > existing.md; mkdir test-project; git add .; git -c user.email=a@b -c user.name=a commit -qm init
    LOG=$(mktemp)
    OPENCODE_DISABLE_FFF=${OPENCODE_DISABLE_FFF-1} $OPENCODE serve --hostname 127.0.0.1 --port $PORT > "$LOG" 2>&1 &
    PID=$!
    trap 'kill $PID 2>/dev/null' EXIT
    for i in $(seq 1 60); do grep -q "server password" "$LOG" && break; sleep 0.5; done
    PW=$(sed -n 's/^server password //p' "$LOG")
    BASE="http://127.0.0.1:$PORT/api/fs"
    LOC="location%5Bdirectory%5D=$PROJ"
    q() { curl -s -u "opencode:$PW" "$1"; }
    echo "warm index: $(q "$BASE/find?query=existing&type=file&limit=200&$LOC")"
    sleep 1
    echo hello > test-project/REPORT.md
    T0=$(date +%s%3N)
    echo "created test-project/REPORT.md"
    echo "list right after create: $(q "$BASE/list?path=$PROJ/test-project&$LOC")"
    for i in $(seq 1 30); do
      R=$(q "$BASE/find?query=REPORT.md&type=file&limit=200&$LOC")
      T=$(( $(date +%s%3N) - T0 ))
      echo "t=+${T}ms find: $R"
      echo "$R" | grep -q REPORT && break
      sleep 0.5
    done

    Run it: sh repro.sh

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/desktopplatform/windowsreproducedtype/bugversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions