Skip to content

feat(mobile): workspace management, share intake and connection retention - #544

Merged
huichen merged 5 commits into
mainfrom
claude/mobile-ux
Sep 10, 2026
Merged

huichen merged 5 commits into
mainfrom
claude/mobile-ux

Conversation

@huichen

@huichen huichen commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

背景

手机端在使用中暴露出的五个问题,本 PR 一并处理(除 iOS 分享扩展外全部完成):

  1. 工作区折叠状态没有持久化,每次启动都恢复成全展开(桌面端已在 fix(desktop): keep collapsed workspaces across restarts and set the macOS Dock icon #542 修过)。
  2. 不能整块删除工作区,工作区内也没有"全选会话"的入口。
  3. 不能从其他 app 分享内容到 FutureOS。
  4. 拍照/选图/选文件走系统原生页面(核对结论:本来就已是原生页面,见下)。
  5. 从拍照页面返回后短暂显示"桌面可能正在睡眠",连接本不该断。

改动

工作区折叠状态持久化(useCollapsedWorkspaces)

折叠集合原本是组件 state,重启即丢。改为 AsyncStorage 持久化(与桌面端
useCollapsedWorkspaces 同一约定),并保留一份进程内缓存:SessionList 在进入/退出对话时
会卸载重挂,没有缓存的话每次返回都会先展开一帧。首次持久化写入发生在读完存储之后,
避免在读到之前就把磁盘上的记录覆盖成空。

删除工作区 + 工作区内全选(桌面 + 手机)

  • 桌面:新增 delete_workspace 桥接命令,直接复用 GUI 的 commands::delete_workspace,
    因此 store 级联、agent 会话删除 outbox、孤儿 scratch/review 目录回收的行为完全一致;
    工作区目录里的用户文件不会被删。
  • 手机:工作区分组右侧新增操作按钮(长按同样入口),可"全选该工作区的会话"(含被折叠、
    当前不可见的子会话),或删除整个工作区;确认框会带上会话数量并说明文件不会被删。
    删除后同步清理本地目录、未读标记与标题覆盖。

连接在原生选页面期间保持(nativePresentation)

系统相机/相册/文件选择器是独立 Activity,会暂停宿主 Activity,RN 因此上报
AppState: background,于是 setAppActive(false) 主动断开了 WSS —— 回到 app 时要重连、
并闪一下"桌面可能正在睡眠"。现在在原生页面展示期间保持连接(有超时上限,避免用户一去不回时
长期挂着连接)。桌面端心跳全程未中断。

分享进 app(Android)

  • app.config.ts 增加 SEND / SEND_MULTIPLE intent filter(text / image / */*)。
  • 新增本地 Expo 模块 modules/future-share-intent:同时捕获冷启动(分享 intent 就是启动
    intent)与热启动(singleTask 走 onNewIntent,此时 Activity.getIntent() 仍是旧 intent)
    两种收件路径;被分享的文件在 JS 索取时才复制进应用缓存目录,content URI 的读权限不必交给 JS。
  • JS 侧把内容落到"新对话"的输入框草稿(复用既有的草稿恢复路径),并新建一个对话,用户确认后
    再发送;原本在输入框里的内容会保留。

其他

  • AppContent 用 useSyncExternalStore 订阅分享信号,使已经停在同一草稿上的编辑框重新读取草稿。
  • 文档:mobile/README.md、docs/wiki/{zh,en}/Remote.md。

未做 / 已知边界

  • iOS 分享扩展未包含:需要单独的 Share Extension target(app.config 无法生成),
    getPendingShare() 在 iOS 上返回 null。需要的话可作为后续 PR。
  • 拍照/选图/选文件本来就调用系统页面(expo-image-picker 的 launchCameraAsync /
    launchImageLibraryAsync、expo-file-system 的 pickFileAsync、Android 无系统相册选择器时
    的 ACTION_PICK),本次未改这部分,只把它们纳入"原生页面期间保持连接"的范围。

验证

  • mobile:tsc --noEmit、eslint . 干净;jest 43 个 suite / 639 个 case 通过
    (新增折叠持久化、工作区菜单与删除、连接保持、分享 intake、原生模块 JS 侧的测试)。
  • desktop:cargo fmt --check、cargo clippy --all-targets -- -D warnings 干净;
    cargo test --lib 1130 通过(含新增的 delete_workspace 桥接命令测试:缺 id 报错、
    级联删除工作区与其会话、磁盘文件保留、重复删除报错)。
  • Android release APK 实际构建通过(FUTURE_VERSION=1.1.7):新增模块编译并注册
    (autolinking 解析出 packages: ['cn.future_os.shareintent.ShareIntentPackage']),
    生成的 manifest 含 5 条 share intent-filter。

🤖 Generated with Claude Code

FutureOS Agent added 5 commits September 10, 2026 18:49
Workspace folds were component state, so every launch brought the list back
expanded (desktop already persists them). Move them into a hook backed by
AsyncStorage, with an in-session cache so a remount does not flash expanded.

Add the phone's side of workspace deletion: a long-press/shortcut menu on a
workspace group that selects every session in it (folds included) or deletes
it. The desktop grows a matching `delete_workspace` bridge command that
reuses the GUI command, so the store cascade, the agent-session delete outbox
and the orphaned scratch dirs behave identically; the user's files on disk
are never touched.
Presenting the system camera or a picker pauses the host activity, which
React Native reports as AppState background — so a photo round trip tore the
WSS down, flashed "the desktop may be sleeping", and paid for a fresh
handshake to restore a link that was never lost. Treat the app as active
while a native surface is presented, bounded by a grace period so a flow the
user never returns from still releases the connection.
Adds an Android share target: SEND/SEND_MULTIPLE intent filters for text,
images and arbitrary files, plus a local `future-share-intent` module that
captures both receipts (a cold start, where the share intent is the launch
intent, and a warm start, where singleTask delivers it through onNewIntent and
Activity.getIntent() still holds the original). Shared files are copied into
app-owned cache storage when JavaScript asks for them, so the content URI's
read grant never has to reach JS.

The payload lands in the composer's new-conversation draft — the composer's
existing restore path — and the intake starts a fresh conversation for it, so a
share is reviewable before it is sent and the previous composer keeps its draft.

iOS has no share extension target in this build; getPendingShare() resolves to
null there.
@huichen
huichen enabled auto-merge (squash) September 10, 2026 11:12
@huichen
huichen merged commit 07e2a55 into main Sep 10, 2026
12 checks passed
@huichen
huichen deleted the claude/mobile-ux branch September 10, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant