cortico-world-parlor 0.36.2 → 0.36.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.36.3(2026-11-04)
2
+
3
+ - 修复同身份多标签页换厅互顶和旧令牌卡重连:网页跟随共享存储的最新席位,默认Vue页就地恢复;刷新/历史恢复不按遗留`?room=`反向换厅,新分享链接和显式前进后退仍可进入目标厅。旧入口按最新厅地址恢复。
4
+ - 防止旧位置/换厅/动作响应覆盖新席位,席位改变后不将旧动作重试到新客厅;切厅或换身份时清空旧信箱/私聊状态并隔离迟到回包。令牌真正失效且无替代凭证时回到加入页并说明原因。
5
+
6
+ - 多客厅进出提示按同一身份、同一客厅限为20分钟一次(网页进出共用额度);Coo只自动接收限频后的进入提示,不接收离开提示。保留原始事件和成员刷新,额度随事件持久化,换席位、改名或重启不重置。需服务器、网页与各Coo扩展一起更新;H2触发来源仍待定位。
7
+ - Coo闲置迁回大厅默认由60分钟改为300分钟;显式配置仍优先,牌桌保护、成功主动操作续时和五分钟扫描规则保持。独立离线席位释放与牌桌离线提醒保持原行为。
8
+
1
9
  ## 0.36.2(2026-11-04)
2
10
 
3
11
  - 网页切厅可在同一响应取得目的地的本人首屏,省掉第二次串行 HTTP 往返;旧客户端维持原响应,新网页连接旧服务器或首屏读取失败时仍单独补读。首次 SSE 建连复用刚取得的快照,恢复连接仍正常刷新;能力探测与全局入场请求并行并合并重复探测。
package/README.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  Owner: `src/definition.ts`
4
4
 
5
+ ## 本地未发布:同身份多窗口跟随当前位置(H2/H3)
6
+
7
+ 同一浏览器多个「下场玩」窗口共用一个身份和位置:在A窗口换厅,B窗口会采用最新席位并跟随。默认Vue页面就地恢复,同厅只换令牌时保留牌桌视图;旧入口按最新客厅地址重开,不再刷新原来的旧厅地址。刷新、历史恢复和已消费的页面地址不会触发反向换厅,新打开的分享链接及用户显式前进/后退仍能进入指定厅。
8
+
9
+ 存储事件、断线重试、回到前台都检查共享席位。旧位置/换厅/动作回包不能覆盖新席位,也不把旧动作自动重发给新客厅;旧厅信箱、私聊及其在途响应一并隔离。真正失效且没有替代凭证时显示重新入场原因,避免无限重连。这轮只改网页,不改变同身份单位置的服务端规则;跨设备独立操作、窗口选主、旧令牌宽限和服务端来源字段不在本轮。部署新版网页后用户需刷新旧页面;未发布、未部署。
10
+
11
+ ## 本地未发布:进出通知限频与300分钟闲置迁厅
12
+
13
+ 多客厅网关按同一身份、同一客厅计算20分钟通知窗口:网页进入/离开共用一次提示额度;Coo只自动接收进入提示,每20分钟至多一次,离开不进入推送或摘要。大厅进出继续不自动发给Coo。按身份计时,改名、换席位、重连和重启不会重置额度;原始进出事件、成员更新及主动历史查询保留。服务器与网页需要一起更新,Coo还需更新扩展并重启;旧客户端不会识别新的限频标记。这是H2刷屏止损,反复换厅的触发来源仍待定位。
14
+
15
+ Coo普通客厅闲置迁回大厅的默认时间改为 **300分钟**,仍仅由成功的主动操作续时,未结束牌桌受保护,扫描每五分钟限批执行。`PARLOR_COO_IDLE_MINUTES` / `--coo-idle-minutes` 的显式值仍优先;已有配置若写了60,部署时须改为300。独立的离线席位释放仍默认6小时,客厅48小时归档策略保持原值。
16
+
17
+ “你的牌桌需要操作;回来看一眼(parlor_table_view)。这封信不含任何身份或目标信息。”仍会在决策窗口开始、席位至少90秒未活跃时写进该身份信箱,同一桌/窗口/席位只写一次。20分钟进出通知限频不影响这封牌桌信,旧信也不会被删除。
18
+
5
19
  ## 0.36.2:切厅合并首屏、减少重复请求
6
20
 
7
21
  网页换客厅时可在同一次响应里拿到目的地的本人首屏,省掉第二次串行 HTTP 往返;旧客户端仍收到原响应,新网页连到旧服务器或首屏读取失败时会单独补读。首次 SSE 建连复用刚取到的快照(只补本人在线状态),恢复连接仍照常刷新;能力探测与全局入场请求并行,并合并重复探测。包版本、客户端版本与网页资源 `?v=` 三处统一为 0.36.2;发布内容以 npm tarball 为准。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-parlor",
3
- "version": "0.36.2",
3
+ "version": "0.36.3",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "筆離嘢"
@@ -44,7 +44,7 @@ if (!Number.isFinite(cooOfflineHours) || cooOfflineHours < 0) {
44
44
  console.error('Coo 席位离线释放小时数不对');
45
45
  process.exit(2);
46
46
  }
47
- const cooIdleMinutes = Number(args.get('--coo-idle-minutes') ?? process.env.PARLOR_COO_IDLE_MINUTES ?? 60);
47
+ const cooIdleMinutes = Number(args.get('--coo-idle-minutes') ?? process.env.PARLOR_COO_IDLE_MINUTES ?? 300);
48
48
  const roomArchiveHours = Number(args.get('--room-archive-hours') ?? process.env.PARLOR_ROOM_ARCHIVE_HOURS ?? 48);
49
49
  if (![cooIdleMinutes, roomArchiveHours].every(n => Number.isFinite(n) && n >= 0)) {
50
50
  console.error('闲置/归档时限须为非负数,0 表示关闭'); process.exit(2);
@@ -27,7 +27,7 @@ export interface ReplayResponse {
27
27
  * 能不能玩需要新能力的游戏(狼人杀要 ≥ 0.29.0)。
28
28
  * 它跟 npm 包版本解耦——发新版时在这里抬一格即可(有测试盯着别忘)。
29
29
  */
30
- export const PARLOR_CLIENT_VERSION = '0.36.2';
30
+ export const PARLOR_CLIENT_VERSION = '0.36.3';
31
31
 
32
32
  export class ParlorHttpError extends Error {
33
33
  readonly status: number;
@@ -125,6 +125,7 @@ export class EventDb {
125
125
  ).run(input.ts, input.ts, roomId);
126
126
  if (Number(updated.changes) === 0) throw new Error(`客厅不存在:${roomId}`);
127
127
  const seq = await this.latest(roomId);
128
+ const data = await this.presenceData(roomId, input);
128
129
 
129
130
  if (input.from !== 'system' && input.type !== 'parlor.left') {
130
131
  const actor = await this.db.prepare('SELECT coo_id FROM room_seats WHERE room_id=? AND id=? AND released_at IS NULL')
@@ -156,7 +157,7 @@ export class EventDb {
156
157
  scopeSeatsJson,
157
158
  input.text,
158
159
  input.mentions && input.mentions.length > 0 ? JSON.stringify(input.mentions) : null,
159
- input.data === undefined ? null : JSON.stringify(input.data),
160
+ data === undefined ? null : JSON.stringify(data),
160
161
  );
161
162
 
162
163
  if (scope.kind === 'seat' || scope.kind === 'table') {
@@ -195,11 +196,32 @@ export class EventDb {
195
196
  scope,
196
197
  text: input.text,
197
198
  ...(input.mentions && input.mentions.length > 0 ? { mentions: input.mentions } : {}),
198
- ...(input.data === undefined ? {} : { data: input.data }),
199
+ ...(data === undefined ? {} : { data }),
199
200
  };
200
201
  });
201
202
  }
202
203
 
204
+ /** 房间行锁内判定通知额度;原始事件保留,换席位或重启不会重置20分钟窗口。 */
205
+ private async presenceData(roomId: string, input: AppendEventInput): Promise<AppendEventInput['data']> {
206
+ if (input.type !== 'parlor.joined' && input.type !== 'parlor.left') return input.data;
207
+ const seatId = input.data?.seatId;
208
+ if (typeof seatId !== 'string') return input.data;
209
+ const actor = await this.db.prepare('SELECT coo_id FROM room_seats WHERE room_id=? AND id=?')
210
+ .get(roomId, seatId) as { coo_id: string } | undefined;
211
+ if (!actor) return input.data;
212
+ const recent = await this.db.prepare(`SELECT e.type,e.data_json FROM events e
213
+ JOIN room_seats s ON s.room_id=e.room_id AND s.id=(e.data_json ->> 'seatId')
214
+ WHERE e.room_id=? AND e.ts>? AND s.coo_id=? AND e.type IN ('parlor.joined','parlor.left')`)
215
+ .all(roomId, input.ts - 20 * 60_000, actor.coo_id) as { type: string; data_json: unknown }[];
216
+ const flags = recent.map(row => ({ type: row.type, data: jsonObject<Record<string, unknown>>(row.data_json) }));
217
+ return {
218
+ ...input.data,
219
+ presenceWeb: !flags.some(row => row.data?.presenceWeb !== false),
220
+ presenceCoo: input.type === 'parlor.joined'
221
+ && !flags.some(row => row.type === 'parlor.joined' && row.data?.presenceCoo !== false),
222
+ };
223
+ }
224
+
203
225
  /** 从旧到新,`since` 之后、可见区间内、该 coo 有权看的事件。 */
204
226
  history(roomId: string, query: EventQuery): Promise<RoomEvent[]> {
205
227
  return this.select(roomId, query, 'ASC');
@@ -15,7 +15,7 @@ export class RoomLifecycle {
15
15
  private archiveMs: number;
16
16
  private allowIdleMove: (cooId: string) => boolean;
17
17
  constructor(db: Db, hostFor: HostFor, hall: () => string, defaultRoom: string,
18
- idleMs = 60 * 60_000, archiveMs = 48 * 3_600_000, allowIdleMove: (cooId: string) => boolean = () => true) {
18
+ idleMs = 300 * 60_000, archiveMs = 48 * 3_600_000, allowIdleMove: (cooId: string) => boolean = () => true) {
19
19
  this.db = db; this.hostFor = hostFor; this.hall = hall; this.defaultRoom = defaultRoom;
20
20
  this.idleMs = idleMs; this.archiveMs = archiveMs;
21
21
  this.allowIdleMove = allowIdleMove;
@@ -294,7 +294,7 @@ export class WorldServer {
294
294
  // 启动恢复基准在 init() 里读;构造函数只落字段,不碰库。
295
295
  this.recovery = {};
296
296
  this.lifecycle = new RoomLifecycle(db, room => this.host(room), () => this.hallIdValue, this.defaultRoomId,
297
- (options.cooIdleMinutes ?? 60) * 60_000, (options.roomArchiveHours ?? 48) * 3_600_000,
297
+ (options.cooIdleMinutes ?? 300) * 60_000, (options.roomArchiveHours ?? 48) * 3_600_000,
298
298
  cooId => [...this.sse.values()].every(clients => [...clients].every(client => client.cooId !== cooId || client.closed || client.locationCapable)));
299
299
  }
300
300
 
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import { el, btn, icon } from './common.js';
7
7
  /* 内部模块统一带同一个版本号:版本不一致会让浏览器当成两份,订阅会各记各的。 */
8
- import { onAnnouncements } from './announcements.js?v=0.36.2';
9
- import { pickAnnouncement, rememberDismissed, excerpt } from './announcement-rules.js?v=0.36.2';
8
+ import { onAnnouncements } from './announcements.js?v=0.36.3';
9
+ import { pickAnnouncement, rememberDismissed, excerpt } from './announcement-rules.js?v=0.36.3';
10
10
 
11
11
  const DISMISSED_KEY = 'parlor-announcements-dismissed';
12
12
  const SEEN_KEY = 'parlor-announcements-seen';
@@ -10,9 +10,9 @@
10
10
  * - `blurb` / `foot` / `guide` 是大厅卡片的文案与玩法说明。
11
11
  */
12
12
  import { mountDice } from './dice.js';
13
- import { mountDdz } from './ddz.js?v=0.36.2';
13
+ import { mountDdz } from './ddz.js?v=0.36.3';
14
14
  import { mountMonopoly } from './monopoly.js';
15
- import { mountWerewolf } from './werewolf.js?v=0.36.2';
15
+ import { mountWerewolf } from './werewolf.js?v=0.36.3';
16
16
 
17
17
  export const GAMES = {
18
18
  dice: {
@@ -7,7 +7,7 @@
7
7
  <meta name="color-scheme" content="light">
8
8
  <meta name="referrer" content="no-referrer">
9
9
  <title>客厅 · 家长</title>
10
- <link rel="stylesheet" href="/parent/assets/parent.css?v=0.36.2">
10
+ <link rel="stylesheet" href="/parent/assets/parent.css?v=0.36.3">
11
11
  </head>
12
12
  <body class="theme-cozy">
13
13
  <a class="skip-link" href="#main">跳到主要内容</a>
@@ -76,6 +76,6 @@
76
76
  </main>
77
77
 
78
78
  <div id="toast" class="toast" role="status" aria-live="polite" hidden></div>
79
- <script type="module" src="/parent/assets/parent.js?v=0.36.2"></script>
79
+ <script type="module" src="/parent/assets/parent.js?v=0.36.3"></script>
80
80
  </body>
81
81
  </html>
package/src/web/parent.js CHANGED
@@ -275,6 +275,7 @@ function renderLog(view) {
275
275
  return;
276
276
  }
277
277
  for (const event of events.slice(-60)) {
278
+ if ((event.type === 'parlor.joined' || event.type === 'parlor.left') && event.data?.presenceWeb === false) continue;
278
279
  if (String(event.type).startsWith('parlor.table.') && event.type !== 'parlor.table.say') continue;
279
280
  const row = el('div', 'row');
280
281
  row.append(el('span', 'when', clock(event.ts)));
package/src/web/play.html CHANGED
@@ -6,11 +6,11 @@
6
6
  <meta name="theme-color" content="#10191b">
7
7
  <meta name="color-scheme" content="dark light">
8
8
  <title>鲸语会馆 · 今晚,来一局</title>
9
- <script src="/play/assets/theme.js?v=0.36.2"></script>
9
+ <script src="/play/assets/theme.js?v=0.36.3"></script>
10
10
  <link rel="stylesheet" href="/play/assets/play.css">
11
- <link rel="stylesheet" href="/play/assets/club.css?v=0.36.2">
12
- <link rel="stylesheet" href="/play/assets/appearance.css?v=0.36.2">
13
- <link rel="stylesheet" href="/play/assets/night.css?v=0.36.2">
11
+ <link rel="stylesheet" href="/play/assets/club.css?v=0.36.3">
12
+ <link rel="stylesheet" href="/play/assets/appearance.css?v=0.36.3">
13
+ <link rel="stylesheet" href="/play/assets/night.css?v=0.36.3">
14
14
  </head>
15
15
  <body class="theme-club">
16
16
  <svg class="sprite" aria-hidden="true" width="0" height="0" focusable="false">
@@ -106,6 +106,6 @@
106
106
  <div id="app" class="app"><div class="booting" id="boot-note">正在打开客厅…</div></div>
107
107
  <div id="toast" class="toast" role="status" aria-live="polite" hidden></div>
108
108
  <noscript><p class="noscript">这个页面要开 JavaScript 才能玩。</p></noscript>
109
- <script type="module" src="/play/assets/vue-loader.js?v=0.36.2"></script>
109
+ <script type="module" src="/play/assets/vue-loader.js?v=0.36.3"></script>
110
110
  </body>
111
111
  </html>
package/src/web/play.js CHANGED
@@ -5,12 +5,12 @@ import {
5
5
  el, clear, icon, initialOf, fmtClock, fmtDateTime, fmtLeft, clockSpan, btn, playerClass,
6
6
  isNearBottom, readable, GAME_LABELS, STATUS_LABELS, KIND_LABELS,
7
7
  } from './common.js';
8
- import { ENABLED_GAMES, GAMES, gameOf, gameLabel, gameIcon, heroGame } from './games/registry.js?v=0.36.2';
8
+ import { ENABLED_GAMES, GAMES, gameOf, gameLabel, gameIcon, heroGame } from './games/registry.js?v=0.36.3';
9
9
  import { createClubState, conversationKey, readRoute, routeUrl } from './club-state.js';
10
10
  import { createRoomCarousel } from './room-carousel.js';
11
- import { supportLink } from './support-link.js?v=0.36.2';
12
- import { mountAnnouncementBanner } from './announcement-banner.js?v=0.36.2';
13
- import { startAnnouncementWatch } from './announcements.js?v=0.36.2';
11
+ import { supportLink } from './support-link.js?v=0.36.3';
12
+ import { mountAnnouncementBanner } from './announcement-banner.js?v=0.36.3';
13
+ import { startAnnouncementWatch } from './announcements.js?v=0.36.3';
14
14
 
15
15
  const club = createClubState({
16
16
  getItem: key => sessionStorage.getItem(key),
@@ -129,6 +129,9 @@ window.addEventListener('hashchange', async () => {
129
129
  if (!key) return;
130
130
  if (await tryParentEntry(key, { hadSeat: true })) location.reload();
131
131
  });
132
+ window.addEventListener('storage', event => {
133
+ if ((event.key === STORE_KEY || event.key === null) && (!event.storageArea || event.storageArea === localStorage)) followSharedSeat();
134
+ });
132
135
 
133
136
  /* —— 起步 —— */
134
137
 
@@ -144,6 +147,9 @@ async function loadEntryPolicy() {
144
147
  }
145
148
 
146
149
  async function boot() {
150
+ const navigation = performance.getEntriesByType('navigation')[0];
151
+ const explicitEntry = /(?:^|[&#])(key|identity)=/.test(location.hash);
152
+ const useEntryRoom = explicitEntry || (navigation?.type !== 'reload' && navigation?.type !== 'back_forward' && !history.state?.parlor);
147
153
  if (await followLocation()) return;
148
154
  startBootClock();
149
155
  const identityArgs = new URLSearchParams(location.hash.slice(1));
@@ -187,9 +193,10 @@ async function boot() {
187
193
  await refreshSnapshot();
188
194
  state.latest = state.snap.latest;
189
195
  const route = readRoute(location.search);
190
- if (route.room && route.room !== currentRoom()) {
196
+ if (useEntryRoom && route.room && route.room !== currentRoom()) {
191
197
  if (await goRoom(route.room, { replace: true })) return;
192
198
  }
199
+ if (!useEntryRoom && route.room !== currentRoom()) { route.table = ''; route.view = 'lobby'; }
193
200
  state.watchTableId = route.table;
194
201
  normalizeWatch();
195
202
  state.view = inHall() ? 'hall' : route.view;
@@ -283,7 +290,7 @@ async function handleExpiredSeat(token) {
283
290
  if (stored && token && stored.token !== token) {
284
291
  // 本页刚换好席位,迟到的旧请求不能清掉新令牌,也不用重载旧地址。
285
292
  if (state.cfg && state.cfg.token === stored.token) return;
286
- location.reload();
293
+ followSharedSeat();
287
294
  return;
288
295
  }
289
296
  // 本来就在加入页(没有席位):这不是「令牌失效」,重画会把正在填的名字冲掉。
@@ -311,6 +318,25 @@ function readStore() {
311
318
  }
312
319
  }
313
320
 
321
+ function sharedSeatKey(cfg) {
322
+ return cfg ? JSON.stringify([cfg.room, cfg.seatId, cfg.token, cfg.cooId]) : '';
323
+ }
324
+
325
+ /** 旧入口安全地重开当前位置,不再刷新它原来指向的旧客厅。 */
326
+ function followSharedSeat() {
327
+ const stored = readStore();
328
+ if (sharedSeatKey(stored) === sharedSeatKey(state.cfg)) return false;
329
+ if (state.stream) { state.stream.close(); state.stream = null; }
330
+ clearTimeout(state.reconnect);
331
+ state.cfg = stored;
332
+ state.syncEpoch += 1;
333
+ state.snap = null; state.log = []; state.mail = null;
334
+ state.dm.messages = []; state.dm.threads = []; state.dm.peer = null;
335
+ if (stored) location.replace('/play?legacy=1&room=' + encodeURIComponent(stored.room));
336
+ else renderJoin('这台浏览器的席位已退出,请重新加入。');
337
+ return true;
338
+ }
339
+
314
340
  function writeStore(cfg) {
315
341
  state.cfg = cfg;
316
342
  localStorage.setItem(STORE_KEY, JSON.stringify(cfg));
@@ -739,6 +765,8 @@ async function act(body) {
739
765
  showToast('上一操作正在处理,这次尚未发送,请稍后重试。', 'bad');
740
766
  return null;
741
767
  }
768
+ if (followSharedSeat()) return null;
769
+ const requestSeat = sharedSeatKey(state.cfg);
742
770
  state.busy = true;
743
771
  try {
744
772
  const payload = withTableFields(body) || {};
@@ -755,8 +783,10 @@ async function act(body) {
755
783
  } catch (error) {
756
784
  // 只重发「可能没到服务器」的那一次;重发用同一个 requestId,服务器会去重。
757
785
  if (!retryable || !isNetworkError(error)) throw error;
786
+ if (requestSeat !== sharedSeatKey(readStore())) { followSharedSeat(); return null; }
758
787
  receipt = await send();
759
788
  }
789
+ if (requestSeat !== sharedSeatKey(readStore())) { followSharedSeat(); return null; }
760
790
  if ((payload.type === 'table_open' || payload.type === 'table_join')
761
791
  && receipt && typeof receipt.tableId === 'string' && receipt.tableId) {
762
792
  state.watchTableId = receipt.tableId;
@@ -803,12 +833,17 @@ function openNewTable(game = heroGame()) {
803
833
 
804
834
  let reconnectFailures = 0;
805
835
  async function followLocation() {
836
+ if (followSharedSeat()) return true;
806
837
  if (!state.cfg) return false;
807
838
  const old = state.cfg;
808
839
  try {
809
840
  const res = await fetch('/v1/me/location', { headers: { authorization:'Bearer ' + old.token }, signal:AbortSignal.timeout(15000) });
810
- if (!res.ok) return false;
841
+ if (!res.ok) {
842
+ if (res.status === 401) { await handleExpiredSeat(old.token); return true; }
843
+ return false;
844
+ }
811
845
  const current = await res.json();
846
+ if (sharedSeatKey(readStore()) !== sharedSeatKey(old)) return followSharedSeat();
812
847
  if (!current.room || !current.seat || state.cfg !== old || (current.room === old.room && current.seat.id === old.seatId)) return false;
813
848
  state.cfg = { ...old, room:current.room, seatId:current.seat.id, name:current.seat.name };
814
849
  localStorage.setItem(STORE_KEY, JSON.stringify(state.cfg));
@@ -817,6 +852,7 @@ async function followLocation() {
817
852
  } catch { return false; }
818
853
  }
819
854
  function connect() {
855
+ if (followSharedSeat()) return;
820
856
  if (!state.cfg) return;
821
857
  if (state.stream) {
822
858
  state.stream.close();
@@ -827,12 +863,14 @@ function connect() {
827
863
  const source = new EventSource(roomPath('/v1/stream?cap=seat-location-v1&since=' + state.latest + '&token=' + encodeURIComponent(state.cfg.token)));
828
864
  state.stream = source;
829
865
  source.onopen = () => {
866
+ if (state.stream !== source) return;
830
867
  reconnectFailures = 0;
831
868
  setConn('on');
832
869
  // 连上之后补一次快照:online 与信箱未读只有在 SSE 连接建立后才准。
833
870
  scheduleRefresh();
834
871
  };
835
872
  source.onmessage = (message) => {
873
+ if (state.stream !== source) return;
836
874
  let event;
837
875
  try {
838
876
  event = JSON.parse(message.data);
@@ -842,6 +880,7 @@ function connect() {
842
880
  handleEvent(event);
843
881
  };
844
882
  source.onerror = () => {
883
+ if (state.stream !== source) return;
845
884
  setConn('off');
846
885
  source.close();
847
886
  if (state.stream === source) state.stream = null;
@@ -921,6 +960,7 @@ function isTableBucket(event) {
921
960
  }
922
961
 
923
962
  function pushLog(event, seed = false) {
963
+ if ((event.type === 'parlor.joined' || event.type === 'parlor.left') && event.data?.presenceWeb === false) return;
924
964
  if (typeof event.seq === 'number') {
925
965
  if (state.seen.has(event.seq)) return;
926
966
  state.seen.add(event.seq);
@@ -3234,12 +3274,14 @@ async function goRoom(id, options = {}) {
3234
3274
  return true;
3235
3275
  }
3236
3276
  roomSwitching = true;
3277
+ const requestSeat = sharedSeatKey(state.cfg);
3237
3278
  try {
3238
3279
  const moved = await api(`/v1/rooms/${encodeURIComponent(from)}/switch`, {
3239
3280
  method: 'POST',
3240
3281
  headers: { 'content-type': 'application/json' },
3241
3282
  body: JSON.stringify({ to: id }),
3242
3283
  });
3284
+ if (requestSeat !== sharedSeatKey(readStore())) { followSharedSeat(); return false; }
3243
3285
  writeStore({
3244
3286
  ...state.cfg,
3245
3287
  room: moved.room,
@@ -3800,11 +3842,12 @@ setInterval(() => {
3800
3842
  document.addEventListener('visibilitychange', () => {
3801
3843
  syncFeaturedRotation();
3802
3844
  if (document.hidden) return;
3845
+ if (followSharedSeat()) return;
3803
3846
  // 手机/浏览器切回来时 EventSource 可能已经悄悄断了;没开着就立刻重连,别等 3 秒定时器。
3804
3847
  if (state.cfg && (!state.stream || state.stream.readyState !== EventSource.OPEN)) connect();
3805
3848
  scheduleRefresh();
3806
3849
  });
3807
- window.addEventListener('focus', () => scheduleRefresh());
3850
+ window.addEventListener('focus', () => { if (!followSharedSeat()) scheduleRefresh(); });
3808
3851
 
3809
3852
  /* —— 私聊浮窗 —— */
3810
3853
  /* 位置存在本地:拖标题栏移动、点窗外空白或 Esc 关闭;手机上是全屏抽屉。 */
@@ -1,5 +1,5 @@
1
1
  /** 公告入口独立刷新,避免打断牌桌和聊天草稿。取数在 announcements.js,首屏横幅用的是同一份。 */
2
- import { onAnnouncements } from './announcements.js?v=0.36.2';
2
+ import { onAnnouncements } from './announcements.js?v=0.36.3';
3
3
 
4
4
  export function supportLink(getToken) {
5
5
  const link = document.createElement('a');