|
|
@@ -254,19 +254,39 @@ export class ChatService {
|
|
|
*/
|
|
|
readonly agentIdle = computed(() => {
|
|
|
const id = this._agentId();
|
|
|
- if (!id) return false;
|
|
|
+ if (!id) return true;
|
|
|
const agent = this.live.agentById(id);
|
|
|
- if (!agent) return false;
|
|
|
+ if (!agent) return true;
|
|
|
/*
|
|
|
- * 🔴 优先用**本会话**的状态(2026-11-09 方案 A)。
|
|
|
+ * 🔴 只用**本会话**的状态,不再回落容器全局 `status`(2026-11-11 统一方案)。
|
|
|
*
|
|
|
- * 容器上报的 `status` 是整个容器一个值:同一容器的会话 A 在跑时,
|
|
|
- * 会话 B 也会被告知「不空闲」→ 回合永远收不了尾(用户实测)。
|
|
|
- * 容器按会话上报时以它为准;没上报(旧容器)才回落到全局 status。
|
|
|
+ * 原来的最后一行 `return agent.status === 'idle'` 是「串台」的根源:
|
|
|
+ * `status` 是整个容器一个值,会话 A 在跑时会话 B 也被判成「不空闲」,
|
|
|
+ * 于是 B 的回合永远收不了尾、右上角显示 A 的进度。
|
|
|
+ *
|
|
|
+ * 现在:容器没上报本会话 → 返回**空闲**(不知道就是不知道)。
|
|
|
+ * 「是不是在干活」由 `resolveSessionPhase()` 统一裁决,
|
|
|
+ * 这里只回答「容器有没有明确说本会话在跑」。
|
|
|
*/
|
|
|
- const mine = sessionRunning(agent.currentSessions, this._sessionId(), this.roomId);
|
|
|
- if (mine !== undefined) return !mine;
|
|
|
- return agent.status === 'idle';
|
|
|
+ return sessionRunning(agent.currentSessions, this._sessionId(), this.roomId, this.myMxId()) !== true;
|
|
|
+ });
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 本会话运行态的**原始信号包**(2026-11-11 统一方案)。
|
|
|
+ *
|
|
|
+ * 各界面不再各自拼信号,一律把它交给 `resolveSessionPhase()` 裁决。
|
|
|
+ * 见该函数的注释:多源冲突是「显示错」的根源。
|
|
|
+ */
|
|
|
+ readonly sessionSignals = computed(() => {
|
|
|
+ const id = this._agentId();
|
|
|
+ const agent = id ? this.live.agentById(id) : undefined;
|
|
|
+ return {
|
|
|
+ turnEnded: this._turnEndedAfter() !== null,
|
|
|
+ sessionRunning: agent
|
|
|
+ ? sessionRunning(agent.currentSessions, this._sessionId(), this.roomId, this.myMxId())
|
|
|
+ : undefined,
|
|
|
+ typing: this._peerTyping(),
|
|
|
+ };
|
|
|
});
|
|
|
/** 正在加载更早历史 */
|
|
|
readonly paginating = this._paginating.asReadonly();
|
|
|
@@ -300,6 +320,13 @@ export class ChatService {
|
|
|
*/
|
|
|
private _blankSessionId: string | null = null;
|
|
|
private provision: MatrixProvision | null = null;
|
|
|
+ /**
|
|
|
+ * 当前登录用户在 Matrix 的 mxid(2026-11-11)。
|
|
|
+ *
|
|
|
+ * 供会话级状态匹配用:容器可能被多人共享,`currentSessions` 里会有别人的会话,
|
|
|
+ * 需要 `userId` 才能区分「谁在跑」。见 `agent-state.ts::sessionStateOf()`。
|
|
|
+ */
|
|
|
+ readonly myMxId = computed(() => this.provision?.userMxId ?? null);
|
|
|
/** 真实态下的当前房间 id */
|
|
|
private roomId: string | null = null;
|
|
|
/**
|