Przeglądaj źródła

feat(plans,chat): 限额可见+静默找回+容器断线提示,主容器技能清单落位

用户实测反馈第二批(2026-12-03):

- /plans 限额(1a):顶层路由没人调 live.ensureLoaded(),容器列表恒空
  → 配额预检永远放行。进页主动加载 + apply() 先等首载再判配额;
  套餐卡名额改显「已用/上限」(两端)
- 过场动画(1b):restoring 不再触发全屏遮罩,回 /plans 静默找回任务
- 网关掉线(问题4):新增 matrix-client watchPresence(User.presence +
  sync 门禁,未就绪报 unknown)→ chat.agentPresence → 两端会话页
  「容器连接中断」提示条 + 重新发送。不用心跳(1h 周期且崩了照发)
- refresh-container-skills dry-run 显示路径修正(_org/<orgId>/)
- 主容器侧:技能清单 + 企微技能兜底源已部署落位(provision.sh 运行时需要)
- 文档:技能下发规范补主容器部署拓扑;R730 文档更正宿主有 python3;
  容器接入指南补网关重启兜底行

验证:npm run build 通过;全量单测 2244/2244 SUCCESS

Co-Authored-By: Claude Code <noreply@anthropic.com>
Huccct 15 godzin temu
rodzic
commit
dedfea6f0c

+ 17 - 0
docs/00-tracking/操作追踪.md

@@ -10433,3 +10433,20 @@ Call log:
   - SKILL.md 补 `INVALID_DISPLAY` 原因码与 displayName 规则说明
   - SKILL.md 补 `INVALID_DISPLAY` 原因码与 displayName 规则说明
   - 单测:新增 35 条(container-name 21 + provision-confirm 11 + 配额),全量 **2244 SUCCESS**
   - 单测:新增 35 条(container-name 21 + provision-confirm 11 + 配额),全量 **2244 SUCCESS**
   - 浏览器实测:弹窗自动聚焦、1 字报错、含空格报错、合法名可提交;入门版名额满(2/1)时弹窗不打开、顶部显示提示
   - 浏览器实测:弹窗自动聚焦、1 字报错、含空格报错、合法名可提交;入门版名额满(2/1)时弹窗不打开、顶部显示提示
+
+- 2026-12-03 13:45:00+08:00:**主容器技能下发链路补齐:清单+兜底源落位,provision.sh 运行环境实测**。
+  - 背景:上午把仓库版 container-provision-job v6.0.0(含 provision.sh)部署到主容器后,发现 provision.sh 期望清单在 `$here/container-skill-manifest.json`(`here`=技能目录父目录),而清单只存在于仓库 `cloud/skills/`,从未随技能下发——下一次开通会打 `[WARN] 无技能清单,跳过下发`,新容器再次静默缺技能(今天上午 agent-node-app-vqcwzeov6h 缺 container-wecom-setup 的同类事故)
+  - 部署:`container-skill-manifest.json` + `cloud/skills/container-wecom-setup/{SKILL.md,wecom_setup.py}`(fallback 源,嵌套路径刻意与清单里的仓库相对路径一致)→ 宿主 `/opt/fmode-containers/agent-node/data/skills/` 下,属主 10000:10000
+  - 验证:用 provision.sh 同款 python 解析逻辑在宿主演算 → `OK container-wecom-setup org`;`bash -n` provision.sh 语法通过
+  - **环境更正**:R730 宿主实测有 `/usr/bin/python3`(3.13)+ docker 26.1.5,旧文档「宿主无 python3」过时,已改 `docs/05-operations/R730服务器-连接与容器部署.md`
+  - 文档:`docs/05-operations/容器技能下发与替换规范.md` 路径 A 补「主容器侧部署拓扑」表——改清单/技能真源后必须重新部署这两个位置
+  - 踩坑:①`base64 -w0` 输出无尾部换行,拼 heredoc 部署脚本时结束标记被粘到数据行尾(远端报 `here-document delimited by end-of-file`),每段 b64 后要补 `echo` ②18001 隧道下午连续抖动,循环重试 6 轮才通
+
+- 2026-12-03 14:10:00+08:00:**用户裁决:「取消开通」本期不做**。已评估并给出两方案(A 全链路取消:云函数 cancel op + provision.sh 阶段间检查取消标记并清理半成品 + 前端二次确认按钮;B 只标记不清理),用户选「本期不做」。现状留档:云函数仅 start/status/retry/list 四操作,工单 status 为字符串字段,未来加 'cancelled' 不需要改表结构。
+
+- 2026-12-03 14:30:00+08:00:**用户实测反馈第二批前端修复(1a 限额可见 / 1b 静默找回 / 4 网关掉线检测)**。
+  - **1a 限额**:根因是 `/plans` 为顶层路由不在 shell 内,`live.ensureLoaded()` 从没人调 —— `existingNames()` 恒空,配额预检永远放行、默认名永远从「我的容器 1」起。修复:两端 ngOnInit 主动 `ensureLoaded()` + `apply()` 改 async、先等首载再判配额(加载失败由服务端配额兜底);套餐卡名额改显「已用/上限」(移动端 `x/N`、桌面端新增 `.plan-quota` 行)
+  - **1b 过场动画**:`loadingHint` 删掉 `restoring()` 分支 —— 开通中回到 /plans 不再重放「正在检查开通任务…」全屏遮罩;restore 静默进行,有任务自然出现 plans-job 区块
+  - **问题 4 网关掉线**:`matrix-client.service::watchPresence()`(`User.presence` 事件 + sync 状态门禁,sync 未就绪报 `unknown` 防误报)→ `chat.service::agentPresence`(随房间订阅绑定/解绑)→ 两端会话页 `connectionInterrupted`(presence=offline 且有未回复回合)显示「容器连接中断,回复可能延迟或未送达」+「重新发送」(重发最后一回合用户原文;注释注明 Hermes 会补收、多数情况无需重发)。**不用容器心跳**:1 小时周期独立 cron,网关崩了照发
+  - 文档:容器接入指南「已知缺口与兜底」表新增网关重启行
+  - 验证:`npm run build` 通过;全量单测 **2244/2244 SUCCESS**(与基线持平)

+ 1 - 0
docs/03-interface/容器接入完整指南-v2-20261111.md

@@ -444,6 +444,7 @@ node scripts/test-multi-session.mjs          # 多会话并发不串台
 |---|---|---|
 |---|---|---|
 | `CANCELLED` | 不发 reaction | 静默 + 5 分钟超时提示 |
 | `CANCELLED` | 不发 reaction | 静默 + 5 分钟超时提示 |
 | 容器崩溃 | 不发 reaction | 同上 + 「容器无响应」提示 |
 | 容器崩溃 | 不发 reaction | 同上 + 「容器无响应」提示 |
+| 网关重启/崩溃(2026-12-03 新增) | /sync 断 → presence 翻 offline;恢复后 Hermes 从 sync 断点补收消息并继续 | presence=offline + 有未回复回合 → 「容器连接中断,回复可能延迟或未送达」+「重新发送」按钮(`matrix-client.service::watchPresence` → `chat.service::agentPresence` → 两端会话页提示条)。**不用容器心跳判**——心跳是 1 小时周期的独立 cron,网关崩了照发。sync 未就绪报 `unknown`,不告警 |
 | `MATRIX_REACTIONS=false` | 从不发 | 全部走时间兜底 |
 | `MATRIX_REACTIONS=false` | 从不发 | 全部走时间兜底 |
 | 正文带 `~` 范围 | 照常发 | App 转义单个 `~`,不会误成删除线 |
 | 正文带 `~` 范围 | 照常发 | App 转义单个 `~`,不会误成删除线 |
 | 正文带 `---` | 照常发 | 渲染成分隔线(建议容器不用) |
 | 正文带 `---` | 照常发 | 渲染成分隔线(建议容器不用) |

+ 1 - 1
docs/05-operations/R730服务器-连接与容器部署.md

@@ -45,5 +45,5 @@ c.connect("server.fmode.cn", port=18001, username="fmode", password="fmgo",
 - 容器实例:`/opt/fmode-containers/<容器名>/data` → 容器内 `/opt/data`
 - 容器实例:`/opt/fmode-containers/<容器名>/data` → 容器内 `/opt/data`
 - 开通模板:`/opt/fmode-templates/default/`(plugins 直接在根下;对开通作业只读,铁则 7)
 - 开通模板:`/opt/fmode-templates/default/`(plugins 直接在根下;对开通作业只读,铁则 7)
 - 网关重启:`docker restart <容器名>`,或仅网关 `docker exec <容器名> /command/s6-svc -r /run/service/gateway-default`
 - 网关重启:`docker restart <容器名>`,或仅网关 `docker exec <容器名> /command/s6-svc -r /run/service/gateway-default`
-- 宿主无 `python3`/`python` 命令;JSON 校验等用容器内 `/opt/hermes/.venv/bin/python`
+- ~~宿主无 `python3`/`python` 命令~~(**已过时,2026-12-03 实测更正**:宿主有 `/usr/bin/python3`,3.13,无 `python`;provision.sh 的 python3 heredoc 直接在宿主跑。容器内另有 `/opt/hermes/.venv/bin/python`)
 - 单命令行参数上限约 128KB(MAX_ARG_STRLEN),大文件须 base64 切片传输
 - 单命令行参数上限约 128KB(MAX_ARG_STRLEN),大文件须 base64 切片传输

+ 16 - 1
docs/05-operations/容器技能下发与替换规范.md

@@ -199,7 +199,22 @@ Hermes 的渠道适配器**只在网关启动时读配置**。技能本身随 `s
 技能在**容器创建前**写进 `$DST/skills/<scope>/<name>/`,属主 10000:10000。
 技能在**容器创建前**写进 `$DST/skills/<scope>/<name>/`,属主 10000:10000。
 清单里 `required: true` 的技能缺文件 → `[FAIL] configure SKILL_FILE_MISSING`,开通失败。
 清单里 `required: true` 的技能缺文件 → `[FAIL] configure SKILL_FILE_MISSING`,开通失败。
 
 
-**不需要额外操作。**
+**⚠️ 主容器侧部署拓扑(2026-12-03 实测定稿)**:provision.sh 在主容器
+`agent-node` 的技能目录里运行,`here` = 技能目录的**父目录**
+(宿主 `/opt/fmode-containers/agent-node/data/skills/`)。因此主容器技能目录下必须有:
+
+| 路径(宿主侧) | 内容 | 来源 |
+|---|---|---|
+| `…/agent-node/data/skills/container-skill-manifest.json` | 清单副本 | 真源 `cloud/skills/container-skill-manifest.json`,改真源后要重新部署 |
+| `…/agent-node/data/skills/cloud/skills/<技能名>/` | repo 型技能的 fallback 源文件 | 与仓库 `cloud/skills/<技能名>/` 同内容(路径嵌套是刻意的:清单 fallback 写的是仓库相对路径,provision.sh 直接拼到 `here` 下) |
+
+缺清单 → provision.sh 只打 `[WARN] 无技能清单,跳过下发`,新容器**静默没有技能**
+(2026-12-03 新容器缺 container-wecom-setup 的坑就是这么来的)。
+改清单或技能后重新部署这两个位置;首次部署脚本留档在
+`.local-backup/tmp-wecom/deploy-manifest.sh`(生成方式见操作追踪 2026-12-03)。
+
+已实测:R730 宿主有 `/usr/bin/python3`(3.13),provision.sh 的 python3 heredoc 可直接跑
+(旧文档「宿主无 python3」已过时,见 R730 连接文档更正)。
 
 
 ### 路径 B:存量容器(批量刷新)
 ### 路径 B:存量容器(批量刷新)
 
 

+ 5 - 1
scripts/refresh-container-skills.mjs

@@ -176,7 +176,11 @@ if (has('--dry-run') || !has('--apply')) {
   console.log('\n[DRY-RUN] 未加 --apply,不执行任何写入。');
   console.log('\n[DRY-RUN] 未加 --apply,不执行任何写入。');
   for (const c of targets) {
   for (const c of targets) {
     for (const s of enabled) {
     for (const s of enabled) {
-      console.log(`  将写入 ${c}:/opt/data/skills/${s.scope || 'custom'}/${s.name}/`);
+      const orgId = manifest.org?.id || 'fmode';
+      const shown = (s.scope || 'custom') === 'org'
+        ? `/opt/data/skills/_org/${orgId}/${s.name}/`
+        : `/opt/data/skills/${s.scope || 'custom'}/${s.name}/`;
+      console.log(`  将写入 ${c}:${shown}`);
     }
     }
   }
   }
   process.exit(0);
   process.exit(0);

+ 27 - 0
src/app/core/chat.service.ts

@@ -599,6 +599,16 @@ export class ChatService {
   private unbindTurnReaction: (() => void) | null = null;
   private unbindTurnReaction: (() => void) | null = null;
   /** 容器推送的回合状态事件(2026-11-12,方案 2) */
   /** 容器推送的回合状态事件(2026-11-12,方案 2) */
   private unbindTurnStatus: (() => void) | null = null;
   private unbindTurnStatus: (() => void) | null = null;
+  /**
+   * 容器 Matrix 在线状态订阅(2026-12-03,网关掉线检测)。
+   *
+   * 心跳是 1 小时周期的独立 cron,反映不了「网关死了」;
+   * presence 随 /sync 断开在秒~分钟级翻 offline,是唯一够快的信号。
+   */
+  private unbindPresence: (() => void) | null = null;
+  private readonly _agentPresence = signal<'online' | 'offline' | 'unavailable' | 'unknown'>('unknown');
+  /** 当前会话容器的在线状态;`'unknown'` = sync 未就绪,不可据此告警 */
+  readonly agentPresence = this._agentPresence.asReadonly();
   /** 全局未读监听解绑(仅登出/销毁时调用) */
   /** 全局未读监听解绑(仅登出/销毁时调用) */
   private unbindUnread: (() => void) | null = null;
   private unbindUnread: (() => void) | null = null;
   /**
   /**
@@ -1461,6 +1471,20 @@ export class ChatService {
         }
         }
         this.requestLiveRefresh();
         this.requestLiveRefresh();
       }) ?? null;
       }) ?? null;
+
+    /*
+     * 容器在线状态(2026-12-03,网关重启/崩溃检测)。
+     *
+     * 心跳是 1 小时周期的独立 cron,网关崩了它照发,判不出「网关死了」;
+     * 网关一死 /sync 长轮询立刻断,presence 在秒~分钟级翻 offline。
+     * 页面据此把「输出中」改判为「连接中断」而不是无限转圈。
+     * sync 未就绪时 watchPresence 报 'unknown',页面不得据此告警。
+     */
+    this._agentPresence.set('unknown');
+    const presenceTarget = this._agentMxId();
+    this.unbindPresence = presenceTarget
+      ? this.mx.watchPresence?.(presenceTarget, (p) => this._agentPresence.set(p)) ?? null
+      : null;
   }
   }
 
 
   /** 回合事件新鲜度窗口:超过 2 分钟的历史回放事件不触发任何云函数刷新 */
   /** 回合事件新鲜度窗口:超过 2 分钟的历史回放事件不触发任何云函数刷新 */
@@ -4214,10 +4238,13 @@ export class ChatService {
     this.unbindTyping?.();
     this.unbindTyping?.();
     this.unbindTurnReaction?.();
     this.unbindTurnReaction?.();
     this.unbindTurnStatus?.();
     this.unbindTurnStatus?.();
+    this.unbindPresence?.();
     this.unbindMessage = null;
     this.unbindMessage = null;
     this.unbindTyping = null;
     this.unbindTyping = null;
     this.unbindTurnReaction = null;
     this.unbindTurnReaction = null;
     this.unbindTurnStatus = null;
     this.unbindTurnStatus = null;
+    this.unbindPresence = null;
+    this._agentPresence.set('unknown');
   }
   }
 
 
   private markSent(id: string): void {
   private markSent(id: string): void {

+ 50 - 0
src/app/core/matrix-client.service.ts

@@ -1546,6 +1546,56 @@ export class MatrixClientService implements OnDestroy {
     };
     };
   }
   }
 
 
+  /**
+   * 订阅指定用户的 Matrix 在线状态(2026-12-03,网关掉线检测)。
+   *
+   * ## 为什么用 presence 而不是容器心跳
+   *
+   * 容器心跳由独立 cron 上报(1 小时周期 + 0-15 分钟抖动),**网关崩了心跳照发**,
+   * 而且 80 分钟才判 stale —— 拿它判「网关死了」最坏要等 2 个多小时。
+   * 网关一死,它的 /sync 长轮询立刻断,homeserver 随即将其标为 offline
+   * 并推给同房间的我们 —— 这是秒级~分钟级的真实信号。
+   *
+   * ## 精度口径
+   *
+   *   · 初次 /sync 完成前拿不到可信 presence,一律报 `'unknown'`,避免误报中断;
+   *   · `'unavailable'`(空闲)算在线 —— 网关空闲时 /sync 长轮询仍然挂着;
+   *   · 我们自己断线重连时也会重发一次当前值(重连后 presence 才重新可信)。
+   *
+   * @returns 退订函数
+   */
+  watchPresence(
+    userId: string,
+    cb: (presence: 'online' | 'offline' | 'unavailable' | 'unknown') => void,
+  ): () => void {
+    const c = this.requireClient();
+    const emit = () => {
+      if (this._syncState() !== 'connected') {
+        cb('unknown');
+        return;
+      }
+      const u = c.getUser(userId) as { presence?: string } | null;
+      const p = u?.presence;
+      cb(p === 'online' || p === 'offline' || p === 'unavailable' ? p : 'unknown');
+    };
+    const presenceHandler = (_ev: unknown, user?: { userId?: string }) => {
+      if (user?.userId === userId) emit();
+    };
+    /* sync 状态翻转(首次同步完成 / 断线重连)也重发一次 */
+    const syncHandler = () => emit();
+    c.on('User.presence' as never, presenceHandler as never);
+    c.on('sync' as never, syncHandler as never);
+    queueMicrotask(emit);
+    return () => {
+      try {
+        c.off('User.presence' as never, presenceHandler as never);
+        c.off('sync' as never, syncHandler as never);
+      } catch {
+        /* 忽略 */
+      }
+    };
+  }
+
   /**
   /**
    * 订阅**容器主动推送的回合状态事件**(2026-11-12,方案 2)。
    * 订阅**容器主动推送的回合状态事件**(2026-11-12,方案 2)。
    *
    *

+ 71 - 0
src/app/desktop/pages/chat/chat.ts

@@ -620,6 +620,20 @@ interface ConversationRow {
 
 
           <!-- 待发消息持有条已移除(2026-11-14 用户裁决「永远不拦,直接发」) -->
           <!-- 待发消息持有条已移除(2026-11-14 用户裁决「永远不拦,直接发」) -->
 
 
+          <!--
+            容器连接中断提示(2026-12-03,用户实测:网关重启/崩溃时「输出中」无限转圈)。
+            信号 = Matrix presence(网关死 → /sync 断 → offline,秒~分钟级),
+            不用容器心跳(1 小时周期且网关崩了照发,判不出来)。
+            恢复在线后此条自动消失;Hermes 会从 sync 断点补收消息,通常无需重发。
+          -->
+          @if (connectionInterrupted()) {
+            <div class="conn-interrupt" role="alert">
+              <i class="fa-solid fa-triangle-exclamation" aria-hidden="true"></i>
+              <span>容器连接中断,回复可能延迟或未送达</span>
+              <button type="button" class="conn-interrupt-btn" (click)="resendPendingTurn()">重新发送</button>
+            </div>
+          }
+
           <app-composer
           <app-composer
             [draft]="chat.draft()"
             [draft]="chat.draft()"
             [hint]="sendHint()"
             [hint]="sendHint()"
@@ -1285,6 +1299,34 @@ interface ConversationRow {
         flex-shrink: 0;
         flex-shrink: 0;
         padding: 0 max(var(--sp-4), calc((100% - 768px) / 2));
         padding: 0 max(var(--sp-4), calc((100% - 768px) / 2));
       }
       }
+      /* 容器连接中断提示条(2026-12-03):与 composer 同宽对齐 */
+      .conn-interrupt {
+        display: flex;
+        align-items: center;
+        gap: var(--sp-2);
+        margin: 0 0 var(--sp-2);
+        padding: var(--sp-2) var(--sp-3);
+        border-radius: 10px;
+        background: var(--warning-subtle);
+        color: var(--warning);
+        font-size: var(--fs-13);
+        line-height: 1.4;
+      }
+      .conn-interrupt > span {
+        flex: 1;
+        min-width: 0;
+      }
+      .conn-interrupt-btn {
+        flex: none;
+        min-height: 32px;
+        padding: 0 var(--sp-3);
+        border: 1px solid var(--warning);
+        border-radius: 8px;
+        background: transparent;
+        color: var(--warning);
+        font-size: var(--fs-13);
+        cursor: pointer;
+      }
       .pending-chip {
       .pending-chip {
         display: inline-flex;
         display: inline-flex;
         align-items: center;
         align-items: center;
@@ -2213,6 +2255,35 @@ export class DkChatPage implements OnDestroy {
    *
    *
    * 规则:相邻且都属于终端活动的消息合成一组;遇到正常对话立即断开。
    * 规则:相邻且都属于终端活动的消息合成一组;遇到正常对话立即断开。
    */
    */
+  /**
+   * 容器离线 + 本端还有没等到回复的回合 → 显示「连接中断」提示条(2026-12-03)。
+   *
+   * 判定用 `chat.agentPresence()`(Matrix presence,秒~分钟级)而**不是**容器心跳
+   * (1 小时周期且与网关进程无关,网关崩了照发)。
+   * `'unknown'`(sync 未就绪)不告警,避免进页瞬间误报。
+   */
+  protected readonly connectionInterrupted = computed(() => {
+    if (this.chat.agentPresence() !== 'offline') return false;
+    return (
+      this.chat.awaitingReplySince() > 0 ||
+      this.aiRows().some((r) => r.kind === 'turn' && r.turn.live)
+    );
+  });
+
+  /**
+   * 「连接中断」提示条上的重新发送:取最后一个回合的用户原文重发(2026-12-03)。
+   *
+   * 注意:Hermes 恢复后会从 sync 断点补收消息,多数情况**不需要**重发;
+   * 这个按钮是「等了很久还没恢复」时的逃生口,代价是恢复后可能收到两条回复。
+   */
+  protected resendPendingTurn(): void {
+    const turns: AssistantTurn[] = [];
+    for (const r of this.aiRows()) if (r.kind === 'turn') turns.push(r.turn);
+    const text = [...turns].reverse().find((t) => t.userMessage?.text?.trim())?.userMessage?.text?.trim();
+    if (!text) return;
+    void this.chat.sendText(text);
+  }
+
   /**
   /**
    * 渲染行(2026-11-07 用户需求):AI 的一整轮合并成一张卡。
    * 渲染行(2026-11-07 用户需求):AI 的一整轮合并成一张卡。
    *
    *

+ 55 - 10
src/app/desktop/pages/plans/plans.ts

@@ -154,6 +154,15 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
             </div>
             </div>
             <h3>{{ item.name }}</h3>
             <h3>{{ item.name }}</h3>
             <p class="plan-tagline">{{ item.tagline }}</p>
             <p class="plan-tagline">{{ item.tagline }}</p>
+            <!-- 名额显示已用/上限(2026-12-03 用户反馈「看不到我的限额」);列表未载出时只显示上限 -->
+            <p class="plan-quota">
+              @if (live.hasData()) {
+                <strong>{{ live.agents().length }}/{{ item.quota }}</strong>
+              } @else {
+                <strong>{{ item.quota }}</strong>
+              }
+              <span>{{ item.quotaLabel }}</span>
+            </p>
 
 
             <div class="plan-price">
             <div class="plan-price">
               <strong>价格待定</strong>
               <strong>价格待定</strong>
@@ -195,15 +204,11 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
 
 
       <app-renewal-guide />
       <app-renewal-guide />
 
 
+      <!--
+        底部不再放「我的容器」入口卡(2026-12-03 用户反馈):
+        顶部状态条已有「管理容器」按钮,两个入口同页重复。
+      -->
       <div class="plans-links">
       <div class="plans-links">
-        <section class="plans-link-card">
-          <i class="fa-solid fa-server" aria-hidden="true"></i>
-          <div>
-            <h3>我的容器</h3>
-            <p>查看已有的容器与名额使用情况</p>
-          </div>
-          <button type="button" class="plans-link-btn" (click)="go('/desktop/my-containers')">查看</button>
-        </section>
         <section class="plans-link-card">
         <section class="plans-link-card">
           <i class="fa-solid fa-shield-halved" aria-hidden="true"></i>
           <i class="fa-solid fa-shield-halved" aria-hidden="true"></i>
           <div>
           <div>
@@ -467,6 +472,22 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
         color: var(--muted);
         color: var(--muted);
         font-size: var(--fs-13);
         font-size: var(--fs-13);
       }
       }
+      .plan-quota {
+        display: flex;
+        align-items: baseline;
+        gap: 3px;
+        margin: var(--sp-2, 8px) 0 0;
+        line-height: 1.2;
+      }
+      .plan-quota strong {
+        font-size: var(--fs-18);
+        font-weight: 600;
+        letter-spacing: -0.02em;
+      }
+      .plan-quota span {
+        color: var(--muted);
+        font-size: var(--fs-12);
+      }
       .plan-price {
       .plan-price {
         display: flex;
         display: flex;
         align-items: baseline;
         align-items: baseline;
@@ -709,6 +730,12 @@ export class DkPlansPage implements OnInit {
 
 
   ngOnInit(): void {
   ngOnInit(): void {
     void this.provision.restorePending();
     void this.provision.restorePending();
+    /*
+     * 配额预检与重名校验都依赖容器列表(2026-12-03):
+     * /plans 是顶层路由不在 shell 内,没人替本页拉 live,
+     * 不主动加载 existingNames() 永远是空 —— 配额预检形同虚设。
+     */
+    void this.live.ensureLoaded();
   }
   }
 
 
   protected readonly plans = computed(() => this.plan.catalog);
   protected readonly plans = computed(() => this.plan.catalog);
@@ -738,7 +765,11 @@ export class DkPlansPage implements OnInit {
    *   · 进阶/企业开通   → 只受理,很快,之后跳等待页
    *   · 进阶/企业开通   → 只受理,很快,之后跳等待页
    */
    */
   protected readonly loadingHint = computed<{ message: string; detail: string } | null>(() => {
   protected readonly loadingHint = computed<{ message: string; detail: string } | null>(() => {
-    if (this.provision.restoring()) return { message: '正在检查开通任务…', detail: '正在找回已有进度,请稍候' };
+    /*
+     * 🔴 restoring 不再上全屏遮罩(2026-12-03 用户实测反馈):
+     *    开通中离开再回 /plans,每次进页都重放一遍「正在检查开通任务…」过场动画。
+     *    restore 本来就是静默找回——完了有任务就显示 plans-banner,没有就无事发生。
+     */
     const p = this.provision.startingPlan();
     const p = this.provision.startingPlan();
     if (!p) return null;
     if (!p) return null;
     if (p === 'trial' || p === 'starter') {
     if (p === 'trial' || p === 'starter') {
@@ -772,8 +803,14 @@ export class DkPlansPage implements OnInit {
    *
    *
    * 与移动端同源逻辑:试用/入门留在本页给提示词,进阶/企业跳全屏等待页。
    * 与移动端同源逻辑:试用/入门留在本页给提示词,进阶/企业跳全屏等待页。
    */
    */
-  protected apply(code: PaidPlanCode | 'trial'): void {
+  protected async apply(code: PaidPlanCode | 'trial'): Promise<void> {
     if (this.provision.isRunning()) return;
     if (this.provision.isRunning()) return;
+    /*
+     * 配额判断依赖容器列表;首载还没落地时 existingNames() 是空数组,
+     * 直接判会永远放行(2026-12-03 用户实测:已有 2 个容器仍没看到名额提示)。
+     * 先等首载完成再校验;加载失败则由服务端配额校验兜底。
+     */
+    await this.live.ensureLoaded();
     /*
     /*
      * 名额已满就别让用户填名字了(2026-12-03)。
      * 名额已满就别让用户填名字了(2026-12-03)。
      * 在弹窗之前拦,而不是等提交后云函数返回 409 ——
      * 在弹窗之前拦,而不是等提交后云函数返回 409 ——
@@ -804,6 +841,14 @@ export class DkPlansPage implements OnInit {
           replaceUrl: true,
           replaceUrl: true,
         });
         });
       }
       }
+    } catch {
+      /*
+       * 提交抛错也要关弹窗(2026-12-03):否则弹窗永远盖在页面上,
+       * 页面级的错误提示(plans-error)用户根本看不到。
+       * 错误本身由 ProvisionService.error() 呈现在页面上。
+       */
+      this.confirmOpen.set(false);
+      this.pendingCode.set(null);
     } finally {
     } finally {
       this.submitting.set(false);
       this.submitting.set(false);
     }
     }

+ 70 - 0
src/app/mobile/pages/chat/chat.ts

@@ -286,6 +286,19 @@ type SheetTab = 'task' | 'file' | 'deliver' | 'state';
       </div>
       </div>
 
 
       <div class="m-composer-area">
       <div class="m-composer-area">
+        <!--
+          容器连接中断提示(2026-12-03,用户实测:网关重启/崩溃时「输出中」无限转圈)。
+          信号 = Matrix presence(网关死 → /sync 断 → offline,秒~分钟级),
+          不用容器心跳(1 小时周期且网关崩了照发,判不出来)。
+          恢复在线后此条自动消失;Hermes 会从 sync 断点补收消息,通常无需重发。
+        -->
+        @if (connectionInterrupted()) {
+          <div class="conn-interrupt" role="alert">
+            <i class="fa-solid fa-triangle-exclamation" aria-hidden="true"></i>
+            <span>容器连接中断,回复可能延迟或未送达</span>
+            <button type="button" class="conn-interrupt-btn" (click)="resendPendingTurn()">重新发送</button>
+          </div>
+        }
         <!-- 待发消息持有条已移除(2026-11-14 用户裁决「永远不拦,直接发」) -->
         <!-- 待发消息持有条已移除(2026-11-14 用户裁决「永远不拦,直接发」) -->
         <!-- 待发附件:图片出缩略图(与 PC 端同构),其余出文件名 chip -->
         <!-- 待发附件:图片出缩略图(与 PC 端同构),其余出文件名 chip -->
         @if (chat.pendingFiles().length > 0) {
         @if (chat.pendingFiles().length > 0) {
@@ -717,6 +730,34 @@ type SheetTab = 'task' | 'file' | 'deliver' | 'state';
          *    margin-inline: var(--mob-gutter),两层叠加让输入框比消息流窄一截。
          *    margin-inline: var(--mob-gutter),两层叠加让输入框比消息流窄一截。
          */
          */
       }
       }
+      /* 容器连接中断提示条(2026-12-03):与 m-dock 同宽(对齐 gutter) */
+      .conn-interrupt {
+        display: flex;
+        align-items: center;
+        gap: var(--sp-2);
+        margin: 0 var(--mob-gutter) var(--sp-2);
+        padding: var(--sp-2) var(--sp-3);
+        border-radius: 10px;
+        background: var(--warning-subtle);
+        color: var(--warning);
+        font-size: var(--fs-12);
+        line-height: 1.4;
+      }
+      .conn-interrupt > span {
+        flex: 1;
+        min-width: 0;
+      }
+      .conn-interrupt-btn {
+        flex: none;
+        min-height: 32px;
+        padding: 0 var(--sp-3);
+        border: 1px solid var(--warning);
+        border-radius: 8px;
+        background: transparent;
+        color: var(--warning);
+        font-size: var(--fs-12);
+        cursor: pointer;
+      }
       .m-pending {
       .m-pending {
         display: flex;
         display: flex;
         gap: var(--sp-2);
         gap: var(--sp-2);
@@ -1045,6 +1086,35 @@ export class MbChatPage implements OnDestroy {
   protected readonly agent = computed(() => this.chat.agent());
   protected readonly agent = computed(() => this.chat.agent());
   /* agentName 已删除(2026-12-02 用户裁决:移动端会话页不展示容器命名) */
   /* agentName 已删除(2026-12-02 用户裁决:移动端会话页不展示容器命名) */
 
 
+  /**
+   * 容器离线 + 本端还有没等到回复的回合 → 显示「连接中断」提示条(2026-12-03)。
+   *
+   * 判定用 `chat.agentPresence()`(Matrix presence,秒~分钟级)而**不是**容器心跳
+   * (1 小时周期且与网关进程无关,网关崩了照发)。
+   * `'unknown'`(sync 未就绪)不告警,避免进页瞬间误报。
+   */
+  protected readonly connectionInterrupted = computed(() => {
+    if (this.chat.agentPresence() !== 'offline') return false;
+    return (
+      this.chat.awaitingReplySince() > 0 ||
+      this.aiRows().some((r) => r.kind === 'turn' && r.turn.live)
+    );
+  });
+
+  /**
+   * 「连接中断」提示条上的重新发送:取最后一个回合的用户原文重发(2026-12-03)。
+   *
+   * 注意:Hermes 恢复后会从 sync 断点补收消息,多数情况**不需要**重发;
+   * 这个按钮是「等了很久还没恢复」时的逃生口,代价是恢复后可能收到两条回复。
+   */
+  protected resendPendingTurn(): void {
+    const turns: AssistantTurn[] = [];
+    for (const r of this.aiRows()) if (r.kind === 'turn') turns.push(r.turn);
+    const text = [...turns].reverse().find((t) => t.userMessage?.text?.trim())?.userMessage?.text?.trim();
+    if (!text) return;
+    void this.chat.sendText(text);
+  }
+
   /**
   /**
    * 消息 → 渲染行:**连续的终端活动消息合并成一个折叠组**。
    * 消息 → 渲染行:**连续的终端活动消息合并成一个折叠组**。
    *
    *

+ 36 - 3
src/app/mobile/pages/plans/plans.ts

@@ -135,7 +135,15 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
               }
               }
               <i class="plan-icon" [class]="iconOf(plan.code)" aria-hidden="true"></i>
               <i class="plan-icon" [class]="iconOf(plan.code)" aria-hidden="true"></i>
               <h3>{{ plan.shortName }}</h3>
               <h3>{{ plan.shortName }}</h3>
-              <p class="plan-quota"><strong>{{ plan.quota }}</strong><span>{{ plan.quotaLabel }}</span></p>
+              <!-- 名额显示已用/上限(2026-12-03 用户反馈「看不到我的限额」);列表未载出时只显示上限 -->
+              <p class="plan-quota">
+                @if (live.hasData()) {
+                  <strong>{{ live.agents().length }}/{{ plan.quota }}</strong>
+                } @else {
+                  <strong>{{ plan.quota }}</strong>
+                }
+                <span>{{ plan.quotaLabel }}</span>
+              </p>
               <p class="plan-price">价格待定</p>
               <p class="plan-price">价格待定</p>
               <p class="plan-unit">{{ plan.billingUnit || plan.billingNote }}</p>
               <p class="plan-unit">{{ plan.billingUnit || plan.billingNote }}</p>
               <button
               <button
@@ -689,6 +697,13 @@ export class MbPlansPage implements OnInit {
 
 
   ngOnInit(): void {
   ngOnInit(): void {
     void this.provision.restorePending();
     void this.provision.restorePending();
+    /*
+     * 配额预检与重名校验都依赖容器列表(2026-12-03):
+     * /plans 是顶层路由不在 shell 内,没人替本页拉 live,
+     * 不主动加载 existingNames() 永远是空 —— 配额预检形同虚设、
+     * 默认名永远从「我的容器 1」开始。
+     */
+    void this.live.ensureLoaded();
   }
   }
 
 
   protected readonly drawerOpen = signal(false);
   protected readonly drawerOpen = signal(false);
@@ -709,7 +724,11 @@ export class MbPlansPage implements OnInit {
 
 
   /** 全屏加载遮罩文案(null = 不显示) */
   /** 全屏加载遮罩文案(null = 不显示) */
   protected readonly loadingHint = computed<{ message: string; detail: string } | null>(() => {
   protected readonly loadingHint = computed<{ message: string; detail: string } | null>(() => {
-    if (this.provision.restoring()) return { message: '正在检查开通任务…', detail: '正在找回已有进度,请稍候' };
+    /*
+     * 🔴 restoring 不再上全屏遮罩(2026-12-03 用户实测反馈):
+     *    开通中离开再回 /plans,每次进页都重放一遍「正在检查开通任务…」过场动画。
+     *    restore 本来就是静默找回——完了有任务就显示 plans-job 区块,没有就无事发生。
+     */
     const p = this.provision.startingPlan();
     const p = this.provision.startingPlan();
     if (!p) return null;
     if (!p) return null;
     if (p === 'trial' || p === 'starter') {
     if (p === 'trial' || p === 'starter') {
@@ -748,8 +767,14 @@ export class MbPlansPage implements OnInit {
    * 跳转前必须 `await` 到 `jobId` 存在 —— 带着 undefined 跳过去,
    * 跳转前必须 `await` 到 `jobId` 存在 —— 带着 undefined 跳过去,
    * 等待页会拉不到任务,用户看到的是空转。
    * 等待页会拉不到任务,用户看到的是空转。
    */
    */
-  protected apply(code: PlanCode): void {
+  protected async apply(code: PlanCode): Promise<void> {
     if (this.provision.isRunning()) return;
     if (this.provision.isRunning()) return;
+    /*
+     * 配额判断依赖容器列表;首载还没落地时 existingNames() 是空数组,
+     * 直接判会永远放行(2026-12-03 用户实测:已有 2 个容器仍没看到名额提示)。
+     * 先等首载完成再校验;加载失败则由服务端配额校验兜底。
+     */
+    await this.live.ensureLoaded();
     /*
     /*
      * 名额已满就别让用户填名字了(2026-12-03)。
      * 名额已满就别让用户填名字了(2026-12-03)。
      * 在弹窗之前拦,而不是等提交后云函数返回 409 ——
      * 在弹窗之前拦,而不是等提交后云函数返回 409 ——
@@ -785,6 +810,14 @@ export class MbPlansPage implements OnInit {
         });
         });
       }
       }
       // onboarding 模式(试用/入门):留在本页,由模板渲染提示词
       // onboarding 模式(试用/入门):留在本页,由模板渲染提示词
+    } catch {
+      /*
+       * 提交抛错也要关弹窗(2026-12-03):否则弹窗永远盖在页面上,
+       * 页面级的错误提示(plans-error)用户根本看不到。
+       * 错误本身由 ProvisionService.error() 呈现在页面上。
+       */
+      this.confirmOpen.set(false);
+      this.pendingCode.set(null);
     } finally {
     } finally {
       this.submitting.set(false);
       this.submitting.set(false);
     }
     }