Compare commits

..

2 Commits

Author SHA1 Message Date
jay 2c627ea095 Merge fix/post-sessions-response-shape: POST /sessions returns full shape 2026-05-16 22:18:54 +02:00
jay df735aa279 fix(sidecar): POST /sessions response now matches GET shape (id+name+state+lastOutputAt)
Previously POST returned only { id, name }, while GET returns
{ id, name, state, lastOutputAt }. iOS clients that share a Decodable
for both endpoints (e.g. SessionItem in pi-remote-ios) failed to decode
the POST response with 'data couldn't be read because it is missing'.

The new session always starts in 'idle' state with empty lastOutputAt.
Documented the new shape in the route header comment.
2026-05-16 22:07:54 +02:00
1 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/**
* S-09 multi-session CRUD routes.
*
* POST /sessions { id, name }
* POST /sessions { id, name, state, lastOutputAt }
* GET /sessions [{ id, name, description, state, lastOutputAt }]
* PATCH /sessions/:id updates @description
* DELETE /sessions/:id kills tmux session, optionally clears buffer
@ -110,7 +110,9 @@ async function handleCreate(
try {
const id = await spawnSession({ name });
sendJson(res, 201, { id, name });
// Include state + lastOutputAt to match the GET /sessions response shape
// so iOS clients can decode the response with the same type.
sendJson(res, 201, { id, name, state: "idle", lastOutputAt: "" });
} catch (err) {
sendJson(res, 500, { error: "internal_error", message: String(err) });
}