Przeglądaj źródła

feat(app): 回车发送 · 折叠网关重启通知 · 试用倒计时 · 本地容器提示词入口

用户实测反馈(2026-12-03)四项优化:
- m-dock:Enter 发送 / Shift+Enter 换行 / Ctrl+⌘+Enter 兼容 / IME 不发送
- 新增 core/gateway-notice:识别网关重启系统消息,回合聚合跳过,两端折叠成一行
- agent-liveness.trialCountdown:试用最后 6 小时在会话页显示剩余时长
- ProvisionService.reissueInstruction + 两端容器设置页「查看接入提示词」(同名幂等复用)

验证:build 通过;单测 2252 SUCCESS(3 个 SafeArea 既知偶发项);浏览器实测入口与 Enter 发送

Co-Authored-By: Claude Code <noreply@anthropic.com>
Huccct 18 godzin temu
rodzic
commit
556c439fec

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

@@ -10478,3 +10478,13 @@ Call log:
   - 验证(以 19170119836 身份):`xlosi3m46q scope=mine` 返回 3 个容器,Windows接入测试 `matrixReady=true/provisioned=true`,会出现在「新建对话」列表
   - 浏览器实测:`/mobile/contacts` 出现「Windows接入测试」并带「本地容器」徽标(截图 app-contacts.png);`/mobile/chat/agent-node-app-5ywuhfefqw/new` → 建房 → 发「APP-E2E 请回复 PONG」→ 收到「PONG」+ ✅(截图 app-debug.png)
   - 踩坑:移动端 dock 的 Enter 是换行,发送需 **Ctrl/⌘+Enter** 或点发送按钮(自动化脚本用 Enter 会静默不发送)
+
+- 2026-12-03 16:30:00+08:00:**App 端四项优化(用户多选确认)+ 两处接入说明**
+  - ① **回车即发送**:`m-dock.onEnter` 改为 Enter 发送、Shift+Enter 换行、Ctrl/⌘+Enter 兼容、IME 组字不发送(spec 已同步)
+  - ② **折叠网关重启通知**:新增 `core/gateway-notice.ts`(识别 Hermes 的「⚠️ Gateway shutting down」「Session restored」「会话已恢复,网关重新在线」原文),回合聚合跳过,两端 aiRows 按时间插回一行「网关已重启,会话已恢复」;规则收紧到句末终止,避免正文讨论网关被误折叠
+  - ③ **试用到期倒计时**:`agent-liveness.trialCountdown()`,最后 6 小时在会话页副标题/桌面状态徽标旁显示「试用剩余 X 小时 Y 分」,到期显示「试用已到期」
+  - ④ **本地容器页提示词入口**:`ProvisionService.reissueInstruction()`(云函数 start 同名幂等复用,不写 pending、不置 starting)→ 两端容器设置页新增「查看接入提示词」按钮 + 试用有效期;浏览器实测展开可见原生分支
+  - 说明:套餐页试用横幅与提示词组件文案改为「本机直接安装或 Docker 容器均可」
+  - 实测(19170119836 身份,localhost):设置页入口+有效期显示 OK;Enter 发送后输入框清空并收到回复 OK
+  - 验证:构建通过;全量单测 **2252 SUCCESS**(3 个失败仍为未触碰的 SafeArea 已知偶发项);新增 8 条单测(网关识别 3 + 通知插入 2 + 倒计时 4 中的部分)
+  - **同期发现(Hermes 侧,非 App)**:`busy_input_mode: interrupt` 下用户连发消息打断任务,出现「↪ Redirected current run」后会话租约未释放(`state.db.session_turn_leases` 过期无用条目),期间新消息只写日志不回复,直到下一步清理才恢复(实测 ALIVE 正常回复)。平台容器同样配置,但任务被限制得小、打断少;需单独评估缓解手段(不属 App 代码范围)

+ 1 - 1
src/app/components/domain/provision-instruction/provision-instruction.ts

@@ -35,7 +35,7 @@ import {
         <i class="fa-solid fa-wand-magic-sparkles" aria-hidden="true"></i>
         <h2>接入提示词已生成</h2>
       </header>
-      <p class="ins-lead">复制下面的内容,粘贴到你的容器里执行。</p>
+      <p class="ins-lead">复制下面的内容,发给你自己的 Hermes 执行(本机安装或 Docker 容器均可——它会先判断你属于哪种环境)。</p>
 
       <pre #code class="ins-code" tabindex="0">{{ text() }}</pre>
 

+ 25 - 0
src/app/core/agent-liveness.spec.ts

@@ -7,6 +7,7 @@ import {
   isReporterSelfTalk,
   livenessOf,
   resolveSessionPhase,
+  trialCountdown,
   onlineLabel,
   sessionPresence,
 } from './agent-liveness';
@@ -273,3 +274,27 @@ describe('resolveSessionPhase(统一状态裁决)', () => {
     expect(r.reason).toBe('idle');
   });
 });
+
+describe('trialCountdown(2026-12-03)', () => {
+  const now = Date.parse('2026-12-03T10:00:00Z');
+  const at = (h: number) => new Date(now + h * 3600_000).toISOString();
+
+  it('非试用容器不显示', () => {
+    expect(trialCountdown({ planCode: 'advanced', trialEndsAt: at(1) }, now)).toBeNull();
+    expect(trialCountdown(undefined, now)).toBeNull();
+  });
+
+  it('剩余超过 6 小时不打扰', () => {
+    expect(trialCountdown({ planCode: 'trial', trialEndsAt: at(7) }, now)).toBeNull();
+  });
+
+  it('最后 6 小时显示剩余时长', () => {
+    expect(trialCountdown({ planCode: 'trial', trialEndsAt: at(5.5) }, now)?.text).toBe('试用剩余 5 小时 30 分');
+    expect(trialCountdown({ planCode: 'trial', trialEndsAt: new Date(now + 20 * 60_000).toISOString() }, now)?.text).toBe('试用剩余 20 分钟');
+  });
+
+  it('已到期给出明确结论', () => {
+    expect(trialCountdown({ planCode: 'trial', trialExpired: true }, now)).toEqual({ text: '试用已到期', expired: true });
+    expect(trialCountdown({ planCode: 'trial', trialEndsAt: at(-1) }, now)).toEqual({ text: '试用已到期', expired: true });
+  });
+});

+ 27 - 0
src/app/core/agent-liveness.ts

@@ -289,3 +289,30 @@ export function blockedHint(v: LivenessView): string | null {
       return '该数字生命当前不可用,暂时无法进入会话。';
   }
 }
+
+/**
+ * 试用到期倒计时(2026-12-03)。
+ *
+ * 用户裁决:试用到期前在会话页顶部提示「还剩 X 小时」,避免突然被拦。
+ * 只在**最后 6 小时**出现;已到期返回「试用已到期」(此时门禁已拦,这里兜底深链)。
+ */
+export interface TrialCountdown {
+  text: string;
+  expired: boolean;
+}
+
+export function trialCountdown(
+  agent: { planCode?: string; trialEndsAt?: string; trialExpired?: boolean } | undefined,
+  now: number,
+): TrialCountdown | null {
+  if (!agent || agent.planCode !== 'trial') return null;
+  if (agent.trialExpired) return { text: '试用已到期', expired: true };
+  const end = Date.parse(agent.trialEndsAt ?? '');
+  if (!Number.isFinite(end)) return null;
+  const left = end - now;
+  if (left <= 0) return { text: '试用已到期', expired: true };
+  if (left > 6 * 3600_000) return null;
+  const hours = Math.floor(left / 3600_000);
+  const mins = Math.max(0, Math.floor((left % 3600_000) / 60_000));
+  return { text: hours > 0 ? `试用剩余 ${hours} 小时 ${mins} 分` : `试用剩余 ${mins} 分钟`, expired: false };
+}

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

@@ -59,6 +59,7 @@ import { RelayService } from './relay.service';
 import { TaskPulseService } from './task-pulse.service';
 import { sessionRunning, sessionStateOf } from './agent-state';
 import { resolveSessionPhase } from './agent-liveness';
+import { gatewayNoticeOf } from './gateway-notice';
 
 export type ConnectionState = 'connecting' | 'connected' | 'disconnected';
 
@@ -4112,6 +4113,12 @@ export class ChatService {
      * 它来自已废弃的「Matrix 回发文件本体」链路,对用户没有信息量,见 isMediaDeliveryFailure。
      */
     if (isMediaDeliveryFailure(m.body)) return;
+    /*
+     * 网关生命周期通知(2026-12-03):Hermes 重启/打断时会发「⚠️ Gateway shutting down」
+     * 「Session restored」这类原文消息,不承载任务内容却会切碎回合、占满正文。
+     * 收下但打标记:不进回合正文,由两端 aiRows 折叠成一行弱化提示(见 gateway-notice.ts)。
+     */
+    if (m.sender !== 'me' && gatewayNoticeOf(m.body) && m.kind !== 'notice') m = { ...m, kind: 'notice' };
     const sid = this._sessionId();
     // 🔴 多会话隔离:别的会话的消息不进入当前会话的列表
     if (!sid || !this.belongsToSession(m, sid, true)) return;

+ 47 - 0
src/app/core/gateway-notice.spec.ts

@@ -0,0 +1,47 @@
+import { gatewayNoticeOf, gatewayNoticeText, withGatewayNotices } from './gateway-notice';
+
+describe('gatewayNoticeOf', () => {
+  it('识别 Hermes 网关重启的英文原文', () => {
+    expect(gatewayNoticeOf('⚠️ Gateway shutting down — Your current task will be interrupted.')).toBe('shutdown');
+    expect(gatewayNoticeOf('Session restored — gateway is back online. What would you like to do next?')).toBe('restored');
+  });
+
+  it('识别中文原文', () => {
+    expect(gatewayNoticeOf('会话已恢复,网关重新在线。接下来想做什么?')).toBe('restored');
+    expect(gatewayNoticeOf('网关正在关闭')).toBe('shutdown');
+  });
+
+  it('正常正文里提到网关不会被折叠', () => {
+    expect(gatewayNoticeOf('请帮我看看网关重启的日志')).toBeNull();
+    expect(gatewayNoticeOf('Gateway shutting down 这个配置在哪个文件?')).toBeNull();
+    expect(gatewayNoticeOf(undefined)).toBeNull();
+    expect(gatewayNoticeOf('x'.repeat(200))).toBeNull();
+  });
+});
+
+describe('withGatewayNotices', () => {
+  const msg = (id: string, sec: number, sender: string, body: string) => ({ id, ts: Date.parse('2026-12-03T08:00:00Z') + sec * 1000, body, sender });
+
+  it('把通知按时间插到回合之间,连续多条合并成一行', () => {
+    const rows = [
+      { key: 'turn-a', at: Date.parse('2026-12-03T08:00:05Z') },
+      { key: 'turn-b', at: Date.parse('2026-12-03T08:00:30Z') },
+    ];
+    const messages = [
+      msg('u1', 0, 'me', '你好'),
+      msg('g1', 20, '@agent:fmode.cn', '⚠️ Gateway shutting down — Your current task will be interrupted.'),
+      msg('g2', 25, '@agent:fmode.cn', 'Session restored — gateway is back online. What would you like to do next?'),
+      msg('u2', 40, 'me', '继续'),
+    ];
+    const out = withGatewayNotices(rows, messages, (r) => r.at);
+    expect(out.map((r) => r.key)).toEqual(['turn-a', 'gw-g2', 'turn-b']);
+    const notice = out[1] as { text: string };
+    expect(gatewayNoticeText(['shutdown'])).toContain('网关已重启');
+    expect(notice.text).toContain('网关已重启');
+  });
+
+  it('没有通知时原样返回', () => {
+    const rows = [{ key: 'turn-a', at: 0 }];
+    expect(withGatewayNotices(rows, [], (r) => r.at)).toEqual(rows);
+  });
+});

+ 98 - 0
src/app/core/gateway-notice.ts

@@ -0,0 +1,98 @@
+/**
+ * 网关重启类系统消息识别(2026-12-03)。
+ *
+ * ## 为什么需要
+ *
+ * 本地接入的 Hermes 网关重启频率比平台容器高(用户手动停/起、系统睡眠、崩溃自愈)。
+ * 每次重启,Hermes 都会往房间发两条原文消息:
+ *   · 「⚠️ Gateway shutting down — Your current task will be interrupted.」
+ *   · 「Session restored — gateway is back online. What would you like to do next?」
+ *   中文版:「会话已恢复,网关重新在线。接下来想做什么?」
+ * 它们不承载任务内容,却会切碎回合、占满正文。App 侧识别后折叠成一行弱化提示。
+ *
+ * ## 口径
+ *
+ * 只认**明确的网关生命周期文案**,不做模糊匹配(正文里正常讨论「网关重启」不能被折叠)。
+ * 按整句起点匹配,允许前置 ⚠️/emoji 与首尾空白。
+ */
+const PATTERNS: readonly RegExp[] = [
+  /^(?:⚠️\s*)?gateway\s+(is\s+)?shutting\s+down\b(?=\s*(?:[—\-–.!,,。!]|$))/i,
+  /^(?:⚠️\s*)?gateway\s+(is\s+)?back\s+online\b(?=\s*(?:[—\-–.!,,。!]|$))/i,
+  /^session\s+restored\b/i,
+  /^(?:⚠️\s*)?网关(正在)?(关闭|断开|重启)(?:了|中)?[。!!…\s]*(?:$|,|,)/,
+  /^会话已恢复/,
+  /^网关(已|重新)在线/,
+];
+
+export type GatewayNotice = 'shutdown' | 'restored';
+
+/** 判定一条容器消息是否为网关生命周期通知;不是则返回 null。 */
+export function gatewayNoticeOf(text: string | undefined | null): GatewayNotice | null {
+  const body = (text ?? '').trim();
+  if (!body || body.length > 120) return null;
+  for (const p of PATTERNS) {
+    if (!p.test(body)) continue;
+    return /shutting|关闭|断开|重启/.test(body) ? 'shutdown' : 'restored';
+  }
+  return null;
+}
+
+/** 折叠后展示一行文案;两组相邻消息合成同一条回合成一句话。 */
+export function gatewayNoticeText(kinds: readonly GatewayNotice[]): string {
+  return kinds.includes('shutdown')
+    ? '网关已重启,当前任务可能被中断,会话已恢复'
+    : '会话已恢复,网关重新在线';
+}
+
+/** 折叠后插入渲染列表的一行(两端共用结构)。 */
+export interface GatewayNoticeRow {
+  kind: 'notice';
+  key: string;
+  text: string;
+}
+
+/**
+ * 把网关通知按时间顺序插回渲染行列表(2026-12-03)。
+ *
+ * 两端 aiRows 共用:回合聚合会跳过这些消息(见 turn-aggregator.ts),
+ * 这里在同一位置补一行弱化提示。连续多条合并成一条,避免反复重启刷屏。
+ *
+ * @param rows    已排好的渲染行(保持原类型,模板里的 `row.turn` 等仍可窄化)
+ * @param messages 原始消息(用于把通知对齐到相邻行)
+ * @param atOf   取一行的时刻(ISO 字符串),通知插在「时刻早于它的行」之前
+ */
+export function withGatewayNotices<Row extends { key: string }>(
+  rows: readonly Row[],
+  messages: readonly { id: string; ts: string | number; body?: string; text?: string; sender: string }[],
+  atOf: (row: Row) => string | number | undefined,
+): (Row | GatewayNoticeRow)[] {
+  const notices = messages
+    .filter((m) => m.sender !== 'me' && gatewayNoticeOf(m.text ?? m.body))
+    .map((m) => ({
+      id: m.id,
+      at: typeof m.ts === 'number' ? m.ts : Date.parse(m.ts) || 0,
+      body: (m.text ?? m.body ?? '').trim(),
+    }));
+  if (!notices.length) return [...rows];
+  const out: (Row | GatewayNoticeRow)[] = [];
+  let i = 0;
+  const flushBefore = (limit: number) => {
+    const batch: string[] = [];
+    while (i < notices.length && notices[i].at <= limit) {
+      batch.push(notices[i].body);
+      i++;
+    }
+    if (batch.length) {
+      const kinds = batch.map((b) => gatewayNoticeOf(b) ?? 'restored');
+      out.push({ kind: 'notice', key: `gw-${notices[i - 1].id}`, text: gatewayNoticeText(kinds) });
+    }
+  };
+  for (const row of rows) {
+    const t = atOf(row);
+    const at = typeof t === 'number' ? t : Date.parse(t ?? '') || Number.POSITIVE_INFINITY;
+    flushBefore(at);
+    out.push(row);
+  }
+  flushBefore(Number.POSITIVE_INFINITY);
+  return out;
+}

+ 29 - 0
src/app/core/provision.service.ts

@@ -309,6 +309,35 @@ export class ProvisionService {
    *
    * @returns `onboarding` 时把提示词写进 `instruction()`;`provision` 时开始轮询
    */
+  /**
+   * 重新获取本地容器的接入提示词(2026-12-03)。
+   *
+   * 云函数 `start` 的 onboarding 分支按 `user + name` **幂等复用**记录,
+   * 不发工单、不碰 R730。所以这里可以绕过「开通队列」那套防重入逻辑:
+   * 与 `start()` 的区别是不写 pending、不置 starting(不会和真正的开通互相干扰),
+   * 只把结果写进 `instruction()` 供容器设置页展示。已过期的试用由云函数拒绝。
+   */
+  async reissueInstruction(agent: { name: string; planCode?: string }): Promise<string | null> {
+    const planCode = agent.planCode === 'starter' ? 'starter' : 'trial';
+    try {
+      const result = await this.api.startProvision({
+        planCode,
+        containerName: agent.name,
+        idempotencyKey: `reissue-${Date.now()}`,
+      });
+      if (result?.mode === 'onboarding' && result.instruction) {
+        this._instruction.set(result.instruction);
+        this._error.set(null);
+        return result.instruction;
+      }
+      this._error.set(result?.message ?? '暂时无法生成接入提示词');
+      return null;
+    } catch (e) {
+      this._error.set(e instanceof Error ? e.message : '暂时无法生成接入提示词');
+      return null;
+    }
+  }
+
   async start(planCode: string, containerName: string): Promise<ProvisionStartResult | null> {
     /*
      * 🔴 防重入(2026-11-27):已在开通中时直接忽略。

+ 6 - 0
src/app/core/turn-aggregator.ts

@@ -1,4 +1,5 @@
 import { Message } from './api/models';
+import { gatewayNoticeOf } from './gateway-notice';
 
 /**
  * 回合(Turn)—— 一次提问产生的全部 agent 输出的集合
@@ -216,6 +217,11 @@ export function buildTurns({ messages, typing, now }: TurnInput): Turn[] {
   };
 
   for (const m of messages) {
+    /*
+     * 网关生命周期通知(2026-12-03)不进回合正文:
+     * 重启/打断时 Hermes 会发「⚠️ Gateway shutting down」「Session restored」,     * 夹进回合会把卡片撑长、切碎过程区。两端 aiRows 把它们单独渲染成一行弱化提示。
+     */
+    if (m.sender !== 'me' && gatewayNoticeOf(m.text)) continue;
     if (m.sender === 'me') {
       /*
        * 🔴 同一轮用户输入里的附件并入上一个回合(2026-11-10 修复)。

+ 43 - 1
src/app/desktop/pages/agent/agent.ts

@@ -8,6 +8,8 @@ import { Agent } from '../../../core/api/models';
 import { AlertService } from '../../../core/alert.service';
 import { blockedHint, livenessOf } from '../../../core/agent-liveness';
 import { AgentRenameService } from '../../../core/agent-rename.service';
+import { ProvisionService } from '../../../core/provision.service';
+import { ProvisionInstructionComponent } from '../../../components/domain/provision-instruction/provision-instruction';
 import { LiveService } from '../../../core/live.service';
 import { PromptModalService } from '../../../components/domain/prompt-modal/prompt-modal.service';
 import { EditionService } from '../../../core/edition.service';
@@ -34,7 +36,7 @@ import { EditionService } from '../../../core/edition.service';
 @Component({
   selector: 'app-dk-agent-page',
   changeDetection: ChangeDetectionStrategy.OnPush,
-  imports: [UserNoticePipe, NgTemplateOutlet, PageComponent, UiButton, UiCard, UiEmpty, UiSkeleton],
+  imports: [UserNoticePipe, NgTemplateOutlet, PageComponent, UiButton, UiCard, UiEmpty, UiSkeleton, ProvisionInstructionComponent],
   template: `
     @if (embedded()) {
       <!-- 嵌入模式(dialog 内):不渲染页面外壳 -->
@@ -95,6 +97,20 @@ import { EditionService } from '../../../core/edition.service';
                     进入会话
                   </ui-button>
                 </div>
+                <!-- 本地容器:重新拿接入提示词(2026-12-03) -->
+                @if (a.planCode === 'trial' || a.planCode === 'starter') {
+                  <div class="action-row instruction-row">
+                    <ui-button variant="outline" [icon]="reissuing() ? 'fa-solid fa-circle-notch fa-spin' : 'fa-solid fa-key'" [disabled]="reissuing()" (click)="showInstruction(a)">
+                      {{ reissuing() ? '正在生成…' : (instruction() ? '收起接入提示词' : '查看接入提示词') }}
+                    </ui-button>
+                    @if (a.trialEndsAt) {
+                      <span class="trial-end">试用有效期至 {{ trialEndText(a.trialEndsAt) }}</span>
+                    }
+                  </div>
+                  @if (instruction(); as ins) {
+                    <div class="instruction-box"><app-provision-instruction [text]="ins" /></div>
+                  }
+                }
                 @if (!canRename()) {
                   <p class="hint">{{ isPersonal() ? '你没有权限重命名这个容器。' : '只有企业管理员可以重命名容器。' }}</p>
                 }
@@ -145,6 +161,16 @@ import { EditionService } from '../../../core/edition.service';
         text-overflow: ellipsis;
         white-space: nowrap;
       }
+      .instruction-row {
+        margin-top: var(--sp-3);
+      }
+      .trial-end {
+        color: var(--muted);
+        font-size: var(--fs-12);
+      }
+      .instruction-box {
+        margin-top: var(--sp-3);
+      }
       .action-row {
         display: flex;
         align-items: center;
@@ -179,6 +205,22 @@ export class DkAgentPage implements OnInit {
   private readonly prompt = inject(PromptModalService);
   protected readonly live = inject(LiveService);
   protected readonly renameSvc = inject(AgentRenameService);
+  private readonly provisionSvc = inject(ProvisionService);
+  /** 接入提示词(2026-12-03):本地容器的重新生成入口 */
+  protected readonly instruction = signal<string | null>(null);
+  protected readonly reissuing = signal(false);
+
+  protected async showInstruction(a: Agent): Promise<void> {
+    if (this.instruction()) { this.instruction.set(null); return; }
+    this.reissuing.set(true);
+    try { this.instruction.set(await this.provisionSvc.reissueInstruction(a)); }
+    finally { this.reissuing.set(false); }
+  }
+
+  protected trialEndText(iso: string): string {
+    const d = new Date(iso);
+    return Number.isFinite(d.getTime()) ? `${d.getMonth() + 1} 月 ${d.getDate()} 日 ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}` : '';
+  }
 
   /** 嵌入模式(agent-modal 复用本页时传 true) */
   readonly embedded = input(false);

+ 44 - 3
src/app/desktop/pages/chat/chat.ts

@@ -22,6 +22,7 @@ import {
   UiTooltip,
 } from '../../../ui';
 import { ComposerComponent } from '../../../components/domain/composer/composer';
+import { withGatewayNotices } from '../../../core/gateway-notice';
 import { NewSessionRequest } from '../../../components/domain/session-tree/session-tree';
 import { MessageBubbleComponent } from '../../../components/domain/message-bubble/message-bubble';
 import { TypingIndicatorComponent } from '../../../components/domain/typing-indicator/typing-indicator';
@@ -35,6 +36,7 @@ import {
   livenessOf,
   resolveSessionPhase,
   sessionPresence,
+  trialCountdown,
 } from '../../../core/agent-liveness';
 import { resolveAgentState } from '../../../core/agent-state';
 import { StatusBadgeComponent } from '../../../components/domain/status-badge/status-badge';
@@ -101,7 +103,8 @@ import { AssistantTurnComponent } from '../../../components/domain/assistant-tur
  */
 type AiRow =
   | { kind: 'msg'; key: string; message: Message }
-  | { kind: 'turn'; key: string; turn: AssistantTurn };
+  | { kind: 'turn'; key: string; turn: AssistantTurn }
+  | { kind: 'notice'; key: string; text: string };
 
 /** 右栏标签 */
 export type RailTab = 'tasks' | 'files' | 'results' | 'status';
@@ -263,6 +266,10 @@ interface ConversationRow {
               @if (!headerPresence().busy && headerPresence().text !== '在线') {
                 <app-status-badge [view]="headerPresence()" />
               }
+              <!-- 试用到期倒计时(2026-12-03):最后 6 小时提示,避免突然被拦 -->
+              @if (trialLeft(); as tl) {
+                <span class="trial-left" [class.trial-left--expired]="tl.expired"><i class="fa-solid fa-hourglass-half" aria-hidden="true"></i> {{ tl.text }}</span>
+              }
             }
               <!--
               页头「当前任务」摘要槽位已删除(2026-12-02 用户裁决):
@@ -496,7 +503,9 @@ interface ConversationRow {
                   }
                 </div>
                 @for (row of aiRows(); track row.key) {
-                  @if (row.kind === 'turn') {
+                  @if (row.kind === 'notice') {
+                    <p class="gw-notice" role="status"><i class="fa-solid fa-rotate" aria-hidden="true"></i> {{ row.text }}</p>
+                  } @else if (row.kind === 'turn') {
                     <!--
                       一整轮 = 一张卡(2026-11-07 用户需求):
                       顶部过程区可折叠 + 合并正文 + 文件宫格。
@@ -1307,6 +1316,28 @@ interface ConversationRow {
         flex-shrink: 0;
         padding: 0 max(var(--sp-4), calc((100% - 768px) / 2));
       }
+      .trial-left {
+        display: inline-flex;
+        align-items: center;
+        gap: 4px;
+        margin-left: var(--sp-2);
+        padding: 2px var(--sp-2);
+        border-radius: 6px;
+        background: var(--warning-subtle);
+        color: var(--warning);
+        font-size: var(--fs-12);
+      }
+      /* 网关重启折叠行(2026-12-03) */
+      .gw-notice {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        gap: var(--sp-1);
+        margin: var(--sp-3) 0;
+        color: var(--muted);
+        font-size: var(--fs-12);
+        text-align: center;
+      }
       /* 试用到期提示条(2026-12-03):与连接中断条同风格 */
       .trial-expired-bar {
         display: flex;
@@ -2396,7 +2427,10 @@ export class DkChatPage implements OnDestroy {
         out.push({ kind: 'turn', key: `turn-${t.id}`, turn: t });
       }
     }
-    return out;
+    /* 网关通知(2026-12-03)按时间插回,见 core/gateway-notice.ts */
+    return withGatewayNotices(out, this.chat.messages(), (r) =>
+      r.kind === 'msg' ? r.message.ts : r.kind === 'turn' ? r.turn.blocks[0]?.startAt ?? (Date.parse(r.turn.userMessage?.ts ?? '') || 0) : undefined,
+    );
   });
 
   /*
@@ -2725,9 +2759,16 @@ export class DkChatPage implements OnDestroy {
       ...sig,
       turnLive: !!liveTurn,
     });
+
     return sessionPresence(this.chat.agent(), resolved.phase);
   });
 
+  /** 试用到期倒计时(2026-12-03):最后 6 小时出现在会话头部,见 core/agent-liveness.ts */
+  readonly trialLeft = computed(() => {
+    this.clockTick();
+    return trialCountdown(this.chat.agent(), Date.now());
+  });
+
   /** 离线/未接入时的横幅提示(null = 在线,不显示) */
   readonly offlineBanner = computed(() => blockedHint(this.currentContainerState()));
 

+ 1 - 1
src/app/desktop/pages/plans/plans.ts

@@ -122,7 +122,7 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
           </div>
           <div class="plans-banner-body">
             <h2>先体验,再决定。<span>两天试用</span></h2>
-            <p>使用你自己的容器接入 Fmode</p>
+            <p>用你自己的 Hermes 接入 Fmode:<b>本机直接安装</b>或 <b>Docker 容器</b>均可</p>
           </div>
           <button type="button" class="plans-banner-btn" [disabled]="provision.startBlocked()" (click)="apply('trial')">
             @if (provision.isStarting('trial')) {

+ 10 - 7
src/app/mobile/components/m-dock/m-dock.spec.ts

@@ -23,10 +23,17 @@ describe('MDockComponent mobile input', () => {
     return event;
   }
 
-  it('keeps ordinary Enter and Shift+Enter available for native newlines', () => {
-    expect(enter().defaultPrevented).toBeFalse();
+  it('sends on Enter and keeps Shift+Enter for native newlines (2026-12-03)', () => {
     expect(enter({ shiftKey: true }).defaultPrevented).toBeFalse();
     expect(sent).toEqual([]);
+    expect(enter().defaultPrevented).toBeTrue();
+    expect(sent).toEqual(['待发送内容']);
+  });
+
+  it('keeps Ctrl/Command+Enter working for muscle memory', () => {
+    fixture.componentRef.setInput('sending', false);
+    enter({ ctrlKey: true });
+    expect(sent).toEqual(['待发送内容']);
   });
 
   it('does not submit during IME composition, including shortcut keys', () => {
@@ -35,11 +42,6 @@ describe('MDockComponent mobile input', () => {
     expect(sent).toEqual([]);
   });
 
-  it('submits once with an external keyboard shortcut', () => {
-    expect(enter({ ctrlKey: true }).defaultPrevented).toBeTrue();
-    expect(sent).toEqual(['待发送内容']);
-  });
-
   it('submits with Command+Enter', () => {
     enter({ metaKey: true });
     expect(sent).toEqual(['待发送内容']);
@@ -50,6 +52,7 @@ describe('MDockComponent mobile input', () => {
     fixture.detectChanges();
     expect(fixture.nativeElement.querySelector('.m-send').disabled).toBeTrue();
     enter({ ctrlKey: true });
+    enter();
     expect(sent).toEqual([]);
   });
 

+ 9 - 1
src/app/mobile/components/m-dock/m-dock.ts

@@ -342,7 +342,15 @@ export class MDockComponent {
   /** 手机回车换行;外接键盘 Ctrl/Cmd+Enter 发送,输入法选字期间不提交。 */
   protected onEnter(e: Event): void {
     const ke = e as KeyboardEvent;
-    if (ke.key !== 'Enter' || ke.isComposing || ke.keyCode === 229 || !(ke.ctrlKey || ke.metaKey)) return;
+    /*
+     * 键位(2026-12-03 用户裁决「回车即发送」):
+     *   · Enter 发送(与微信/企微一致,enterkeyhint 本来也提示 enter=发送)
+     *   · Shift+Enter 换行
+     *   · Ctrl/⌘+Enter 仍可发送(保留旧习惯,不改用户的肌肉记忆)
+     *   · 输入法组字中(isComposing / keyCode 229)一律不发送,否则选词回车会被吞
+     */
+    if (ke.key !== 'Enter' || ke.isComposing || ke.keyCode === 229) return;
+    if (ke.shiftKey) return;
     ke.preventDefault();
     this.submit();
   }

+ 43 - 1
src/app/mobile/pages/agent/agent.ts

@@ -9,6 +9,8 @@ import { LiveService } from '../../../core/live.service';
 import { MAppBarComponent } from '../../components/m-app-bar/m-app-bar';
 import { MEmptyComponent } from '../../components/m-empty/m-empty';
 import { EditionService } from '../../../core/edition.service';
+import { ProvisionService } from '../../../core/provision.service';
+import { ProvisionInstructionComponent } from '../../../components/domain/provision-instruction/provision-instruction';
 
 /**
  * 容器设置(移动端,2026-11-04 精简)
@@ -27,7 +29,7 @@ import { EditionService } from '../../../core/edition.service';
 @Component({
   selector: 'app-mb-agent-page',
   changeDetection: ChangeDetectionStrategy.OnPush,
-  imports: [UserNoticePipe, MAppBarComponent, MEmptyComponent],
+  imports: [UserNoticePipe, MAppBarComponent, MEmptyComponent, ProvisionInstructionComponent],
   template: `
     <div class="m-page">
       <app-m-app-bar title="容器设置" [back]="true" (backTap)="back()" />
@@ -76,6 +78,21 @@ import { EditionService } from '../../../core/edition.service';
                     进入会话
                   </button>
 
+                  <!-- 本地接入的容器:重新拿接入提示词(2026-12-03)
+                       刷新页面后提示词就丢了,用户不必回套餐页从头找 -->
+                  @if (a.planCode === 'trial' || a.planCode === 'starter') {
+                    <button type="button" class="m-chat-btn m-chat-btn--ghost" [disabled]="reissuing()" (click)="showInstruction(a)">
+                      <i class="fa-solid" [class]="reissuing() ? 'fa-circle-notch fa-spin' : 'fa-key'"></i>
+                      {{ reissuing() ? '正在生成…' : (instruction() ? '收起接入提示词' : '查看接入提示词') }}
+                    </button>
+                    @if (instruction(); as ins) {
+                      <div class="m-instruction"><app-provision-instruction [text]="ins" /></div>
+                    }
+                    @if (a.trialEndsAt) {
+                      <p class="m-hint">试用有效期至 {{ trialEndText(a.trialEndsAt) }}</p>
+                    }
+                  }
+
                   @if (error()) {
                     <p class="m-err" role="alert">{{ (error()) | userNotice:'暂时无法完成,请稍后再试。' }}</p>
                   }
@@ -188,6 +205,14 @@ import { EditionService } from '../../../core/edition.service';
         cursor: not-allowed;
       }
       /* 次操作:与主色的「重命名」区分开 */
+      .m-chat-btn--ghost {
+        /* 次要操作(查看接入提示词):弱化,不与「进入会话」抢注意力 */
+        margin-top: var(--sp-2);
+        color: var(--ink-2);
+      }
+      .m-instruction {
+        margin-top: var(--sp-3);
+      }
       .m-chat-btn {
         display: inline-flex;
         align-items: center;
@@ -292,6 +317,7 @@ export class MbAgentPage {
   private readonly router = inject(Router);
   private readonly alert = inject(AlertService);
   protected readonly live = inject(LiveService);
+  protected readonly provisionSvc = inject(ProvisionService);
   protected readonly renameSvc = inject(AgentRenameService);
 
   protected readonly error = signal<string | null>(null);
@@ -309,6 +335,22 @@ export class MbAgentPage {
   }
 
   /** 打开重命名弹层 */
+  /** 接入提示词(2026-12-03):本地容器的重新生成入口 */
+  protected readonly instruction = signal<string | null>(null);
+  protected readonly reissuing = signal(false);
+
+  protected async showInstruction(a: Agent): Promise<void> {
+    if (this.instruction()) { this.instruction.set(null); return; }
+    this.reissuing.set(true);
+    try { this.instruction.set(await this.provisionSvc.reissueInstruction(a)); }
+    finally { this.reissuing.set(false); }
+  }
+
+  protected trialEndText(iso: string): string {
+    const d = new Date(iso);
+    return Number.isFinite(d.getTime()) ? `${d.getMonth() + 1} 月 ${d.getDate()} 日 ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}` : '';
+  }
+
   protected rename(agent: Agent): void {
     this.error.set(null);
     this.draft.set(agent.name);

+ 27 - 3
src/app/mobile/pages/chat/chat.ts

@@ -49,6 +49,8 @@ import { TaskPulseService } from '../../../core/task-pulse.service';
 import { BackButtonService } from '../../../core/back-button.service';
 import { fileIdentity } from '../../../core/s3-link';
 import { mergeConsecutiveBodies } from '../../../core/message-merge';
+import { withGatewayNotices } from '../../../core/gateway-notice';
+import { trialCountdown } from '../../../core/agent-liveness';
 import {
   AssistantTurn,
   isTurnStalled,
@@ -84,7 +86,9 @@ type MessageRow =
 /** 卡片渲染行(2026-11-07):用户消息一行,AI 一整轮一张卡 */
 type AiRow =
   | { kind: 'msg'; key: string; message: Message }
-  | { kind: 'turn'; key: string; turn: AssistantTurn };
+  | { kind: 'turn'; key: string; turn: AssistantTurn }
+  /* 网关重启类通知折叠成一行(2026-12-03),见 core/gateway-notice.ts */
+  | { kind: 'notice'; key: string; text: string };
 
 /** 回合内部的一块:正文一条,或一组工具执行过程 */
 type TurnBlock =
@@ -263,7 +267,9 @@ type SheetTab = 'task' | 'file' | 'deliver' | 'state';
               与桌面端共用 app-assistant-turn。用户消息仍走 app-m-msg,保持移动观感。
             -->
             @for (row of aiRows(); track row.key) {
-              @if (row.kind === 'turn') {
+              @if (row.kind === 'notice') {
+                <p class="m-gateway-notice" role="status"><i class="fa-solid fa-rotate" aria-hidden="true"></i> {{ row.text }}</p>
+              } @else if (row.kind === 'turn') {
                 <!--
                   2026-12-02 用户裁决:恢复桌面同款等待反馈(删掉 hideRunningHint)。
                   此前(674428a)隐藏了「已处理 Ns · 继续处理任务过程」,声称由
@@ -573,6 +579,17 @@ type SheetTab = 'task' | 'file' | 'deliver' | 'state';
         font-size: var(--fs-icon);
         cursor: pointer;
       }
+      /* 网关重启折叠行(2026-12-03):一行弱化提示,不占正文 */
+      .m-gateway-notice {
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        gap: var(--sp-1);
+        margin: var(--sp-3) var(--mob-gutter);
+        color: var(--muted);
+        font-size: var(--fs-11, 11px);
+        text-align: center;
+      }
       /* 试用到期提示条(2026-12-03):与连接中断条同风格,左侧文案 + 右侧去开通 */
       .trial-expired-bar {
         display: flex;
@@ -1265,7 +1282,10 @@ export class MbChatPage implements OnDestroy {
         out.push({ kind: 'turn', key: `turn-${t.id}`, turn: dedupeTurnFiles(t) });
       }
     }
-    return out;
+    /* 网关通知(2026-12-03)按时间插回:行的时刻取用户消息 / 回合首条块的时间 */
+    return withGatewayNotices(out, this.chat.messages(), (r) =>
+      r.kind === 'msg' ? r.message.ts : r.kind === 'turn' ? r.turn.blocks[0]?.startAt ?? (Date.parse(r.turn.userMessage?.ts ?? '') || 0) : undefined,
+    );
   });
 
   /*
@@ -1533,6 +1553,10 @@ export class MbChatPage implements OnDestroy {
     if (this.chat.connection() === 'disconnected') {
       return '网络已断开';
     }
+    /* 试用到期倒计时(2026-12-03):最后 6 小时接管副标题,避免突然被拦 */
+    this.clockTick();
+    const trial = trialCountdown(a, Date.now());
+    if (trial) return trial.text;
     return this.presence().text;
   });
 

+ 1 - 1
src/app/mobile/pages/plans/plans.ts

@@ -107,7 +107,7 @@ import { suggestContainerName } from '../../../components/domain/provision-confi
             <div class="plans-trial-icon"><i class="fa-solid fa-wand-magic-sparkles" aria-hidden="true"></i></div>
             <div class="plans-trial-body">
               <h2>先体验,再决定<span>两天试用</span></h2>
-              <p>使用你自己的容器接入 Fmode</p>
+              <p>用你自己的 Hermes 接入 Fmode:<b>本机直接安装</b>或 <b>Docker 容器</b>均可</p>
             </div>
             <button type="button" class="plans-trial-btn" (click)="apply('trial')" [disabled]="provision.startBlocked()">
               @if (provision.isStarting('trial')) {