[GH-ISSUE #5422] [GUI] the browser-chat handover runs twice when two windows open on the first 0.2.11 start #3240

Open
opened 2026-11-07 14:39:06 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @TheHubUser4860938 on GitHub (Nov 6, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5422

Problem: on the first start after the 0.2.10 -> 0.2.11 upgrade, two windows opened together each hand the whole browser archive to the host: for a multi-MB archive the first start writes the archive twice and every moved chat lands at rev 2.

Environment: Strata 0.2.11 (app and Terminal 0.2.11, Control and engine 0.1.57) · Linux x86_64 · NVIDIA RTX 4090 24 GB, 125 GB RAM · Qwen3.8-Flash-Next family

Reproduce: fill one browser profile's localStorage with several chats (two windows share it), start the 0.2.11 host, open the app in two windows at once: both requests import; the host takes each chat once (content-safe) and the second window's writes raise every rev.
Expected: one import request from the window that claims the handover; the other window sees the claimed archive.
Actual: chat-sync.ts hydrateChats sets HOST_FLAG_KEY only after transport.importMany returns, and importMany is a loop of per-chat saves, not one queued unit - both windows read "not flagged" before either has set it.
Reproduction status: reproduced locally (two hydrateChats calls sharing one localStorage stub and one chat store: both report moved = N).

The fix we run: claim the flag synchronously before requesting the import, and read it after the initial list (a pre-list read is a snapshot the other window's claim cannot reach); a refused move clears the flag again so a disk-full handover is retried. Happy to PR it.

Originally created by @TheHubUser4860938 on GitHub (Nov 6, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5422 Problem: on the first start after the 0.2.10 -> 0.2.11 upgrade, two windows opened together each hand the whole browser archive to the host: for a multi-MB archive the first start writes the archive twice and every moved chat lands at rev 2. Environment: Strata 0.2.11 (app and Terminal 0.2.11, Control and engine 0.1.57) · Linux x86_64 · NVIDIA RTX 4090 24 GB, 125 GB RAM · Qwen3.8-Flash-Next family Reproduce: fill one browser profile's localStorage with several chats (two windows share it), start the 0.2.11 host, open the app in two windows at once: both requests import; the host takes each chat once (content-safe) and the second window's writes raise every rev. Expected: one import request from the window that claims the handover; the other window sees the claimed archive. Actual: `chat-sync.ts` `hydrateChats` sets `HOST_FLAG_KEY` only after `transport.importMany` returns, and `importMany` is a loop of per-chat saves, not one queued unit - both windows read "not flagged" before either has set it. Reproduction status: reproduced locally (two `hydrateChats` calls sharing one localStorage stub and one chat store: both report `moved = N`). The fix we run: claim the flag synchronously before requesting the import, and read it after the initial `list` (a pre-list read is a snapshot the other window's claim cannot reach); a refused move clears the flag again so a disk-full handover is retried. Happy to PR it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3240
No description provided.