Skip to content

fix(location): report server home for tilde expansion - #55239

Closed
sghng wants to merge 5 commits into
anomalyco:devfrom
sghng:server-home-tilde
Closed

sghng wants to merge 5 commits into
anomalyco:devfrom
sghng:server-home-tilde

Conversation

@sghng

@sghng sghng commented Oct 13, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #55171

Type of change

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

What does this PR do?

/cd ~ in the TUI expanded ~ against the client's home directory before
sending it to the server. A macOS client attached to a Linux server therefore
sent /Users/<user> paths to a machine where they don't exist, and the
directory change failed with Location not found: /Users/<user>.

The root cause was two-fold: the client expanded too early with the wrong
home, and the server never reported its home directory — so a remote client
had no authoritative value to expand against. (packages/app even carried a
home: "" placeholder in loadPathQuery, waiting for the server to report
it.)

Same bug family as #47665 (client-side path resolution while attached to a
remote server), hit through the /cd slash command's tilde expansion.

  • Schema: Location.Info gains an optional home field. Optional so
    newer clients still decode older-server responses during version skew;
    excess-property stripping keeps old clients safe against newer servers.
  • Server: location.get reports home from Global.Service, yielded in
    the handler group generator (build time) so per-request effects keep
    requiring only middleware-provided services.
  • TUI: the /cd handler and directory autocomplete expand ~/~/...
    against the synced location home, falling back to the client home only for
    local servers or servers that don't report a home.
  • App: loadPathQuery fills its long-standing home: "" placeholder from
    the reported value, which brings the server-home-aware picker and display
    paths to life.
  • Regenerated the generated client types and the OpenAPI snapshots
    (packages/protocol, services/www).

home is reported exclusively by location.get: wrapped endpoints encode
through the Location.response/PublicRef wrapper, which carries only the
directory, so stamping it there never reached the wire (an earlier iteration
did; a test now locks the split in both directions).

How did you verify your code works?

Test cases run, attachment from client run.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

If you do not follow this template your PR will be automatically rejected.

sghng added 5 commits October 13, 2026 16:50
Clients attached to a remote server expanded ~ in /cd against their own
home directory, so a macOS client sent /Users/... paths to a Linux
server. The server never reported its home, leaving remote clients no
authoritative value to expand against.

- Location.Info gains an optional home field, populated by location.get
  and the response wrapper from the server's Global home
- the TUI /cd handler and directory autocomplete expand ~ against the
  synced location home, falling back to the client home for local or
  older servers
- the web app fills its path.home placeholder from the reported value
The server home now reaches the tab preview through loadPathQuery, so
the previously dead abbreviation branch runs for every connection.
Anchor it on the path prefix like the other home consumers instead of
replacing the first substring occurrence, which could rewrite a
directory that merely contains the home path.
Wrapped endpoints encode through Location.response, whose PublicRef
carries only the directory, so the home field set in the response
wrapper never reached the wire. home is reported exclusively by
location.get, and the test now locks that split: location.get carries
home while wrapped responses carry only the directory.
…ty home

The workerd runtime reports os.homedir() as an empty string, which is
not nullish, so it would win the ?? chain and expand ~ against nothing.
Treat it as absent and fall through to the client home.
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot closed this Oct 13, 2026
@opencode-agent

Copy link
Copy Markdown
Contributor

Thanks for tracking this down and for the clear write-up!

I think this duplicates #55203, which was opened earlier for the same issue (#55171) and is still being worked on:

Your version puts home on location.get and also fills the home: "" placeholder in packages/app. If you think either of those is worth having, please say so on #55203, or review or test it there. That would help get the fix in.

@sghng

sghng commented Oct 13, 2026

Copy link
Copy Markdown
Author

Thanks. That PR was created just 4hrs ago and I didn't notice.

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.

tui(v2): /cd tilde expansion uses client home for remote servers

1 participant