Quellcode durchsuchen

feat(mobile): v1.0.3 对话标题可编辑 + 输入区紧凑化

按 UX 方案网页与用户现场反馈,做布局与交互优化,不改数据契约。

标题可编辑
- m-app-bar 新增 titleEditable / titleTap,静态页面不受影响
- 新增 m-title-editor 底部编辑弹层(字数计数、iOS 16px 防缩放)
- ChatService.renameSession 写 m.room.name 状态事件,跨端同步
- ChatSessionService.setTitle 就地更新本地表,避免等 sync 才回显

输入区紧凑化
- 项目切换器去掉冗余「切换」二字,箭头即表达可展开
- 项目名改为 flex 撑满,长名字显示更完整
- 附件按钮触摸区不变(44px),视觉盒收进 32px 消除视觉突兀

构建修复
- colors.xml 删除重复的 splash_background(与 ic_launcher_background.xml 冲突导致 mergeReleaseResources 失败)
- 开屏底色对齐 SplashAnimView 的白色容器,避免冷启动色差

发布脚本
- publish-apk.mjs 支持 release 产物(FMODE_APK_DIR),原先只认 debug 包
liuyuyang vor 15 Stunden
Ursprung
Commit
69b1e21bc5

+ 3 - 4
android/app/src/main/res/values/colors.xml

@@ -12,9 +12,8 @@
     <color name="colorAccent">#06B6D4</color>
 
     <!--
-      闪屏底色(2026-11-23)
-      取开机画面主色 #0B1220,让「系统闪屏 → splash 图 → WebView」三帧同色,
-      用户感知是一次淡入,而不是先白屏再深色。
+      ⚠️ splash_background 定义在 ic_launcher_background.xml(白色),不要在这里重复定义。
+      开屏动画 SplashAnimView 的容器背景是 Color.WHITE,系统闪屏底色必须与之一致,
+      否则冷启动会闪一下色差。两处同时定义会让 mergeReleaseResources 报 Duplicate resources。
     -->
-    <color name="splash_background">#0B1220</color>
 </resources>

+ 20 - 7
scripts/publish-apk.mjs

@@ -36,7 +36,6 @@ const BUCKET = 'obs://www-ai.fmode.cn';
 const CDN_BASE = 'https://ai.fmode.cn';
 const OBS_EP = 'obs.cn-south-1.myhuaweicloud.com';
 const CDN_REGION = 'cn-north-1';
-const APK_DIR = join(projectRoot, 'android/app/build/outputs/apk/debug');
 const SITE_DIR = join(projectRoot, 'prototypes/fmode-download-20261120');
 const TMP_DIR = join(projectRoot, 'scripts/.tmp-publish');
 
@@ -117,20 +116,34 @@ function resolveHcloud() {
 
 // ── 1. APK 元信息 ──────────────────────────────────────────────────────────
 console.log('\n=== [1/6] 读取 APK 元信息 ===');
-const apkPath = join(APK_DIR, 'app-debug.apk');
+/*
+ * 产物目录(2026-11-23 补 release 支持)
+ *
+ * 原脚本只认 debug 包,但上线必须用签过名的 release ——
+ * debug 包签名是调试钥匙,装上去以后无法用正式包覆盖升级。
+ * 用 FMODE_APK_DIR 指定,默认仍走 debug(兼容老用法)。
+ */
+const APK_DIR = process.env.FMODE_APK_DIR
+  || join(projectRoot, 'android/app/build/outputs/apk/debug');
+const apkPath = join(APK_DIR, 'app-release.apk');
+const apkDebugPath = join(APK_DIR, 'app-debug.apk');
 const metaPath = join(APK_DIR, 'output-metadata.json');
-if (!existsSync(apkPath) || !existsSync(metaPath)) {
-  console.error('❌ 找不到 APK 产物,请先构建:cd android && gradle assembleDebug');
+const apkFile = existsSync(apkPath) ? apkPath : apkDebugPath;
+if (!existsSync(apkFile) || !existsSync(metaPath)) {
+  console.error('❌ 找不到 APK 产物。先构建:');
+  console.error('   release: cd android && ./gradlew assembleRelease');
+  console.error('   debug  : npm run cap:apk');
   process.exit(1);
 }
 const meta = JSON.parse(readFileSync(metaPath, 'utf8'));
+const apkPathFinal = apkFile;
 const versionName = meta.elements?.[0]?.versionName;
 if (!versionName) {
   console.error('❌ output-metadata.json 中没有 versionName');
   process.exit(1);
 }
-const { size, mtimeMs } = statSync(apkPath);
-const md5 = createHash('md5').update(readFileSync(apkPath)).digest('hex');
+const { size, mtimeMs } = statSync(apkPathFinal);
+const md5 = createHash('md5').update(readFileSync(apkPathFinal)).digest('hex');
 const fileName = `fmode-app-v${versionName}.apk`;
 const fileSizeText = `${(size / 1024 / 1024).toFixed(1)} MB`;
 const today = new Date().toLocaleDateString('sv-SE'); // YYYY-MM-DD
@@ -149,7 +162,7 @@ if (!skipApk) {
     process.exit(1);
   }
   // -meta 偶发不生效,chattri REPLACE_NEW 双保险(deploy-kit apk-publish.sh 实测写法)
-  run('obsutil', ['cp', apkPath, remoteApk, '-acl=public-read',
+  run('obsutil', ['cp', apkPathFinal, remoteApk, '-acl=public-read',
     '-meta=Content-Type:application/vnd.android.package-archive', `-e=${OBS_EP}`]);
   run('obsutil', ['chattri', remoteApk,
     '-meta=Content-Type:application/vnd.android.package-archive', '-direct=REPLACE_NEW', `-e=${OBS_EP}`]);

+ 16 - 0
src/app/core/chat-session.service.ts

@@ -595,6 +595,22 @@ export class ChatSessionService {
     return this._all().find((s) => s.id === id);
   }
 
+  /**
+   * 就地更新会话标题(2026-11-23)
+   *
+   * 只改本地表里这一条的 title,其余字段原样保留。
+   * 用于 Matrix 房间名改完后的即时回显 —— 不写持久层,
+   * 下次 sync 会拿到服务端的权威值。
+   */
+  setTitle(id: string, title: string): void {
+    const name = title.trim();
+    if (!name) return;
+    this._all.update((list) =>
+      list.map((s) => (s.id === id ? { ...s, title: name } : s)),
+    );
+  }
+
+
   /** 某 agent 最近的会话(默认会话 = 上次聊的) */
   latestFor(agentId: string): ChatSession | undefined {
     return this.listFor(agentId)[0];

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

@@ -308,6 +308,27 @@ export class ChatService {
   readonly agentId = this._agentId.asReadonly();
   /** 当前会话 id(线程根) */
   readonly sessionId = this._sessionId.asReadonly();
+
+  /**
+   * 重命名会话(2026-11-23)
+   *
+   * 标题的权威来源是 Matrix 房间名 `m.room.name`,写它是**唯一起效**的路径 ——
+   * 本地改一份副本只会让别的端看不到,还会和下次同步打架。
+   *
+   * 这里做两件事:
+   *   1. 写房间状态事件(跨端生效)
+   *   2. 立刻更新本地会话表(否则要等一次 sync 才看到新名字,像没保存成功)
+   */
+  async renameSession(roomId: string, title: string): Promise<void> {
+    const name = title.trim();
+    if (!roomId || !name) return;
+
+    await this.mx.setRoomState(roomId, 'm.room.name', { name });
+
+    /* 本地表就地更新:Matrix 的 sync 有延迟,不补这一步用户会以为没生效 */
+    this.sessions.setTitle(roomId, name);
+  }
+
   /** 当前会话元信息(标题/预览/归档状态) */
   readonly currentSession = computed<ChatSession | undefined>(() => {
     const id = this._sessionId();

+ 39 - 1
src/app/mobile/components/m-app-bar/m-app-bar.ts

@@ -28,8 +28,11 @@ import { ChangeDetectionStrategy, Component, computed, input, output } from '@an
         <span class="m-fab-spacer" aria-hidden="true"></span>
       }
 
-      <div class="m-title">
+      <div class="m-title" [class.is-editable]="titleEditable()" (click)="onTitleTap()">
         <span class="m-title-main">{{ title() }}</span>
+        @if (titleEditable()) {
+          <i class="fa-solid fa-pen m-title-pen" aria-hidden="true"></i>
+        }
         @if (subtitle()) {
           <small>{{ subtitle() }}</small>
         }
@@ -125,6 +128,25 @@ import { ChangeDetectionStrategy, Component, computed, input, output } from '@an
         line-height: 1.2;
         color: var(--ink);
       }
+      /*
+       * 标题可编辑态(2026-11-23)
+       * 笔形图标只在 titleEditable 时出现,静态标题页面不受影响。
+       * 用 ::after 的间距 + 图标淡色,避免抢标题本身的视觉焦点。
+       */
+      .m-title.is-editable {
+        cursor: pointer;
+        border-radius: var(--r-tag);
+      }
+      .m-title.is-editable:active {
+        opacity: 0.6;
+      }
+      .m-title-pen {
+        margin-left: 6px;
+        font-size: 0.7em;
+        opacity: 0.45;
+        flex: none;
+      }
+
       .m-title-main {
         display: block;
         /* 标题使用完整中栏宽度,与按钮之间的间距由网格 gap 保证。 */
@@ -163,6 +185,22 @@ import { ChangeDetectionStrategy, Component, computed, input, output } from '@an
 export class MAppBarComponent {
   readonly title = input('');
   readonly subtitle = input('');
+
+  /**
+   * 标题是否可点编辑(2026-11-23 用户要求「对话标题不能点击编辑」)。
+   *
+   * 默认 false —— 其他页面(我的、工作台等)标题是静态的,不该出现笔形图标。
+   * 只有会话页传 true,才会显示笔形并响应点击。
+   */
+  readonly titleEditable = input(false);
+
+  /** 点击标题时触发,由父组件打开编辑弹层 */
+  readonly titleTap = output<void>();
+
+  /** 只有可编辑时才把点击往上传,避免静态标题误触发 */
+  protected onTitleTap(): void {
+    if (this.titleEditable()) this.titleTap.emit();
+  }
   /** 左侧显示返回箭头 */
   readonly back = input(false);
   /** 左侧显示抽屉入口(与 back 互斥,back 优先) */

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

@@ -122,6 +122,17 @@ import { UploadPhase } from '../../../core/upload-state';
         flex: 1 1 auto;
         min-width: 0;
       }
+      /*
+       * 附件按钮(2026-11-23 用户反馈「圆圈太大,跟旁边按钮不协调」)
+       *
+       * 问题不是按钮大,而是**视觉重量失衡**:
+       *   44×44 的完整方块里只放一个图标,四周全是空气,看起来像个突兀的大圆。
+       *   而同行的项目切换是个扁胶囊,两者放在一起头重脚轻。
+       *
+       * 改法:占位仍是 44×44(无障碍触摸区不能砍),
+       *      但用负外边距把视觉盒收进 32×32,图标同步缩小一档。
+       *      点起来一样大,看起来和旁边的胶囊是一个重量级。
+       */
       .m-tool {
         display: grid;
         place-items: center;
@@ -129,11 +140,19 @@ import { UploadPhase } from '../../../core/upload-state';
         height: var(--touch-min);
         flex: none;
         border: 0;
-        border-radius: var(--r-tag);
+        border-radius: 50%;
         background: none;
         color: var(--muted);
         font-size: var(--fs-icon);
         cursor: pointer;
+        margin: -6px;
+      }
+      .m-tool > i {
+        font-size: 0.92em;
+      }
+      .m-tool:disabled {
+        opacity: 0.45;
+        cursor: not-allowed;
       }
       .m-target {
         display: inline-flex;

+ 10 - 4
src/app/mobile/components/m-project-switcher/m-project-switcher.ts

@@ -31,7 +31,10 @@ const ORPHAN_PROJECT_ID = '__orphan__';
       >
         <i class="fa-regular fa-folder-open" aria-hidden="true"></i>
         <span class="m-project-name">{{ currentWorkspace()?.name ?? '选择项目' }}</span>
-        <span class="m-project-switch">切换</span>
+        <!--
+          2026-11-23 用户反馈:这里原来还有「切换」两个字 + 箭头,太占地方。
+          箭头本身已经表达了「可点、可展开」,去掉冗余文字后项目名能显示更完整。
+        -->
         <i class="fa-solid fa-chevron-right m-project-chevron" aria-hidden="true"></i>
       </button>
     </div>
@@ -237,9 +240,12 @@ const ORPHAN_PROJECT_ID = '__orphan__';
         cursor: pointer;
       }
       .m-project-trigger.is-set { border-color: color-mix(in srgb, var(--primary) 35%, var(--edge)); color: var(--primary); }
-      .m-project-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-      .m-project-switch { flex: none; color: var(--muted); font-size: var(--fs-11); }
-      .m-project-chevron { color: var(--muted); font-size: var(--fs-10); }
+      /*
+       * 项目名:去掉「切换」二字后可以占满剩余宽度(2026-11-23)。
+       * 原来 max-width 卡得比较紧,长项目名被截得只剩几个字。
+       */
+      .m-project-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
+      .m-project-chevron { color: var(--muted); font-size: var(--fs-10); flex: none; }
       .m-project-root { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: flex-end; }
       .m-project-mask { position: absolute; inset: 0; border: 0; background: var(--overlay); }
       .m-project-sheet {

+ 188 - 0
src/app/mobile/components/m-title-editor/m-title-editor.ts

@@ -0,0 +1,188 @@
+import { Component, ChangeDetectionStrategy, input, output, signal, effect, ElementRef, viewChild } from '@angular/core';
+
+/**
+ * 会话标题编辑弹层(2026-11-23 新建)
+ *
+ * 背景:用户反馈「对话标题不能点击编辑」。标题来自 Matrix 房间名,
+ * 由首句总结生成后就不再变化,聊着聊着主题偏了标题还是错的。
+ *
+ * 形态参照 `m-confirm`(同类底部确认弹层),保持移动端交互一致:
+ * 底部升起、遮罩可点关闭、主按钮在右。
+ *
+ * 只负责「输入 + 提交」,改名和同步房间名由父组件做 ——
+ * 组件不知道 Matrix 的存在,方便复用到其他场景。
+ */
+@Component({
+  selector: 'app-m-title-editor',
+  changeDetection: ChangeDetectionStrategy.OnPush,
+  template: `
+    @if (open()) {
+      <div class="mte-mask" role="dialog" aria-modal="true" aria-label="编辑会话标题" (click)="onCancel()">
+        <section class="mte-sheet" (click)="$event.stopPropagation()">
+          <div class="mte-grabber" aria-hidden="true"></div>
+          <h2 class="mte-title">编辑会话标题</h2>
+          <p class="mte-hint">仅修改显示名称,不影响对话内容</p>
+
+          <input
+            #field
+            type="text"
+            class="mte-input"
+            [value]="draft()"
+            (input)="onInput($event)"
+            (keydown.enter)="onConfirm()"
+            maxlength="60"
+            placeholder="给这段对话起个名字"
+            aria-label="会话标题"
+          />
+          <div class="mte-count">{{ draft().length }}/60</div>
+
+          <div class="mte-actions">
+            <button type="button" class="mte-btn" (click)="onCancel()">取消</button>
+            <button
+              type="button"
+              class="mte-btn mte-btn--primary"
+              [disabled]="!canSave()"
+              (click)="onConfirm()"
+            >
+              保存
+            </button>
+          </div>
+        </section>
+      </div>
+    }
+  `,
+  styles: [
+    `
+      .mte-mask {
+        position: fixed;
+        inset: 0;
+        z-index: var(--z-modal);
+        display: flex;
+        align-items: flex-end;
+        background: var(--overlay);
+      }
+      .mte-sheet {
+        width: 100%;
+        padding: var(--sp-3) var(--mob-gutter) calc(var(--sp-5) + env(safe-area-inset-bottom));
+        background: var(--surface);
+        border-radius: var(--r-sheet) var(--r-sheet) 0 0;
+        box-sizing: border-box;
+      }
+      .mte-grabber {
+        width: 36px;
+        height: 4px;
+        margin: 0 auto var(--sp-3);
+        border-radius: 2px;
+        background: var(--edge);
+      }
+      .mte-title {
+        margin: 0 0 4px;
+        font-size: var(--fs-16);
+        font-weight: 600;
+        color: var(--ink);
+      }
+      .mte-hint {
+        margin: 0 0 var(--sp-3);
+        font-size: var(--fs-12);
+        color: var(--muted);
+      }
+      /*
+       * 字号 16px —— 低于 16px 时 iOS 会在聚焦时自动放大页面,
+       * 这是移动端输入框的硬约束,不是设计偏好。
+       */
+      .mte-input {
+        width: 100%;
+        box-sizing: border-box;
+        padding: 12px var(--sp-3);
+        border: 1px solid var(--edge);
+        border-radius: var(--r-tag);
+        background: var(--bg);
+        color: var(--ink);
+        font-size: 16px;
+        outline: none;
+      }
+      .mte-input:focus {
+        border-color: var(--primary);
+      }
+      .mte-count {
+        margin-top: 6px;
+        text-align: right;
+        font-size: var(--fs-11);
+        color: var(--muted);
+      }
+      .mte-actions {
+        display: flex;
+        gap: var(--sp-3);
+        margin-top: var(--sp-4);
+      }
+      .mte-btn {
+        flex: 1;
+        min-height: var(--touch-min);
+        border: 1px solid var(--edge);
+        border-radius: var(--r-tag);
+        background: var(--surface);
+        color: var(--ink);
+        font-size: var(--fs-15);
+        cursor: pointer;
+      }
+      .mte-btn--primary {
+        border-color: var(--primary);
+        background: var(--primary);
+        color: #fff;
+      }
+      .mte-btn:disabled {
+        opacity: 0.45;
+        cursor: not-allowed;
+      }
+    `,
+  ],
+})
+export class TitleEditorComponent {
+  readonly open = input(false);
+  /** 打开时填入的初始标题 */
+  readonly initial = input('');
+
+  readonly save = output<string>();
+  readonly cancel = output<void>();
+
+  protected readonly draft = signal('');
+
+  private readonly field = viewChild<ElementRef<HTMLInputElement>>('field');
+
+  constructor() {
+    /*
+     * 每次打开重新灌入初值 —— 用 effect 监听 open,
+     * 保证上一次没保存的残留内容不会带到下一次。
+     */
+    effect(() => {
+      if (this.open()) {
+        this.draft.set(this.initial());
+        // 等弹层渲染完再聚焦,否则拿不到元素
+        setTimeout(() => {
+          const el = this.field()?.nativeElement;
+          el?.focus();
+          el?.select();
+        }, 60);
+      }
+    });
+  }
+
+  protected onInput(ev: Event): void {
+    this.draft.set((ev.target as HTMLInputElement).value);
+  }
+
+  protected canSave(): boolean {
+    const v = this.draft().trim();
+    return v.length > 0 && v !== this.initial().trim();
+  }
+
+  protected onConfirm(): void {
+    const v = this.draft().trim();
+    if (!v || v === this.initial().trim()) return;
+    this.save.emit(v);
+  }
+
+  protected onCancel(): void {
+    this.cancel.emit();
+  }
+}

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

@@ -16,6 +16,7 @@ import { MDockComponent } from '../../components/m-dock/m-dock';
 import { MDrawerComponent } from '../../components/m-drawer/m-drawer';
 import { MNewChatSheetComponent } from '../../components/m-new-chat/m-new-chat';
 import { MProjectSwitcherComponent } from '../../components/m-project-switcher/m-project-switcher';
+import { TitleEditorComponent } from '../../components/m-title-editor/m-title-editor';
 import { MEmptyComponent } from '../../components/m-empty/m-empty';
 import { MMsgComponent } from '../../components/m-msg/m-msg';
 import { FilePreviewComponent } from '../../../components/preview/file-preview/file-preview';
@@ -107,6 +108,7 @@ type SheetTab = 'task' | 'file' | 'deliver' | 'state';
     MDrawerComponent,
     MNewChatSheetComponent,
     MProjectSwitcherComponent,
+    TitleEditorComponent,
     MEmptyComponent,
     MMsgComponent,
     MBadgeComponent,
@@ -123,7 +125,9 @@ type SheetTab = 'task' | 'file' | 'deliver' | 'state';
         [subtitle]="subtitle()"
         [back]="true"
         [rightCount]="2"
+        [titleEditable]="true"
         (backTap)="back()"
+        (titleTap)="openTitleEditor()"
       >
         <!--
           会话切换(2026-11-09):抽屉组件早就引入了却没用,导致移动端进了
@@ -361,6 +365,17 @@ type SheetTab = 'task' | 'file' | 'deliver' | 'state';
       (created)="createProjectChat($event)"
     />
 
+    <!--
+      会话标题编辑(2026-11-23 用户要求)
+      标题点击进来改显示名,只改房间名,不动消息内容。
+    -->
+    <app-m-title-editor
+      [open]="titleEditorOpen()"
+      [initial]="title()"
+      (save)="onTitleSave($event)"
+      (cancel)="titleEditorOpen.set(false)"
+    />
+
     <!-- 成果抽屉(Demo 07:任务 / 文件 / 成果 / 状态) -->
     @if (sheetOpen()) {
       <div class="m-sheet-root" role="dialog" aria-modal="true" aria-label="会话面板" [appLockScroll]="true">
@@ -1222,6 +1237,38 @@ export class MbChatPage implements OnDestroy {
     () => this.chat.currentSession()?.title ?? this.chat.agent()?.name ?? '会话',
   );
 
+  /**
+   * 标题编辑弹层开关(2026-11-23 用户要求「标题不能点击编辑」)
+   *
+   * 只在会话页开放 —— 标题来自 Matrix 房间名,改名走 m.room.name 状态事件,
+   * 需要房间内的 power level。改不动时给个明确提示,不静默失败。
+   */
+  protected readonly titleEditorOpen = signal(false);
+
+  protected openTitleEditor(): void {
+    if (!this.chat.currentSession()?.roomId) return;
+    this.titleEditorOpen.set(true);
+  }
+
+  /**
+   * 保存标题。
+   *
+   * 写 Matrix 房间名(`m.room.name`)—— 这是标题的权威来源,
+   * 本端和其他端(含其他成员的客户端)都会同步到。
+   * 不改本地少量副本,避免两处状态打架。
+   */
+  protected async onTitleSave(next: string): Promise<void> {
+    const roomId = this.chat.currentSession()?.roomId;
+    this.titleEditorOpen.set(false);
+    if (!roomId) return;
+
+    try {
+      await this.chat.renameSession(roomId, next);
+    } catch (e) {
+      console.warn('[chat] 标题保存失败', e);
+    }
+  }
+
   /**
    * 在**当前容器**再开一条对话(2026-11-14)。
    *