Repository navigation
fix(client): treat an empty XDG_STATE_HOME as unset - #61288
JorgeRojas2712 wants to merge 2 commits into
Conversation
`fallback()` resolved the registration path with `??` while `roots()` uses `||`, so an empty `XDG_STATE_HOME` made the client look at the relative `opencode/service.json` while the server still wrote to `$HOME/.local/state`. The XDG spec defines the same default for an unset and an empty value, so a healthy service was invisible to default discovery. Fixes anomalyco#61259
There was a problem hiding this comment.
The fix works. I ran the #61259 reproduction in both checkouts. On the base, an empty XDG_STATE_HOME makes the client look for the relative path opencode/service.json while the server writes to $HOME/.local/state/opencode/service.json. With this change, the unset, empty and absolute values all resolve to the same path as the server's roots(). In packages/client, the full test suite passes (260/0) and tsc --noEmit is clean. Every caller still uses options.file ?? fallback(), so an explicit file still takes precedence.
Public API: no API changes. The only change in behaviour is that the client now treats an empty XDG_STATE_HOME as unset, as the server and the XDG spec already do (backwards compatible).
One small point: the three-line doc comment isn't needed for a one-character fix and can be dropped to keep the change minimal. Also note that #60683 edits the same fallback() line, so one of the two will need a rebase.
Related: #56708
There was a problem hiding this comment.
The new commit only merges dev and doesn't change this fix. I re-ran the #61259 reproduction on the new head: with XDG_STATE_HOME unset, empty or set to a full path, the client and server resolve the same registration path, and service-fallback.test.ts passes. Public API is unchanged: the only change in behaviour is that the client now treats an empty XDG_STATE_HOME as unset, like the server already does (backwards compatible). Nothing new to raise.
|
Hola 👋 Este PR está listo para revisión, pero los workflows siguen en El bot de triage ya volvió a correr la reproducción de #61259 sobre el head actual y no encontró nada que objetar. ¿Falta algo más de mi parte, o hace falta que alguien apruebe los workflows para que el PR avance? |
Issue for this PR
Closes #61259
Type of change
What does this PR do?
fallback()resolved the default service registration with??, so an emptyXDG_STATE_HOMEproduced the relative pathopencode/service.json. The server'sroots()uses||and keeps writing to$HOME/.local/state, so a running service was invisible to default client discovery. The XDG spec treats an empty value like an unset one, so I changed the operator to match the server.How did you verify your code works?
I reproduced it first with a temporary
HOME: unset and absoluteXDG_STATE_HOMEresolved to the same path as the server, empty did not. After the change all three match.bun testinpackages/client: 260 pass, 0 fail.bun run typecheckinpackages/client: no errors.packages/client/test/service-fallback.test.tscovers unset, empty and absolute values. The empty case fails ondevwithout the source change.Checklist
Added by the opencode bot (AI-generated).
Related: #56708