mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-24 04:47:03 +00:00
* fix: keep one stable HAPI session id per Claude conversation Every terminal `hapi claude -r` minted a new HAPI session id for the same Claude conversation; the hub then merged the duplicates after the fact and deleted the older row, so links and peer references to it broke, and two live duplicates hid one row in the web sidebar. CLI: resolve identity before Claude starts (HAPI_SESSION_ID is fixed at bootstrap). `--resume <id>` / `--continue` look up the owning HAPI session and reopen it with the same id, handing an active remote session over and refusing one controlled by another terminal; bare `--resume` uses the `hapi resume` picker filtered to Claude. Rotated Claude ids are kept in `claudeSessionIdHistory` so older ids still match. Hub: schema v35 adds `session_redirects`; every merge that deletes a row records old -> survivor, and client-facing lookups follow it (sockets and job ownership stay strict). New `GET /cli/sessions/resume-target-by-agent`. Web: a merged-away URL moves to the survivor instead of bouncing home, and live Claude duplicates stay visible in the sidebar. * fix: keep job-key remaps and hub-archived resumes working after redirects Review follow-up for the stable session identity change. - Job routes: the session lookup now follows a merged-away id to the survivor, so `requestedSessionId` must stay the raw URL id. Otherwise a colliding `<old id>/<key>` remap was bypassed and PATCH/DELETE/late PUT through the old id hit the survivor's own job. - Terminal resume of an inactive session now asks the hub to clear a hub-authored archive first (`POST /cli/sessions/:id/prepare-local-resume`, same clear as hub reopen), so `hapi claude --resume/--continue` (and `hapi resume`) no longer exit on the #1911 existing-session guard. * fix(cli): refuse an explicit Claude resume whose transcript is gone Reopening the owning HAPI session drops --resume and hands the id to the local launcher, which silently starts a fresh conversation when the transcript is missing — under the existing HAPI id, title and history. Check the transcript before any handoff or archive change and fail explicitly instead. * fix: follow merged-session redirects on /api only for clients that rebind Native clients store a session detail under the requested id and drop SSE events for any other id, so a merged-away id that resolved to the survivor loaded history but never showed live messages. `SyncEngine.resolveSessionAccess` is strict again by default; `/api` routes follow redirects only with `x-hapi-follow-session-redirects: 1`, which the web client (that rebinds to the returned id) sends. Native clients keep the previous 404. CLI REST always follows. Job routes still keep the raw URL id for key remaps under both modes.