Repository navigation
fix(chat): persist steering retry identity before dispatch #6254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
songoow
wants to merge
3
commits into
loopx-project:main
Choose a base branch
from
songoow:codex/steering-retry-persistence-20261012
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+117
−13
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
apps/presentation/dashboard/src/features/personal-workspace/steering-recovery.test.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
|
|
||
| const key = JSON.stringify(["inline", "session", "turn"]); | ||
| const request = {sessionId: "session", turnId: "turn", text: "Keep the original constraint", id: "original-request"}; | ||
|
|
||
| test("steering identity survives reload only after exact persistent readback", async () => { | ||
| let stored = null; | ||
| globalThis.window = {sessionStorage: {getItem: () => stored, setItem: (_, value) => {stored = value;}}}; | ||
| const first = await import("./steering-recovery.ts?write"); | ||
| assert.equal(first.retainSteeringRequest(key, request), true); | ||
| const reloaded = await import("./steering-recovery.ts?read"); | ||
| assert.deepEqual(reloaded.readSteeringRequest(key), request); | ||
| reloaded.retireSteeringRequest(key, "another-request"); | ||
| assert.deepEqual(reloaded.readSteeringRequest(key), request, "A late response cannot retire another request"); | ||
| reloaded.retireSteeringRequest(key, request.id); | ||
| assert.equal(reloaded.readSteeringRequest(key), undefined); | ||
| }); | ||
|
|
||
| test("unavailable storage preserves the page draft but refuses dispatch qualification", async () => { | ||
| let available = false, stored = null; | ||
| globalThis.window = {sessionStorage: {getItem: () => stored, setItem: (_, value) => { | ||
| if (!available) throw new Error("synthetic storage failure"); | ||
| stored = value; | ||
| }}}; | ||
| const recovery = await import("./steering-recovery.ts?unavailable"); | ||
| assert.equal(recovery.retainSteeringRequest(key, request), false); | ||
| assert.deepEqual(recovery.readSteeringRequest(key), request, "The unsent draft is still editable in this page"); | ||
| available = true; | ||
| assert.equal(recovery.retainSteeringRequest(key, request), true); | ||
| const reloaded = await import("./steering-recovery.ts?recovered"); | ||
| assert.deepEqual(reloaded.readSteeringRequest(key), request, "Repair does not mint a new operation identity"); | ||
| }); | ||
|
|
||
| test("a silently dropped browser write is not a durable retry identity", async () => { | ||
| globalThis.window = {sessionStorage: {getItem: () => null, setItem() {}}}; | ||
| const recovery = await import("./steering-recovery.ts?dropped"); | ||
| assert.equal(recovery.retainSteeringRequest(key, request), false); | ||
| assert.deepEqual(recovery.readSteeringRequest(key), request); | ||
| }); | ||
|
|
||
|
|
||
| test("a durable request retries independently of another conversation's unsaved draft", async () => { | ||
| let stored = null, writable = true; | ||
| globalThis.window = {sessionStorage: {getItem: () => stored, setItem: (_, value) => { | ||
| if (!writable) throw new Error("QuotaExceededError"); | ||
| stored = value; | ||
| }}}; | ||
| const recovery = await import("./steering-recovery.ts?independent"); | ||
| assert.equal(recovery.retainSteeringRequest(key, request), true); | ||
| writable = false; | ||
| const otherKey = JSON.stringify(["composer", "other-goal", "other-agent"]); | ||
| const other = {...request, sessionId: "other-session", turnId: "other-turn", id: "other-request"}; | ||
| assert.equal(recovery.retainSteeringRequest(otherKey, other), false); | ||
| assert.equal(recovery.retainSteeringRequest(key, request), true); | ||
| assert.deepEqual(JSON.parse(stored), [[key, request]]); | ||
| for (const field of ["sessionId", "turnId", "text", "id"]) { | ||
| assert.equal(recovery.retainSteeringRequest(key, {...request, [field]: "changed"}), false, field); | ||
| } | ||
| assert.equal(recovery.retainSteeringRequest("another-key", request), false); | ||
| globalThis.window.sessionStorage.getItem = () => {throw new Error("read unavailable");}; | ||
| assert.equal(recovery.retainSteeringRequest(key, request), false, "page cache is not persistent evidence"); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Qualify the current durable request rather than rewriting the whole shared cache. A can already have an exact persisted sessionId/turnId/text/id, while a failed B draft remains only in the shared Map. If storage cannot grow to A+B, retrying A returns false here and both callers refuse dispatch although A’s safety prerequisite is met. Reproduced in the actual helper across Goal/Agent keys and in the packaged inline/composer UI (zero POST, stored A unchanged; storage recovery sends A with the original ingress ID). Check the persisted target tuple and permit an exact already-durable retry; keep new/mismatched/read-failed identities blocked. Add this case alongside the existing never-persisted/drop tests.