fix: web session handling and legacy session recovery - #1554
Conversation
Four fixes verified against the running daemon and web UI: - web: stop thinking blocks and tool calls from collapsing into one giant duplicated text blob when the page reconnects or resyncs mid-turn - web: keep the server access token across tab close and browser restarts, so it only needs to be entered once per device - web: add workspaces by typing an absolute path directly in the workspace picker's search box, with live validation and completion suggestions - agent-core: recognize the legacy top-level cwd in session state files so sessions created by older versions appear in the session list and open in the web UI
🦋 Changeset detectedLatest commit: 13c6568 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13c6568884
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // switches from fuzzy search to path mode. A valid path live-follows (the | ||
| // browser jumps to it, so "Open this folder" submits it); an invalid one | ||
| // shows a specific error plus prefix-matched candidates in the list. | ||
| const PATH_LIKE = /^(?:\/|~(?:\/|$))/; |
There was a problem hiding this comment.
Recognize Windows absolute paths
When the web UI is used with a Windows daemon, absolute paths such as C:\Users\me or UNC paths do not start with / or ~, so this predicate never enters path mode. The server-side browser accepts platform-absolute paths via node:path.isAbsolute, so these paths are instead treated as fuzzy-search text, and in degraded mode pressing Enter does nothing because the paste fallback was removed.
Useful? React with 👍 / 👎.
| // Success: keep the dialog alive so it can fly into the workspace anchor; it | ||
| // emits close when the animation finishes (handleCloseAddWorkspace owns | ||
| // showAddWorkspace from there). | ||
| addWorkspaceSucceeded.value = true; |
There was a problem hiding this comment.
Guard late workspace-add completions
If the user closes the picker while addWorkspaceByPath is still in flight and that request later succeeds, this late write leaves addWorkspaceSucceeded stuck at true after the dialog has unmounted. openAddWorkspace does not reset it, and AddWorkspaceDialog only reacts to a false→true change, so the next successful add will not trigger the success close/animation and the picker remains open.
Useful? React with 👍 / 👎.
|
Closing: the four bundled fixes have been split up.
Branch |
|
Correction: #1567 now carries only the server token persistence fix. The legacy session-recovery parts (legacy top-level |
Related Issue
No linked issue — these are four user-facing fixes verified together against the running daemon and web UI. Problems explained below.
Problem
in_flight_turnaccumulated the whole turn's text even though themessagestranscript already carried every completed step, so a reseeding client double-rendered prior steps as raw text.sessionStorageonly, so every new tab or browser restart forced entering it again.state.jsononly records a bare top-levelcwd, which the startup session-index rebuild did not recognize.What changed
Mid-turn resync (server + protocol + web)
InFlightTurnTrackerresets accumulated assistant/thinking text at everyturn.step.started, soin_flight_turndescribes only the step still streaming; completed steps come from the transcript.agentEventProjector) resets its local text/thinking counters at the same boundary so live deltas stay aligned with the seeded snapshot.packages/protocoldocuments the step-relative semantics on thein_flight_turnschema.Token persistence (web)
serverAuthmirrors the credential tolocalStorageinstead ofsessionStorage, so it survives tab close and browser restarts, with a one-time upgrade that adopts any legacysessionStoragecopy so the update itself does not force a re-entry. A 401 still clears it, andkimi server rotate-tokeninvalidates stale copies.Workspace path entry (web)
AddWorkspaceDialogswitches from fuzzy search to path mode when the input starts with/or~: live validation, prefix-matched completion candidates, and specific errors (path not found / parent does not exist). A valid path live-follows the browser so pressing Enter or "Open this folder" adds it; when file browsing is unavailable the picker degrades to a type-a-path box.Dialognow exposes its panel/overlay so consumers can run exit animations).useWorkspaceStateunions the global session walk (the same source Cmd+K search uses) into the per-workspace load, so sessions with inconsistent workspace mappings — symlinked cwds, stale index entries, removed workspaces — stay visible.Legacy session recovery (agent-core)
SessionStorereindex now falls back to the kimi-cli-era bare top-levelcwd(afterworkDirandcustom.cwd) when recovering a session's workDir, so those sessions get a correct index entry and appear in the web UI.buildProtocolContentpasses raw kosong content parts through for tool results that carry media (image/video/audio), matching the livetool.resultevent shape so REST consumers can still render the media.Tests: new
server-auth.test.ts(persistence + legacy-store migration), newinFlightTurnTracker.test.ts(step-boundary reset), extendedagent-event-projector/turn-logic(resync keeps structured blocks, no blob),message-service(media tool results), andsession-store(legacy cwd recovery).Verification: affected package suites pass — kimi-web 45 tests, agent-core 33 tests, server 4 tests — plus
vue-tsc/tsc --noEmittypechecks for the three touched packages. The four fixes were also verified end-to-end in the running web UI.Checklist
gen-changesetsskill, or this PR needs no changeset. (Four patch changesets included, one per fix.)gen-docsskill, or this PR needs no doc update. (Web UI behavior fixes; CLI user docs unaffected.)