Skip to content

fix(app): learn the server's home folder when the server connects after the window opens - #65773

Draft
Hona wants to merge 1 commit into
devfrom
fix/home-folder-after-connect
Draft

Hona wants to merge 1 commit into
devfrom
fix/home-folder-after-connect

Conversation

@Hona

@Hona Hona commented Nov 23, 2026

Copy link
Copy Markdown
Member

Issue for this PR

Closes #65772

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

A path under the home folder in a reply, such as ~/notes/todo.md, is a link when the file exists, and a click opens it. Until now the app never held the server's home folder, so the ~ expansion from #65689 never ran.

  • Cause: sync.tsx took the config and path results out of the useQueries list once. useQueries replaces its results whenever its options change, and the options read the connection status. A context created before the server connected kept the two results from before the connection.
  • Fix: createGlobalQueries in global-sync/bootstrap.ts reads each result from the list when it is asked for. The global store's path and config getters call it.
  • The session tab's preview path reads the same value, so a folder under home now shows as ~/… there.
sequenceDiagram
    participant S as sync.tsx
    participant Q as useQueries
    participant C as connection
    S->>Q: queries, enabled: connected() = false
    Q-->>S: [config A, path A] (pending, idle)
    Note over S: before: keeps A for good
    C->>Q: connected() = true
    Q->>Q: replaces the list with [config B, path B]
    Q->>Q: fetch, result lands in B (home folder known)
    Note over S: before: still reads A, home = ""
    Note over S: after: reads list[1] = B when asked
Loading
// before: the two results are taken once
const [configQuery, pathQuery] = useQueries(() => ({ queries: [/* enabled: connected() */] }))

// after: each result is read from the list when asked
const queries = useQueries(() => ({ queries: [/* enabled: connected() */] }))
const path = () => (queries[1].isPending ? empty : (queries[1].data ?? empty))

How did you verify your code works?

The desktop app on Windows, built from dev (7cfd868443) and from this branch, on a server whose default location is under C:\Users\tester, with a session whose reply names ~/notes/todo.md (exists), ~/notes/missing.md and src/util/format.ts:

~/notes/todo.md ~/notes/missing.md Home folder the store holds
Before plain code, no file request plain code ""
After link; a click opens the file in a tab plain code C:\Users\tester

packages/app/test-browser/global-queries.test.ts covers a server that connects after the context is created; it fails on the old shape with an empty home folder.

Screenshots / recordings

Before: ~/notes/todo.md is plain code After: it is a link, and a click opens the file
Before: the home path is plain code After: the home path is a link and its file is open in a tab

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…er the window opens

The global store took the config and path results out of the useQueries list once. useQueries replaces its results whenever its options change, and the options read the connection status, so the two results kept the state from before the server connected: the path stayed empty and ~ file links were never links.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop: a ~ path in a reply is never a link (the app holds no home folder for the server)

1 participant