fix(settings): a tab-return read never undoes a pick or save made while it was out

- session-ui.js: drop the answer when the case-sync chain moved during the read; settings-ui.js calls _applyServerCaseSettings with ?.
- i18n.js: zh-CN for the failed case-options save toast, case name passed through
- tests: regression for the stale read, zh-CN toast row
This commit is contained in:
Devvyn committed 2026-11-09 14:01:09 +08:00
1 parent bb088bcd3e
commit 607c88afd9
5 files changed
+37 -2

No files matched your search

+4
View File
@@ -526,6 +526,10 @@ describe('the new toasts in zh-CN', () => {
'Saved on this device, not on the server: the server could not be reached',
'已保存到本设备,但未保存到服务器:无法连接到服务器',
],
[
'Options for "demo" (until the next sync) saved on this device, not on the server: HTTP 500',
'案例“demo”的选项已保存到本设备(同步前有效),但未保存到服务器:HTTP 500',
],
[`Tunnel not stopped: ${TORN}`, `隧道未停止:${TORN}`],
];
for (const [english, chinese] of cases) {
+24
View File
@@ -262,6 +262,30 @@ describe('returning to the tab', () => {
expect(unchanged.hidden.size).toBe(0);
});
it('does not undo a pick or a case save made while its read was out', async () => {
let release!: () => void;
const gate = new Promise<void>((r) => (release = r));
const { app, select, store } = makeApp({ syncCaseState: true }, async (_url, init) => {
if (init?.method === 'PUT') return { body: { success: true, data: {} } };
await gate; // the server read this copy before the pick and the save below reached it
return env({
syncCaseState: true,
lastPickedCase: 'alpha',
caseSettings: { beta: { agentTeams: false, opusContext1m: true } },
});
});
const refresh = app._syncCaseStateFromServer();
await settle();
select.value = 'beta';
await app.saveLastUsedCase('beta');
app.saveCaseSettings('beta', entry);
await app._caseSyncChain;
release();
await refresh;
expect(select.value).toBe('beta');
expect(JSON.parse(store.get('caseSettings_beta')!)).toEqual(entry);
});
it('asks for nothing on a tab return while this device has sync off', async () => {
const { app, select, calls } = makeApp({}, () => env({ syncCaseState: true, lastUsedCase: 'beta' }));
await app._syncCaseStateFromServer();