Skip to content

Go implementation of DeepSeek Harness and self-hosted personal agent.

Go

feat(ui): refresh web workspace and chat rendering

xyc467d1f7d236a
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index ef938cc..d136a3c 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -78,6 +78,11 @@ The Web Controller serves bundled JavaScript dependency notices at
`/assets/licenses.txt`. Vite generates the file from the installed packages,
including the ISC notice for Lucide icons.
+The Web interface self-hosts Inter via `@fontsource-variable/inter` (SIL Open
+Font License 1.1); its copyright and license are included in the generated
+browser notices. File-format icons reuse vscode-icons (MIT), with the original
+notice at `frontend/src/assets/file-icons/LICENSE`.
+
The agent-browser plugin installs the official CLI and contributes original Skill files from
https://github.com/vercel-labs/agent-browser (Apache-2.0). The image includes
the upstream license at `/usr/share/go-bot/plugins/agent-browser/UPSTREAM_LICENSE`.
@@ -120,3 +125,38 @@ The wrapper uses `yaml` (ISC) for the upstream native configuration format.
Its icon is the official Google AI Studio mark from
https://www.gstatic.com/images/branding/productlogos/ai_studio/v1/web-512dp/logo_ai_studio_color_1x_web_512dp.png.
Google names and marks belong to Google.
+
+## Mobile image masks
+
+The mobile interface uses `@react-native-masked-view/masked-view` (MIT) to fade
+scrolling image previews against the existing background. The package includes
+its original MIT license: https://github.com/react-native-masked-view/masked-view.
+
+MIT License
+
+Copyright (c) 2015-present, Facebook, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+## Mobile clipboard
+
+`expo-clipboard` 58.0.4 uses the MIT-licensed Expo modules from
+https://github.com/expo/expo. Its original MIT notice is retained in the
+installed package and mobile dependency tree. It provides the native copy
+operation for Markdown table and code source.
diff --git a/docs/api.md b/docs/api.md
index 575318a..5dddea2 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -62,6 +62,12 @@ Serve a custom browser UI from the same origin as the Controller API, or use the
| POST /v1/host/stop | Stop Docker or release ECI for the selected account |
| DELETE /v1/host/instance | Delete compute and retain the account and external storage |
+For multipart messages, send the `content` form field first, followed by mixed
+`images` / `files` parts in upload order. The admitted user message contains the
+image/file blocks in that same order, followed by the text block. This is also
+the order stored in the session log and passed to the model. Both clients show
+user attachments above the text; assistant block order is preserved.
+
For `POST /v1/accounts`, send `{"userId":"alice"}`. Account creation returns
the name with HTTP 201. Model settings are available before the Host starts.
diff --git a/docs/chat-media-display-plan.zh-CN.md b/docs/chat-media-display-plan.zh-CN.md
new file mode 100644
index 0000000..9ce1176
--- /dev/null
+++ b/docs/chat-media-display-plan.zh-CN.md
@@ -0,0 +1,31 @@
+# 会话图片与工具调用展示
+
+状态:按确认的轻量版接入 Web 和移动端;查看图片使用紧凑尺寸。
+
+## 展示规则
+
+- `readimage` 中文显示为「查看图片」。连续调用合并为独立的图片工具组,默认展开,可收起;文字、其他工具或文件打断后另起一组。
+- 图片工具组不再显示一套普通工具卡片和另一套重复图片。保留名称、张数、进行中或完成状态,以及展开入口。
+- `generateimage` 保留相同图片展示能力,但本次不重新注册或启用该工具。
+- 查看图片的预览为 118px 正方形,沿左侧正文边界排列;使用轻量标题,不加外层容器。
+- 交付图片为 Web 164px、移动端 146px 的正方形预览,横向排列。圆角分别为 10px、11px;间距 10px。打开后完整展示原图比例。
+- 横向溢出时,边缘由实到虚;滑动进入时渐显、离开时渐隐。只有存在溢出的边缘才遮罩,到达起点或终点时对应侧清晰。
+- `present` 明确交付的 PNG/JPEG/WebP/GIF/AVIF/BMP 图片自动获取并预览;其他文件仍使用原有点击下载卡片。SVG 和 HTML 不自动作为图片预览。无法解码的交付图片退回文件卡片。
+- 移动端保存图片进入本地图片区及手机图库,按现有保存流程请求图库权限;交付图片以账号与后端路径识别,不进入文件区。浏览图片本身不会将它存入本地库。
+
+## 数据与职责
+
+沿用现有 Host SSE、`tool/result.images`、公开 `assistant/message` 文件块和 HTTP 文件内容接口。查看图片来自附件系统,交付图片继续来自工作区路径,不复制到上传附件区,不解析 Markdown 链接或扫描工作区创建交付。
+
+`groupDisplayBlocks` 为双端提供同一分组逻辑;仅将呈现视图转换为图片工具组或图片行,不改动会话日志事实、Agent 执行或交付机制。图片文件扩展名只决定是否尝试预览,实际无法显示时回退。
+
+Web 使用 CSS alpha mask;移动端使用 Expo 支持的 MaskedView 与已有 LinearGradient,实现真正透明的边缘渐隐,保留页面原有底色。
+
+## 验证范围
+
+验证连续查看、文字和其他工具打断、异步返回顺序、交付图片与文档混排、收起再展开、横向滑动、边缘渐隐、全屏预览和移动端保存。通过可控模型协议响应驱动真实 Controller → Host 工具执行与 SSE,不调用付费模型。保留实际界面截图在本地忽略目录 `.local/media-integration-qa/`。
+
+## 设计参考
+
+- [Taste Skill](https://github.com/Leonxlnx/taste-skill):间距、字体层级、弱边框、图标一致性和动效节制。
+- [Ronas · AI Chatbot Web App UI Design](https://dribbble.com/shots/25955732-AI-Chatbot-Web-App-UI-Design):用户确认的会话内小幅图片展示参考,只采用图片展示方式,沿用项目整体风格。
diff --git a/docs/markdown-and-demo-refresh-plan.zh-CN.md b/docs/markdown-and-demo-refresh-plan.zh-CN.md
new file mode 100644
index 0000000..be36fe6
--- /dev/null
+++ b/docs/markdown-and-demo-refresh-plan.zh-CN.md
@@ -0,0 +1,35 @@
+# Markdown 展示与演示更新方案
+
+## 范围
+
+Web 保留已有文字、引用和表格视觉风格。表格和代码块增加固定在容器上方的轻量复制操作,内容在容器内部横向滚动,页面本身不横向溢出。表格允许长单元格在合理列宽内换行,列数多时滚动;代码保留换行和缩进,不强行折行。
+
+表格与代码块均复制对应元素的原始 Markdown,保留表格分隔符、围栏与语言标记;不转成 TSV,也不复制渲染后的纯文本。操作提供成功或失败反馈,中英文标签随本地语言切换。Web 同时支持安全上下文 Clipboard API 和普通 HTTP 的用户点击复制。
+
+移动端参考 Taste Skill 的对齐、留白、层级和克制交互,沿用现有近白底与浅青紫环境色。正文 16px/27px 行高;段落、标题、列表与引用保留更清楚的垂直间距。行内代码采用中性浅灰底和等宽字体,代码块采用浅灰底、细边框、语言名与始终可见的复制入口。表格采用中性表头,固定同列宽度,内部横向滚动。复制按钮至少 44px 触控区域,滚动与会话纵向滚动互不替代。
+
+除用户附件顺序调整外,不更改 Host、AgentLoop、SSE 或日志内容,不引入语法高亮库;保持已有 Markdown 图片按原文显示的约定。
+
+## 实施与验证
+
+提取双端各自的 Markdown 展示组件。验证短表格、多列表格、长代码、复制后的实际内容、流式追加后复制最新内容、中英文、Web 深浅主题以及移动端纵横滚动。通过真实 Web 和原生 Android 应用截图检查,先验证排版再录制。
+
+## 演示素材
+
+使用已保存的原始真实会话日志、公开投影和原始交付产物重新展示,不再次调用付费模型,不改写原始请求或回答。重录中英文移动端各五个案例:浏览器调研、Word、PPT、双参考图生图、定时任务;同时完成中英文 Web 生图演示。全程展示完整会话页面;Word/PPT 成品继续使用原有 WPS 实际展示截图,与会话片段组成同一动图,中文版 PPT 重点为第二页。
+
+导出 GIF 使用每帧独立调色板,核对解码后的关键帧与截图,避免额外压暗或丢失主体细节。更新两份 README 的资源引用和必要说明,保持每组案例第一行三个、第二行两个居中。原始录制与验证脚本留在被忽略的 .local 中。
+
+参考:https://github.com/Leonxlnx/taste-skill
+
+## 用户附件顺序
+
+草稿保留现有附件预览。发送时 Host 按上传顺序组装 image/file,再追加本次 text;模型上下文与新会话日志一致。双端用户气泡将附件置顶,旧历史仅在显示时调整顺序,不改写事实;助手的文字、工具、图片和文件仍按原顺序穿插。
+
+## 完成情况
+
+已完成双端表格、代码块内部横向滚动与原始 Markdown 复制;移动端行内代码使用真实圆角容器,并调整正文、标题、列表、引用间距。Web 深浅主题、普通 HTTP 复制与原生 Android 滚动、复制已实测。
+
+已通过 42 项前端测试、移动端 TypeScript 检查、Go HTTP API 测试与 Android 原生构建。用户附件顺序已覆盖混合图片/文件的后端测试,双端显示回归测试确认助手块顺序不变。
+
+已更新中英文共 10 份移动端 GIF 与 2 份 Web 生图 GIF。移动端保持原始真实会话和交付产物,Word/PPT 使用原有 WPS 展示;双语 README 均已在浏览器检查,五个案例按 3+2 居中展示,资源全部可加载。GIF 逐帧解码核对通过,未额外整体压暗。
diff --git a/docs/stream-text-playback-plan.zh-CN.md b/docs/stream-text-playback-plan.zh-CN.md
new file mode 100644
index 0000000..60f611e
--- /dev/null
+++ b/docs/stream-text-playback-plan.zh-CN.md
@@ -0,0 +1,66 @@
+# Web 与移动端流式文本连续展示方案
+
+状态:已实现并完成 Web、Android 模拟器验收。范围只涉及客户端展示;Host、Controller、SSE 协议、会话日志、AgentLoop 和 500ms 的正式事件检查均保持原样。
+
+## 1. 目标
+
+将收到的完整文本和已经展示到的位置分开管理。每条增量只追加接收内容,播放位置继续向前,不按 text-delta 重启动画。Web 与 React Native 复用同一套播放算法;不添加打字光标。接受 Markdown 在语法闭合时发生的局部排版变化,不增加表格或代码块的专用缓存解析器。
+
+## 2. 数据与身份
+
+- 原始 TranscriptCache 继续即时接收、去重并保存完整 SSE 数据,播放不阻塞网络接收、业务状态和日志游标。
+- 客户端消息保留公开事件已有的 turn、step 元数据;草稿与正式消息通过同一 turn/step 和文本块序号对应。
+- 每个可见会话有一个临时播放器,保存各文本块的目标文本、Unicode 字符边界和展示位置,不持久化到后端、本地文件或账号设置。
+- 正式 assistant/message 替换草稿时,使用稳定展示标识并保留已显示位置;目标文本补全后继续展示剩余内容。若发生重试或修正,保留实际相同的已展示前缀,不拼接已经废弃的回答。
+
+## 3. 连续播放
+
+- 通过 requestAnimationFrame 驱动,最多约 30 次/秒更新文本,不为每个字单独创建动画或定时器。
+- 以 Unicode 字符簇为边界,支持中文、代理对和组合 emoji;运行环境缺少 Intl.Segmenter 时退化为 Unicode 码点,至少不截断代理对。
+- 基础速度每秒 60 个字符簇,按积压量自适应提速,最高每秒 360 个字符簇。不是要求用户等完整真实生成时间,也不人为延迟首段内容到达。
+- 先展示更早的文本,再推进后续文本;正文之后的工具、图片和文件保持原有内容块顺序。它们自身没有逐字动画,执行状态及审批/提问仍由原始数据立即更新。
+- 后端完成不等于客户端播放完成。完成事件不跳过待展示文字;生成提示可在客户端播放结束后消失,但停止操作、排队、模型切换和发送逻辑仍以真实后端状态为准。
+- Markdown 仍交给两端现有库,以当前已展示前缀重新解析。无变化的文本组件记忆化,避免每一帧重复解析所有历史文本。
+
+## 4. 生命周期
+
+| 情况 | 行为 |
+| --- | --- |
+| 首次加载历史、加载更早消息 | 已有文本直接显示,不重播历史 |
+| 当前可见会话收到新内容 | 连续渐进展示 |
+| 正式消息提交、turn/end 到达 | 保留位置,继续展示剩余文本 |
+| 切换会话或账号 | 丢弃旧会话播放器;新会话当前快照直接显示 |
+| SSE 重连 baseline | 直接显示恢复快照,后续增量恢复渐进展示 |
+| 页面隐藏、移动端进入后台 | 停止动画;回来后直接显示已收到的内容 |
+| 用户启用系统减少动态效果 | 直接显示全部已收到文字 |
+| 取消、失败、重试、草稿消失 | 以真实 Transcript 为准,移除不存在的草稿;不将未提交内容伪造成正式消息 |
+| 审批、askuserquestion | 不等待文字播放,继续通过原有面板即时交互 |
+
+## 5. 实现位置
+
+- `frontend/src/chat/textPlayback.ts`:不依赖 UI 的播放器,负责身份映射、接收/展示状态、速率和有序输出。
+- `frontend/src/chat/useTextPlayback.ts`:共用 React hook,负责帧调度和清理。
+- `frontend/src/chat/transcript.ts`:保留 step,记录重连 baseline 的客户端重置计数,不改变对外协议。
+- Web Chat 与 mobile Conversation:在内容分组和渲染之前使用播放器;分别接入页面可见性和 AppState/减少动态效果。
+- 两端现有 Markdown 组件:保留渲染规则,增加稳定文本的组件记忆化。
+
+## 6. 验收
+
+1. 共享逻辑测试:增量追加不重置、完整消息与 turn/end 不跳满、分块/分 step 顺序、用户消息不延迟、历史不重播、重连/换会话、取消/重试、Unicode、减少动态效果和调度清理。
+2. Web 类型检查、已有测试和构建;移动端类型检查和 Android QA 构建。
+3. 使用固定长 Markdown 的模拟模型服务,不消耗真实模型 tokens。通过真实 Host→Controller→Web/Android 链路验证慢速、快速和大段分片输入。
+4. 录制真实页面和模拟器画面,检查等待、连续播放、后端完成但仍播放、最终完整内容及重新进入会话不重播。
+
+## 7. 实测结果(2026-11-22)
+
+- Web 测试共 36 项通过,包括追加增量、正式消息提交、turn/end、跨文本块、跨 step、取消/修正、历史分页、baseline、Unicode 和速度控制。
+- Web 生产构建、移动端 TypeScript 检查通过;最终 Android QA Release 包编译、覆盖安装成功。没有新增第三方依赖。
+- 固定 843 字符 Markdown 分成 169 次增量,在约 0.11 秒到达。真实 Web 和 Android 页面均继续渐进展示,Web 采样约 4 秒完成展开;正式消息到达没有跳过剩余文字。
+- 额外验证了慢速增量、Web 停止、切换会话后历史直接展示,以及真实 Go shellexecute 工具调用前后的正文与工具卡片衔接;工具场景始终只有一个助手头像。
+- 下一 step 的开始帧可能先于上一 step 的日志投影,客户端只在同一 turn 确实有后续流式草稿时暂留前一步草稿,待对应日志到达继续使用同一播放位置;不是新增会话事实。
+- 使用本机模拟模型服务,没有消耗真实模型 tokens。验证通过真实 Host→Controller→客户端链路,未更改后端事件机制。iOS 本次未做独立运行验收。
+- 私有录制、日志和测试脚本位于被忽略的 `.local/playback-qa/`,不作为开源仓库资源提交。
+
+## 8. 边界
+
+不更改权限审批、工具管线、会话事实和后端完成语义;不增加新模型协议、第三方渲染库、光标或用户配置项。播放速度为前端常量,可根据验收体验调整。没有保证每秒 360 个字符簇足以瞬间消化任意长度的回复;系统减少动态效果、后台恢复和重连均可直接追上当前内容。
diff --git a/docs/web-lumeo-redesign-plan.zh-CN.md b/docs/web-lumeo-redesign-plan.zh-CN.md
new file mode 100644
index 0000000..1d60439
--- /dev/null
+++ b/docs/web-lumeo-redesign-plan.zh-CN.md
@@ -0,0 +1,109 @@
+# Go Bot Web 视觉与交互重构
+
+软件应用:自托管 Personal Agent 的真实 Web 客户端,主要操作为进入会话并发送消息。
+
+状态:已完成实现与本地浏览器验收。分支:`feat/frontend-refresh`。
+
+## 1. 设计依据与取舍
+
+主参考:[Lumeo - AI Assistant Result](https://dribbble.com/shots/25712260-Lumeo-AI-Assistant-Result),Barly Design / Uxerflow。已在真实浏览器观看 15.68 秒原型视频,逐帧检查欢迎页、用户消息、结果展开、导航和输入区。
+
+辅助参考:[Taste Skill](https://github.com/Leonxlnx/taste-skill/blob/main/skills/taste-skill/SKILL.md) 的字体层级、间距、图标、边框对比、焦点、悬浮反馈和真实页面视觉复查。用户指定的原型优先,不采用该 skill 面向营销页的随机配色、整屏 hero、营销卡片、shader 或营销页自动检查脚本。
+
+还原原型中的近白画布、细窄导航、轻边框、低阴影、紧凑工具条、淡紫选中态、深色发送按钮和克制的分层进入动画。使用 Go Bot 自有 logo 和真实功能,不复制原型的商标、文案、图片和代码。原型右侧 Sources / Suggested tasks / Suggested questions 不引入,也不制造当前后端没有的能力。
+
+## 2. 功能与页面映射
+
+| 区域 | 真实功能 | 新表现 |
+| --- | --- | --- |
+| 固定窄导航 | 会话、任务、插件市场、文件系统、设置、账号与停止 Host | 64px 左轨;20px Lucide 细线图标;当前项浅紫底与侧边指示;悬浮/键盘提示名称 |
+| 会话侧栏 | 主会话、最近会话、新建、归档、分页、待审批/问题标记 | 左轨右侧展开约 264px;会话区随之平移/收窄;主会话单独强调;行尾保留菜单 |
+| 会话顶部 | 当前会话、模型/端点、执行权限 | 紧凑上下文工具条;模型、权限可选;右侧主题和语言入口 |
+| 会话正文 | 用户/助手、有序内容块、流式播放、工具卡、问题/审批 | 用户淡紫气泡;助手开放正文与单个头像;保持先前实现的渐进文本播放 |
+| 输入区 | 文字、附件选择/粘贴、排队/steer、停止、发送 | 细边框与微弱阴影的输入容器;附件在草稿中显示;发送实心深色;交互状态保持真实 |
+| 任务 | 读取 Host schedules、SSE 变更、打开关联会话 | 独立任务页:待执行/已完成两类,列表与详情;状态细节放在详情,不新增搜索 |
+| 文件系统 | /root/harness 逐层展开、刷新、复制路径、分页 | 右侧约 320px 资源面板;小屏为侧滑覆盖层;不展示为本地文件库 |
+| 插件市场 | 后端目录、安装/更新/启停、详情、授权、教程 | 同一浅色/深色体系;桌面两列、窄屏一列;官方图标和后端描述原样驱动 |
+| 设置 | 模型、协议、搜索供应商、主动服务 | 同一壳层保留导航;小标题、表单分组与细边框,减少重按钮感 |
+| 登录 | 创建/打开账号、语言 | 克制居中表单;Go Bot 标识;登录前也可切主题与语言 |
+
+本次任务界面只新增查看、刷新、详情和打开关联会话;创建/修改任务仍可通过现有 Agent 工具和移动端完成。不改后端 schedule 的计算、存储、投递与归档机制。
+
+## 3. 布局及自适应
+
+- 大屏:左轨 64px;会话侧栏展开 264px;中央正文上限约 840px;文件面板 320px。会话侧栏默认收起,点击会话图标切换;在其它页面点击会话返回聊天并展开列表。
+- 侧栏和右侧文件面板占用真实布局空间,中央区域可收缩;中等宽度的文件系统改为覆盖层,避免正文被压成窄条。
+- 任务页内部为列表和详情两栏,窄屏切成列表/详情两步;不显示空的右侧推荐容器。
+- 窄屏 Web 保留图标左轨;会话和文件系统使用有遮罩的侧滑面板。主内容、表格、模型菜单和设置表单不产生页面横向溢出。
+- 切换设置、任务与插件不重新建立 Host SSE,不丢弃已加载会话缓存;当前进行中的问题和审批继续按会话记录。
+
+## 4. 色彩系统
+
+| Token | 浅色 | 深色 |
+| --- | --- | --- |
+| 页面画布 | #FFFFFF | #141416 |
+| 轻背景/面板 | #F8F8FA | #1B1B1E |
+| 次级面板 | #F3F3F6 | #222226 |
+| 主要文字 | #202024 | #ECECF1 |
+| 次要文字 | #74747D | #A0A0AA |
+| 边框 | #EAEAF0 | #323239 |
+| 强调 | #7863BE | #BAA8F2 |
+| 浅强调背景 | #F0EBFC | #30293F |
+| 用户气泡 | #EAE3FB | #393044 |
+
+默认浅色,右上角切换深浅主题,偏好仅保存在浏览器 `go-bot.web-theme`,不随账号上传。所有界面使用语义 token;弹窗、输入框、权限/模型菜单、代码、表格、链接、错误和文件卡均覆盖两套主题。插件官方图标不随意改色。
+
+## 5. 字体、图标与内容
+
+- 英文/数字:通过 Fontsource 本地打包 Inter Variable Latin,避免运行时依赖 Google Fonts/CDN。
+- 中文:PingFang SC、Microsoft YaHei UI、Noto Sans CJK SC 等系统无衬线回退,按中文阅读调整字距和行高。
+- 正文 15–16px,行高约 1.8;导航/表单 13–14px;辅助标签 11–12px。标题遵循 28/23/19/16px 层级,避免原界面中大字号和大按钮抢占正文。
+- Markdown 保留现有语法能力,单独处理标题间距、列表缩进、引用边线、表格表头/行线/横向滚动、代码字体/背景和链接颜色。不混淆 Markdown 图片文本与 image 内容块。
+- UI 图标统一 Lucide,主要为 18–20px、1.6–1.75px 描边,无混杂填充图标。
+- PDF、Word、Excel、PowerPoint、Markdown 文件图标复用项目已采用的 vscode-icons 免费资源,保留 MIT 许可。
+- 图片为适度大小的正方形缩略图,多图横向排列并在容器内部滚动;点击以黑底全屏查看,可关闭和下载。文件卡呈现文件类型图标、名称、描述和明确下载动作,不制造 artifact 类型。
+
+## 6. 动效和交互
+
+- 窄导航切换整个工作区,默认选中会话;任务、插件市场和设置替换聊天视图,聊天状态仍保存在原有缓存中。会话列表只在会话入口展开。
+- 空会话首次发送:居中 Logo 与引导文字淡出,同一个输入框平滑下移到底部,消息区淡入;不更换输入框节点,不丢失焦点,失败时保留草稿并恢复空会话布局。
+- 空会话欢迎区采用更突出的 128px Logo、30px 标题和 20px 引导文字;窄屏适度缩放,低高度窗口压缩欢迎区占位,避免与顶部工具条或输入框相碰。
+
+- 首次进入:壳层先稳定出现;当前页面内容 240–420ms 淡入/上移 8–12px;同组元素轻微错开,整个过程约 600ms 内完成。
+- 会话侧栏:布局宽度随开关变化,内部内容向右进入,约 240ms,关闭更短;聊天缓存和输入草稿不因开关卸载。
+- 页面切换:内容区短淡入,不重播整段会话消息;聊天滚动时不逐行做入场动画。
+- 工具组:细线折叠行,状态清晰,展开时显示各工具,不把工具名做成大按钮;更新状态不导致整组重播。
+- 主题切换:短颜色过渡,不闪白、不重载;系统减少动态效果时取消位移和动画。
+- 模型/权限/账号菜单、弹窗:点击外部、Escape 可关闭,适当还原焦点;阻塞业务操作期间保留原有必要保护。
+- 审批、提问立即交互,不能等待正文播放;停止和发送继续依据真实后端状态。
+- 默认插件准备、安装进度和错误为轻量状态反馈,不能覆盖整个页面或阻止导航。
+
+## 7. 实现与验证
+
+1. 写出上述方案及原型观察记录,保留之前的流式播放修改与未提交文档。
+2. 新建主题、左轨和任务视图;重组 App 与会话侧栏;替换旧渐变 CSS,使用统一 token,并覆盖现有设置/插件/授权样式。
+3. 调整聊天工具条、Markdown、工具卡、图片与文件;保留真实 API 与交互状态。
+4. 检查 Web 测试与生产构建、移动端类型检查(共享会话类型不得损坏移动端)。不新增无意义的后端测试。
+5. 在真实浏览器验证:登录/创建账号、主会话/新建/归档、会话侧栏、流式文字、模型/权限菜单、附件草稿、工具/图片/文件、文件系统、任务列表与详情、模型/搜索/主动服务设置、插件详情与授权面板。
+6. 1440、1024、768 和 390 宽度,深浅主题、中英界面逐步截图;检查视觉层级、对比度、留白、弹窗、焦点、关闭和溢出;至少基于实际截图完成一次视觉修正。
+7. 使用模拟模型和已有 QA Host 数据,不消耗真实模型 tokens;产出实际界面截图/动图及验收记录。临时原型截图、测试脚本与日志保存在被忽略的 `.local/web-redesign/`。
+
+## 8. 参考与许可
+
+- [Lumeo 原型](https://dribbble.com/shots/25712260-Lumeo-AI-Assistant-Result):视觉与动效分析;不分发其原始媒体。
+- [Taste Skill](https://github.com/Leonxlnx/taste-skill):辅助设计审查,用户指定原型优先。
+- [Lucide](https://lucide.dev/license):ISC;继续采用当前依赖。
+- [Fontsource 自托管字体](https://fontsource.org/docs/getting-started/install)、[Inter](https://rsms.me/inter/):按字体包许可打包。
+- vscode-icons:复用移动端已保留许可的文件类型资源。
+
+## 9. 实施与验收记录
+
+- 壳层由 `layout/NavigationRail`、`WorkspaceHeader` 和 `Theme` 组织;样式拆为 shell、chat、settings、tasks,插件页面使用相同颜色变量。主题脚本在应用挂载前读取本地偏好,字体随构建自托管。
+- 新增 Web 任务浏览器,使用原有 `/v1/host/schedules` 和 `schedule/changed` 通知。真实创建了周期、暂停、到期完成三类测试任务,验证分类、详情、时区、最近投递和关联会话;验收后移除了这些临时任务。
+- 真实浏览器检查 1440×1000、1024×800、768×900 和 390×844。桌面左轨实测 64px、展开栏 264px,聊天区从 x=64 移至 x=328;检查的四档宽度没有文档横向溢出。窄屏会话栏和文件栏覆盖显示,主内容暂不可交互,关闭后恢复焦点。
+- 中英切换、深浅切换及刷新后的本地偏好保持正常;浏览器确认 Inter 已加载。插件市场、详情、安装状态、启用、API Key 授权表单和取消授权均以真实 QA Host 验证,未填写真实服务密钥。临时安装的测试插件已移除。
+- 使用模拟模型,经真实 Controller → Host → SSE 和 Go 工具执行链验证流式 Markdown、`shellexecute`、`readimage`、`present`、审批与提问。实际下载并读取交付文件;图片可黑底全屏打开和关闭;权限审批后继续,问题回答后继续。未进行新的真实模型付费调用。
+- 模型/权限菜单外部点击收起;附件选择只进入草稿,切到设置再返回仍保留;归档确认可取消;主会话仍不可归档。会话缓存和单条 Host SSE 沿用现有机制。
+- 首次发送录屏发现 Logo 的入场动画会覆盖退出透明度过渡,已修正并重录。实测透明度由 1 → 0.81 → 0.35 → 0.11 → 0,输入框纵坐标从约 584px 连续移动至 864px,焦点保持 `message`。录制为 `.local/web-redesign/first-send.gif`。
+- 前端 39 项测试通过,TypeScript/Vite 生产构建通过,Linux arm64 Controller(嵌入新 Web)构建通过,移动端类型检查通过,`git diff --check` 通过。最终浏览器控制台未记录错误。本轮没有重新打移动端包或验证 ECI。
+- 测试入口为本机 8084 QA Controller;8080 原服务未替换。模拟端点已删除,测试会话模型与默认端点已恢复,模拟模型服务已停止。截图、视频帧、临时脚本和日志均位于 Git 忽略的 `.local/web-redesign/`;原型原始媒体未加入仓库。
diff --git a/frontend/README.md b/frontend/README.md
index eb22768..72051e2 100644
--- a/frontend/README.md
+++ b/frontend/README.md
@@ -3,7 +3,7 @@
Follow the [local Quickstart](../README.md#quickstart) from the repository root and open
[http://127.0.0.1:8080/](http://127.0.0.1:8080/). The Controller serves the
page and relays API calls and SSE to the selected account's Docker or ECI Host.
-Create or open an account by name. Configure OpenAI Responses or Anthropic Messages endpoints using the protocol dropdown in Model settings, and use the model picker below a chat to change its model. Under **Settings → Web search**, save a key for DeepSeek, Zhipu, Doubao, Tavily, or Brave Search and choose **Use provider**.
+Create or open an account by name. Configure OpenAI Responses or Anthropic Messages endpoints using the protocol dropdown in Model settings, and use the model picker in the chat header to change its model. Under **Settings → Web search**, save a key for DeepSeek, Zhipu, Doubao, Tavily, or Brave Search and choose **Use provider**.
For a custom mobile, desktop or web interface, use the Controller's
[HTTP and SSE API](../docs/api.md). The [minimal example](../examples/frontend-minimal/index.html)
@@ -13,13 +13,14 @@ Use **New chat** to create a session. Right-click a row in **Chats** to delete
it from the list. The Host archives the session and retains its data on disk.
On touch screens, the row menu offers the same action.
-Open the account menu at the bottom of the sidebar for **Settings**,
-**File system**, and **Stop Host**. Use **File system** to browse the account's Host data at
+The narrow left rail switches between **Chats**, **Tasks**, **Plugin market**,
+and **Settings**. Click **Chats** to expand its conversation list. Open the
+account menu at the bottom for **Stop Host**. Use **File system** to browse the account's Host data at
`/root/harness`. Expand directories to see their contents, select an entry to
copy its absolute path, or refresh the selected directory. The panel keeps
its position when you switch chats.
-Choose **English** or **简体中文** on the account page or in **Settings**.
+Choose **English** or **简体中文** on the account page or in the workspace header.
The preference is saved per browser. When no preference is saved, the app uses
the first supported browser language, with English as the fallback. Messages
and Agent responses keep their original language.
@@ -32,6 +33,13 @@ while switching chats or opening settings. A pending question or approval in
another chat adds a chat-list indicator; open that chat to respond. Execution
approvals have no fixed timeout and reappear after reconnecting.
+New assistant text appears progressively on Web and mobile. Playback follows
+the received text continuously across stream chunks and the committed message,
+without a typing cursor. History opens immediately; reconnecting, returning from
+the background, or enabling the system's reduced-motion preference shows the
+current received text directly. Playback affects display only: tools, questions,
+approvals and turn completion keep their existing backend behavior.
+
Use the plus button to choose attachments, or paste files when your browser
provides them in the clipboard. The composer keeps them in the draft until
you send the message. You can remove individual attachments before sending.
@@ -65,4 +73,13 @@ A plain Go build keeps the API-only Controller available. The Host image
contains the compiled Host and agent tools. If using ECI, build the image cache from
the same version so the Host supports cold history and archiving.
-The welcome robot is [Lucide Bot](https://lucide.dev/icons/bot).
+The interface uses the project's whale logo and [Lucide](https://lucide.dev/) icons.
+
+The upper-right theme button switches between light and dark appearances. Theme
+and language preferences stay in this browser, independently of the account.
+Tasks reads the Host schedule catalog: paused jobs remain Upcoming; only ended
+jobs appear under Completed. The detail view shows the next run, schedule rule,
+last delivery and associated conversation. Create or change tasks through your
+Agent or the existing API.
+
+Visual architecture and validation: [Lumeo redesign plan](../docs/web-lumeo-redesign-plan.zh-CN.md).
diff --git a/frontend/index.html b/frontend/index.html
index 5e8261b..de23500 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -3,7 +3,8 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
- <meta name="theme-color" content="#e2eafa" />
+ <meta name="theme-color" content="#ffffff" />
+ <script src="/theme-init.js"></script>
<meta name="description" content="Chat with your local Go Bot agent." />
<link rel="icon" type="image/png" sizes="64x64" href="/src/assets/harness-favicon.png" />
<title>Go Bot</title>
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 207cb19..2bbd7aa 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -6,6 +6,7 @@
"": {
"name": "go-bot-web",
"dependencies": {
+ "@fontsource-variable/inter": "^5.3.0",
"eventsource-parser": "4.1.3",
"lucide-react": "1.72.0",
"react": "19.3.1",
@@ -57,6 +58,15 @@
"tslib": "^2.4.0"
}
},
+ "node_modules/@fontsource-variable/inter": {
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/@fontsource-variable/inter/-/inter-5.3.0.tgz",
+ "integrity": "sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA==",
+ "license": "OFL-1.1",
+ "funding": {
+ "url": "https://github.com/sponsors/ayuhito"
+ }
+ },
"node_modules/@napi-rs/wasm-runtime": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 079f9ed..a361051 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -11,6 +11,7 @@
"node": ">=22.12"
},
"dependencies": {
+ "@fontsource-variable/inter": "^5.3.0",
"eventsource-parser": "4.1.3",
"lucide-react": "1.72.0",
"react": "19.3.1",
diff --git a/frontend/public/theme-init.js b/frontend/public/theme-init.js
new file mode 100644
index 0000000..e87a441
--- /dev/null
+++ b/frontend/public/theme-init.js
@@ -0,0 +1 @@
+try { document.documentElement.dataset.theme = localStorage.getItem('go-bot.web-theme') === 'dark' ? 'dark' : 'light' } catch { document.documentElement.dataset.theme = 'light' }
diff --git a/frontend/src/AccountEntry.tsx b/frontend/src/AccountEntry.tsx
index 870f241..94ac107 100644
--- a/frontend/src/AccountEntry.tsx
+++ b/frontend/src/AccountEntry.tsx
@@ -3,6 +3,7 @@ import { LanguagePicker, useLocale } from './locale'
import { LoaderCircle } from 'lucide-react'
import { APIError, getModelSettings, registerAccount } from './api/controller'
import { HarnessAvatar } from './HarnessAvatar'
+import { ThemeToggle } from './layout/Theme'
export function AccountEntry({ onOpen }: { onOpen: (userId: string, created: boolean) => void }) {
const { t } = useLocale()
@@ -42,7 +43,7 @@ export function AccountEntry({ onOpen }: { onOpen: (userId: string, created: boo
<form className="account-card" onSubmit={submit}>
<div className="account-card-heading">
<div className="brand"><HarnessAvatar className="brand-mark" />Go Bot</div>
- <LanguagePicker />
+ <div className="account-preferences"><ThemeToggle /><LanguagePicker /></div>
</div>
<h1>{create ? t('Create an account') : t('Open your account')}</h1>
<fieldset disabled={Boolean(phase)}>
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 47ac893..8dc2b8a 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import { LanguagePicker, useLocale } from './locale'
-import { ArrowLeft, Globe, Image, Menu, SlidersHorizontal, Sparkles } from 'lucide-react'
+import { ArrowLeft, FolderOpen, Globe, Image, SlidersHorizontal, Sparkles } from 'lucide-react'
import { Proactive } from './settings/Proactive'
import { APIError, archiveSession, createSession, listSessions, openAccount, readHostStream, stopHost, type ProviderPage, type SessionRow } from './api/controller'
import { AccountEntry } from './AccountEntry'
@@ -16,8 +16,12 @@ import { ExtensionDialogs } from './extensions/Dialogs'
import { ModelRequiredDialog } from './chat/ModelRequiredDialog'
import { preparePlugins } from './api/extensions'
import { imageGenerationSettingsEnabled } from './features'
+import { NavigationRail } from './layout/NavigationRail'
+import { ThemeToggle } from './layout/Theme'
+import { WorkspaceHeader } from './layout/WorkspaceHeader'
+import { Tasks } from './tasks/Tasks'
-type SettingsPage = 'models' | ProviderPage | 'plugins' | 'proactive'
+type SettingsPage = 'models' | ProviderPage | 'plugins' | 'proactive' | 'tasks'
function currentSettings(): SettingsPage | undefined {
if (window.location.pathname === '/settings/models') return 'models'
@@ -25,6 +29,7 @@ function currentSettings(): SettingsPage | undefined {
if (window.location.pathname === '/settings/proactive') return 'proactive'
if (window.location.pathname === '/settings/image-generation') return imageGenerationSettingsEnabled ? 'image-generation' : 'models'
if (window.location.pathname === '/plugins') return 'plugins'
+ if (window.location.pathname === '/tasks') return 'tasks'
}
function settingsNavigationAllowed(resume: () => void) {
@@ -77,7 +82,8 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
const [selected, setSelected] = useState(currentSession)
const [drawerOpen, setDrawerOpen] = useState(false)
const [filesOpen, setFilesOpen] = useState(false)
- const [compact, setCompact] = useState(() => window.matchMedia('(max-width: 1059px)').matches)
+ const [compact, setCompact] = useState(() => window.matchMedia('(max-width: 1199px)').matches)
+ const [small, setSmall] = useState(() => window.matchMedia('(max-width: 760px)').matches)
const filesOverlay = filesOpen && compact
const [error, setError] = useState('')
const [creating, setCreating] = useState(false)
@@ -187,7 +193,7 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
function pop() {
const settings = currentSettings()
setSettingsPage(settings)
- if (settings) return
+ if (settings) { setDrawerOpen(false); return }
setSettingsVersion(value => value + 1)
setSelected(currentSession() ?? mainSessionId)
}
@@ -199,16 +205,17 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
}, [refresh, hostReady])
useEffect(() => {
- const desktop = window.matchMedia('(min-width: 681px)')
+ const desktop = window.matchMedia('(min-width: 761px)')
function closeAtDesktop() {
if (desktop.matches) setDrawerOpen(false)
+ setSmall(!desktop.matches)
}
desktop.addEventListener('change', closeAtDesktop)
return () => desktop.removeEventListener('change', closeAtDesktop)
}, [])
useEffect(() => {
- const layout = window.matchMedia('(max-width: 1059px)')
+ const layout = window.matchMedia('(max-width: 1199px)')
function resize() { setCompact(layout.matches) }
layout.addEventListener('change', resize)
return () => layout.removeEventListener('change', resize)
@@ -216,13 +223,12 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
function closeDrawer() {
setDrawerOpen(false)
- requestAnimationFrame(() => document.querySelector<HTMLElement>('.drawer-toggle')?.focus())
+ requestAnimationFrame(() => document.querySelector<HTMLElement>('.rail-links > button')?.focus())
}
function closeFiles() {
setFilesOpen(false)
- const selector = window.matchMedia('(max-width: 680px)').matches ? '.drawer-toggle' : '#account-menu-toggle'
- requestAnimationFrame(() => document.querySelector<HTMLElement>(selector)?.focus())
+ requestAnimationFrame(() => document.querySelector<HTMLElement>('.navigation-rail [aria-controls="host-files"]')?.focus())
}
function toggleFiles() {
@@ -234,12 +240,12 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
setFilesOpen(true)
}
- function choose(id?: string) {
+ function choose(id?: string, revealChats = false) {
const complete = () => {
const path = id ? '/chat/' + id : '/'
if (window.location.pathname !== path) window.history.pushState(null, '', path)
setSelected(id)
- setDrawerOpen(false)
+ setDrawerOpen(revealChats || (!small && !settingsOpen && drawerOpen))
if (settingsOpen) {
setSettingsPage(undefined)
setSettingsVersion(value => value + 1)
@@ -262,7 +268,7 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
}
function showSettings() {
- if (settingsPage === 'plugins') { selectSettings('models'); setDrawerOpen(false); return }
+ if (settingsPage === 'plugins' || settingsPage === 'tasks') { selectSettings('models'); setDrawerOpen(false); return }
if (settingsOpen) {
setDrawerOpen(false)
return
@@ -283,10 +289,25 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
if (settingsNavigationAllowed(complete)) complete()
}
+ function showTasks() {
+ const complete = () => {
+ const returnTo = settingsOpen ? window.history.state?.returnTo || '/' : window.location.pathname
+ window.history.pushState({ returnTo }, '', '/tasks')
+ setSettingsPage('tasks')
+ setDrawerOpen(false)
+ }
+ if (settingsPage !== 'tasks' && settingsNavigationAllowed(complete)) complete()
+ }
+
+ function toggleChats() {
+ if (settingsOpen) choose(selected || mainSessionId, true)
+ else setDrawerOpen(value => !value)
+ }
+
function selectSettings(page: SettingsPage) {
if (page === settingsPage) return
const complete = () => {
- window.history.replaceState(window.history.state, '', page === 'plugins' ? '/plugins' : '/settings/' + page)
+ window.history.replaceState(window.history.state, '', page === 'plugins' ? '/plugins' : page === 'tasks' ? '/tasks' : '/settings/' + page)
setSettingsPage(page)
}
if (settingsNavigationAllowed(complete)) complete()
@@ -375,24 +396,25 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
return true
}
+ const headerActions = <><button type="button" className="icon-button header-files" aria-label={t('File system')} title={t('File system')} disabled={!hostReady} aria-expanded={filesOpen} onClick={toggleFiles}><FolderOpen size={18} /></button><ThemeToggle /><LanguagePicker /></>
+ const section = settingsPage === 'tasks' ? 'tasks' : settingsPage === 'plugins' ? 'plugins' : settingsPage ? 'settings' : 'chats'
return (
- <div className={filesOpen ? 'app app-files-open' : 'app'}>
- <Sidebar userId={userId} cache={transcriptCache} rows={[...(mainSessionId ? [{ sessionId: mainSessionId, title: 'Go Bot', createdAt: '', isMain: true }] : []), ...rows.filter(row => row.sessionId !== mainSessionId)]} selected={selected} hasMore={Boolean(cursor)} isLoading={loading} creating={creating || !hostReady}
- filesOpen={filesOpen} filesAvailable={hostReady} filesOverlay={filesOverlay} onFiles={toggleFiles}
- hostReady={hostReady} stoppingHost={stoppingHost} stopHostError={stopHostError} onStopHost={exitHost}
- error={error} needsModel={needsModel} drawerOpen={drawerOpen} onSettings={showSettings} onPlugins={showPlugins} pluginsOpen={settingsPage === 'plugins'} onCreate={() => { void start().catch(() => {}) }} onChoose={choose}
+ <div className={'app' + (filesOpen ? ' app-files-open' : '') + (drawerOpen ? ' app-sidebar-open' : '')}>
+ <NavigationRail userId={userId} section={section} chatsOpen={drawerOpen} filesOpen={filesOpen} ready={hostReady} stopping={stoppingHost} error={stopHostError}
+ onChats={toggleChats} onTasks={showTasks} onPlugins={showPlugins} onFiles={toggleFiles} onSettings={showSettings} onStop={() => void exitHost()} />
+ <div className="sidebar-slot">
+ <Sidebar cache={transcriptCache} rows={[...(mainSessionId ? [{ sessionId: mainSessionId, title: 'Go Bot', createdAt: '', isMain: true }] : []), ...rows.filter(row => row.sessionId !== mainSessionId)]} selected={selected} hasMore={Boolean(cursor)} isLoading={loading} creating={creating || !hostReady}
+ filesOverlay={filesOverlay}
+ error={error} needsModel={needsModel} drawerOpen={drawerOpen} onSettings={showSettings} onCreate={() => { void start().catch(() => {}) }} onChoose={id => choose(id)}
onDelete={remove} onMore={() => { void refresh(cursor) }} onClose={closeDrawer}
onRetry={() => { setError(''); if (hostReady) void refresh(); else setHostAttempt(attempt => attempt + 1) }} />
- {settingsPage && <main className="model-settings" inert={drawerOpen || filesOverlay}>
- <div className="settings-topbar">
- <button type="button" className="icon-button drawer-toggle" onClick={() => setDrawerOpen(true)}
- aria-expanded={drawerOpen} aria-controls="chat-sidebar" aria-label={t('Open chats')}><Menu size={22} /></button>
- </div>
- <div className={settingsPage === 'plugins' ? 'model-settings-panel plugin-settings-panel' : 'model-settings-panel'}>
+ </div>
+ {settingsPage && <main className={'model-settings' + (settingsPage === 'tasks' ? ' tasks-workspace' : '')} inert={(drawerOpen && small) || filesOverlay}>
+ <WorkspaceHeader title={settingsPage === 'tasks' ? 'Tasks' : settingsPage === 'plugins' ? 'Plugin market' : 'Settings'} actions={headerActions} />
+ {settingsPage === 'tasks' ? <Tasks userId={userId} cache={transcriptCache} onChat={id => choose(id)} /> : <div className={settingsPage === 'plugins' ? 'model-settings-panel plugin-settings-panel page-enter' : 'model-settings-panel page-enter'}>
<header className="settings-header">
<div className="settings-header-actions">
<button type="button" className="settings-back" onClick={closeSettings}><ArrowLeft size={17} /> {t(settingsPage === 'plugins' && selectedPlugin ? 'Plugin market' : 'Back to chats')}</button>
- <LanguagePicker />
</div>
{!(settingsPage === 'plugins' && selectedPlugin) && <h1>{t(settingsPage === 'plugins' ? 'Plugin market' : 'Settings')}</h1>}
</header>
@@ -411,7 +433,7 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
: settingsPage === 'proactive' ? <Proactive userId={userId} onModels={() => selectSettings('models')} />
: <ToolProviders key={settingsPage} userId={userId} page={settingsPage} />}
</div>
- </div>
+ </div>}
</main>}
{hostReady && (preparingPlugins || prepareError) && <div className="preparation-banner" role="status">
<span>{t(preparingPlugins ? 'Preparing browser and Office capabilities…' : 'Some plugins could not be prepared.')}</span>
@@ -419,8 +441,8 @@ function AccountChat({ userId, onExit }: { userId: string; onExit: () => void })
<button className="text-button" onClick={showPlugins}>{t('View plugins')}</button>
</div>}
{modelRequired && <ModelRequiredDialog onClose={() => setModelRequired(false)} onSettings={() => { setModelRequired(false); showSettings() }} />}
- {hostReady && <Chat hidden={settingsOpen} userId={userId} cache={transcriptCache} settingsVersion={settingsVersion} onSettings={showSettings} onPlugins={showPlugins} isMain={selected === mainSessionId} drawerOpen={drawerOpen} filesOverlay={filesOverlay} key={selected ?? 'welcome'} id={selected}
- onOpenMenu={() => setDrawerOpen(true)} onAccepted={markTitle} onUnavailable={unavailable} onTitleRefresh={() => { void refresh() }} />}
+ {hostReady && <Chat hidden={settingsOpen} userId={userId} cache={transcriptCache} settingsVersion={settingsVersion} onSettings={showSettings} onPlugins={showPlugins} isMain={selected === mainSessionId} drawerOpen={drawerOpen && small} filesOverlay={filesOverlay} headerActions={headerActions} key={selected ?? 'welcome'} id={selected}
+ onOpenMenu={toggleChats} onAccepted={markTitle} onUnavailable={unavailable} onTitleRefresh={() => { void refresh() }} />}
{hostReady && <HostFiles userId={userId} open={filesOpen} overlay={filesOverlay} onClose={closeFiles} />}
</div>
)
diff --git a/frontend/src/assets/file-icons/LICENSE b/frontend/src/assets/file-icons/LICENSE
new file mode 100644
index 0000000..8ae68c5
--- /dev/null
+++ b/frontend/src/assets/file-icons/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright The vscode-icons Contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/frontend/src/assets/file-icons/vscode-icons.json b/frontend/src/assets/file-icons/vscode-icons.json
new file mode 100644
index 0000000..92cda6f
--- /dev/null
+++ b/frontend/src/assets/file-icons/vscode-icons.json
@@ -0,0 +1,7 @@
+{
+ "pdf": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><defs><linearGradient id=\"b\" x1=\"625.787\" x2=\"632.847\" y1=\"825.641\" y2=\"812.848\" gradientTransform=\"rotate(.063 730247.83 -555381.24)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"#fff\"/><stop offset=\"1\" stop-color=\"#e1e1e1\"/></linearGradient><linearGradient id=\"d\" x1=\"634.081\" x2=\"635.169\" y1=\"810.251\" y2=\"809.248\" gradientTransform=\"translate(-610.524 -802.52)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"#fff\"/><stop offset=\"1\" stop-color=\"#c8c8c8\"/></linearGradient><linearGradient id=\"f\" x1=\"14.019\" x2=\"10.665\" y1=\"-116.816\" y2=\"-106.493\" gradientTransform=\"matrix(1 0 0 -1 .04 -103.785)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\".127\" stop-color=\"#8a0000\"/><stop offset=\".244\" stop-color=\"#900000\" stop-opacity=\".999\"/><stop offset=\".398\" stop-color=\"#a00000\" stop-opacity=\".999\"/><stop offset=\".573\" stop-color=\"#bc0000\" stop-opacity=\".998\"/><stop offset=\".761\" stop-color=\"#e20000\" stop-opacity=\".997\"/><stop offset=\".867\" stop-color=\"#fa0000\" stop-opacity=\".996\"/></linearGradient><linearGradient id=\"g\" x1=\"14.16\" x2=\"10.541\" y1=\"-117.225\" y2=\"-106.084\" gradientTransform=\"matrix(1 0 0 -1 .04 -103.785)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\".315\" stop-color=\"#5e0000\"/><stop offset=\".444\" stop-color=\"#830000\" stop-opacity=\".999\"/><stop offset=\".618\" stop-color=\"#ae0000\" stop-opacity=\".998\"/><stop offset=\".775\" stop-color=\"#cd0000\" stop-opacity=\".997\"/><stop offset=\".908\" stop-color=\"#e00000\" stop-opacity=\".996\"/><stop offset=\"1\" stop-color=\"#e70000\" stop-opacity=\".996\"/></linearGradient><filter id=\"a\" width=\"120%\" height=\"120%\" x=\"-10%\" y=\"-10%\"><feGaussianBlur stdDeviation=\".2\"/></filter><filter id=\"c\" width=\"140%\" height=\"140%\" x=\"-20%\" y=\"-20%\"><feGaussianBlur stdDeviation=\".25\"/></filter><filter id=\"e\" width=\"120%\" height=\"140%\" x=\"-10%\" y=\"-20%\"><feGaussianBlur stdDeviation=\".08\"/></filter></defs><path stroke=\"#000\" stroke-width=\".3\" d=\"M9.064 3.162h11.6a31.5 31.5 0 0 1 7.524 7.538v17.842H9.064Z\" filter=\"url(#a)\" opacity=\".6\" transform=\"translate(.03 .3)\"/><path fill=\"url(#b)\" d=\"M9.064 3.162h11.6a31.5 31.5 0 0 1 7.524 7.538v17.842H9.064Z\"/><path fill=\"none\" stroke=\"#c8c8c8\" stroke-width=\".5\" d=\"M9.064 3.162h11.6a31.5 31.5 0 0 1 7.524 7.538v17.842H9.064Z\"/><path d=\"M20.662 3.162a31.8 31.8 0 0 1 7.526 7.538 6.77 6.77 0 0 0-5.332-2.03 6.03 6.03 0 0 0-2.194-5.508\" filter=\"url(#c)\" opacity=\".75\" transform=\"matrix(.8026 0 0 .831 5 1.36)\"/><path fill=\"url(#d)\" d=\"M20.662 3.162a31.8 31.8 0 0 1 7.526 7.538 6.77 6.77 0 0 0-5.332-2.03 6.03 6.03 0 0 0-2.194-5.508\"/><path fill=\"none\" stroke=\"#c8c8c8\" stroke-width=\".5\" d=\"M20.662 3.162a31.8 31.8 0 0 1 7.526 7.538 6.77 6.77 0 0 0-5.332-2.03 6.03 6.03 0 0 0-2.194-5.508Z\"/><path fill=\"none\" stroke=\"#c8c8c8\" stroke-width=\"4\" d=\"M5.339 6.496h14.1v2.7h-14.1z\"/><path fill=\"#f91d0a\" d=\"M15.819 19.855c.466-.914 1-1.943 1.42-2.977l.168-.408c-.554-2.108-.886-3.8-.589-4.894a.755.755 0 0 1 .763-.458h.254c.484-.007.711.608.737.847a4 4 0 0 1-.141 1.072 2.6 2.6 0 0 0-.161-1.091c-.2-.439-.391-.7-.562-.743a.54.54 0 0 0-.2.407 6 6 0 0 0-.077.939 10.5 10.5 0 0 0 .433 2.729q.08-.235.14-.447c.059-.222.433-1.691.433-1.691s-.094 1.956-.226 2.547q-.042.187-.092.375a8.6 8.6 0 0 0 2.145 3.351 6.7 6.7 0 0 0 1.24.852 17 17 0 0 1 2.517-.189 3.15 3.15 0 0 1 1.938.433.74.74 0 0 1 .213.484 1.5 1.5 0 0 1-.041.282c.01-.051.01-.3-.755-.546a8.9 8.9 0 0 0-3.086-.043c1.566.766 3.093 1.147 3.576.919a1 1 0 0 0 .262-.254 2.7 2.7 0 0 1-.146.484.76.76 0 0 1-.377.258c-.764.2-2.752-.268-4.485-1.258a36.6 36.6 0 0 0-5.768 1.371c-1.675 2.936-2.935 4.284-3.959 3.771l-.377-.189a.44.44 0 0 1-.141-.474c.119-.584.852-1.465 2.324-2.344.158-.1.864-.469.864-.469s-.523.506-.645.605c-1.175.963-2.042 2.174-2.021 2.644v.041c1-.142 2.495-2.174 4.419-5.939m.61.312a78 78 0 0 1-.926 1.682 24.6 24.6 0 0 1 4.975-1.408 8 8 0 0 1-.637-.485 8.5 8.5 0 0 1-2.1-2.729 23 23 0 0 1-1.317 2.94\"/><path d=\"M3.54 4.83h17.97v6.35H3.54z\" filter=\"url(#e)\" opacity=\".3\"/><path fill=\"url(#f)\" d=\"M3.75 4.968h17.264v5.803H3.75z\"/><path fill=\"url(#g)\" d=\"M21.343 11.119H3.437V4.62h17.906ZM20.7 5.264H4.081v5.209H20.7Z\"/><path fill=\"#fff9f9\" d=\"M8.262 5.819h1.256a1.1 1.1 0 0 1 .859.331 1.34 1.34 0 0 1 .3.937 1.35 1.35 0 0 1-.3.942 1.1 1.1 0 0 1-.859.328h-.5v1.349h-.756zm.757.726v1.086h.419a.42.42 0 0 0 .34-.141.6.6 0 0 0 .12-.4.6.6 0 0 0-.12-.4.42.42 0 0 0-.34-.141h-.419m2.949.031v2.369h.271a.85.85 0 0 0 .708-.3 1.38 1.38 0 0 0 .246-.885 1.38 1.38 0 0 0-.244-.88.86.86 0 0 0-.71-.3h-.271m-.757-.758h.8a2.9 2.9 0 0 1 .989.121 1.3 1.3 0 0 1 .562.427 1.8 1.8 0 0 1 .307.607 2.8 2.8 0 0 1 .1.779 2.8 2.8 0 0 1-.1.786 1.8 1.8 0 0 1-.307.607 1.3 1.3 0 0 1-.566.43 3 3 0 0 1-.991.125h-.8V5.819m3.342 0H16.6v.758h-1.29V7.3h1.209v.758H15.31v1.648h-.757V5.819\"/></svg>\n",
+ "word": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><defs><linearGradient id=\"a\" x1=\"4.494\" x2=\"13.832\" y1=\"-1712.086\" y2=\"-1695.914\" gradientTransform=\"translate(0 1720)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"#2368c4\"/><stop offset=\".5\" stop-color=\"#1a5dbe\"/><stop offset=\"1\" stop-color=\"#1146ac\"/></linearGradient></defs><path fill=\"#41a5ee\" d=\"M28.806 3H9.705a1.19 1.19 0 0 0-1.193 1.191V9.5l11.069 3.25L30 9.5V4.191A1.19 1.19 0 0 0 28.806 3\"/><path fill=\"#2b7cd3\" d=\"M30 9.5H8.512V16l11.069 1.95L30 16Z\"/><path fill=\"#185abd\" d=\"M8.512 16v6.5l10.418 1.3L30 22.5V16Z\"/><path fill=\"#103f91\" d=\"M9.705 29h19.1A1.19 1.19 0 0 0 30 27.809V22.5H8.512v5.309A1.19 1.19 0 0 0 9.705 29\"/><path d=\"M16.434 8.2H8.512v16.25h7.922a1.2 1.2 0 0 0 1.194-1.191V9.391A1.2 1.2 0 0 0 16.434 8.2\" opacity=\".1\"/><path d=\"M15.783 8.85H8.512V25.1h7.271a1.2 1.2 0 0 0 1.194-1.191V10.041a1.2 1.2 0 0 0-1.194-1.191\" opacity=\".2\"/><path d=\"M15.783 8.85H8.512V23.8h7.271a1.2 1.2 0 0 0 1.194-1.191V10.041a1.2 1.2 0 0 0-1.194-1.191\" opacity=\".2\"/><path d=\"M15.132 8.85h-6.62V23.8h6.62a1.2 1.2 0 0 0 1.194-1.191V10.041a1.2 1.2 0 0 0-1.194-1.191\" opacity=\".2\"/><path fill=\"url(#a)\" d=\"M3.194 8.85h11.938a1.193 1.193 0 0 1 1.194 1.191v11.918a1.193 1.193 0 0 1-1.194 1.191H3.194A1.19 1.19 0 0 1 2 21.959V10.041A1.19 1.19 0 0 1 3.194 8.85\"/><path fill=\"#fff\" d=\"M6.9 17.988q.035.276.046.481h.028q.015-.195.065-.47c.05-.275.062-.338.089-.465l1.255-5.407h1.624l1.3 5.326a8 8 0 0 1 .162 1h.022a8 8 0 0 1 .135-.975l1.039-5.358h1.477l-1.824 7.748h-1.727l-1.237-5.126q-.054-.222-.122-.578t-.084-.52h-.021q-.021.189-.084.561t-.1.552L7.78 19.871H6.024L4.19 12.127h1.5l1.131 5.418a5 5 0 0 1 .079.443\"/></svg>\n",
+ "powerpoint": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><defs><linearGradient id=\"a\" x1=\"4.494\" x2=\"13.832\" y1=\"-1748.086\" y2=\"-1731.914\" gradientTransform=\"translate(0 1756)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"#ca4c28\"/><stop offset=\".5\" stop-color=\"#c5401e\"/><stop offset=\"1\" stop-color=\"#b62f14\"/></linearGradient></defs><path fill=\"#ed6c47\" d=\"M18.93 17.3 16.977 3h-.146A12.9 12.9 0 0 0 3.953 15.854V16Z\"/><path fill=\"#ff8f6b\" d=\"M17.123 3h-.146v13l6.511 2.6L30 16v-.146A12.9 12.9 0 0 0 17.123 3\"/><path fill=\"#d35230\" d=\"M30 16v.143A12.905 12.905 0 0 1 17.12 29h-.287a12.907 12.907 0 0 1-12.88-12.857V16Z\"/><path d=\"M17.628 9.389V23.26a1.2 1.2 0 0 1-.742 1.1 1.2 1.2 0 0 1-.45.091H7.027a10 10 0 0 1-.521-.65 12.74 12.74 0 0 1-2.553-7.657v-.286A12.7 12.7 0 0 1 6.05 8.85a9 9 0 0 1 .456-.65h9.93a1.2 1.2 0 0 1 1.192 1.189\" opacity=\".1\"/><path d=\"M16.977 10.04v13.871a1.2 1.2 0 0 1-.091.448 1.2 1.2 0 0 1-1.1.741H7.62q-.309-.314-.593-.65a10 10 0 0 1-.521-.65 12.74 12.74 0 0 1-2.553-7.657v-.286A12.7 12.7 0 0 1 6.05 8.85h9.735a1.2 1.2 0 0 1 1.192 1.19\" opacity=\".2\"/><path d=\"M16.977 10.04v12.571a1.2 1.2 0 0 1-1.192 1.189H6.506a12.74 12.74 0 0 1-2.553-7.657v-.286A12.7 12.7 0 0 1 6.05 8.85h9.735a1.2 1.2 0 0 1 1.192 1.19\" opacity=\".2\"/><path d=\"M16.326 10.04v12.571a1.2 1.2 0 0 1-1.192 1.189H6.506a12.74 12.74 0 0 1-2.553-7.657v-.286A12.7 12.7 0 0 1 6.05 8.85h9.084a1.2 1.2 0 0 1 1.192 1.19\" opacity=\".2\"/><path fill=\"url(#a)\" d=\"M3.194 8.85h11.938a1.193 1.193 0 0 1 1.194 1.191v11.918a1.193 1.193 0 0 1-1.194 1.191H3.194A1.19 1.19 0 0 1 2 21.959V10.041A1.19 1.19 0 0 1 3.194 8.85\"/><path fill=\"#fff\" d=\"M9.293 12.028a3.3 3.3 0 0 1 2.174.636 2.27 2.27 0 0 1 .756 1.841 2.56 2.56 0 0 1-.373 1.376 2.5 2.5 0 0 1-1.059.935 3.6 3.6 0 0 1-1.591.334H7.687v2.8H6.141v-7.922ZM7.686 15.94h1.331a1.74 1.74 0 0 0 1.177-.351 1.3 1.3 0 0 0 .4-1.025q0-1.309-1.525-1.31H7.686z\"/></svg>\n",
+ "excel": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><defs><linearGradient id=\"a\" x1=\"4.494\" x2=\"13.832\" y1=\"-2092.086\" y2=\"-2075.914\" gradientTransform=\"translate(0 2100)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"#18884f\"/><stop offset=\".5\" stop-color=\"#117e43\"/><stop offset=\"1\" stop-color=\"#0b6631\"/></linearGradient></defs><path fill=\"#185c37\" d=\"M19.581 15.35 8.512 13.4v14.409A1.19 1.19 0 0 0 9.705 29h19.1A1.19 1.19 0 0 0 30 27.809V22.5Z\"/><path fill=\"#21a366\" d=\"M19.581 3H9.705a1.19 1.19 0 0 0-1.193 1.191V9.5L19.581 16l5.861 1.95L30 16V9.5Z\"/><path fill=\"#107c41\" d=\"M8.512 9.5h11.069V16H8.512Z\"/><path d=\"M16.434 8.2H8.512v16.25h7.922a1.2 1.2 0 0 0 1.194-1.191V9.391A1.2 1.2 0 0 0 16.434 8.2\" opacity=\".1\"/><path d=\"M15.783 8.85H8.512V25.1h7.271a1.2 1.2 0 0 0 1.194-1.191V10.041a1.2 1.2 0 0 0-1.194-1.191\" opacity=\".2\"/><path d=\"M15.783 8.85H8.512V23.8h7.271a1.2 1.2 0 0 0 1.194-1.191V10.041a1.2 1.2 0 0 0-1.194-1.191\" opacity=\".2\"/><path d=\"M15.132 8.85h-6.62V23.8h6.62a1.2 1.2 0 0 0 1.194-1.191V10.041a1.2 1.2 0 0 0-1.194-1.191\" opacity=\".2\"/><path fill=\"url(#a)\" d=\"M3.194 8.85h11.938a1.193 1.193 0 0 1 1.194 1.191v11.918a1.193 1.193 0 0 1-1.194 1.191H3.194A1.19 1.19 0 0 1 2 21.959V10.041A1.19 1.19 0 0 1 3.194 8.85\"/><path fill=\"#fff\" d=\"m5.7 19.873 2.511-3.884-2.3-3.862h1.847L9.013 14.6c.116.234.2.408.238.524h.017q.123-.281.26-.546l1.342-2.447h1.7l-2.359 3.84 2.419 3.905h-1.809l-1.45-2.711A2.4 2.4 0 0 1 9.2 16.8h-.024a1.7 1.7 0 0 1-.168.351l-1.493 2.722Z\"/><path fill=\"#33c481\" d=\"M28.806 3h-9.225v6.5H30V4.191A1.19 1.19 0 0 0 28.806 3\"/><path fill=\"#107c41\" d=\"M19.581 16H30v6.5H19.581Z\"/></svg>\n",
+ "markdown": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\"><path fill=\"none\" stroke=\"#755838\" d=\"M2.5 7.955h27v16.091h-27z\"/><path fill=\"#755838\" d=\"M5.909 20.636v-9.272h2.727l2.728 3.409 2.727-3.409h2.727v9.272h-2.727v-5.318l-2.727 3.409-2.728-3.409v5.318zm17.046 0-4.091-4.5h2.727v-4.772h2.727v4.772h2.727z\"/></svg>\n"
+}
diff --git a/frontend/src/chat/Chat.tsx b/frontend/src/chat/Chat.tsx
index 7252ed2..3d24ad3 100644
--- a/frontend/src/chat/Chat.tsx
+++ b/frontend/src/chat/Chat.tsx
@@ -1,6 +1,6 @@
-import { useEffect, useLayoutEffect, useRef, useState } from 'react'
+import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import { useLocale } from '../locale'
-import { ArrowUp, FileText, LoaderCircle, Menu, Plus, Square, X } from 'lucide-react'
+import { ArrowUp, FileText, LoaderCircle, PanelLeft, Plus, Square, X } from 'lucide-react'
import { HarnessAvatar } from '../HarnessAvatar'
import { APIError, readTranscript, sendMessage, stopTurn, updateQueue } from '../api/controller'
import { MessageBubble } from './ChatContent'
@@ -9,6 +9,9 @@ import { QuestionPanel } from './QuestionPanel'
import { addMessageFiles, isMessageImage } from './attachments'
import { ModelRequiredDialog } from './ModelRequiredDialog'
import { ModelPicker } from './ModelPicker'
+import { useTextPlayback } from './useTextPlayback'
+import { usePlaybackPreference } from './usePlaybackPreference'
+import { WorkspaceHeader } from '../layout/WorkspaceHeader'
import { attemptMessage, emptyTranscript, groupAssistantReplies, messageText, textMessage, visibleQueue, type Message } from './transcript'
import { prependTranscriptPage, type TranscriptCache } from './transcriptCache'
@@ -45,9 +48,10 @@ type ChatProps = {
onAccepted: (id: string, text: string) => void
onUnavailable: (id: string) => void
onTitleRefresh: () => void
+ headerActions?: ReactNode
}
-export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, settingsVersion, onSettings, onPlugins, isMain, onOpenMenu, onAccepted, onUnavailable, onTitleRefresh }: ChatProps) {
+export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, settingsVersion, onSettings, onPlugins, isMain, onOpenMenu, onAccepted, onUnavailable, onTitleRefresh, headerActions }: ChatProps) {
const { t } = useLocale()
const cached = id ? cache.get(id) : undefined
const [transcript, setTranscript] = useState(() => cached?.transcript ?? emptyTranscript())
@@ -131,18 +135,25 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
}, [cache, id, loadAttempt, userId])
const pendingMessages = pending.filter(item => !transcript.messages.some(message => message.id === item.id))
- const displayedMessages = [...transcript.messages, ...pendingMessages]
+ const displayedMessages = useMemo(() => {
+ const messages = [...transcript.messages, ...pending.filter(item => !transcript.messages.some(message => message.id === item.id))]
+ const draft = transcript.draft ? attemptMessage(transcript.draft) : null
+ if (draft) messages.push(draft)
+ return messages
+ }, [transcript.messages, transcript.draft, pending])
const queue = visibleQueue(transcript, displayedMessages)
const draft = transcript.draft ? attemptMessage(transcript.draft) : null
- if (draft?.blocks.length) displayedMessages.push(draft)
- const replies = groupAssistantReplies(displayedMessages)
+ const playbackAllowed = usePlaybackPreference()
+ const playback = useTextPlayback(userId + '/' + id, displayedMessages,
+ playbackAllowed && !hidden && !loading && !connecting, transcript.streamEpoch)
+ const replies = groupAssistantReplies(playback.messages)
const activeTurn = transcript.activeTurn
const hasReply = activeTurn !== null && replies.some(message => message.role === 'assistant' && message.turn === activeTurn)
const messageObserved = transcript.messages.some(message => message.id === awaitingMessage) ||
transcript.queue.some(message => message.id === awaitingMessage)
const waiting = activeTurn !== null ? !hasReply && transcript.questions.length === 0
: Boolean(awaitingMessage && !messageObserved)
- const generating = activeTurn !== null && transcript.questions.length === 0
+ const generating = (activeTurn !== null || playback.pending) && transcript.questions.length === 0
const showWelcome = !loading && !historyError && transcript.messages.length === 0 && pendingMessages.length === 0 &&
!draft && !waiting && activeTurn === null && transcript.questions.length === 0
useEffect(() => {
@@ -171,7 +182,7 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
} else if (following.current) {
panel.scrollTop = panel.scrollHeight
}
- }, [transcript, pending.length, waiting, files.length])
+ }, [transcript, playback.messages, pending.length, waiting, files.length])
async function loadOlder() {
const entry = id ? cache.get(id) : undefined
@@ -304,9 +315,7 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
<div className="composer-tools">
<button type="button" className="attachment-button" aria-label={t('Add attachments')} title={t('Add attachments')}
disabled={submitting} onClick={() => filePicker.current?.click()}><Plus size={21} /></button>
- <ModelPicker generating={activeTurn !== null} userId={userId} id={id} settingsVersion={settingsVersion} onSettings={onSettings} onSaving={setModelSaving} />
- {id && <PermissionPicker key={id} userId={userId} sessionId={id} streamState={transcript.permission}
- disabled={activeTurn !== null || submitting} onSaving={setPermissionSaving} />}
+ <span className="composer-hint">{t('Message Go Bot')}</span>
</div>
<div className="composer-submit">
{activeTurn !== null && <button className="stop-generation" type="button" title={t('Stop generating')}
@@ -324,10 +333,12 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
return (
<main className="workspace" hidden={hidden} inert={drawerOpen || filesOverlay}>
- <header className="topbar">
- <button className="icon-button drawer-toggle" type="button" onClick={onOpenMenu} aria-expanded={drawerOpen} aria-controls="chat-sidebar" aria-label={t('Open chats')}><Menu size={22} /></button>
- <span>{isMain ? t('Main chat') : t('Go Bot Chat')}</span>
- </header>
+ <WorkspaceHeader title={isMain ? 'Main chat' : 'Go Bot Chat'} actions={headerActions} start={<>
+ <button className="icon-button drawer-toggle" type="button" onClick={onOpenMenu} aria-controls="chat-sidebar" aria-label={t('Open chats')} title={t('Open chats')}><PanelLeft size={18} /></button>
+ <ModelPicker generating={activeTurn !== null} userId={userId} id={id} settingsVersion={settingsVersion} onSettings={onSettings} onSaving={setModelSaving} />
+ {id && <PermissionPicker key={id} userId={userId} sessionId={id} streamState={transcript.permission}
+ disabled={activeTurn !== null || submitting} onSaving={setPermissionSaving} />}
+ </>} />
{modelRequired && <ModelRequiredDialog selection={modelRequired === 'selection'} onClose={() => setModelRequired(undefined)}
onSettings={() => { setModelRequired(undefined); onSettings() }} onChoose={() => {
setModelRequired(undefined); requestAnimationFrame(() => document.querySelector<HTMLButtonElement>('.model-picker-trigger')?.click())
@@ -336,17 +347,13 @@ export function Chat({ hidden, userId, cache, id, drawerOpen, filesOverlay, sett
<div className="chat-empty">
<HarnessAvatar className="welcome-avatar" />
</div>
- ) : showWelcome ? (
- <div className="welcome">
- <div className="welcome-copy">
+ ) : (
+ <div className={'conversation' + (showWelcome ? ' is-welcome' : '')}>
+ <div className="welcome-copy" aria-hidden={!showWelcome}>
<HarnessAvatar className="welcome-avatar" />
<h1>{t(greeting())}</h1>
<p>{t('How can I help you today?')}</p>
</div>
- <div className="welcome-input">{form}{failure && <p className="feedback" role="alert">{t(failure)}</p>}</div>
- </div>
- ) : (
- <div className="conversation">
<div className="transcript-scroll" ref={scroll} onScroll={event => {
const panel = event.currentTarget
following.current = panel.scrollHeight - panel.scrollTop - panel.clientHeight < 88
diff --git a/frontend/src/chat/ChatContent.tsx b/frontend/src/chat/ChatContent.tsx
index 770a4ee..8d90bbf 100644
--- a/frontend/src/chat/ChatContent.tsx
+++ b/frontend/src/chat/ChatContent.tsx
@@ -1,11 +1,12 @@
-import { useEffect, useState } from 'react'
+import { useEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react'
import { useLocale } from '../locale'
-import { Check, ChevronRight, CircleAlert, FileDown, LoaderCircle, Terminal, Wrench } from 'lucide-react'
-import ReactMarkdown from 'react-markdown'
-import remarkGfm from 'remark-gfm'
+import { Check, ChevronLeft, ChevronRight, CircleAlert, Download, Image as Picture, LoaderCircle, RotateCcw, Terminal, Wrench, X } from 'lucide-react'
+import { MarkdownText } from './MarkdownText'
+export { MarkdownText } from './MarkdownText'
import { fetchChatFile } from '../api/controller'
import { HarnessAvatar } from '../HarnessAvatar'
-import { groupDisplayBlocks, messageText, type AttachmentRef, type FileRef, type Message, type ToolBlock, type Transcript } from './transcript'
+import { FileIcon } from '../files/FileIcon'
+import { groupDisplayBlocks, messageBlocksForDisplay, messageText, type ChatImage, type FileRef, type Message, type ToolBlock, type Transcript } from './transcript'
type SessionAddress = { userId: string; sessionId?: string }
@@ -15,9 +16,9 @@ export function MessageBubble({ message, tools, ...address }: SessionAddress & {
const isAssistant = message.role === 'assistant'
return (
<article className={'message ' + (isAssistant ? 'assistant-message' : 'user-message')}>
- {isAssistant && <HarnessAvatar className="reply-mark" />}
+ {isAssistant && <div className="assistant-identity"><HarnessAvatar className="reply-mark" /><span>Go Bot</span></div>}
<div className={isAssistant ? 'message-blocks markdown' : 'message-blocks'}>
- {groupDisplayBlocks(message.blocks, tools).map(block => {
+ {groupDisplayBlocks(messageBlocksForDisplay(message), tools).map(block => {
switch (block.type) {
case 'text':
return isAssistant ? <MarkdownText key={block.id} text={block.text} /> : <div key={block.id}>{block.text}</div>
@@ -25,12 +26,14 @@ export function MessageBubble({ message, tools, ...address }: SessionAddress & {
return <ToolCard key={block.id} block={block} progress={tools[block.callId]} />
case 'tool-group':
return <ToolGroup key={block.id} blocks={block.tools} tools={tools} />
+ case 'image-tools':
+ return <ImageToolGroup key={block.id} blocks={block.tools} images={block.images} tools={tools} {...address} />
case 'file':
return <FileBlock key={block.id} name={block.name} description={block.description} file={block.file} {...address} />
case 'image-row':
- return <div key={block.id} className="chat-image-row">
- {block.images.map(image => <ImageBlock key={image.id} attachment={image.attachment} {...address} />)}
- </div>
+ return <ImageStrip key={block.id}>
+ {block.images.map(image => <ImageBlock key={image.id} image={image} {...address} />)}
+ </ImageStrip>
}
})}
</div>
@@ -38,29 +41,10 @@ export function MessageBubble({ message, tools, ...address }: SessionAddress & {
)
}
-export function MarkdownText({ text }: { text: string }) {
- const { t } = useLocale()
- return <div>
- <ReactMarkdown remarkPlugins={[remarkGfm]} skipHtml components={{
- a: ({ children, href }) => href && /^(https?:|mailto:|#)/i.test(href)
- ? <a href={href} target="_blank" rel="noreferrer">{children}</a>
- : <span>{children}</span>,
- img: ({ node, alt }) => {
- const start = node?.position?.start.offset
- const end = node?.position?.end.offset
- return start !== undefined && end !== undefined ? text.slice(start, end) : alt
- },
- table: ({ children }) => <div className="markdown-table-scroll" role="region" aria-label={t('Table')} tabIndex={0}>
- <table>{children}</table>
- </div>,
- }}>{text}</ReactMarkdown>
- </div>
-}
-
const toolLabels: Record<string, string> = {
exit_plan_mode: 'Review the plan',
read_file: 'Read file', write_file: 'Write file', edit_file: 'Edit file',
- readimage: 'Read image', generateimage: 'Generate image',
+ readimage: 'View images', generateimage: 'Generate image',
bash: 'Run command', shell: 'Run command', shellexecute: 'Run command',
web_search: 'Search the web', web_fetch: 'Open web page',
present: 'Present files', skill: 'Load skill',
@@ -128,39 +112,106 @@ function FileBlock({ name, description, file, userId, sessionId }: SessionAddres
setBusy(false)
}
}
- return <div>
+ return <div className="file-delivery">
<button type="button" className="chat-file" disabled={busy || !sessionId} onClick={() => { void download() }}>
- <FileDown size={16} aria-hidden="true" /> <span>{filename}</span>
+ <FileIcon name={filename} /><span className="chat-file-copy"><strong>{filename}</strong><small>{description || t('Download file')}</small></span>
+ {busy ? <LoaderCircle size={17} className="spinner" /> : <Download size={17} aria-hidden="true" />}
</button>
- {description && <div className="chat-file-description">{description}</div>}
{error && <div className="feedback" role="status">{t(error)}</div>}
</div>
}
-function ImageBlock({ attachment, userId, sessionId }: SessionAddress & { attachment: AttachmentRef }) {
+function ImageStrip({ children, compact = false }: { children: ReactNode; compact?: boolean }) {
+ const { t } = useLocale()
+ const ref = useRef<HTMLDivElement>(null)
+ const [edges, setEdges] = useState({ left: 1, right: 1 })
+ useEffect(() => {
+ const node = ref.current
+ if (!node) return
+ const measure = () => setEdges({
+ left: 1 - Math.min(1, Math.max(0, node.scrollLeft - 2) / 24),
+ right: 1 - Math.min(1, Math.max(0, node.scrollWidth - node.clientWidth - node.scrollLeft - 2) / 24),
+ })
+ const observer = new ResizeObserver(measure)
+ observer.observe(node)
+ if (node.firstElementChild) observer.observe(node.firstElementChild)
+ node.addEventListener('scroll', measure, { passive: true })
+ measure()
+ return () => { observer.disconnect(); node.removeEventListener('scroll', measure) }
+ }, [children])
+ const shift = (direction: number) => ref.current?.scrollBy({ left: direction * 140, behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'instant' : 'smooth' })
+ return <div className="chat-image-scroller"><div ref={ref} className={'chat-image-row' + (compact ? ' compact-images' : '')}
+ role="region" aria-label={t('Images — scroll horizontally')} tabIndex={0}
+ style={{ '--image-edge-left': edges.left, '--image-edge-right': edges.right } as CSSProperties}
+ onKeyDown={event => {
+ if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return
+ event.preventDefault()
+ shift(event.key === 'ArrowLeft' ? -1 : 1)
+ }}>{children}</div>
+ {edges.left < 1 && <button className="image-scroll-arrow previous" type="button" aria-label={t('Previous images')} onClick={() => shift(-1)}><ChevronLeft size={16} /></button>}
+ {edges.right < 1 && <button className="image-scroll-arrow next" type="button" aria-label={t('Next images')} onClick={() => shift(1)}><ChevronRight size={16} /></button>}
+ </div>
+}
+
+function ImageToolGroup({ blocks, images, tools, ...address }: SessionAddress & { blocks: ToolBlock[]; images: ChatImage[]; tools: Transcript['toolResults'] }) {
const { t } = useLocale()
- const { attachmentId, name, width, height } = attachment
+ const [open, setOpen] = useState(true)
+ const running = blocks.filter(block => !tools[block.callId]?.status).length
+ const failed = blocks.some(block => tools[block.callId]?.status === 'failed' || tools[block.callId]?.status === 'cancelled')
+ const count = images.length + running || blocks.length
+ return <section className="image-tool-group">
+ <button className="image-tool-header" type="button" aria-expanded={open} onClick={() => setOpen(value => !value)}>
+ <Picture size={15} aria-hidden="true" /><span>{t(blocks[0].name === 'readimage' ? 'View images' : 'Generate image')}</span>
+ <small>{count === 1 ? t('1 image') : t('{count} images', { count })}</small>
+ {running ? <LoaderCircle size={13} className="spinner image-tool-state" aria-label={t('Running')} />
+ : failed ? <CircleAlert size={13} className="image-tool-state" aria-label={t('Failed')} />
+ : <Check size={13} className="image-tool-state" aria-label={t('Finished')} />}
+ <ChevronRight size={14} className={open ? 'image-tool-chevron expanded' : 'image-tool-chevron'} aria-hidden="true" />
+ </button>
+ <div className="image-tool-body" hidden={!open}>
+ {(images.length > 0 || running > 0) && <ImageStrip compact>
+ {images.map(image => <ImageBlock key={image.id} image={image} {...address} />)}
+ {Array.from({ length: Math.min(3, running) }, (_, index) => <div className="chat-image-placeholder" key={'pending/' + index} aria-label={t('Loading image')}><LoaderCircle size={18} className="spinner" /></div>)}
+ </ImageStrip>}
+ {!images.length && !running && <p className="chat-status">{t('No images to display.')}</p>}
+ </div>
+ </section>
+}
+
+function ImageBlock({ image, userId, sessionId }: SessionAddress & { image: ChatImage }) {
+ const { t } = useLocale()
+ const { file, name, width, height } = image
+ const identity = file.source === 'attachment' ? file.attachmentId : file.path
const [href, setHref] = useState('')
const [failed, setFailed] = useState(false)
+ const [retry, setRetry] = useState(0)
+ const [preview, setPreview] = useState(false)
+ const dialog = useRef<HTMLDialogElement>(null)
+ useEffect(() => {
+ if (preview) dialog.current?.showModal()
+ else dialog.current?.close()
+ }, [preview])
useEffect(() => {
if (!sessionId) return
const abort = new AbortController()
let objectURL = ''
- void fetchChatFile(userId, sessionId, { source: 'attachment', attachmentId }, name, abort.signal).then(blob => {
+ setHref('')
+ setFailed(false)
+ void fetchChatFile(userId, sessionId, file, name, abort.signal).then(blob => {
if (abort.signal.aborted) return
objectURL = URL.createObjectURL(blob)
setHref(objectURL)
- }).catch(() => {
- if (!abort.signal.aborted) setFailed(true)
- })
- return () => {
- abort.abort()
- if (objectURL) URL.revokeObjectURL(objectURL)
- }
- }, [userId, sessionId, attachmentId, name])
- if (failed) return <span className="chat-status">{t('Image unavailable.')}</span>
- if (!href) return <div className="chat-image-placeholder" aria-label={t('Loading image')} />
- return <a href={href} target="_blank" rel="noreferrer" aria-label={name || t('Open image')}>
+ }).catch(() => { if (!abort.signal.aborted) setFailed(true) })
+ return () => { abort.abort(); if (objectURL) URL.revokeObjectURL(objectURL) }
+ }, [userId, sessionId, file.source, identity, name, retry])
+ if (failed) return file.source === 'presented'
+ ? <FileBlock name={name} file={file} userId={userId} sessionId={sessionId} />
+ : <button className="chat-image-retry" type="button" onClick={() => setRetry(value => value + 1)}><RotateCcw size={18} /><span>{t('Image unavailable. Retry')}</span></button>
+ if (!href) return <div className="chat-image-placeholder" aria-label={t('Loading image')}><LoaderCircle size={18} className="spinner" /></div>
+ return <><button type="button" className="chat-image-button" aria-label={name || t('Open image')} onClick={() => setPreview(true)}>
<img className="chat-image" src={href} alt={name || t('Attachment')} width={width} height={height} onError={() => setFailed(true)} />
- </a>
+ </button><dialog ref={dialog} className="image-preview" aria-label={t('Image preview')} onCancel={event => { event.preventDefault(); setPreview(false) }} onClick={event => { if (event.target === event.currentTarget) setPreview(false) }}>
+ <div className="image-preview-actions"><a className="icon-button" href={href} download={name || 'image'} aria-label={t('Download image')}><Download size={21} /></a><button type="button" className="icon-button" aria-label={t('Close image')} onClick={() => setPreview(false)}><X size={23} /></button></div>
+ <img src={href} alt={name || t('Attachment')} />
+ </dialog></>
}
diff --git a/frontend/src/chat/MarkdownText.tsx b/frontend/src/chat/MarkdownText.tsx
new file mode 100644
index 0000000..d1b24bf
--- /dev/null
+++ b/frontend/src/chat/MarkdownText.tsx
@@ -0,0 +1,54 @@
+import { memo, useEffect, useRef, useState, type ReactNode } from 'react'
+import ReactMarkdown from 'react-markdown'
+import remarkGfm from 'remark-gfm'
+import { Check, Copy } from 'lucide-react'
+import { useLocale } from '../locale'
+
+async function copyMarkdown(text: string) {
+ if (navigator.clipboard && window.isSecureContext) return navigator.clipboard.writeText(text)
+ // Plain HTTP deployments still support a user-initiated copy.
+ const previous = document.activeElement as HTMLElement | null
+ const input = document.createElement('textarea')
+ input.value = text
+ input.style.cssText = 'position:fixed;left:-9999px;top:0'
+ document.body.append(input)
+ try {
+ input.select()
+ if (!document.execCommand('copy')) throw new Error('copy failed')
+ } finally { input.remove(); previous?.focus({ preventScroll: true }) }
+}
+
+function MarkdownPanel({ kind, raw, language, children }: { kind: 'table' | 'code'; raw: string; language?: string; children: ReactNode }) {
+ const { t } = useLocale()
+ const [status, setStatus] = useState<'idle' | 'copied' | 'failed'>('idle')
+ const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
+ useEffect(() => () => clearTimeout(timer.current), [])
+ const label = status === 'copied' ? 'Copied' : status === 'failed' ? 'Copy failed. Try again.' : kind === 'table' ? 'Copy table' : 'Copy code'
+ return <div className={'markdown-panel markdown-' + kind + '-panel'}>
+ <div className="markdown-panel-toolbar"><span>{kind === 'table' ? t('Table') : language || t('Code')}</span>
+ <button type="button" className="markdown-copy" aria-label={t(label)} onClick={async () => {
+ clearTimeout(timer.current)
+ try { await copyMarkdown(raw); setStatus('copied') } catch { setStatus('failed') }
+ timer.current = setTimeout(() => setStatus('idle'), 2200)
+ }}>{status === 'copied' ? <Check size={13} /> : <Copy size={13} />}<span aria-live="polite">{t(label)}</span></button>
+ </div>
+ <div className={kind === 'table' ? 'markdown-table-scroll' : 'markdown-code-scroll'} role="region" aria-label={t(kind === 'table' ? 'Table — scroll horizontally' : 'Code — scroll horizontally')} tabIndex={0}>{children}</div>
+ </div>
+}
+
+export const MarkdownText = memo(function MarkdownText({ text }: { text: string }) {
+ const raw = (node: { position?: { start: { offset?: number }; end: { offset?: number } } } | undefined) => {
+ const start = node?.position?.start.offset, end = node?.position?.end.offset
+ return start !== undefined && end !== undefined ? text.slice(start, end) : ''
+ }
+ return <div><ReactMarkdown remarkPlugins={[remarkGfm]} skipHtml components={{
+ a: ({ children, href }) => href && /^(https?:|mailto:|#)/i.test(href) ? <a href={href} target="_blank" rel="noreferrer">{children}</a> : <span>{children}</span>,
+ img: ({ node, alt }) => raw(node) || alt,
+ table: ({ node, children }) => <MarkdownPanel kind="table" raw={raw(node)}><table>{children}</table></MarkdownPanel>,
+ pre: ({ node, children }) => {
+ const code = node?.children.find(child => child.type === 'element' && child.tagName === 'code')
+ const language = code?.type === 'element' ? String(code.properties.className || '').match(/language-([\w+-]+)/)?.[1] : undefined
+ return <MarkdownPanel kind="code" raw={raw(node)} language={language}><pre>{children}</pre></MarkdownPanel>
+ },
+ }}>{text}</ReactMarkdown></div>
+})
diff --git a/frontend/src/chat/textPlayback.ts b/frontend/src/chat/textPlayback.ts
new file mode 100644
index 0000000..6c26670
--- /dev/null
+++ b/frontend/src/chat/textPlayback.ts
@@ -0,0 +1,130 @@
+import type { Block, Message } from './transcript.ts'
+
+type Text = { target: string; ends: number[]; shown: number }
+export type PlaybackView = { messages: Message[]; pending: boolean; pendingTurn?: number }
+const segmenter = typeof Intl.Segmenter === 'function' ? new Intl.Segmenter(undefined, { granularity: 'grapheme' }) : undefined
+
+function boundaries(text: string) {
+ if (segmenter) return Array.from(segmenter.segment(text), part => part.index + part.segment.length)
+ let end = 0
+ return Array.from(text, point => (end += point.length))
+}
+
+// Draft IDs and committed message/block IDs differ. turn/step is the common
+// identity already carried by both; file-only deliveries keep their own ID.
+function messageKey(message: Message) {
+ return message.role === 'assistant' && message.turn !== undefined && message.step !== undefined
+ ? `step/${message.turn}/${message.step}` : `message/${message.id}`
+}
+function textKeys(message: Message) {
+ let index = 0
+ return message.blocks.map(block => block.type === 'text' ? `${messageKey(message)}/text/${index++}` : '')
+}
+
+/** Presentation only. Received messages and stream cursors are never modified. */
+export class TextPlayback {
+ private source: Message[] = []
+ private texts = new Map<string, Text>()
+ private known = new Set<string>()
+ private ordered: { key: string; turn?: number }[] = []
+ private initialized = false
+ private enabled = false
+ private epoch = 0
+ private lastAt = 0
+ private credit = 0
+
+ sync(messages: Message[], enabled: boolean, epoch: number, now: number) {
+ const wasPending = this.pending
+ const snap = !this.initialized || !enabled || enabled !== this.enabled || epoch !== this.epoch
+ if (!snap) {
+ // A later step's live frame can outrun the 500ms journal projection.
+ // Keep the previous step's provisional text until its commit arrives,
+ // but only while a later live draft proves this is still the same turn.
+ // Cancellation, a reset baseline and same-step retries do not retain it.
+ const received = new Set(messages.map(messageKey))
+ for (const previous of this.source) {
+ if (!previous.streaming || received.has(messageKey(previous))) continue
+ const later = messages.findIndex(message => message.streaming && message.turn === previous.turn &&
+ message.step !== undefined && previous.step !== undefined && message.step > previous.step)
+ if (later >= 0) messages = [...messages.slice(0, later), previous, ...messages.slice(later)]
+ }
+ }
+ const lastKnown = messages.reduce((last, message, index) => this.known.has(messageKey(message)) ? index : last, -1)
+ const next = new Map<string, Text>()
+ const ordered: typeof this.ordered = []
+ messages.forEach((message, position) => {
+ if (message.role !== 'assistant') return
+ const keys = textKeys(message)
+ message.blocks.forEach((block, index) => {
+ if (block.type !== 'text') return
+ const key = keys[index]
+ const previous = this.texts.get(key)
+ const ends = previous?.target === block.text ? previous.ends : boundaries(block.text)
+ let shown = previous?.shown ?? 0
+ if (snap || !previous && position < lastKnown) shown = ends.length
+ else if (previous && !block.text.startsWith(previous.target)) {
+ // An abandoned attempt can be replaced by corrected text. Keep only
+ // the already visible common prefix; never append the old attempt.
+ const visibleEnd = previous.ends[previous.shown - 1] ?? 0
+ let common = 0
+ while (common < visibleEnd && previous.target[common] === block.text[common]) common++
+ shown = ends.filter(end => end <= common).length
+ }
+ next.set(key, { target: block.text, ends, shown: Math.min(shown, ends.length) })
+ ordered.push({ key, turn: message.turn })
+ })
+ })
+ this.source = messages
+ this.texts = next
+ this.ordered = ordered
+ this.known = new Set(messages.map(messageKey))
+ this.enabled = enabled
+ this.epoch = epoch
+ this.initialized = true
+ if (snap || !wasPending) { this.lastAt = now; this.credit = 0 }
+ }
+
+ get pending() { return this.ordered.some(({ key }) => { const text = this.texts.get(key)!; return text.shown < text.ends.length }) }
+
+ advance(now: number) {
+ const elapsed = Math.max(0, Math.min(100, now - this.lastAt)) / 1000
+ this.lastAt = now
+ const remaining = this.ordered.reduce((sum, { key }) => { const text = this.texts.get(key)!; return sum + text.ends.length - text.shown }, 0)
+ if (!remaining) { this.credit = 0; return false }
+ this.credit += elapsed * Math.min(360, Math.max(60, remaining / 0.8))
+ let budget = Math.floor(this.credit)
+ this.credit -= budget
+ let changed = false
+ for (const { key } of this.ordered) {
+ if (!budget) break
+ const text = this.texts.get(key)!
+ const count = Math.min(budget, text.ends.length - text.shown)
+ text.shown += count
+ budget -= count
+ changed ||= count > 0
+ }
+ return changed
+ }
+
+ view(): PlaybackView {
+ let blocked = false
+ let pendingTurn: number | undefined
+ const messages: Message[] = []
+ for (const message of this.source) {
+ if (message.role !== 'assistant') { messages.push(message); continue }
+ if (blocked) continue
+ const keys = textKeys(message)
+ const blocks: Block[] = []
+ for (let index = 0; index < message.blocks.length; index++) {
+ const block = message.blocks[index]
+ if (block.type !== 'text') { blocks.push(block); continue }
+ const text = this.texts.get(keys[index])!
+ const value = text.target.slice(0, text.ends[text.shown - 1] ?? 0)
+ if (value) blocks.push({ ...block, id: keys[index], text: value })
+ if (text.shown < text.ends.length) { blocked = true; pendingTurn = message.turn; break }
+ }
+ if (blocks.length) messages.push({ ...message, id: messageKey(message), blocks })
+ }
+ return { messages, pending: this.pending, pendingTurn }
+ }
+}
diff --git a/frontend/src/chat/transcript.ts b/frontend/src/chat/transcript.ts
index 795419d..8db1977 100644
--- a/frontend/src/chat/transcript.ts
+++ b/frontend/src/chat/transcript.ts
@@ -12,35 +12,61 @@ export type Block =
export type ToolBlock = Extract<Block, { type: 'tool' }>
type ToolGroup = { id: string; type: 'tool-group'; tools: ToolBlock[] }
-type ImageRow = { id: string; type: 'image-row'; images: ImageBlock[] }
-type DisplayBlock = Exclude<Block, ImageBlock> | ToolGroup | ImageRow
+export type ChatImage = { id: string; file: FileRef; name?: string; mediaType?: string; width?: number; height?: number }
+type ImageRow = { id: string; type: 'image-row'; images: ChatImage[] }
+type ImageTools = { id: string; type: 'image-tools'; name: string; tools: ToolBlock[]; images: ChatImage[] }
+type DisplayBlock = Exclude<Block, ImageBlock> | ToolGroup | ImageRow | ImageTools
+
+function attachmentImage(block: ImageBlock): ChatImage {
+ const { attachmentId, ...metadata } = block.attachment
+ return { id: block.id, file: { source: 'attachment', attachmentId }, ...metadata }
+}
+
+// Only explicit presented raster files become previews. Markdown links and uploaded
+// file blocks keep their existing semantics. A failed preview falls back to a file.
+export function isPresentedImage(file: FileRef) {
+ return file.source === 'presented' && /\.(png|jpe?g|webp|gif|avif|bmp)$/i.test(file.path)
+}
export function groupDisplayBlocks(blocks: Block[], toolResults: Transcript['toolResults']): DisplayBlock[] {
- const ordered = blocks.flatMap<Block>(block =>
- block.type === 'tool' ? [block, ...(toolResults[block.callId]?.images ?? [])] : [block],
- )
const groups: DisplayBlock[] = []
- for (const block of ordered) {
+ const image = (item: ChatImage) => {
const previous = groups.at(-1)
- if (block.type === 'image') {
- if (previous?.type === 'image-row') {
- previous.images.push(block)
- } else {
- groups.push({ id: block.id, type: 'image-row', images: [block] })
- }
- } else if (block.type === 'tool' && previous?.type === 'tool-group') {
- previous.tools.push(block)
- } else if (block.type === 'tool' && previous?.type === 'tool') {
- groups[groups.length - 1] = { id: previous.id, type: 'tool-group', tools: [previous, block] }
+ if (previous?.type === 'image-row') previous.images.push(item)
+ else groups.push({ id: item.id, type: 'image-row', images: [item] })
+ }
+ for (const block of blocks) {
+ const previous = groups.at(-1)
+ if (block.type === 'tool' && (block.name === 'readimage' || block.name === 'generateimage')) {
+ const images = (toolResults[block.callId]?.images ?? []).map(attachmentImage)
+ if (previous?.type === 'image-tools' && previous.name === block.name) {
+ previous.tools.push(block)
+ previous.images.push(...images)
+ } else groups.push({ id: block.id, type: 'image-tools', name: block.name, tools: [block], images })
+ } else if (block.type === 'image') image(attachmentImage(block))
+ else if (block.type === 'file' && isPresentedImage(block.file)) {
+ image({ id: block.id, file: block.file, name: block.name })
} else {
- groups.push(block)
+ if (block.type === 'tool' && previous?.type === 'tool-group') previous.tools.push(block)
+ else if (block.type === 'tool' && previous?.type === 'tool') {
+ groups[groups.length - 1] = { id: previous.id, type: 'tool-group', tools: [previous, block] }
+ } else groups.push(block)
+ if (block.type === 'tool') for (const result of toolResults[block.callId]?.images ?? []) image(attachmentImage(result))
}
}
return groups
}
+// User attachments precede the instruction visually, including older histories.
+// Assistant blocks always retain their original interleaving.
+export function messageBlocksForDisplay(message: Message): Block[] {
+ if (message.role !== 'user') return message.blocks
+ return [...message.blocks.filter(block => block.type === 'image' || block.type === 'file'),
+ ...message.blocks.filter(block => block.type !== 'image' && block.type !== 'file')]
+}
+
type MessageData = { id: string; blocks: Block[] }
-export type Message = MessageData & { role: 'user' | 'assistant' | 'notice'; turn?: number }
+export type Message = MessageData & { role: 'user' | 'assistant' | 'notice'; turn?: number; step?: number; streaming?: boolean }
export type QueueItem = MessageData & { placement: 'queued' | 'steering' }
export type Question = {
id: string
@@ -75,6 +101,8 @@ export type Transcript = {
questions: PendingQuestion[]
permission?: SessionPermission
toolResults: Record<string, ToolProgress>
+ // Client-only reset boundary for a restored stream snapshot, not a log fact.
+ streamEpoch?: number
}
type Chunk = { type: string; index?: number; blockType?: string; text?: string; block?: { type: string; text?: string } }
@@ -115,9 +143,9 @@ export function groupAssistantReplies(messages: Message[]): Message[] {
return groups
}
-function appendMessage(state: Transcript, role: Message['role'], message: MessageData, turn?: number): Transcript {
+function appendMessage(state: Transcript, role: Message['role'], message: MessageData, turn?: number, step?: number): Transcript {
if (!message.blocks?.length || state.messages.some(item => item.id === message.id)) return state
- return { ...state, messages: [...state.messages, { ...message, role, turn }] }
+ return { ...state, messages: [...state.messages, { ...message, role, turn, ...(step === undefined ? {} : { step }) }] }
}
export function applySessionEvent(previous: Transcript, event: SessionEvent): Transcript {
@@ -150,7 +178,7 @@ export function applySessionEvent(previous: Transcript, event: SessionEvent): Tr
if (state.draft && state.draft.turn === turn && state.draft.step === step && event.seq > state.draft.startedAfterSeq) {
state = { ...state, draft: null }
}
- return appendMessage(state, 'assistant', message, turn)
+ return appendMessage(state, 'assistant', message, turn, step)
}
case 'tool/call': {
const { callId } = event.data as { callId: string }
@@ -196,7 +224,7 @@ export function attemptMessage(attempt: Attempt): Message {
const blocks = Object.entries(attempt.texts).map(([index, text]) => ({
id: attempt.attemptId + '/' + index, type: 'text' as const, text,
}))
- return { id: attempt.attemptId, role: 'assistant', turn: attempt.turn, blocks }
+ return { id: attempt.attemptId, role: 'assistant', turn: attempt.turn, step: attempt.step, streaming: true, blocks }
}
export function applyStreamEvent(state: Transcript, kind: string, data: unknown): Transcript {
@@ -212,6 +240,7 @@ export function applyStreamEvent(state: Transcript, kind: string, data: unknown)
if (kind === 'permissions.state') return { ...state, permission: data as SessionPermission }
if (kind === 'questions.state') return { ...state, questions: (data as { questions?: PendingQuestion[] }).questions ?? [] }
if (kind === 'assistant-stream-baseline') {
+ state = { ...state, streamEpoch: (state.streamEpoch ?? 0) + 1 }
const { baseline } = data as { baseline: { revision: number; activeAttempt?: AttemptSnapshot } }
const current = baseline.activeAttempt
if (!current) return { ...state, draft: null }
diff --git a/frontend/src/chat/usePlaybackPreference.ts b/frontend/src/chat/usePlaybackPreference.ts
new file mode 100644
index 0000000..3d3c304
--- /dev/null
+++ b/frontend/src/chat/usePlaybackPreference.ts
@@ -0,0 +1,16 @@
+import { useEffect, useState } from 'react'
+
+export function usePlaybackPreference() {
+ const [enabled, setEnabled] = useState(() => !document.hidden && !matchMedia('(prefers-reduced-motion: reduce)').matches)
+ useEffect(() => {
+ const motion = matchMedia('(prefers-reduced-motion: reduce)')
+ const update = () => setEnabled(!document.hidden && !motion.matches)
+ document.addEventListener('visibilitychange', update)
+ motion.addEventListener('change', update)
+ return () => {
+ document.removeEventListener('visibilitychange', update)
+ motion.removeEventListener('change', update)
+ }
+ }, [])
+ return enabled
+}
diff --git a/frontend/src/chat/useTextPlayback.ts b/frontend/src/chat/useTextPlayback.ts
new file mode 100644
index 0000000..c402d01
--- /dev/null
+++ b/frontend/src/chat/useTextPlayback.ts
@@ -0,0 +1,40 @@
+import { useLayoutEffect, useMemo, useReducer } from 'react'
+import type { Message } from './transcript'
+import { TextPlayback } from './textPlayback'
+
+// Both clients provide visibility/reduced-motion preferences. Keep messages
+// memoized at the caller: playback ticks must not recreate the source array.
+export function useTextPlayback(scope: string, messages: Message[], enabled: boolean, epoch = 0) {
+ const player = useMemo(() => new TextPlayback(), [scope])
+ const animation = useMemo(() => ({ frame: 0, lastRender: 0, running: false }), [player])
+ const [, redraw] = useReducer(value => value + 1, 0)
+ useLayoutEffect(() => {
+ player.sync(messages, enabled, epoch, performance.now())
+ redraw()
+ if (!player.pending) {
+ animation.running = false
+ cancelAnimationFrame(animation.frame)
+ return
+ }
+ // New network chunks update the target without cancelling/restarting
+ // the animation clock. This also keeps the 30fps cap across dense chunks.
+ if (animation.running) return
+ animation.running = true
+ animation.lastRender = 0
+ const tick = (now: number) => {
+ if (!animation.running) return
+ if (now - animation.lastRender >= 32) {
+ animation.lastRender = now
+ if (player.advance(now)) redraw()
+ }
+ if (player.pending) animation.frame = requestAnimationFrame(tick)
+ else animation.running = false
+ }
+ animation.frame = requestAnimationFrame(tick)
+ }, [player, animation, messages, enabled, epoch])
+ useLayoutEffect(() => () => {
+ animation.running = false
+ cancelAnimationFrame(animation.frame)
+ }, [animation])
+ return player.view()
+}
diff --git a/frontend/src/extensions/extensions.css b/frontend/src/extensions/extensions.css
index 9b4a21d..4b11342 100644
--- a/frontend/src/extensions/extensions.css
+++ b/frontend/src/extensions/extensions.css
@@ -1,10 +1,10 @@
.extensions-settings { min-width: 0; }
-.extension-account-row { display: flex; align-items: center; gap: 14px; padding: 18px 0; border-top: 1px solid #dce2ec; }
+.extension-account-row { display: flex; align-items: center; gap: 14px; padding: 18px 0; border-top: 1px solid var(--line); }
.extension-account-row > svg { color: var(--muted); flex: none; }
-.extension-auth-method { min-width: 0; max-width: 160px; padding: 9px; font: inherit; font-size: 12px; border: 1px solid #d8dfeb; border-radius: 10px; background: #ffffff80; color: inherit; }
-.extension-auth-dialog { width: min(540px, calc(100vw - 36px)); max-height: calc(100dvh - 64px); margin: auto; padding: 0; border: 1px solid #ffffffdc; border-radius: 25px; background: #f8f9fdf7; color: var(--ink); box-shadow: 0 20px 90px #23375320; }
-.extension-auth-dialog::backdrop { background: #1e294849; backdrop-filter: blur(7px); }
-.extension-auth-heading { display: flex; align-items: center; gap: 13px; padding: 24px 24px 20px; border-bottom: 1px solid #e1e5ef; }
+.extension-auth-method { min-width: 0; max-width: 160px; padding: 9px; font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); color: inherit; }
+.extension-auth-dialog { width: min(540px, calc(100vw - 36px)); max-height: calc(100dvh - 64px); margin: auto; padding: 0; border: 1px solid var(--canvas); border-radius: 14px; background: var(--canvas); color: var(--ink); box-shadow: 0 20px 90px #00000008; }
+.extension-auth-dialog::backdrop { background: var(--scrim, #17172055); backdrop-filter: blur(7px); }
+.extension-auth-heading { display: flex; align-items: center; gap: 13px; padding: 24px 24px 20px; border-bottom: 1px solid var(--surface-2); }
.extension-auth-heading > svg { color: var(--muted); }
.extension-auth-heading > div { flex: 1; min-width: 0; }
.extension-auth-heading h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.025em; overflow-wrap: anywhere; }
@@ -12,21 +12,21 @@
.extension-auth-content { display: grid; gap: 24px; padding: 24px; }
.extension-auth-content p { margin: 0; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.extension-auth-notice { display: grid; gap: 12px; }
-.extension-auth-notice code { justify-self: start; padding: 10px 14px; border: 1px solid #dde2ef; border-radius: 12px; background: #ffffffc9; font-size: 17px; letter-spacing: .06em; overflow-wrap: anywhere; }
+.extension-auth-notice code { justify-self: start; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); font-size: 17px; letter-spacing: .06em; overflow-wrap: anywhere; }
.extension-auth-notice a { display: inline-flex; align-items: center; gap: 7px; justify-self: start; font-size: 13px; color: var(--accent); text-underline-offset: 4px; }
.extension-auth-question { margin: 0; }
.extension-auth-question fieldset { display: grid; gap: 16px; border: 0; padding: 0; margin: 0; min-width: 0; }
.extension-auth-question legend { margin-bottom: 14px; padding: 0; font-size: 14px; font-weight: 550; }
.extension-auth-question .account-submit { min-height: 42px; width: auto; margin: 0; padding: 10px 20px; font-size: 13px; }
.extension-auth-options { display: grid; gap: 10px; }
-.extension-auth-question .extension-auth-options label { display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 14px; border: 1px solid #dce2ed; border-radius: 12px; background: #ffffffb3; }
-.extension-auth-question .extension-auth-options label.is-selected { border-color: #bab9d2; background: #f1f0fa; }
+.extension-auth-question .extension-auth-options label { display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); }
+.extension-auth-question .extension-auth-options label.is-selected { border-color: var(--line); background: var(--accent-soft); }
.extension-auth-question .extension-auth-options input { width: 16px; height: 16px; min-width: 16px; min-height: 0; flex: none; padding: 0; margin: 0; accent-color: var(--accent); }
.extension-auth-options span { display: grid; gap: 5px; }
.extension-auth-options strong { font-size: 13px; font-weight: 550; }
.extension-auth-options small { color: var(--muted); font-size: 12px; line-height: 1.5; font-weight: 400; }
.extension-auth-wait, .extension-auth-complete { display: flex; gap: 10px; align-items: center; color: var(--muted); }
-.extension-auth-complete { color: #397863; }
+.extension-auth-complete { color: var(--success, #51846d); }
.extension-auth-spinner { animation: extension-auth-spin 1.2s linear infinite; flex: none; }
@keyframes extension-auth-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .extension-auth-spinner { animation: none; } }
@@ -37,18 +37,18 @@
.extension-header-actions { flex: none; }
.extension-header-actions .model-secondary { display: inline-flex; align-items: center; gap: 7px; }
.extension-icon { display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); min-width: 44px; min-height: 44px; border-radius: 10px; }
-.extension-icon:hover { background: #e4eaf5; }
+.extension-icon:hover { background: var(--surface-2); }
.extension-runtime { display: flex; align-items: center; gap: 12px; margin: 4px 0 20px; color: var(--muted); font-size: 12px; }
.extension-runtime .extension-text { margin-left: auto; }
-.extension-state { display: inline-flex; align-items: center; gap: 6px; color: #6c7382; font-size: 11px; font-weight: 550; white-space: nowrap; }
+.extension-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 550; white-space: nowrap; }
.extension-state i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
-.extension-state-good { color: #397863; }
-.extension-state-bad { color: #a04b56; }
-.extension-list { display: grid; border-top: 1px solid #d8e1ee; }
-.extension-row { min-width: 0; border-bottom: 1px solid #d8e1ee; }
+.extension-state-good { color: var(--success, #51846d); }
+.extension-state-bad { color: var(--danger); }
+.extension-list { display: grid; border-top: 1px solid var(--line); }
+.extension-row { min-width: 0; border-bottom: 1px solid var(--line); }
.extension-row-toggle { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 87px; padding: 17px 5px; border: 0; text-align: left; background: transparent; color: inherit; }
-.extension-row-toggle:hover:not(:disabled) { background: #ffffff50; }
-.extension-row-icon { display: grid; place-items: center; flex: none; width: 32px; color: #64728e; }
+.extension-row-toggle:hover:not(:disabled) { background: var(--canvas); }
+.extension-row-icon { display: grid; place-items: center; flex: none; width: 32px; color: var(--muted); }
.extension-identity { flex: 1; display: grid; gap: 6px; min-width: 0; }
.extension-identity strong { font-size: 14px; font-weight: 610; overflow-wrap: anywhere; }
.extension-identity small { color: var(--muted); font-size: 12px; }
@@ -59,47 +59,47 @@
.extension-facts > div { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 12px; }
.extension-facts dt { color: var(--muted); }
.extension-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
-.extension-text { display: inline-flex; align-items: center; gap: 6px; padding: 7px 5px; min-height: 44px; border: 0; background: transparent; font-size: 12px; color: #4c5b82; text-align: left; border-radius: 8px; }
-.extension-text:hover:not(:disabled) { color: var(--accent); background: #e7edf6; }
-.extension-text.danger { color: #9b4c58; }
+.extension-text { display: inline-flex; align-items: center; gap: 6px; padding: 7px 5px; min-height: 44px; border: 0; background: transparent; font-size: 12px; color: var(--muted); text-align: left; border-radius: 8px; }
+.extension-text:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
+.extension-text.danger { color: var(--danger); }
.extension-actions .account-submit { padding: 10px 18px; font-size: 13px; }
.extension-actions .model-secondary { font-size: 12px; min-height: 44px; }
-.extension-feedback { display: flex; align-items: start; gap: 9px; padding: 12px 14px; border-radius: 12px; background: #e9f0ec; font-size: 12px; line-height: 1.65; color: #3f6a59; margin: 0 0 18px; overflow-wrap: anywhere; flex-wrap: wrap; }
+.extension-feedback { display: flex; align-items: start; gap: 9px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); font-size: 12px; line-height: 1.65; color: var(--success, #51846d); margin: 0 0 18px; overflow-wrap: anywhere; flex-wrap: wrap; }
.extension-feedback svg { flex: none; margin-top: 2px; }
-.extension-error { color: #924854; background: #f6e9ed; }
-.extension-diagnostic { font-size: 12px; line-height: 1.7; color: #896d50; overflow-wrap: anywhere; white-space: pre-wrap; }
-.extension-empty { display: grid; justify-items: center; text-align: center; padding: 48px 20px 54px; color: #7b879b; }
-.extension-empty h3 { margin: 19px 0 8px; font-size: 16px; font-weight: 590; color: #40506b; }
+.extension-error { color: var(--danger); background: var(--danger-soft); }
+.extension-diagnostic { font-size: 12px; line-height: 1.7; color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
+.extension-empty { display: grid; justify-items: center; text-align: center; padding: 48px 20px 54px; color: var(--muted); }
+.extension-empty h3 { margin: 19px 0 8px; font-size: 16px; font-weight: 590; color: var(--ink); }
.extension-empty p { max-width: 44ch; margin: 0; font-size: 13px; line-height: 1.75; }
-.extension-details { margin: 24px 0; border-top: 1px solid #d8e1ee; }
-.extension-details > summary { display: flex; align-items: center; gap: 9px; min-height: 57px; font-size: 13px; color: #596980; cursor: pointer; list-style: none; }
+.extension-details { margin: 24px 0; border-top: 1px solid var(--line); }
+.extension-details > summary { display: flex; align-items: center; gap: 9px; min-height: 57px; font-size: 13px; color: var(--muted); cursor: pointer; list-style: none; }
.extension-details > summary::-webkit-details-marker, .extension-advanced > summary::-webkit-details-marker { display: none; }
.extension-details > summary > :last-child { margin-left: auto; }
-.extension-details > summary > span { font-size: 11px; color: #7a879b; }
+.extension-details > summary > span { font-size: 11px; color: var(--muted); }
.extension-details[open] > summary > :last-child, .extension-advanced[open] > summary > svg { transform: rotate(180deg); }
.extension-details-body { padding: 3px 0 10px; }
-.extension-editor { padding: 23px; margin: 9px 0 22px; border-radius: 18px; background: #ffffff9c; border: 1px solid #ffffffd9; box-shadow: 0 5px 22px #3c537006, inset 0 1px 0 #ffffff; }
+.extension-editor { padding: 23px; margin: 9px 0 22px; border-radius: 11px; background: var(--canvas); border: 1px solid var(--canvas); box-shadow: 0 5px 22px #00000008, inset 0 1px 0 #fff; }
.extension-editor h3 { margin: 0 0 23px; font-weight: 600; font-size: 16px; letter-spacing: -.025em; }
.extension-editor label small { color: var(--muted); font-weight: 400; font-size: 11px; line-height: 1.6; }
.model-form .extension-check { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 500; }
.model-form .extension-check input { width: 16px; min-height: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.extension-advanced { margin: 0; }
-.extension-advanced > summary { display: flex; justify-content: space-between; align-items: center; min-height: 44px; cursor: pointer; color: #5e6b82; font-size: 12px; list-style: none; }
+.extension-advanced > summary { display: flex; justify-content: space-between; align-items: center; min-height: 44px; cursor: pointer; color: var(--muted); font-size: 12px; list-style: none; }
.extension-advanced > div { display: grid; gap: 16px; padding: 10px 0 17px; }
.model-form textarea.extension-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.7; tab-size: 2; }
-.extension-package-review { padding-top: 19px; border-top: 1px solid #e0e6f0; }
+.extension-package-review { padding-top: 19px; border-top: 1px solid var(--surface-2); }
.extension-package-review > strong { font-size: 13px; overflow-wrap: anywhere; }
.extension-package-review > strong > span { color: var(--muted); font-weight: 400; margin-left: 8px; }
.extension-package-review > p { font-size: 12px; line-height: 1.7; color: var(--muted); }
-.extension-authorization { padding: 16px; margin: 16px 0; border-radius: 12px; background: #e9eef8; }
+.extension-authorization { padding: 16px; margin: 16px 0; border-radius: 12px; background: var(--accent-soft); }
.extension-authorization p { color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 0; }
.extension-authorization a { display: inline-flex; align-items: center; gap: 7px; color: var(--accent); text-decoration: none; font-size: 12px; }
.extension-authorization .extension-text { margin-left: 12px; }
.extension-skeleton { display: grid; gap: 16px; margin: 28px 0; }
-.extension-skeleton span { height: 63px; border-radius: 12px; background: linear-gradient(90deg, #e3e9f3, #f7f9fc, #e3e9f3); background-size: 200% 100%; animation: extension-loading 1.8s ease infinite; }
+.extension-skeleton span { height: 63px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2), var(--surface-2), var(--surface-2)); background-size: 200% 100%; animation: extension-loading 1.8s ease infinite; }
.extension-editor-back { margin-top: 16px; }
-.extension-confirm { width: min(410px, calc(100vw - 36px)); padding: 27px; border: 1px solid #ffffffd9; border-radius: 21px; background: #f6f8fd; color: #354158; box-shadow: 0 24px 90px #2d3c6a28; }
-.extension-confirm::backdrop { background: #27345437; backdrop-filter: blur(3px); }
+.extension-confirm { width: min(410px, calc(100vw - 36px)); padding: 27px; border: 1px solid var(--canvas); border-radius: 14px; background: var(--canvas); color: var(--ink); box-shadow: 0 24px 90px #00000008; }
+.extension-confirm::backdrop { background: var(--scrim, #17172055); backdrop-filter: blur(3px); }
.extension-confirm h2 { margin: 0 0 13px; font-size: 19px; font-weight: 610; letter-spacing: -.03em; }
.extension-confirm p { font-size: 14px; line-height: 1.75; color: var(--muted); margin: 0 0 23px; }
.extension-confirm .extension-actions { justify-content: flex-end; }
@@ -122,35 +122,35 @@
.extension-schema { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font: 12px/1.7 ui-monospace, monospace; }
-.extension-tabs { display: flex; gap: 6px; align-self: flex-start; padding: 4px; margin: 2px 0 22px; border-radius: 15px; background: #e8ecf555; }
-.extension-tabs button { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 9px 18px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: #748097; font: inherit; font-size: 14px; }
-.extension-tabs button[aria-selected="true"] { background: #ffffffc7; color: #354567; border-color: #dce3ef77; box-shadow: 0 2px 5px #26344705; }
+.extension-tabs { display: flex; gap: 6px; align-self: flex-start; width: max-content; max-width: 100%; padding: 4px; margin: 2px 0 22px; border-radius: 9px; background: var(--surface-2); }
+.extension-tabs button { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 9px 18px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); font: inherit; font-size: 14px; }
+.extension-tabs button[aria-selected="true"] { background: var(--canvas); color: var(--ink); border-color: var(--line); box-shadow: 0 2px 5px #00000008; }
.extension-tabs button span { font-size: 12px; font-variant-numeric: tabular-nums; opacity: .7; }
-.extension-capabilities { color: #586780; padding-left: 19px; font-size: 14px; line-height: 1.85; margin: 12px 0 20px; }
-.extension-editor input[type="checkbox"] { width: 18px; min-height: 18px; padding: 0; align-self: flex-start; accent-color: #47598c; }
+.extension-capabilities { color: var(--muted); padding-left: 19px; font-size: 14px; line-height: 1.85; margin: 12px 0 20px; }
+.extension-editor input[type="checkbox"] { width: 18px; min-height: 18px; padding: 0; align-self: flex-start; accent-color: var(--accent); }
/* Plugin catalog: quiet application rows, two columns on desktop. */
.plugin-settings-panel { width: min(100%, 1040px); }
.plugin-market-intro { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.plugin-market-intro p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.plugin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 46px; row-gap: 12px; margin: 22px -10px 0; }
.plugin-tile { display: flex; align-items: center; min-width: 0; gap: 5px; border-radius: 16px; padding: 3px 4px 3px 0; transition: background .18s ease; }
-.plugin-tile:hover, .plugin-tile:focus-within { background: #ffffff70; }
+.plugin-tile:hover, .plugin-tile:focus-within { background: var(--canvas); }
.plugin-tile-main { display: flex; gap: 16px; align-items: center; flex: 1; min-width: 0; min-height: 112px; padding: 17px 10px; border: 0; border-radius: 14px; background: transparent; text-align: left; color: var(--ink); }
-.plugin-mark { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border: 1px solid #26334c12; border-radius: 14px; background: #fff; color: #68738b; overflow: hidden; box-shadow: 0 1px 2px #25314a04; }
+.plugin-mark { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border: 1px solid var(--muted); border-radius: 14px; background: #fff; color: var(--muted); overflow: hidden; box-shadow: 0 1px 2px #00000008; }
.plugin-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
-.plugin-mark-large { width: 66px; height: 66px; border-radius: 18px; }
+.plugin-mark-large { width: 66px; height: 66px; border-radius: 11px; }
.plugin-tile-copy { display: grid; gap: 7px; min-width: 0; }
.plugin-tile-copy strong { font-size: 15px; font-weight: 600; letter-spacing: -.015em; line-height: 1.4; }
.plugin-tile-copy small { color: var(--muted); font-size: 13px; line-height: 1.6; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
-.plugin-icon-button { display: grid; place-items: center; width: 44px; height: 44px; min-width: 44px; border: 0; border-radius: 12px; color: #697387; background: transparent; cursor: pointer; transition: background .15s, color .15s, transform .15s; }
-.plugin-icon-button:hover:not(:disabled) { background: #ffffffc9; color: var(--ink); }
+.plugin-icon-button { display: grid; place-items: center; width: 44px; height: 44px; min-width: 44px; border: 0; border-radius: 12px; color: var(--muted); background: transparent; cursor: pointer; transition: background .15s, color .15s, transform .15s; }
+.plugin-icon-button:hover:not(:disabled) { background: var(--canvas); color: var(--ink); }
.plugin-icon-button:active:not(:disabled) { transform: scale(.96); }
.plugin-more { position: relative; flex: none; }
-.plugin-action-menu { position: absolute; top: calc(100% + 5px); right: 0; z-index: 5; width: 205px; padding: 6px; border: 1px solid #dfe3eb; border-radius: 15px; background: #fcfcfef5; backdrop-filter: blur(20px); box-shadow: 0 12px 38px #27354a18, 0 2px 6px #27354a09; }
+.plugin-action-menu { position: absolute; top: calc(100% + 5px); right: 0; z-index: 5; width: 205px; padding: 6px; border: 1px solid var(--line); border-radius: 15px; background: var(--canvas); backdrop-filter: blur(20px); box-shadow: 0 12px 38px #00000008, 0 2px 6px #00000008; }
.plugin-action-menu button { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 11px; padding: 11px 12px; border: 0; border-radius: 10px; color: var(--ink); background: transparent; text-align: left; font: inherit; font-size: 13px; }
-.plugin-action-menu button:hover { background: #edf0f7; }
-.plugin-action-menu button.danger { color: #ab5260; }
-.plugin-runtime-details { margin-top: 36px; border-top: 1px solid #26334c10; padding-top: 10px; color: var(--muted); font-size: 12px; }
+.plugin-action-menu button:hover { background: var(--surface-2); }
+.plugin-action-menu button.danger { color: var(--danger); }
+.plugin-runtime-details { margin-top: 36px; border-top: 1px solid var(--muted); padding-top: 10px; color: var(--muted); font-size: 12px; }
.plugin-runtime-details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.plugin-show-detail { max-width: 720px; margin: 0 auto; }
.plugin-detail-navigation { display: flex; align-items: center; justify-content: space-between; margin: -12px 0 23px; }
@@ -158,18 +158,18 @@
.plugin-detail-header { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 30px; }
.plugin-detail-header h1 { margin: 1px 0 9px; font-size: 25px; font-weight: 600; letter-spacing: -.035em; outline: none; }
.plugin-detail-header p, .plugin-detail-section p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.8; }
-.plugin-activation { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 23px; margin: 24px 0; border: 1px solid #ffffffdc; border-radius: 18px; background: #ffffff85; box-shadow: 0 1px 7px #2f416004; }
+.plugin-activation { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 23px; margin: 24px 0; border: 1px solid var(--canvas); border-radius: 11px; background: var(--canvas); box-shadow: 0 1px 7px #00000008; }
.plugin-activation > div { display: grid; gap: 9px; }
.plugin-activation strong { font-size: 14px; font-weight: 550; }
-.plugin-switch { width: 43px; min-height: 26px; padding: 3px; border: 0; border-radius: 20px; background: #cbd0dc; transition: background .2s; }
-.plugin-switch span { display: block; width: 20px; height: 20px; border-radius: 100%; background: white; box-shadow: 0 1px 3px #24304b25; transition: transform .2s; }
-.plugin-switch[aria-checked="true"] { background: #7983ac; }
+.plugin-switch { width: 43px; min-height: 26px; padding: 3px; border: 0; border-radius: 12px; background: var(--line); transition: background .2s; }
+.plugin-switch span { display: block; width: 20px; height: 20px; border-radius: 100%; background: white; box-shadow: 0 1px 3px #00000008; transition: transform .2s; }
+.plugin-switch[aria-checked="true"] { background: var(--accent); }
.plugin-switch[aria-checked="true"] span { transform: translateX(17px); }
-.plugin-detail-section { padding: 25px 0; border-bottom: 1px solid #26334c0e; }
+.plugin-detail-section { padding: 25px 0; border-bottom: 1px solid var(--muted); }
.plugin-detail-section h3 { margin: 0 0 15px; font-size: 14px; font-weight: 600; }
.plugin-detail-section ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.plugin-detail-section li { display: flex; align-items: flex-start; gap: 11px; font-size: 14px; line-height: 1.6; color: var(--muted); }
-.plugin-detail-section li svg { flex: none; margin-top: 4px; color: #6a8d80; }
+.plugin-detail-section li svg { flex: none; margin-top: 4px; color: var(--success, #51846d); }
.plugin-detail-section p + p { margin-top: 12px; }
.plugin-detail-facts { display: flex; flex-wrap: wrap; gap: 24px 46px; margin: 26px 0; font-size: 12px; }
.plugin-detail-facts > div { display: grid; gap: 9px; }
@@ -178,19 +178,19 @@
.plugin-market .plugin-primary { display: inline-flex; align-items: center; gap: 9px; width: auto; min-height: 44px; font-size: 14px; padding: 10px 19px; margin: 0 0 8px; }
.plugin-progress { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.plugin-progress svg { animation: extension-auth-spin 1.2s linear infinite; }
-.plugin-market button:focus-visible { outline: 2px solid #8c98be; outline-offset: 3px; }
+.plugin-market button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 700px) { .plugin-grid { grid-template-columns: minmax(0, 1fr); gap: 5px; margin-top: 15px; } .plugin-tile-main { min-height: 104px; } .plugin-detail-header { gap: 16px; } .plugin-detail-header h1 { font-size: 23px; } .plugin-detail-facts { gap: 24px; } }
@media (prefers-reduced-motion: reduce) { .plugin-market * { animation: none !important; transition: none !important; } }
-.plugin-update-tag { color: #5d70a0; font-size: 11px; font-weight: 600; }
-.plugin-update-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 21px; border: 1px solid #d9e1ef; border-radius: 16px; background: #f8faffb3; margin: 20px 0; }
+.plugin-update-tag { color: var(--muted); font-size: 11px; font-weight: 600; }
+.plugin-update-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 21px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); margin: 20px 0; }
.plugin-update-banner > div { display: grid; gap: 7px; }
.plugin-update-banner strong { font-size: 13px; font-weight: 550; }
.plugin-update-banner small { color: var(--muted); font-size: 12px; }
.plugin-detail-navigation { justify-content: flex-end; margin-bottom: 12px; min-height: 30px; }
-.plugin-setup-guide { margin: 0 0 28px; padding: 23px 26px; border-radius: 20px; background: rgba(255,255,255,.5); border: 1px solid rgba(105,115,151,.10); color: var(--muted); font-size: 14px; line-height: 1.8; }
+.plugin-setup-guide { margin: 0 0 28px; padding: 23px 26px; border-radius: 12px; background: var(--canvas); border: 1px solid var(--line); color: var(--muted); font-size: 14px; line-height: 1.8; }
.plugin-setup-guide h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--ink); }
.plugin-setup-guide ol { padding-left: 22px; }
.plugin-setup-guide li { padding: 3px 0 7px 4px; }
@@ -198,14 +198,14 @@
.plugin-tutorial { margin: 0 0 28px; max-width: 800px; }
.plugin-tutorial-heading h2 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.plugin-tutorial-heading p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 14px; }
-.plugin-tutorial video, .plugin-tutorial-preview { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; background: #e9edf3; border: 1px solid rgba(105,115,151,.10); }
+.plugin-tutorial video, .plugin-tutorial-preview { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 11px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.plugin-tutorial-preview { position: relative; padding: 0; cursor: pointer; }
.plugin-tutorial-preview img { width:100%; height:100%; object-fit:contain; }
-.plugin-tutorial-preview span { position:absolute; inset:0; display:flex; gap:12px; flex-direction:column; align-items:center; justify-content:center; background:rgba(21,31,47,.27); color:white; font-size:13px; }
+.plugin-tutorial-preview span { position:absolute; inset:0; display:flex; gap:12px; flex-direction:column; align-items:center; justify-content:center; background:var(--scrim, #17172055); color:white; font-size:13px; }
.plugin-setup-guide summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink); }
.plugin-setup-guide[open] summary { margin-bottom: 16px; }
-.extension-auth-file { display: grid; justify-items: start; gap: 12px; padding: 22px; border: 1px dashed #c8ccda; border-radius: 15px; background: #ffffff80; color: var(--muted); }
+.extension-auth-file { display: grid; justify-items: start; gap: 12px; padding: 22px; border: 1px dashed var(--line); border-radius: 15px; background: var(--canvas); color: var(--muted); }
.extension-auth-file p { margin: 0; font-size: 13px; line-height: 1.65; }
.extension-auth-file .extension-file-input { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; overflow: hidden; }
diff --git a/frontend/src/files/FileIcon.tsx b/frontend/src/files/FileIcon.tsx
new file mode 100644
index 0000000..f6a09e3
--- /dev/null
+++ b/frontend/src/files/FileIcon.tsx
@@ -0,0 +1,15 @@
+import { FileArchive, FileAudio, FileCode, FileImage, FileText, FileVideo } from 'lucide-react'
+import icons from '../assets/file-icons/vscode-icons.json'
+const formats: Record<string, keyof typeof icons> = {
+ pdf: 'pdf', doc: 'word', docx: 'word', odt: 'word', rtf: 'word',
+ xls: 'excel', xlsx: 'excel', csv: 'excel', ods: 'excel',
+ ppt: 'powerpoint', pptx: 'powerpoint', odp: 'powerpoint', md: 'markdown', markdown: 'markdown',
+}
+export function FileIcon({ name }: { name: string }) {
+ const extension = name.split('.').at(-1)?.toLowerCase() ?? ''
+ const svg = icons[formats[extension]]
+ const Icon = /^(zip|tar|gz|rar|7z)$/.test(extension) ? FileArchive : /^(png|jpg|jpeg|gif|webp|svg)$/.test(extension) ? FileImage
+ : /^(mp3|wav|m4a|flac)$/.test(extension) ? FileAudio : /^(mp4|mov|webm)$/.test(extension) ? FileVideo
+ : /^(js|ts|json|html|css|py|go|sh|yaml)$/.test(extension) ? FileCode : FileText
+ return <span className="file-type-icon" aria-hidden="true">{svg ? <img src={'data:image/svg+xml,' + encodeURIComponent(svg)} alt="" /> : <Icon size={22} strokeWidth={1.5} />}</span>
+}
diff --git a/frontend/src/layout/NavigationRail.tsx b/frontend/src/layout/NavigationRail.tsx
new file mode 100644
index 0000000..5f8a4ba
--- /dev/null
+++ b/frontend/src/layout/NavigationRail.tsx
@@ -0,0 +1,50 @@
+import { useEffect, useRef, useState } from 'react'
+import { CalendarClock, FolderOpen, MessageCircle, Power, Puzzle, Settings2 } from 'lucide-react'
+import { HarnessAvatar } from '../HarnessAvatar'
+import { useLocale } from '../locale'
+
+type Props = {
+ userId: string; section: 'chats' | 'tasks' | 'plugins' | 'settings'; chatsOpen: boolean; filesOpen: boolean
+ ready: boolean; stopping: boolean; error: string
+ onChats: () => void; onTasks: () => void; onPlugins: () => void; onFiles: () => void; onSettings: () => void
+ onStop: () => void
+}
+export function NavigationRail(props: Props) {
+ const { t } = useLocale()
+ const [account, setAccount] = useState(false)
+ const dock = useRef<HTMLDivElement>(null)
+ useEffect(() => {
+ if (!account) return
+ const outside = (event: PointerEvent) => { if (!dock.current?.contains(event.target as Node)) setAccount(false) }
+ document.addEventListener('pointerdown', outside)
+ return () => document.removeEventListener('pointerdown', outside)
+ }, [account])
+ const items = [
+ { id: 'chats', label: 'Chats', Icon: MessageCircle, run: props.onChats },
+ { id: 'tasks', label: 'Tasks', Icon: CalendarClock, run: props.onTasks },
+ { id: 'plugins', label: 'Plugin market', Icon: Puzzle, run: props.onPlugins },
+ { id: 'files', label: 'File system', Icon: FolderOpen, run: props.onFiles },
+ ] as const
+ return <nav className="navigation-rail" aria-label={t('Main navigation')}>
+ <button className="rail-brand" type="button" aria-label={t('Open chats')} title="Go Bot" onClick={props.onChats}><HarnessAvatar className="rail-logo" /></button>
+ <div className="rail-links">{items.map(({ id, label, Icon, run }) => <button key={id} type="button" className="rail-button" onClick={run}
+ disabled={!props.ready && (id === 'files' || id === 'tasks')} aria-label={t(label)} title={t(label)}
+ aria-current={id !== 'files' && props.section === id ? 'page' : undefined}
+ aria-expanded={id === 'chats' ? props.chatsOpen : id === 'files' ? props.filesOpen : undefined}
+ aria-controls={id === 'chats' ? 'chat-sidebar' : id === 'files' ? 'host-files' : undefined}>
+ <Icon size={20} strokeWidth={1.65} /><span className="rail-tooltip">{t(label)}</span>
+ </button>)}</div>
+ <div className="rail-bottom">
+ <button type="button" className="rail-button" aria-label={t('Settings')} title={t('Settings')} aria-current={props.section === 'settings' ? 'page' : undefined} onClick={props.onSettings}><Settings2 size={20} strokeWidth={1.65} /><span className="rail-tooltip">{t('Settings')}</span></button>
+ <div className="rail-account" ref={dock} onKeyDown={event => { if (event.key === 'Escape') { setAccount(false); dock.current?.querySelector<HTMLButtonElement>('button')?.focus() } }}>
+ <button id="account-menu-toggle" className="rail-avatar" type="button" aria-label={t('Account actions')} title={props.userId} aria-expanded={account} onClick={() => setAccount(value => !value)}>{Array.from(props.userId)[0]?.toUpperCase()}</button>
+ {account && <div className="account-popover" role="group" aria-label={t('Account actions')}>
+ <div className="rail-account-heading"><strong>{props.userId}</strong><span>{t(props.ready ? 'Personal workspace' : 'Host unavailable')}</span></div>
+ <button type="button" onClick={() => { setAccount(false); props.onSettings() }}><Settings2 size={17} />{t('Settings')}</button>
+ <button type="button" className="stop-host" disabled={!props.ready || props.stopping} onClick={props.onStop}><Power size={17} />{t(props.stopping ? 'Stopping Host…' : 'Stop Host')}</button>
+ {props.error && <p className="feedback" role="alert">{t(props.error)}</p>}
+ </div>}
+ </div>
+ </div>
+ </nav>
+}
diff --git a/frontend/src/layout/Theme.tsx b/frontend/src/layout/Theme.tsx
new file mode 100644
index 0000000..f807d49
--- /dev/null
+++ b/frontend/src/layout/Theme.tsx
@@ -0,0 +1,26 @@
+import { createContext, useContext, useLayoutEffect, useState, type ReactNode } from 'react'
+import { Moon, Sun } from 'lucide-react'
+import { useLocale } from '../locale'
+
+type Theme = 'light' | 'dark'
+const Context = createContext<{ theme: Theme; toggle: () => void } | undefined>(undefined)
+function initial(): Theme {
+ try { return localStorage.getItem('go-bot.web-theme') === 'dark' ? 'dark' : 'light' } catch { return 'light' }
+}
+export function ThemeProvider({ children }: { children: ReactNode }) {
+ const [theme, setTheme] = useState(initial)
+ useLayoutEffect(() => {
+ document.documentElement.dataset.theme = theme
+ document.querySelector('meta[name="theme-color"]')?.setAttribute('content', theme === 'dark' ? '#141416' : '#ffffff')
+ try { localStorage.setItem('go-bot.web-theme', theme) } catch { /* Storage can be disabled. */ }
+ }, [theme])
+ return <Context.Provider value={{ theme, toggle: () => setTheme(value => value === 'light' ? 'dark' : 'light') }}>{children}</Context.Provider>
+}
+export function ThemeToggle() {
+ const { t } = useLocale()
+ const value = useContext(Context)!
+ const label = t(value.theme === 'light' ? 'Switch to dark theme' : 'Switch to light theme')
+ return <button type="button" className="icon-button theme-toggle" aria-label={label} title={label} onClick={value.toggle}>
+ {value.theme === 'light' ? <Moon size={18} /> : <Sun size={18} />}
+ </button>
+}
diff --git a/frontend/src/layout/WorkspaceHeader.tsx b/frontend/src/layout/WorkspaceHeader.tsx
new file mode 100644
index 0000000..f659ca7
--- /dev/null
+++ b/frontend/src/layout/WorkspaceHeader.tsx
@@ -0,0 +1,11 @@
+import type { ReactNode } from 'react'
+import { ChevronRight } from 'lucide-react'
+import { useLocale } from '../locale'
+export function WorkspaceHeader({ title, start, actions }: { title: string; start?: ReactNode; actions?: ReactNode }) {
+ const { t } = useLocale()
+ return <header className="workspace-header">
+ <div className="workspace-header-start">{start ?? <span className="workspace-label">Go Bot</span>}</div>
+ <div className="workspace-breadcrumb"><span>Go Bot</span><ChevronRight size={13} /><strong title={title}>{t(title)}</strong></div>
+ <div className="workspace-header-actions">{actions}</div>
+ </header>
+}
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index c39fd9e..94da2c1 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -1,6 +1,8 @@
import { createRoot } from 'react-dom/client'
import { App } from './App'
import { LocaleProvider } from './locale'
+import { ThemeProvider } from './layout/Theme'
+import '@fontsource-variable/inter/wght.css'
import './styles/app.css'
-createRoot(document.getElementById('root')!).render(<LocaleProvider><App /></LocaleProvider>)
+createRoot(document.getElementById('root')!).render(<LocaleProvider><ThemeProvider><App /></ThemeProvider></LocaleProvider>)
diff --git a/frontend/src/messages.ts b/frontend/src/messages.ts
index a1308c5..801b1cf 100644
--- a/frontend/src/messages.ts
+++ b/frontend/src/messages.ts
@@ -4,8 +4,50 @@ import { proactiveChinese } from './settings/proactiveState'
export type Language = 'en' | 'zh-CN'
const chinese: Readonly<Record<string, string>> = {
+ 'Copy table': '复制表格', 'Copy code': '复制代码', 'Copied': '已复制', 'Copy failed. Try again.': '复制失败,重试', 'Code': '代码',
+ 'Table — scroll horizontally': '表格,可左右滚动', 'Code — scroll horizontally': '代码,可左右滚动',
...extensionChinese,
...proactiveChinese,
+ 'Switch to dark theme': '切换为深色主题',
+ 'Switch to light theme': '切换为浅色主题',
+ 'Main navigation': '主导航',
+ 'Tasks': '定时任务',
+ 'Your conversations': '你的会话',
+ 'Message Go Bot': '发送消息给 Go Bot',
+ 'Download file': '下载文件',
+ 'Close image': '关闭图片',
+ 'Image preview': '图片预览',
+ 'Download image': '下载图片',
+ 'Scheduled work, all in one place.': '在这里查看助手安排的定时任务。',
+ 'Refresh tasks': '刷新任务',
+ 'Could not load tasks. Try again.': '无法读取任务,请重试。',
+ 'Upcoming': '即将执行',
+ 'Completed': '已完成',
+ 'Loading tasks…': '正在加载任务…',
+ 'No upcoming tasks': '暂无待执行任务',
+ 'No completed tasks': '暂无已完成任务',
+ 'Ask your agent to schedule something in a conversation.': '你可以在会话中让助手安排定时任务。',
+ 'Active': '运行中',
+ 'Paused': '已暂停',
+ 'Next run': '下次执行',
+ 'Schedule': '执行规则',
+ 'Delivery target': '投递会话',
+ 'New conversation each time': '每次新建会话',
+ 'Create a conversation once': '首次新建会话后复用',
+ 'Existing conversation': '指定会话',
+ 'Last delivery': '最近投递',
+ 'Working directory': '工作目录',
+ 'Instructions': '任务内容',
+ 'The last delivery is queued or running.': '最近一次投递正在排队或执行。',
+ 'Open conversation': '打开会话',
+ 'One time': '单次执行',
+ 'Every': '每',
+ 'hours': '小时',
+ 'minutes': '分钟',
+ 'seconds': '秒',
+ 'Daily': '每天',
+ 'Weekly': '每周',
+ 'Custom rule': '自定义规则',
'Add an endpoint to start chatting.': '添加端点后即可开始聊天。',
'Main chat': '主会话',
'Preparing browser and Office capabilities…': '正在准备浏览器与 Office 能力…',
@@ -208,7 +250,15 @@ const chinese: Readonly<Record<string, string>> = {
"Read file": "读取文件",
"Write file": "写入文件",
"Edit file": "编辑文件",
- "Read image": "读取图片",
+ "Read image": "查看图片",
+ "Previous images": "向左浏览图片",
+ "Next images": "向右浏览图片",
+ "View images": "查看图片",
+ "1 image": "1 张",
+ "{count} images": "{count} 张",
+ "Images — scroll horizontally": "图片,可左右滑动",
+ "No images to display.": "没有可显示的图片。",
+ "Image unavailable. Retry": "图片暂不可用,重试",
"Generate image": "生成图片",
"Run command": "执行命令",
"Search the web": "搜索网页",
diff --git a/frontend/src/sessions/Sidebar.tsx b/frontend/src/sessions/Sidebar.tsx
index ba03b54..5e90523 100644
--- a/frontend/src/sessions/Sidebar.tsx
+++ b/frontend/src/sessions/Sidebar.tsx
@@ -1,13 +1,11 @@
import { useEffect, useRef, useState } from 'react'
import { useLocale } from '../locale'
-import { ChevronDown, Ellipsis, FolderTree, MessageSquare, MessageSquarePlus, Power, Puzzle, Settings, Trash2, X } from 'lucide-react'
-import { HarnessAvatar } from '../HarnessAvatar'
+import { Ellipsis, MessageSquare, Plus, Trash2, X } from 'lucide-react'
import type { SessionRow } from '../api/controller'
import type { TranscriptCache } from '../chat/transcriptCache'
type Props = {
cache: TranscriptCache
- userId: string
rows: SessionRow[]
selected?: string
hasMore: boolean
@@ -16,16 +14,7 @@ type Props = {
error: string
needsModel: boolean
onSettings: () => void
- onPlugins: () => void
- pluginsOpen: boolean
- filesOpen: boolean
- filesAvailable: boolean
filesOverlay: boolean
- onFiles: () => void
- hostReady: boolean
- stoppingHost: boolean
- stopHostError: string
- onStopHost: () => Promise<void>
drawerOpen: boolean
onCreate: () => void
onChoose: (id: string) => void
@@ -41,19 +30,6 @@ export function Sidebar(props: Props) {
const { language, t } = useLocale()
const rowTitle = (row: SessionRow) => row.isMain ? 'Go Bot' : row.title || t('New chat')
const [menu, setMenu] = useState<ContextMenu | null>(null)
- const [accountOpen, setAccountOpen] = useState(false)
- const accountDock = useRef<HTMLDivElement>(null)
- const accountButton = useRef<HTMLButtonElement>(null)
-
- useEffect(() => {
- if (!accountOpen) return
- function outside(event: PointerEvent) {
- if (!accountDock.current?.contains(event.target as Node)) setAccountOpen(false)
- }
- document.addEventListener('pointerdown', outside)
- return () => document.removeEventListener('pointerdown', outside)
- }, [accountOpen])
-
const [confirm, setConfirm] = useState<ContextMenu | null>(null)
const [deleting, setDeleting] = useState(false)
const menuRef = useRef<HTMLButtonElement>(null)
@@ -62,7 +38,6 @@ export function Sidebar(props: Props) {
useEffect(() => {
if (props.drawerOpen) drawerClose.current?.focus()
- else setAccountOpen(false)
}, [props.drawerOpen])
useEffect(() => {
@@ -102,17 +77,16 @@ export function Sidebar(props: Props) {
<>
{props.drawerOpen && <button type="button" className="scrim" onClick={props.onClose} aria-label={t('Close chats')} />}
<aside id="chat-sidebar" className={props.drawerOpen ? 'sidebar drawer-open' : 'sidebar'} aria-label={t('Chats')}
- inert={props.filesOverlay}
+ inert={!props.drawerOpen || props.filesOverlay} aria-hidden={!props.drawerOpen}
onKeyDown={event => { if (event.key === 'Escape' && !menu && !event.defaultPrevented) props.onClose() }}>
- <div className="brand">
- <HarnessAvatar className="brand-mark" />
- <span>Go Bot</span>
- <button ref={drawerClose} type="button" className="icon-button drawer-close" onClick={props.onClose} aria-label={t('Close chats')}><X size={21} /></button>
+ <div className="sidebar-header">
+ <h2>{t('Chats')}</h2>
+ <button ref={drawerClose} type="button" className="icon-button drawer-close" onClick={props.onClose} aria-label={t('Close chats')}><X size={18} /></button>
</div>
<button type="button" className="new-chat" onClick={props.onCreate} disabled={props.creating}>
- <MessageSquarePlus size={21} strokeWidth={1.75} /><span>{t('New chat')}</span>
+ <Plus size={18} strokeWidth={1.7} /><span>{t('New chat')}</span>
</button>
- <div className="section-heading">{t('Chats')}</div>
+ <div className="section-heading">{t('Your conversations')}</div>
<div className="session-list">
{props.error && <p className="sidebar-feedback" role="alert">{t(props.error)} <button type="button" className="text-button" onClick={props.needsModel ? props.onSettings : props.onRetry}>{props.needsModel ? t('Open model settings') : t('Retry')}</button></p>}
{!props.error && !props.isLoading && props.rows.length === 0 && <p className="sidebar-feedback">{t('No chats yet')}</p>}
@@ -149,41 +123,6 @@ export function Sidebar(props: Props) {
))}
{props.hasMore && <button type="button" className="text-button more" disabled={props.isLoading} onClick={props.onMore}>{t('Load more')}</button>}
</div>
- <div className="sidebar-footer">
- <button id="plugin-market-link" type="button" className="sidebar-destination" aria-current={props.pluginsOpen ? 'page' : undefined} onClick={props.onPlugins}><Puzzle size={19} strokeWidth={1.7} /><span>{t('Plugin market')}</span></button>
- <div className="account-dock" ref={accountDock} onBlur={event => {
- if (!event.currentTarget.contains(event.relatedTarget)) setAccountOpen(false)
- }} onKeyDown={event => {
- if (event.key === 'Escape' && accountOpen) {
- event.preventDefault()
- setAccountOpen(false)
- accountButton.current?.focus()
- }
- }}>
- <button ref={accountButton} type="button" id="account-menu-toggle" className="account-trigger"
- aria-expanded={accountOpen} aria-controls="account-actions" onClick={() => setAccountOpen(value => !value)}>
- <span className="account-avatar" aria-hidden="true">{Array.from(props.userId)[0]?.toUpperCase()}</span>
- <span className="account-identity"><strong title={props.userId}>{props.userId}</strong>
- <small>{props.hostReady ? t('Personal workspace') : t('Host unavailable')}</small></span>
- <ChevronDown size={16} aria-hidden="true" className="account-chevron" />
- </button>
- {accountOpen && <div id="account-actions" className="account-popover" role="group" aria-label={t('Account actions')}>
- <button type="button" onClick={() => { setAccountOpen(false); props.onSettings() }}>
- <Settings size={18} aria-hidden="true" /> {t('Settings')}
- </button>
- <button type="button" onClick={() => { setAccountOpen(false); props.onFiles() }}
- disabled={!props.filesAvailable} aria-controls="host-files" aria-expanded={props.filesOpen}>
- <FolderTree size={18} aria-hidden="true" /> {t('File system')}
- </button>
- <div className="account-menu-divider" />
- <button type="button" className="stop-host" onClick={() => { void props.onStopHost() }}
- disabled={!props.hostReady || props.stoppingHost}>
- <Power size={18} aria-hidden="true" /> {props.stoppingHost ? t('Stopping Host…') : t('Stop Host')}
- </button>
- </div>}
- {props.stopHostError && <p className="sidebar-feedback" role="alert">{t(props.stopHostError)}</p>}
- </div>
- </div>
</aside>
{menu && (
<div className="context-menu" role="menu" aria-label={t('Chat actions')}
diff --git a/frontend/src/styles/app.css b/frontend/src/styles/app.css
index b30f181..c93b198 100644
--- a/frontend/src/styles/app.css
+++ b/frontend/src/styles/app.css
@@ -1,748 +1,4 @@
-:root {
- color: #222931;
- background: #eef2f9;
- font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
- font-synthesis: none;
- text-rendering: optimizeLegibility;
- --muted: #566274;
- --accent: #435592;
- --focus: #5369c9;
- --sidebar-width: clamp(250px, 21vw, 304px);
- --content-width: 900px;
-}
-*, *::before, *::after { box-sizing: border-box; }
-html, body, #root { margin: 0; height: 100%; }
-body { min-width: 320px; }
-button, textarea { font: inherit; color: inherit; }
-button { cursor: pointer; }
-button:disabled { cursor: default; }
-button:focus-visible, textarea:focus-visible, a:focus-visible {
- outline: 2px solid var(--focus);
- outline-offset: 3px;
-}
-.app {
- display: grid;
- grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
- min-height: 0;
- height: 100dvh;
- background:
- radial-gradient(ellipse at -12% 105%, #b3b4e9 0%, transparent 49%),
- linear-gradient(155deg, #e5eefb, #e4e8f7 65%, #dce4f8);
-}
-.sidebar {
- min-height: 0;
- display: flex;
- flex-direction: column;
- padding: 38px 23px 24px;
-}
-.brand {
- display: flex;
- align-items: center;
- gap: 12px;
- min-height: 41px;
- padding: 0 5px;
- font-size: 22px;
- font-weight: 680;
- letter-spacing: -.055em;
- white-space: nowrap;
-}
-.brand-mark {
- width: 41px;
- height: 41px;
- display: block;
- flex: none;
- object-fit: contain;
-}
-.new-chat {
- width: 100%;
- min-height: 57px;
- margin: 37px 0 35px;
- padding: 13px 16px;
- display: flex;
- gap: 11px;
- justify-content: center;
- align-items: center;
- background: #f4f7ffcc;
- border: 1px solid #ffffff91;
- border-radius: 16px;
- font-weight: 570;
- font-size: 15px;
- transition: background .16s, box-shadow .16s;
-}
-.new-chat:hover:not(:disabled) { background: #f9fbff; box-shadow: 0 7px 20px #6879b218; }
-.new-chat:disabled { opacity: .67; }
-.section-heading {
- padding: 0 10px 12px;
- font-size: 13px;
- font-weight: 650;
- color: #48546b;
-}
-.session-list { min-height: 0; overflow: auto; scrollbar-width: thin; }
-.account-dock { position: relative; flex: none; margin-top: auto; padding-top: 12px; }
-.account-trigger {
- display: flex; align-items: center; gap: 11px; width: 100%; min-width: 0; min-height: 64px;
- padding: 9px 13px; border: 1px solid #fff7; border-radius: 17px;
- background: #f5f8ff85; text-align: left; transition: background .15s, border-color .15s;
-}
-.account-trigger:hover, .account-trigger[aria-expanded="true"] { background: #f7faffb8; border-color: #fffc; }
-.account-avatar {
- display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
- color: #fff; background: #5869a9; font-size: 15px; font-weight: 650;
-}
-.account-identity { display: grid; gap: 2px; flex: 1; min-width: 0; font-size: 14px; }
-.account-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
-.account-identity small { color: var(--muted); font-size: 11px; }
-.account-chevron { flex: none; color: var(--muted); transition: transform .15s; }
-.account-trigger[aria-expanded="true"] .account-chevron { transform: rotate(180deg); }
-.account-popover {
- position: absolute; z-index: 7; inset: auto 0 calc(100% + 8px); display: grid; gap: 3px;
- padding: 9px; border: 1px solid #fff9; border-radius: 18px; background: #f7f9ffee;
- box-shadow: 0 12px 38px #25335025, inset 0 1px #fffc; backdrop-filter: blur(18px);
-}
-.account-popover button {
- display: flex; align-items: center; gap: 12px; min-height: 43px; padding: 0 10px;
- border: 0; border-radius: 10px; text-align: left; background: transparent; font-size: 14px;
-}
-.account-popover button:hover:not(:disabled) { background: #e3e9f8; }
-.account-popover button:disabled { opacity: .52; }
-.account-popover button svg { flex: none; color: #56647c; }
-.account-popover .stop-host, .account-popover .stop-host svg { color: #9b354b; }
-.account-menu-divider { height: 1px; margin: 5px 6px; background: #dce3f1; }
-.chat-row {
- display: flex;
- align-items: center;
- min-width: 0;
- min-height: 46px;
- margin-bottom: 4px;
- padding-right: 5px;
- border-radius: 10px;
-}
-.chat-row:hover { background: #f8faff59; }
-.chat-row.selected { background: #f8faff95; }
-.chat-link {
- display: flex;
- flex: 1;
- align-items: center;
- min-width: 0;
- min-height: 46px;
- padding: 7px 8px 7px 10px;
- gap: 10px;
- border: 0;
- border-radius: 10px;
- background: none;
- text-align: left;
- font-size: 13px;
-}
-.chat-link svg { flex: none; color: #596780; }
-.chat-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.chat-label small { display: block; color: var(--muted); font-size: 11px; padding-top: 2px; }
-.icon-button {
- display: grid;
- place-items: center;
- border: 0;
- background: transparent;
- color: #4d5b76;
- min-width: 34px;
- min-height: 34px;
- border-radius: 9px;
-}
-.icon-button:hover { background: #f8faffb9; }
-.row-actions { flex: none; opacity: 0; }
-.chat-row:hover .row-actions, .chat-row:focus-within .row-actions, .chat-row.selected .row-actions { opacity: 1; }
-.sidebar-feedback { padding: 3px 10px; color: #515e77; font-size: 13px; line-height: 1.55; }
-.text-button { border: 0; padding: 4px 5px; color: #3d51a0; background: transparent; text-decoration: underline; }
-.more { display: block; margin: 8px; }
-.workspace {
- display: grid;
- grid-template-rows: auto minmax(0, 1fr);
- min-width: 0;
- min-height: 0;
- overflow: hidden;
- border-radius: 31px 0 0 0;
- background:
- radial-gradient(ellipse at 89% 0%, #ebe5fa 0%, transparent 55%),
- radial-gradient(ellipse at 48% 65%, #e0f1fb 0%, transparent 70%),
- linear-gradient(133deg, #e9f2fc, #e7ecfb 61%, #e5eefb);
- box-shadow: -1px 0 0 #ffffff60;
-}
-.topbar {
- min-height: 63px;
- padding: 19px 23px;
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- color: #414955;
- font-size: 15px;
- font-weight: 600;
-}
-.welcome {
- width: min(var(--content-width), 100%);
- min-height: 0;
- margin-inline: auto;
- padding: clamp(42px, 13dvh, 123px) 35px 26px;
- overflow: auto;
-}
-.welcome-copy { text-align: center; }
-.chat-empty {
- min-height: 0;
- display: grid;
- place-items: center;
-}
-.chat-empty .welcome-avatar { margin: 0; }
-.welcome-avatar {
- width: 142px;
- height: 142px;
- margin: 0 auto 19px;
- display: block;
- object-fit: contain;
- filter: drop-shadow(0 9px 12px #4f619631);
-}
-.welcome h1 {
- margin: 0 0 10px;
- letter-spacing: -.065em;
- font-size: clamp(40px, 4.5vw, 66px);
- font-weight: 610;
- line-height: 1.06;
-}
-.welcome-copy p {
- margin: 0;
- font-size: clamp(18px, 2.2vw, 27px);
- color: #596575;
- letter-spacing: -.035em;
-}
-.welcome-input { margin-top: clamp(36px, 8dvh, 82px); }
-.composer {
- display: grid;
- align-content: space-between;
- min-height: 130px;
- padding: 18px 19px 15px;
- gap: 5px;
- border-radius: 24px;
- background: #f8fdffce;
- border: 1px solid #ffffffe3;
- box-shadow: 0 15px 55px #677ea418, 0 1px 2px #7290ae10;
-}
-.composer:focus-within { border-color: #a7b4e3; }
-.composer textarea {
- display: block;
- border: 0;
- padding: 0 3px;
- outline: none;
- resize: none;
- background: transparent;
- line-height: 1.55;
- font-size: 16px;
-}
-.composer textarea:focus-visible { outline: none; }
-.composer textarea::placeholder { color: #596776; opacity: 1; }
-.composer-actions { display: flex; justify-content: flex-end; }
-.send-button {
- width: 41px;
- height: 41px;
- border: 0;
- border-radius: 14px;
- display: grid;
- place-items: center;
- background: #5667b1;
- color: #fff;
- box-shadow: 0 4px 10px #4558a52c;
-}
-.send-button:hover:not(:disabled) { background: #4556a0; }
-.send-button:disabled { color: #5f6e8d; background: #e3eafb; box-shadow: none; }
-.conversation { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
-.transcript-scroll { overflow: auto; scrollbar-width: thin; }
-.transcript, .chat-input { width: min(var(--content-width), 100%); margin-inline: auto; padding-inline: 35px; }
-.transcript { display: flex; flex-direction: column; gap: 19px; padding-block: 28px 22px; }
-.chat-input { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
-.chat-input .composer { min-height: 108px; }
-.message { max-width: 100%; overflow-wrap: anywhere; font-size: 16px; line-height: 1.65; }
-.user-message {
- align-self: flex-end;
- max-width: min(86%, 650px);
- white-space: pre-wrap;
- padding: 10px 15px;
- border-radius: 17px 17px 4px 17px;
- background: #e1e7fb;
- border: 1px solid #d6dff8;
-}
-.assistant-message { display: flex; align-items: flex-start; gap: 12px; }
-.reply-mark {
- flex: none;
- display: block;
- width: 31px;
- height: 31px;
- margin-top: 1px;
- padding: 2px;
- border-radius: 10px;
- background: #edf3ff;
- object-fit: contain;
-}
-.markdown { min-width: 0; }
-.markdown > div { min-width: 0; }
-.markdown > :first-child { margin-top: 0; }
-.markdown > :last-child { margin-bottom: 0; }
-.markdown pre { max-width: 100%; overflow: auto; white-space: pre; overflow-wrap: normal; padding: 11px 13px; border-radius: 10px; background: #f4f7ffcc; border: 1px solid #cad7ed; }
-.markdown code { font-size: .9em; }
-.markdown :not(pre) > code { padding: .08em .28em; border-radius: 4px; background: #e9eefb; }
-.markdown-table-scroll { overflow-x: auto; margin-block: 1em; border: 1px solid #cad7ed; border-radius: 10px; }
-.markdown table { width: 100%; border-collapse: collapse; font-size: .9em; }
-.markdown th, .markdown td { min-width: 5rem; padding: 7px 11px; text-align: start; vertical-align: top; border-bottom: 1px solid #dce3f3; }
-.markdown th { background: #edf2fc; }
-.markdown tbody tr:last-child td { border-bottom: 0; }
-.markdown a { color: #374e9b; }
-.chat-status, .feedback { color: var(--muted); font-size: 13px; margin: 0 0 7px; }
-.feedback { color: #843a53; padding: 7px 3px; }
-.welcome-input .feedback { margin-top: 5px; }
-.context-menu {
- position: fixed;
- z-index: 30;
- width: 180px;
- padding: 4px;
- border: 1px solid #dce1f0;
- border-radius: 12px;
- background: #f9fbff;
- box-shadow: 0 10px 24px #3b4c802c;
-}
-.context-menu button {
- display: flex; align-items: center; gap: 9px;
- width: 100%; min-height: 39px; padding: 8px;
- border: 0; border-radius: 8px; background: none;
- text-align: left; font-size: 14px; color: #8b3c54;
-}
-.context-menu button:focus, .context-menu button:hover { background: #f1e9f2; outline: 0; }
-.archive-dialog {
- width: min(385px, calc(100vw - 32px));
- padding: 23px;
- border: 1px solid #e0e6f6;
- border-radius: 20px;
- background: #f8fbff;
- color: #222931;
- box-shadow: 0 18px 50px #35436c35;
-}
-.archive-dialog::backdrop { background: #26324f47; }
-.archive-dialog h2 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
-.archive-dialog p { color: #505b70; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
-.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
-.dialog-actions button { padding: 8px 12px; border: 1px solid #d7def0; background: #edf1fb; border-radius: 9px; font-size: 14px; }
-.dialog-actions .danger { background: #984460; color: white; border-color: #984460; }
-.drawer-toggle, .drawer-close, .scrim { display: none; }
-.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
-.spinner { animation: spin .85s linear infinite; }
-@keyframes spin { to { transform: rotate(360deg); } }
-@media (max-width: 680px) {
- .app { grid-template-columns: minmax(0, 1fr); }
- .workspace { border-radius: 0; }
- .topbar { min-height: 55px; }
- .drawer-toggle { display: grid; position: absolute; left: 12px; top: 10px; }
- .drawer-close { display: grid; margin-left: auto; }
- .scrim { display: block; position: fixed; inset: 0; z-index: 8; border: 0; background: #28375456; }
- .sidebar { display: none; }
- .sidebar.drawer-open {
- display: flex;
- position: fixed;
- z-index: 9;
- inset: 0 auto 0 0;
- width: min(290px, 84vw);
- padding: 24px 17px;
- background: linear-gradient(150deg, #e1ebfb, #d3d6f7);
- box-shadow: 10px 0 35px #3b4f7d2f;
- }
- .row-actions { opacity: 1; }
- .welcome { padding: clamp(38px, 10dvh, 95px) 19px 24px; }
- .welcome-input { margin-top: 42px; }
- .welcome-avatar { width: 116px; height: 116px; }
- .transcript, .chat-input { padding-inline: 14px; }
- .composer { min-height: 112px; padding: 14px; }
-}
-@media (hover: none) { .row-actions { opacity: 1; } }
-@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
-
-.account-page {
- min-height: 100dvh;
- display: grid;
- place-items: center;
- padding: 28px 18px;
- background: linear-gradient(156deg, #e6effc, #d6d8f8 76%, #c4c9f2);
-}
-.account-card {
- width: min(100%, 420px);
- padding: 30px;
- border: 1px solid #fff;
- border-radius: 24px;
- background: #f9faff;
- box-shadow: 0 22px 64px #495a921f;
-}
-.account-card .brand { padding: 0; }
-.account-card-heading, .settings-header-actions {
- display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
-}
-.language-picker, .account-card .language-picker {
- display: inline-flex; align-items: center; gap: 6px; flex: none; color: var(--muted);
-}
-.language-picker select {
- border: 1px solid #d8e1f0; border-radius: 8px; min-height: 32px; padding: 0 6px;
- background: #ffffffa8; color: inherit; font: inherit; font-size: 13px;
-}
-.account-card h1 { margin: 24px 0 20px; font-size: 23px; letter-spacing: -.035em; }
-.account-card fieldset { display: grid; gap: 15px; margin: 0; padding: 0; border: 0; }
-.account-card label { display: grid; gap: 6px; font-size: 14px; font-weight: 560; }
-.account-card input {
- width: 100%;
- min-height: 44px;
- border: 1px solid #c8d2e7;
- border-radius: 10px;
- padding: 9px 11px;
- background: #fff;
- font: inherit;
- color: inherit;
-}
-.account-card input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
-.account-submit {
- min-height: 44px;
- border: 0;
- border-radius: 10px;
- background: var(--accent);
- color: #fff;
- font-weight: 600;
-}
-.account-submit:disabled { opacity: .68; }
-.account-switch { margin-top: 15px; padding: 6px 0; border: 0; background: none; color: #3e519a; font-size: 14px; }
-.account-status, .account-error { margin: 14px 0 0; font-size: 14px; }
-.account-status { display: flex; align-items: center; gap: 7px; color: var(--muted); }
-.account-error { color: #98313b; }
-
-.workspace[hidden] { display: none; }
-.composer-actions { justify-content: space-between; align-items: center; gap: 10px; }
-.composer-tools { display: flex; align-items: center; gap: 7px; min-width: 0; }
-.composer-submit { display: flex; flex: none; align-items: center; gap: 6px; }
-.stop-generation { display: grid; place-items: center; width: 37px; height: 37px; border: 0; border-radius: 12px; color: #435592; background: #e8eefb; }
-.stop-generation:hover:not(:disabled) { background: #dce6f8; }
-.attachment-button {
- display: grid; place-items: center; flex: none; width: 36px; height: 36px;
- border: 0; background: transparent; color: #526484; border-radius: 10px;
-}
-.attachment-button:hover:not(:disabled) { background: #e8eefb; }
-.attachment-button:disabled { opacity: .5; }
-.composer .send-button { flex: none; width: 37px; height: 37px; border-radius: 12px; background: #495d9e; }
-.composer .send-button:disabled { background: #e7edf8; }
-.draft-files { display: flex; flex-wrap: wrap; gap: 7px; max-height: 120px; overflow: auto; list-style: none; margin: 0 0 5px; padding: 3px; }
-.draft-files li {
- display: flex; align-items: center; gap: 8px; max-width: min(100%, 230px); min-width: 0;
- background: #edf2fc; border: 1px solid #dbe4f4; border-radius: 11px; padding: 5px;
-}
-.draft-file-preview { display: grid; place-items: center; flex: none; width: 32px; height: 32px; overflow: hidden; border-radius: 7px; background: #dfe8f8; color: #495d9e; }
-.draft-file-preview img { width: 100%; height: 100%; object-fit: cover; }
-.draft-file-label { display: grid; gap: 2px; min-width: 0; font-size: 12px; }
-.draft-file-label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 630; }
-.draft-file-label small { font-size: 10px; color: var(--muted); }
-.draft-files button { display: grid; place-items: center; width: 27px; min-height: 32px; flex: none; border: 0; border-radius: 6px; color: var(--muted); background: transparent; }
-.draft-files button:hover:not(:disabled) { color: #9b354b; background: #f3e7ed; }
-.attachment-error { margin: 0; }
-
-.model-settings { position: relative; min-width: 0; min-height: 0; overflow: auto; border-radius: 31px 0 0 0; padding: clamp(18px, 5vw, 62px); background: radial-gradient(ellipse at top left, #e3eafa, transparent 70%), #f1f4fa; }
-.settings-topbar { display: none; }
-.model-settings-panel { width: min(100%, 760px); margin: auto; padding-bottom: 38px; }
-.settings-header { display: grid; justify-items: start; gap: 21px; }
-.settings-header h1 { margin: 0; font-size: clamp(30px, 5vw, 44px); letter-spacing: -.055em; line-height: 1.1; font-weight: 660; }
-.settings-back { display: inline-flex; align-items: center; gap: 7px; background: transparent; border: 0; border-radius: 8px; padding: 6px 0; color: var(--muted); font-size: 13px; }
-.settings-back:hover { color: var(--accent); }
-.settings-nav { display: flex; overflow-x: auto; gap: clamp(10px, 3vw, 27px); margin-top: 22px; border-bottom: 1px solid #d8e1f0; }
-.settings-nav button {
- display: flex; flex: none; align-items: center; gap: 6px; min-height: 44px; white-space: nowrap;
- border: 0; border-bottom: 2px solid transparent; padding: 0 2px; background: transparent;
- color: var(--muted); font-size: clamp(12px, 2vw, 14px);
-}
-.settings-nav button:focus-visible { outline-offset: -3px; }
-.settings-nav button:hover, .settings-nav [aria-current="page"] { color: var(--accent); }
-.settings-nav [aria-current="page"] { border-color: var(--accent); font-weight: 650; }
-.settings-content { padding-top: 24px; }
-.model-settings .settings-section-title { font-size: 22px; letter-spacing: -.025em; }
-.model-settings h2 { margin: 0 0 8px; font-size: 1.075rem; overflow-wrap: anywhere; }
-.model-muted { color: #556176; overflow-wrap: anywhere; font-size: 14px; }
-.model-card { background: #ffffffbe; border: 1px solid #dde5f0; border-radius: 17px; margin: 14px 0; padding: clamp(16px, 4vw, 25px); box-shadow: 0 4px 18px #52698c0a; }
-.provider-settings-intro p { margin: 5px 0 18px; line-height: 1.5; }
-.provider-notice, .provider-current { font-size: 13px; margin: 0 0 12px; }
-.provider-notice { color: #176248; }
-.provider-current { color: #52627a; }
-.provider-current strong { margin-left: 7px; color: var(--ink, #263452); }
-.proactive-settings { max-width: 690px; }
-.proactive-control { display: flex; align-items: center; gap: 15px; padding-block: 24px; }
-.proactive-control > svg { margin-top: 2px; flex-shrink: 0; color: #596589; }
-.proactive-control-copy { flex: 1; min-width: 0; }
-.proactive-control-copy h3 { margin: 0; font-size: 15px; font-weight: 600; }
-.proactive-control-copy p { margin: 0; line-height: 1.6; font-size: 13px; }
-.proactive-switch { position: relative; display: inline-flex; width: 39px; height: 23px; flex-shrink: 0; cursor: pointer; }
-.proactive-switch input { position: absolute; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
-.proactive-switch span { width: 100%; border-radius: 20px; background: #cfd4df; transition: background .18s; pointer-events: none; }
-.proactive-switch span::after { content: ''; display: block; width: 17px; height: 17px; margin: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 3px #1d223126; transition: transform .18s; }
-.proactive-switch input:checked + span { background: #384c80; }
-.proactive-switch input:checked + span::after { transform: translateX(16px); }
-.proactive-switch input:focus-visible + span { outline: 2px solid #7d91c2; outline-offset: 4px; }
-.proactive-switch input:disabled + span { opacity: .55; }
-.proactive-status { padding: 14px 4px 18px; }
-.proactive-status-heading { display: flex; align-items: center; gap: 9px; font-size: 13px; color: #536178; }
-.proactive-dot { width: 7px; height: 7px; border-radius: 50%; background: #799a8b; }
-.proactive-dot.running { background: #6576ac; animation: proactive-breathe 1.8s ease-in-out infinite; }
-.proactive-dot.disabled, .proactive-dot.host-stopped { background: #a1a8b5; }
-.proactive-dot.error, .proactive-dot.unavailable, .proactive-dot.waiting-for-model { background: #ba9260; }
-.proactive-status dl { margin: 25px 0 0; font-size: 13px; }
-.proactive-status dl > div { display: grid; grid-template-columns: minmax(92px, auto) minmax(0, 1fr); gap: 20px; margin: 20px 0; align-items: start; }
-.proactive-status dt { display: flex; gap: 8px; align-items: center; color: #6b758a; white-space: nowrap; }
-.proactive-status dt svg { flex-shrink: 0; }
-.proactive-status dd { min-width: 0; margin: 0; color: #37445e; text-align: right; }
-.proactive-reason { color: #6b758a; line-height: 1.6; overflow-wrap: anywhere; font-size: 12px; margin: 9px 0 0; max-width: 390px; }
-@media (max-width: 600px) { .proactive-status dl > div { grid-template-columns: 1fr; gap: 10px; } .proactive-status dd { text-align: left; } .proactive-reason { max-width: none; } }
-.proactive-footer { border-top: 1px solid #dce2ec; padding-top: 18px; }
-.proactive-footer p { font-size: 12px; line-height: 1.65; max-width: 550px; }
-.proactive-footer button { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; margin-top: 5px; }
-@keyframes proactive-breathe { 50% { opacity: .35; } }
-@media (prefers-reduced-motion: reduce) { .proactive-dot.running { animation: none; } .proactive-switch span, .proactive-switch span::after { transition: none; } }
-.provider-list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid #dce5f2; border-radius: 15px; background: #fff9; }
-.provider-row + .provider-row { border-top: 1px solid #e1e8f3; }
-.provider-row-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 68px; padding: 8px clamp(12px, 3vw, 19px); }
-.provider-row-identity { min-width: 0; }
-.provider-row h3, .provider-row p { margin: 0; overflow-wrap: anywhere; }
-.provider-row h3 { font-size: 15px; font-weight: 650; }
-.provider-row p { color: #52627a; font-size: 12px; margin-top: 4px; }
-.provider-row-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
-.provider-active, .provider-edit { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; }
-.provider-active { color: #176248; }
-.provider-edit { background: transparent; border: 0; border-radius: 8px; color: var(--accent); padding: 0 8px; }
-.provider-edit, .provider-use, .provider-form button { min-height: 44px; }
-.provider-edit:hover:not(:disabled) { background: #eaf0fc; }
-.provider-edit[aria-expanded="true"] svg { transform: rotate(180deg); }
-.provider-form { margin: 0 clamp(12px, 3vw, 19px); border-top: 1px solid #e1e8f3; padding: 15px 0 19px; }
-.provider-form input { min-height: 44px; }
-.provider-doc-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--accent); font-size: 13px; text-underline-offset: 3px; }
-.provider-form .provider-doc-link { min-height: 44px; margin-top: -8px; width: fit-content; }
-@media (max-width: 520px) {
- .provider-row-main { flex-wrap: wrap; gap: 4px; }
- .provider-row-identity { flex: 1 0 100%; }
- .provider-row-actions { justify-content: flex-start; }
- .provider-edit { padding-inline: 7px; }
-}
-.model-settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
-.model-secondary {
- display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent;
- border-radius: 8px; padding: 7px 10px; background: #edf2fb; color: #364976; font-size: 13px;
-}
-.model-secondary:hover:not(:disabled), .model-secondary[aria-pressed="true"] { background: #e2eafb; }
-.model-secondary:disabled { opacity: .55; }
-.model-default { background: #e9effb; border-radius: 8px; font-size: .72rem; font-weight: 550; padding: 3px 6px; }
-.model-list { padding-left: 20px; font-size: 14px; }
-.model-list span, .model-form small { color: var(--muted); }
-.model-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 14px; }
-.model-form label, .model-picker-menu label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
-.model-form input, .model-form textarea, .model-form select, .model-picker-menu select {
- width: 100%; border-radius: 9px; border: 1px solid #d8e1ee; background: #f9fbff; color: #262e48;
- padding: 9px 11px; font: inherit; font-weight: 400;
-}
-.model-form :is(input, textarea, select):focus-visible, .model-picker-menu select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
-.model-form .account-submit { width: auto; min-height: 37px; padding: 7px 12px; background: #495d9e; font-size: 13px; border-radius: 9px; }
-.model-picker { position: relative; min-width: 0; max-width: 320px; }
-.model-picker-trigger {
- display: flex; align-items: center; gap: 7px; max-width: 100%; min-height: 35px; border: 0;
- border-radius: 10px; padding: 5px 9px; background: #edf2fb; color: #415485; font-size: 12px;
-}
-.model-picker-trigger:hover, .model-picker-trigger[aria-expanded="true"] { background: #e2eafb; }
-.model-picker-trigger svg { flex: none; }
-.model-picker-label { display: grid; text-align: left; min-width: 0; }
-.model-picker-label :is(small, strong) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.model-picker-label small { color: #5a6880; font-size: 10px; }
-.model-picker-label strong { font-weight: 660; }
-.model-picker-menu {
- position: absolute; z-index: 4; left: -39px; bottom: calc(100% + 10px); width: min(285px, calc(100vw - 58px));
- border: 1px solid #e0e7f3; border-radius: 15px; background: #fafdff; padding: 12px;
- box-shadow: 0 10px 30px #25335024;
-}
-.model-picker-options { display: grid; gap: 3px; max-height: min(12rem, 27dvh); overflow: auto; margin-top: 8px; }
-.model-picker-options button {
- display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 36px;
- padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; color: #2b3455;
- overflow-wrap: anywhere; text-align: left; font-size: 13px;
-}
-.model-picker-options button:hover, .model-picker-options button[aria-pressed="true"] { background: #e9effb; }
-.model-picker-options svg { flex: none; }
-.model-picker > small { display: block; color: #90394f; margin-top: 3px; }
-
-.message-blocks { display: grid; gap: 8px; min-width: 0; }
-.message-blocks > div > :first-child { margin-top: 0; }
-.message-blocks > div > :last-child { margin-bottom: 0; }
-.history-actions { display: flex; align-items: center; gap: 8px; }
-.generation-row { display: flex; align-items: center; gap: 12px; min-height: 31px; }
-.generation-follow { padding-left: 43px; min-height: 20px; margin-top: -8px; }
-.generation-copy { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
-.generation-dots { display: inline-flex; gap: 3px; }
-.generation-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); animation: generation-pulse 1.5s ease-in-out infinite; }
-.generation-dots i:nth-child(2) { animation-delay: .15s; }
-.generation-dots i:nth-child(3) { animation-delay: .3s; }
-@keyframes generation-pulse { 0%, 60%, 100% { opacity: .42; } 30% { opacity: 1; } }
-.history-actions { justify-content: center; }
-.tool-card { width: fit-content; max-width: 100%; border: 1px solid #dce4f3; background: #f5f8ff88; border-radius: 10px; color: #4c5b74; font-size: 12px; }
-.tool-card summary { cursor: pointer; list-style: none; }
-.tool-card summary, .tool-summary { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 9px; }
-.tool-card summary:hover { background: #e7edf888; border-radius: 9px; }
-.tool-card summary::-webkit-details-marker { display: none; }
-.tool-card svg { flex: none; }
-.tool-card[open] > summary .tool-chevron { transform: rotate(90deg); }
-.tool-chevron { transition: transform .14s; }
-.tool-group-items { display: grid; gap: 2px; margin: 2px 10px 8px; padding-left: 5px; border-left: 1px solid #d5dfef; }
-.tool-group-items .tool-card { width: 100%; border: 0; background: transparent; }
-.tool-card :is(.tool-state, small) { margin-left: auto; white-space: nowrap; }
-.tool-state.done { color: #3f735e; }
-.tool-state.issue { color: #9b4a58; }
-.tool-detail { padding: 0 10px 7px 30px; color: var(--muted); }
-.chat-file { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; color: #374e9b; background: #f4f7ff; border: 1px solid #d6dff8; border-radius: 8px; text-align: left; }
-.chat-file svg { flex: none; }
-.chat-file-description { color: var(--muted); font-size: 13px; }
-.chat-image-row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; overflow-x: auto; }
-.chat-image-row > * { flex: 0 0 auto; width: min(70%, 174px); }
-.chat-image-row > :only-child { width: min(100%, 224px); }
-.chat-image-row > a:focus-visible { outline-offset: -2px; }
-.chat-image, .chat-image-placeholder { display: block; aspect-ratio: 1; border-radius: 9px; background: #dce5f5; }
-.chat-image { width: 100%; height: auto; object-fit: cover; }
-.message-queue { list-style: none; margin: 0 0 6px; padding: 3px 9px; border: 1px solid #dce3f3; border-radius: 10px; font-size: 13px; }
-.message-queue li { display: flex; align-items: center; gap: 7px; }
-.message-queue li + li { border-top: 1px solid #dce3f3; }
-.queue-summary { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
-.message-queue small { color: var(--muted); }
-.question-dock { max-height: 35vh; overflow: auto; margin-bottom: 6px; }
-.question-panel { background: #f8faff; border: 1px solid #d6dff8; border-radius: 12px; padding: 11px; font-size: 14px; }
-.question-panel + .question-panel { margin-top: 6px; }
-.question-panel fieldset { margin: 8px 0; padding: 3px 0 0; border: 0; }
-.question-panel legend { font-weight: 600; }
-.question-panel p { margin: 4px 0; }
-.question-option { display: flex; align-items: flex-start; gap: 6px; padding: 3px 0; }
-.question-option small { display: block; color: var(--muted); }
-.question-custom { width: 100%; margin-top: 4px; padding: 5px 8px; border: 1px solid #d6dff8; border-radius: 7px; }
-
-.host-files {
- display: flex;
- flex-direction: column;
- min-width: 0;
- min-height: 0;
- border-left: 1px solid #cbd6ee;
- background: #f4f7ff;
-}
-.host-files[hidden] { display: none; }
-.host-files-header, .host-files-location { padding: 12px 16px; border-bottom: 1px solid #dce3f3; }
-.host-files-header { display: flex; align-items: center; gap: 4px; }
-.host-files-header h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 650; }
-.host-files-header .icon-button:disabled { opacity: .48; }
-.host-files-path {
- display: flex;
- align-items: center;
- gap: 5px;
- padding: 0 4px 0 8px;
- border: 1px solid #dce3f3;
- border-radius: 8px;
- background: #fff;
-}
-.host-files-path code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
-.host-files-path .icon-button { flex: none; }
-.host-files-state { margin: 6px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
-.host-files-tree { min-height: 0; overflow: auto; padding: 9px 12px 20px; }
-.host-file-list { list-style: none; padding: 0; margin: 0; }
-.host-file-branch { border-left: 1px solid #dce3f3; margin-left: 11px; padding-left: 10px; }
-.host-file-row {
- display: flex;
- width: 100%;
- align-items: center;
- gap: 6px;
- padding: 6px 7px;
- border: 0;
- border-radius: 7px;
- background: transparent;
- font-size: 13px;
- text-align: left;
-}
-.host-file-row svg { flex: none; color: #53628b; }
-.host-file-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.host-file-row small { color: var(--muted); white-space: nowrap; }
-.host-file-row:hover { background: #e9eefb; }
-.host-file-row[aria-current] { background: #dfe7fb; color: #33468f; }
-.host-file-leaf { margin-left: 21px; }
-.host-file-root { font-weight: 620; }
-.host-files-scrim { display: none; }
-
-@media (min-width: 1060px) {
- .app-files-open { grid-template-columns: var(--sidebar-width) minmax(0, 1fr) clamp(310px, 28vw, 420px); }
-}
-@media (max-width: 1059px) {
- .host-files-scrim { display: block; position: fixed; inset: 0; z-index: 10; border: 0; background: #28375456; }
- .host-files {
- position: fixed;
- z-index: 11;
- inset: 0 0 0 auto;
- width: min(420px, 92vw);
- box-shadow: -10px 0 35px #3b4f7d2f;
- }
-}
-
-@media (max-width: 680px) {
- .model-settings { border-radius: 0; padding-top: 62px; }
- .settings-topbar { display: block; }
- .settings-nav { gap: 13px; }
- .settings-nav svg { width: 14px; height: 14px; }
- .draft-files li { max-width: min(100%, 205px); }
- .attachment-button { width: 40px; height: 40px; }
- .composer .send-button { width: 41px; height: 41px; }
- .app .model-picker-trigger { min-height: 38px; }
-}
-
-.permission-trigger { gap: 5px; white-space: nowrap; }
-.permission-menu { min-width: min(280px, 78vw); }
-.permission-menu p { margin: 2px 5px 7px; font-size: 12px; color: #5a6880; }
-.permission-menu .model-picker-options { max-height: none; }
-.permission-menu strong, .permission-menu small { display: block; text-align: left; }
-.permission-menu small { color: #5a6880; margin-top: 3px; }
-.permission-approval { padding: 14px; border-radius: 16px; box-shadow: 0 7px 20px #25345a12; }
-.permission-approval header { display: flex; gap: 10px; align-items: center; }
-.permission-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 11px; background: #e5ebfc; color: #354981; }
-.permission-approval header small, .permission-note { display: block; color: #596780; }
-.permission-approval p { margin: 10px 0; }
-.permission-approval pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 8rem; overflow: auto; margin: 8px 0; padding: 9px; border-radius: 8px; background: #eef2fa; }
-.permission-decisions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
-.permission-decisions button { padding: 7px 12px; border: 1px solid #d6dff8; border-radius: 9px; background: #fff; color: #334269; font-weight: 650; }
-.permission-decisions button:last-child { background: #455ca0; color: #fff; border-color: #455ca0; }
-
-.model-form select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line, #dddce8); border-radius: 12px; background: rgba(255,255,255,.8); color: inherit; font: inherit; }
-.model-protocol-badge { display: inline-block; font-size: 11px; line-height: 1.7; padding: 1px 7px; margin-right: 5px; border: 1px solid rgba(98,81,138,.14); border-radius: 6px; vertical-align: middle; }
-.model-request-url { overflow-wrap: anywhere; }
-
-.model-id-editor { display: grid; gap: 10px; }
-.model-id-row { display: flex; gap: 6px; align-items: center; }
-.model-id-row input { min-width: 0; flex: 1; }
-.model-id-row small { white-space: nowrap; color: #5c6072; }
-.model-row-action { display: grid; place-items: center; padding: 8px; border: none; border-radius: 8px; background: transparent; color: #5c6072; }
-.model-row-action:hover { background: #eeecf6; }
-.model-row-action:disabled { opacity: .3; }
-
-.chat-label .session-attention { display: flex; align-items: center; gap: 5px; padding-top: 4px; color: #8a6138; font-size: 11px; font-weight: 500; }
-.session-attention > span { width: 5px; height: 5px; border-radius: 50%; background: #bc8b55; flex: none; }
-
-.question-detail { max-height: 30vh; overflow: auto; padding: 6px 12px; margin: 10px 0; border: 1px solid rgba(112,122,163,.12); border-radius: 10px; background: rgba(255,255,255,.65); }
-.question-detail.markdown h1 { font-size: 18px; margin: 8px 0 12px; }
-.question-detail.markdown h2 { font-size: 15px; margin: 14px 0 6px; }
-.question-panel .question-option { padding: 7px 2px; gap: 8px; }
-
-.question-dock:has(.plan-review) { max-height: min(60vh, 480px); }
-.plan-review .question-detail { max-height: min(18vh, 160px); }
-
-.sidebar-footer { flex: none; margin-top: auto; padding-top: 12px; }
-.sidebar-destination { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 45px; padding: 11px 14px; border: 0; border-radius: 13px; background: transparent; color: #53617b; text-align: left; font: inherit; font-size: 14px; }
-.sidebar-destination:hover, .sidebar-destination[aria-current="page"] { background: #ffffff70; color: #35496f; }
-
-/* First-run controls use the same quiet surfaces as the composer. */
-.main-chat-label { display: block; font-size: 11px; color: var(--muted, #777985); margin-top: 3px; font-weight: 400; }
-.onboarding-actions { display: flex; justify-content: center; gap: 20px; margin: 0 0 10px; }
-.preparation-banner { position: fixed; z-index: 20; top: 58px; right: 24px; max-width: min(460px, calc(100vw - 48px)); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 11px 16px; border: 1px solid rgba(115, 122, 148, .14); border-radius: 16px; background: rgba(249, 250, 254, .94); backdrop-filter: blur(16px); box-shadow: 0 6px 24px rgba(51, 58, 89, .05); font-size: 12px; color: #656c7e; }
-.model-required-dialog { width: min(420px, calc(100vw - 36px)); box-sizing: border-box; border: 1px solid rgba(115, 122, 148, .16); border-radius: 24px; padding: 32px; background: #fafbfe; color: #383f52; box-shadow: 0 18px 80px rgba(38, 44, 67, .13); }
-.model-required-dialog::backdrop { background: rgba(31, 37, 58, .2); backdrop-filter: blur(3px); }
-.model-required-close { position: absolute; right: 13px; top: 13px; }
-.model-required-dialog h2 { font-size: 22px; font-weight: 600; margin: 18px 0 10px; }
-.model-required-dialog p { font-size: 14px; line-height: 1.7; }
-.model-required-dialog small { color: #777e8e; line-height: 1.7; }
-.model-required-actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 26px; align-items: center; }
-.model-required-actions .account-submit { width: auto; margin: 0; font-size: 14px; }
+@import './shell.css';
+@import './chat.css';
+@import './settings.css';
+@import './tasks.css';
diff --git a/frontend/src/styles/chat.css b/frontend/src/styles/chat.css
new file mode 100644
index 0000000..3e64bf4
--- /dev/null
+++ b/frontend/src/styles/chat.css
@@ -0,0 +1,222 @@
+.conversation { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
+.transcript-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
+.transcript { width: min(var(--content-width),100%); margin: 0 auto; padding: 35px 30px 24px; }
+.message { margin: 0 0 30px; min-width: 0; animation: message-arrive 280ms var(--ease); }
+.assistant-identity { display: flex; align-items: center; gap: 7px; height: 28px; margin: 0 0 12px; color: var(--muted); font-size: 11px; font-weight: 500; }
+.reply-mark { display: block; width: 29px; height: 29px; object-fit: contain; flex: none; }
+.message-blocks { display: flex; flex-direction: column; gap: 14px; min-width: 0; font-size: 15px; line-height: 1.8; }
+.user-message { display: flex; justify-content: flex-end; margin-left: 9%; }
+.user-message .message-blocks { background: var(--bubble); border-radius: 11px 11px 3px 11px; padding: 11px 16px; max-width: 94%; font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; gap: 10px; }
+.assistant-message .message-blocks > div:empty { display: none; }
+.markdown { color: var(--ink); overflow-wrap: anywhere; }
+.markdown > div > :first-child { margin-top: 0; }
+.markdown > div > :last-child { margin-bottom: 0; }
+.markdown p { margin: 0 0 15px; }
+.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { line-height: 1.4; letter-spacing: -.02em; font-weight: 600; color: var(--ink); }
+.markdown h1 { font-size: 27px; margin: 30px 0 18px; }
+.markdown h2 { font-size: 22px; margin: 28px 0 14px; }
+.markdown h3 { font-size: 18px; margin: 24px 0 12px; }
+.markdown h4 { font-size: 16px; margin: 22px 0 10px; }
+.markdown h5, .markdown h6 { font-size: 14px; margin: 20px 0 9px; }
+.markdown strong { font-weight: 600; }
+.markdown ul, .markdown ol { padding-left: 23px; margin: 0 0 17px; }
+.markdown li { padding-left: 3px; margin: 5px 0; }
+.markdown li > p { margin: 5px 0; }
+.markdown li::marker { color: var(--muted); }
+.markdown input[type='checkbox'] { accent-color: var(--accent); margin: 0 8px 0 0; }
+.markdown blockquote { margin: 18px 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--line-strong); color: var(--muted); }
+.markdown blockquote p:last-child { margin-bottom: 0; }
+.markdown code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: .86em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; }
+.markdown pre { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin: 18px 0; padding: 17px 20px; overflow: auto; line-height: 1.7; font-size: 13px; }
+.markdown pre code { border: 0; padding: 0; font-size: inherit; background: transparent; }
+.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 25px 0; }
+.markdown a { text-decoration: none; border-bottom: 1px solid color-mix(in srgb,var(--accent) 35%,transparent); }
+.markdown a:hover { border-bottom-color: currentColor; }
+.markdown table { border-collapse: collapse; width: 100%; font-size: 13px; text-align: left; }
+.markdown th { background: var(--surface); font-weight: 550; color: var(--ink); }
+.markdown th, .markdown td { padding: 10px 14px; border-bottom: 1px solid var(--line); min-width: 110px; }
+.markdown tr:last-child td { border-bottom: 0; }
+.markdown del { color: var(--muted); }
+.markdown .footnotes { margin-top: 24px; color: var(--muted); font-size: 12px; }
+.chat-input { flex: none; padding: 12px 30px 24px; width: min(var(--content-width),100%); margin: 0 auto; }
+.composer { border: 1px solid var(--line-strong); border-radius: 12px; background: var(--canvas); padding: 9px 11px 9px; box-shadow: var(--shadow); transition: border-color 150ms, box-shadow 150ms; }
+.composer:focus-within { border-color: color-mix(in srgb,var(--accent) 50%,var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb,var(--accent) 5%,transparent), var(--shadow); }
+.composer textarea { resize: none; display: block; width: 100%; min-height: 50px; max-height: 220px; border: 0; background: transparent; outline: none; padding: 7px 4px; font-size: 14px; line-height: 1.65; }
+.composer textarea:focus-visible { outline: none; }
+.composer textarea::placeholder { color: var(--quiet); }
+.composer-actions, .composer-tools, .composer-submit { display: flex; align-items: center; gap: 7px; }
+.composer-actions { justify-content: space-between; }
+.composer-tools { min-width: 0; }
+.composer-hint { color: var(--quiet); font-size: 10px; }
+.attachment-button { width: 30px; height: 30px; display: grid; place-items: center; flex: none; padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); }
+.attachment-button:hover { background: var(--surface-2); color: var(--ink); }
+.send-button, .stop-generation { width: 32px; height: 32px; display: grid; place-items: center; flex: none; padding: 0; border-radius: 8px; }
+.send-button { background: var(--button-ink); color: var(--button-text); }
+.send-button:hover { opacity: .82; }
+.send-button:disabled { opacity: .28; }
+.stop-generation { background: var(--surface-2); color: var(--ink); }
+.model-picker { position: relative; min-width: 0; }
+.model-picker-trigger { border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); min-height: 32px; padding: 5px 8px; display: flex; align-items: center; gap: 6px; font-size: 11px; box-shadow: 0 1px 2px #14142003; }
+.model-picker-trigger:hover { background: var(--surface); border-color: var(--line-strong); }
+.model-picker-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
+.model-picker-label small { display: none; }
+.model-picker-label strong { font-size: 11px; font-weight: 500; }
+.model-picker-trigger > svg:first-child { color: var(--muted); }
+.model-picker-trigger > svg:last-child { width: 12px; }
+.model-picker-menu { position: absolute; z-index: 60; top: calc(100% + 10px); left: 0; width: min(310px,calc(100vw - 90px)); border: 1px solid var(--line); background: var(--canvas); border-radius: 11px; padding: 10px; box-shadow: var(--popover-shadow); animation: popover-enter 180ms var(--ease); font-size: 12px; }
+.model-picker-menu label { display: grid; gap: 7px; color: var(--muted); }
+.model-picker-menu select { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px; color: var(--ink); }
+.model-picker-options { max-height: 260px; overflow: auto; display: grid; gap: 3px; margin-top: 8px; }
+.model-picker-options > button { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 9px; border-radius: 7px; text-align: left; }
+.model-picker-options > button:hover, .model-picker-options > button[aria-checked='true'], .model-picker-options > button[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent); }
+.model-picker-options strong { display: block; font-size: 12px; font-weight: 550; }
+.model-picker-options small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
+.model-picker-menu > p { color: var(--muted); font-size: 11px; padding: 0 5px; }
+.permission-menu { width: min(300px,calc(100vw - 90px)); }
+.chat-empty { flex: 1; display: grid; place-items: center; min-height: 0; padding: 25px; }
+.welcome-copy { position: absolute; z-index: 1; left: 20px; right: 20px; bottom: calc(clamp(90px,28vh,300px) + 170px); text-align: center; pointer-events: none; opacity: 0; transform: translateY(-12px); transition: opacity 220ms, transform 420ms var(--ease); }
+.welcome-avatar { width: 128px; height: 128px; object-fit: contain; }
+.welcome-copy h1 { font-size: 30px; font-weight: 550; letter-spacing: -.035em; margin: 16px 0 5px; }
+.welcome-copy p { color: var(--muted); margin: 0; font-size: 20px; letter-spacing: -.02em; }
+.is-welcome .welcome-copy { opacity: 1; transform: translateY(0); }
+.conversation .chat-input { transition: margin-bottom 560ms var(--ease), width 560ms var(--ease); }
+.is-welcome .chat-input { width: min(680px,100%); margin-bottom: clamp(90px,28vh,300px); }
+.is-welcome .transcript-scroll { opacity: 0; pointer-events: none; }
+.transcript-scroll { transition: opacity 250ms 120ms; }
+.chat-empty .welcome-avatar { width: 128px; height: 128px; }
+.generation-row { display: flex; align-items: center; gap: 10px; padding: 0 0 10px; font-size: 11px; color: var(--muted); }
+.generation-follow { margin-top: -13px; }
+.generation-copy { display: inline-flex; align-items: center; gap: 7px; }
+.generation-dots { display: inline-flex; gap: 3px; align-items: center; }
+.generation-dots i { width: 3px; height: 3px; border-radius: 50%; background: var(--quiet); animation: dot-breathe 1.2s infinite; }
+.generation-dots i:nth-child(2) { animation-delay: .15s; }.generation-dots i:nth-child(3) { animation-delay: .3s; }
+.chat-status { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 12px 0; }
+.history-actions { margin-bottom: 22px; display: grid; justify-items: center; }
+.reconnecting { padding: 0 4px; margin: 0 0 10px; }
+.onboarding-actions { display: flex; justify-content: flex-start; gap: 18px; margin-bottom: 8px; }
+.tool-card { color: var(--muted); width: min(100%,560px); border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 12px; line-height: 1.6; }
+.tool-card summary, .tool-summary { display: flex; align-items: center; gap: 9px; padding: 11px 13px; }
+.tool-card summary { cursor: pointer; list-style: none; }
+.tool-summary > span { flex: 1; }
+.tool-card summary::-webkit-details-marker { display: none; }
+.tool-card summary > span { flex: 1; }
+.tool-card summary small { font-size: 10px; color: var(--quiet); }
+.tool-card summary:hover { background: var(--surface-2); border-radius: inherit; }
+.tool-chevron { transition: transform 180ms var(--ease); }
+.tool-card[open] > summary > .tool-chevron { transform: rotate(90deg); }
+.tool-group-items { border-top: 1px solid var(--line); padding: 2px 12px 7px; }
+.tool-group-items .tool-card { border: 0; border-radius: 0; background: transparent; }
+.tool-group-items .tool-card + .tool-card { border-top: 1px solid var(--line); }
+.tool-group-items .tool-card summary { padding: 9px 2px; }
+.tool-card > p, .tool-detail { padding: 0 13px 10px; margin: 0; }
+.tool-state.done { color: #5b9277; }.tool-state.issue { color: var(--danger); }
+.image-tool-group { width: min(100%,560px); min-width: 0; }
+.image-tool-header { border:0; background:transparent; cursor:pointer; width: 100%; min-height: 40px; padding: 0; border: 0; background: transparent; cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; text-align: left; }
+.image-tool-header:hover { color: var(--ink); }
+.image-tool-header small { font-size: 10px; color: var(--quiet); }
+.image-tool-state { margin-left: auto; }
+.image-tool-chevron { transition: transform 180ms var(--ease); }
+.image-tool-chevron.expanded { transform: rotate(90deg); }
+.image-tool-body { padding-top: 4px; }
+.image-tool-body[hidden] { display: none; }
+.chat-image-scroller { position:relative; max-width:100%; min-width:0; width:fit-content; }
+.chat-image-row { --image-size: 164px; --image-fade: 30px; display: flex; align-items: flex-start; gap: 10px; overflow-x: auto; overflow-y: hidden; max-width: 100%; width: max-content; padding: 1px 0 5px; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain; mask-image: linear-gradient(to right,rgba(0,0,0,var(--image-edge-left,1)),#000 var(--image-fade),#000 calc(100% - var(--image-fade)),rgba(0,0,0,var(--image-edge-right,1))); }
+.chat-image-row::-webkit-scrollbar { display: none; }
+.chat-image-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
+.chat-image-row.compact-images { --image-size: 118px; }
+.chat-image-button,.chat-image-placeholder,.chat-image-retry { display: flex; align-items: center; justify-content: center; width: var(--image-size); height: var(--image-size); flex: 0 0 var(--image-size); padding: 0; border-radius: 10px; border: 0; overflow: hidden; background: var(--surface); scroll-snap-align: start; }
+.chat-image { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 200ms var(--ease); }
+.chat-image-button:hover .chat-image { transform: scale(1.025); }
+.chat-image-placeholder,.chat-image-retry { background: var(--surface-2); color: var(--muted); }
+.chat-image-retry { flex-direction: column; gap: 8px; font-size: 11px; }
+.chat-image-row .file-delivery { min-width: 220px; }
+
+.image-scroll-arrow { position:absolute; top:calc(50% - 17px); width:30px; height:30px; padding:0; display:grid; place-items:center; border-radius:50%; border:1px solid var(--line); background:var(--canvas); color:var(--muted); box-shadow:0 2px 8px #0001; opacity:0; pointer-events:none; transition:opacity 150ms; }
+.image-scroll-arrow.previous { left:5px; }.image-scroll-arrow.next { right:5px; }
+.chat-image-scroller:hover .image-scroll-arrow,.chat-image-scroller:focus-within .image-scroll-arrow { opacity:1; pointer-events:auto; }
+@media (hover:none) { .image-scroll-arrow { display:none; } }
+
+.file-delivery { width: min(100%,390px); }
+.chat-file { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); color: var(--ink); }
+.chat-file:hover { border-color: var(--line-strong); background: var(--surface); box-shadow: var(--shadow); }
+.file-type-icon { width: 37px; height: 41px; display: grid; place-items: center; flex: none; color: var(--muted); }
+.file-type-icon img { width: 32px; height: 35px; object-fit: contain; }
+.chat-file-copy { min-width: 0; flex: 1; display: grid; gap: 3px; }
+.chat-file-copy strong { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.chat-file-copy small { color: var(--muted); font-size: 11px; line-height: 1.5; }
+.chat-file > svg { color: var(--quiet); }
+.draft-files { display: flex; flex-wrap: wrap; gap: 7px; padding: 3px 2px 8px; margin: 0; list-style: none; }
+.draft-files li { display: flex; align-items: center; gap: 7px; max-width: min(250px,100%); border: 1px solid var(--line); border-radius: 8px; padding: 5px 7px; background: var(--surface); }
+.draft-file-preview { display: flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; overflow: hidden; border-radius: 5px; color: var(--muted); background: var(--surface-2); }
+.draft-file-preview > img { display: block; width: 100%; height: 100%; object-fit: cover; }
+.draft-file-preview > svg { flex: none; }
+.draft-file-label { display: grid; gap: 1px; min-width: 0; }
+.draft-file-label strong { font-size: 11px; font-weight: 500; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.draft-file-label small { color: var(--muted); font-size: 9px; }
+.draft-files button { color: var(--muted); display: grid; place-items: center; padding: 4px; }
+.message-queue { margin: 0 0 10px; padding: 7px 12px; list-style: none; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
+.message-queue li { display: flex; align-items: center; gap: 9px; font-size: 11px; }
+.queue-summary { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.message-queue li > small { color: var(--muted); }
+.question-dock { max-height: min(60vh,480px); overflow: auto; margin-bottom: 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
+.question-panel { padding: 17px 18px; font-size: 13px; }
+.question-panel strong { font-weight: 550; }
+.question-panel fieldset { border: 0; padding: 0; margin: 14px 0; }
+.question-panel legend { padding: 0; font-weight: 500; font-size: 13px; margin-bottom: 7px; }
+.question-option { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; }
+.question-option input { accent-color: var(--accent); margin-top: 4px; }
+.question-option small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
+.question-custom { width: 100%; border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); padding: 8px 10px; }
+.question-detail { max-height: 160px; overflow: auto; margin: 10px 0; background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
+.question-detail.markdown h1 { font-size: 20px; }.question-detail.markdown h2 { font-size: 17px; }
+.permission-approval header { display: flex; gap: 10px; align-items: center; }
+.permission-approval header small, .permission-note { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
+.permission-icon { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); width: 34px; height: 34px; border-radius: 9px; }
+.permission-approval pre { padding: 11px; max-height: 120px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--canvas); border: 1px solid var(--line); border-radius: 7px; font-size: 12px; }
+.permission-decisions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
+.permission-decisions button { padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 7px; font-size: 12px; }
+.permission-decisions button:last-child { border-color: transparent; background: var(--button-ink); color: var(--button-text); }
+.image-preview { position: fixed; inset: 0; margin: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; padding: 72px 30px 30px; background: #08080bf5; border: 0; color: #fff; }
+.image-preview[open] { display: grid; place-items: center; }
+.image-preview > img { display: block; max-width: 100%; max-height: calc(100dvh - 110px); object-fit: contain; border-radius: 4px; }
+.image-preview-actions { position: absolute; top: 20px; right: 23px; display: flex; gap: 12px; }
+.image-preview-actions .icon-button { color: #ddd; width: 38px; height: 38px; }
+.image-preview-actions .icon-button:hover { background: #fff2; }
+@keyframes dot-breathe { 0%,80%,100% { opacity: .4; } 40% { opacity: 1; } }
+@keyframes message-arrive { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
+@media (max-width: 760px) {
+ .transcript { padding: 24px 17px 18px; }.chat-input { padding: 10px 13px 15px; }
+ .message-blocks { font-size: 14px; line-height: 1.8; }.user-message .message-blocks { font-size: 13px; }
+ .markdown h1 { font-size: 23px; }.markdown h2 { font-size: 20px; }.markdown h3 { font-size: 17px; }
+ .model-picker-label { max-width: 130px; }.model-picker-trigger { font-size: 10px; padding: 5px 6px; gap: 4px; }
+ .model-picker-label strong { font-size: 10px; }.model-picker-trigger > svg:first-child { display: none; }
+ .permission-menu { left: auto; right: -40px; }
+ .welcome-copy .welcome-avatar { width: 112px; height: 112px; }
+ .welcome-copy h1 { font-size: 28px; }.welcome-copy p { font-size: 18px; }
+ .chat-image-row { --image-size:146px; --image-fade:26px; } .chat-image-row.compact-images { --image-size:118px; }.composer-hint { display: none; }
+ .markdown th, .markdown td { min-width: 90px; padding: 8px 11px; }
+ .image-preview { padding: 65px 10px 20px; }
+}
+@media (max-height: 700px) {
+ .welcome-copy { bottom: calc(clamp(35px,16vh,110px) + 155px); }
+ .welcome-copy .welcome-avatar { width: 96px; height: 96px; }
+ .welcome-copy h1 { font-size: 26px; }.welcome-copy p { font-size: 18px; }
+ .is-welcome .chat-input { margin-bottom: clamp(35px,16vh,110px); }
+}
+
+/* Image tools use a light disclosure row; previews stay separate from tool cards. */
+@media (prefers-reduced-motion: reduce) { .image-tool-chevron { transition: none; } }
+
+/* Keep actions stationary while wide Markdown scrolls inside the message. */
+.markdown-panel { width: 100%; min-width: 0; margin: 18px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--canvas); }
+.markdown-panel-toolbar { min-height: 36px; padding: 3px 10px 3px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; border-bottom: 1px solid var(--line); background: var(--surface); }
+.markdown-copy { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 3px 7px; border-radius: 5px; font-size: 11px; color: var(--muted); }
+.markdown-copy:hover { color: var(--ink); background: var(--surface-2); }
+.markdown-copy:active { transform: translateY(1px); }
+.markdown-table-scroll, .markdown-code-scroll { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
+.markdown-table-scroll table { width: max-content; min-width: 100%; }
+.markdown-table-scroll th, .markdown-table-scroll td { max-width: 320px; overflow-wrap: anywhere; }
+.markdown-code-panel { background: var(--surface); }
+.markdown-code-scroll pre { border: 0; border-radius: 0; margin: 0; width: max-content; min-width: 100%; overflow: visible; box-sizing: border-box; white-space: pre; overflow-wrap: normal; }
+.markdown-code-scroll pre code { white-space: pre; overflow-wrap: normal; }
+@media (max-width: 600px) { .markdown-copy { min-height: 38px; } }
diff --git a/frontend/src/styles/settings.css b/frontend/src/styles/settings.css
new file mode 100644
index 0000000..544fc14
--- /dev/null
+++ b/frontend/src/styles/settings.css
@@ -0,0 +1,122 @@
+.account-page { min-height: 100dvh; display: grid; place-items: center; padding: 25px; background: var(--surface); }
+.account-card { width: min(410px,100%); border: 1px solid var(--line); border-radius: 18px; padding: 30px; background: var(--canvas); box-shadow: var(--shadow); animation: surface-enter 500ms var(--ease); }
+.account-card-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 36px; gap: 10px; }
+.brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; white-space: nowrap; }
+.brand-mark { width: 35px; height: 35px; object-fit: contain; }
+.account-preferences { display: flex; align-items: center; gap: 4px; }
+.account-card h1 { font-size: 23px; font-weight: 550; letter-spacing: -.035em; margin: 0 0 24px; }
+.account-card fieldset, .model-form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 17px; min-width: 0; }
+.account-card label, .model-form label { display: grid; gap: 8px; font-size: 12px; font-weight: 500; }
+.account-card input, .model-form input, .model-form select, .model-form textarea { width: 100%; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--canvas); color: var(--ink); padding: 9px 11px; font-size: 13px; }
+.account-card input:focus, .model-form input:focus, .model-form select:focus, .model-form textarea:focus { border-color: var(--accent); }
+.account-submit { margin-top: 5px; }
+.account-card .account-submit { width: 100%; }
+.account-switch { width: 100%; font-size: 12px; color: var(--muted); margin-top: 20px; padding: 8px; }
+.account-switch:hover { color: var(--accent); }
+.account-status { display: flex; gap: 7px; align-items: center; font-size: 12px; color: var(--muted); }
+.account-status svg { animation: spin 1s linear infinite; }
+.model-settings { overflow: hidden; }
+.model-settings-panel { width: min(100%,1040px); min-height: 0; flex: 1; padding: 30px 40px 50px; margin: 0 auto; overflow: auto; scrollbar-width: thin; }
+.settings-header { margin: 0 0 25px; }
+.settings-header h1 { font-size: 27px; font-weight: 550; letter-spacing: -.035em; margin: 17px 0 0; }
+.settings-header-actions { display: flex; align-items: center; justify-content: space-between; }
+.settings-back { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); padding: 0; }
+.settings-back:hover { color: var(--ink); }
+.settings-nav { display: flex; align-items: center; gap: 3px; padding: 3px; margin-bottom: 28px; background: var(--surface-2); border-radius: 9px; width: max-content; max-width: 100%; overflow: auto; scrollbar-width: none; }
+.settings-nav button { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; font-size: 12px; white-space: nowrap; border-radius: 6px; color: var(--muted); }
+.settings-nav button[aria-current] { color: var(--ink); background: var(--canvas); box-shadow: 0 1px 4px #1414200d; }
+.settings-content { min-width: 0; }
+.settings-section-title { font-size: 19px; font-weight: 550; letter-spacing: -.025em; margin: 0 0 6px; }
+.model-muted { font-size: 12px; line-height: 1.75; color: var(--muted); }
+.model-settings-toolbar, .provider-settings-intro { margin: 0 0 22px; }
+.model-settings-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
+.model-settings-toolbar h2 { font-size: 19px; font-weight: 550; margin: 0 0 6px; }
+.model-settings-toolbar p { margin: 0; }
+.model-list { display: grid; gap: 7px; padding: 0; list-style: none; margin: 18px 0; font-size: 12px; }
+.model-list li { padding: 9px 11px; background: var(--surface); border-radius: 6px; }
+.model-list li span { color: var(--muted); font-size: 10px; }
+.model-card + .model-card, .model-card + .settings-add { margin-top: 14px; }
+.model-card { padding: 20px; border: 1px solid var(--line); background: var(--canvas); border-radius: 11px; }
+.model-card header { display: flex; gap: 15px; justify-content: space-between; align-items: flex-start; }
+.model-card h2, .model-card h3 { font-size: 15px; font-weight: 550; margin: 0 0 6px; }
+.model-card p { margin: 5px 0; font-size: 12px; overflow-wrap: anywhere; }
+.model-card code { color: var(--muted); font-size: 11px; }
+.model-card footer, .model-settings-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 17px; }
+.model-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); padding: 8px 12px; font-size: 12px; line-height: 1.5; min-height: 34px; }
+.model-secondary:hover { background: var(--surface); border-color: var(--line-strong); }
+.model-secondary.danger { color: var(--danger); }
+.model-default, .model-protocol-badge { display: inline-block; vertical-align: middle; color: var(--muted); background: var(--surface-2); padding: 2px 7px; margin: 0 5px 0 0; border-radius: 5px; font-size: 10px; font-weight: 400; }
+.model-default { color: var(--accent); background: var(--accent-soft); }
+.model-form { padding: 23px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; max-width: 700px; }
+.model-form h2 { margin: 0 0 23px; font-size: 19px; font-weight: 550; }
+.model-form small { font-size: 11px; color: var(--muted); line-height: 1.6; }
+.model-request-url { overflow-wrap: anywhere; }
+.model-settings-actions .account-submit { margin-top: 0; }
+.model-id-editor { display: grid; gap: 9px; font-size: 12px; }
+.model-id-row { display: flex; align-items: center; gap: 4px; }
+.model-id-row input { min-width: 0; flex: 1; }
+.model-id-row small { font-size: 10px; white-space: nowrap; }
+.model-row-action { width: 26px; height: 30px; border-radius: 5px; padding: 0; display: grid; place-items: center; color: var(--muted); }
+.model-row-action:hover { background: var(--surface-2); }
+.settings-add { justify-self: start; }
+.provider-choices, .provider-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 22px; }
+.provider-option { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 13px; background: var(--canvas); font-size: 12px; }
+.provider-option[aria-pressed='true'], .provider-option.selected { border-color: var(--line-strong); background: var(--accent-soft); color: var(--accent); }
+.provider-selected, .provider-status { color: var(--accent); font-size: 10px; }
+.provider-form header, .provider-card-heading { display: flex; align-items: center; gap: 10px; }
+.provider-form .account-submit { justify-self: start; }
+.provider-use { margin-left: auto; }
+.provider-save-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
+.provider-current { color: var(--muted); font-size: 12px; margin: 22px 0 12px; }
+.provider-current strong { color: var(--ink); font-weight: 500; margin-left: 5px; }
+.provider-list { padding: 0; margin: 0 0 20px; list-style: none; border-top: 1px solid var(--line); }
+.provider-row { border-bottom: 1px solid var(--line); padding: 20px 0; }
+.provider-row-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
+.provider-row-identity h3 { margin: 0 0 5px; font-size: 14px; font-weight: 550; }
+.provider-row-identity p { margin: 0; font-size: 11px; color: var(--muted); }
+.provider-row-actions { display: flex; align-items: center; gap: 15px; }
+.provider-active { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-size: 11px; }
+.provider-edit, .provider-doc-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
+.provider-edit { padding: 8px; border-radius: 6px; color: var(--muted); }
+.provider-edit:hover { background: var(--surface-2); color: var(--ink); }
+.provider-edit[aria-expanded='true'] svg { transform: rotate(180deg); }
+.provider-form { margin-top: 17px; }
+.provider-notice { font-size: 12px; color: var(--accent); }
+.proactive-control { display: flex; align-items: center; gap: 14px; margin: 24px 0 18px; }
+.proactive-control > svg { color: var(--accent); }
+.proactive-control-copy { flex: 1; }.proactive-control-copy h3 { margin: 0; font-size: 14px; }
+.proactive-switch { position: relative; display: inline-flex; width: 34px; height: 20px; flex: none; }
+.proactive-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
+.proactive-switch span { width: 34px; height: 20px; border-radius: 20px; background: var(--line-strong); transition: background 150ms; }
+.proactive-switch span::after { content: ''; position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #0002; transition: transform 180ms var(--ease); }
+.proactive-switch input:checked + span { background: var(--accent); }.proactive-switch input:checked + span::after { transform: translateX(14px); }.proactive-switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }
+.proactive-status { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); padding: 20px; }
+.proactive-status-heading { display: flex; align-items: center; gap: 8px; font-size: 12px; }
+.proactive-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }.proactive-dot.disabled { background: var(--quiet); }
+.proactive-status dl { display: grid; gap: 17px; margin: 20px 0 0; font-size: 12px; }.proactive-status dt { display: flex; align-items: center; gap: 7px; color: var(--muted); }.proactive-status dd { margin: 5px 0 0; }.proactive-reason { font-size: 11px; color: var(--muted); line-height: 1.6; margin: 6px 0; }
+.proactive-footer { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-top: 18px; }.proactive-footer p { margin: 0; max-width: 550px; }.proactive-footer button { white-space: nowrap; }
+.host-files { grid-column: 4; grid-row: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--surface); z-index: 30; animation: files-enter 260ms var(--ease); }
+.host-files-header { display: flex; align-items: center; gap: 2px; padding: 17px 14px; height: 68px; border-bottom: 1px solid var(--line); flex: none; }
+.host-files-header h2 { flex: 1; margin: 0; font-size: 13px; font-weight: 550; }
+.host-files-location { padding: 14px 16px; border-bottom: 1px solid var(--line); }
+.host-files-path { display: flex; gap: 4px; align-items: center; padding: 7px 8px 7px 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); }
+.host-files-path code { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--muted); font-size: 10px; }
+.host-files-state { margin: 8px 0 0; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }.host-files-state code { font: inherit; }
+.host-files-tree { flex: 1; min-height: 0; overflow: auto; padding: 12px 12px 20px; scrollbar-width: thin; }
+.host-file-list { list-style: none; margin: 0; padding: 0; }
+.host-file-branch { border-left: 1px solid var(--line); margin-left: 11px; padding-left: 9px; }
+.host-file-row { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; text-align: left; padding: 8px 7px; border-radius: 6px; font-size: 11px; line-height: 1.4; }
+.host-file-row > svg { color: var(--muted); }.host-file-row > span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }.host-file-row small { font-size: 9px; color: var(--quiet); white-space: nowrap; }
+.host-file-row:hover { background: var(--surface-2); }.host-file-row[aria-current] { color: var(--accent); background: var(--accent-soft); }.host-file-leaf { margin-left: 21px; }.host-file-root { font-weight: 500; }
+.host-files-scrim { display: none; }
+@keyframes files-enter { from { opacity: .5; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
+@media (max-width: 1199px) {
+ .host-files { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px,calc(100vw - var(--rail-width))); box-shadow: var(--popover-shadow); }
+ .host-files-scrim { display: block; position: fixed; z-index: 25; inset: 0 0 0 var(--rail-width); background: #17172030; backdrop-filter: blur(2px); }
+}
+@media (max-width: 760px) {
+ .model-settings-panel { padding: 23px 17px 35px; }.settings-header h1 { font-size: 24px; }.settings-nav { margin-bottom: 23px; }.settings-nav button { padding: 8px 10px; font-size: 11px; }.settings-nav button svg { display: none; }
+ .model-form, .model-card { padding: 16px; }.model-id-row { flex-wrap: wrap; }.model-id-row input { flex-basis: calc(100% - 8px); }.model-settings-toolbar { align-items: flex-start; flex-wrap: wrap; }
+ .proactive-footer { display: block; }.proactive-footer button { margin-top: 12px; }.host-files-header { height: 58px; }
+ .account-page { padding: 18px; }.account-card { padding: 24px; }.account-card-heading { gap: 4px; }.account-preferences { gap: 0; }
+}
diff --git a/frontend/src/styles/shell.css b/frontend/src/styles/shell.css
new file mode 100644
index 0000000..ac304a3
--- /dev/null
+++ b/frontend/src/styles/shell.css
@@ -0,0 +1,154 @@
+:root {
+ font-family: 'Inter Variable', 'PingFang SC', 'Microsoft YaHei UI', 'Noto Sans CJK SC', sans-serif;
+ font-synthesis: none; text-rendering: optimizeLegibility;
+ --canvas: #fff; --surface: #f8f8fa; --surface-2: #f3f3f6; --surface-hover: #efeff3;
+ --ink: #202024; --muted: #74747d; --quiet: #92929d; --line: #eaeaf0; --line-strong: #d8d8e1;
+ --accent: #7863be; --accent-soft: #f0ebfc; --bubble: #eae3fb; --focus: #8d75d1;
+ --button-ink: #202024; --button-text: #fff; --danger: #b5404d; --danger-soft: #fff0f1;
+ --shadow: 0 6px 24px #1919250a, 0 1px 4px #19192506; --popover-shadow: 0 12px 48px #19192514, 0 2px 8px #19192508;
+ --rail-width: 64px; --sidebar-width: 264px; --files-width: 320px; --content-width: 840px;
+ --ease: cubic-bezier(.22,1,.36,1); color: var(--ink); background: var(--canvas); color-scheme: light;
+}
+:root[data-theme='dark'] {
+ --canvas: #141416; --surface: #1b1b1e; --surface-2: #222226; --surface-hover: #29292f;
+ --ink: #ececf1; --muted: #a0a0aa; --quiet: #80808b; --line: #303037; --line-strong: #45454e;
+ --accent: #baa8f2; --accent-soft: #30293f; --bubble: #393044; --focus: #baa8f2;
+ --button-ink: #eeedf4; --button-text: #202024; --danger: #ef929b; --danger-soft: #382329;
+ --shadow: 0 6px 24px #0002, 0 1px 4px #0002; --popover-shadow: 0 14px 48px #0006, 0 2px 8px #0004; color-scheme: dark;
+}
+*, *::before, *::after { box-sizing: border-box; }
+html, body, #root { margin: 0; height: 100%; }
+body { min-width: 320px; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
+button, input, textarea, select { font: inherit; color: inherit; }
+button { cursor: pointer; background: transparent; border: 0; }
+button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
+button { transition: background 150ms, color 150ms, border-color 150ms, box-shadow 150ms, transform 120ms; }
+button:active:not(:disabled) { transform: translateY(1px); }
+button:disabled { cursor: default; opacity: .45; }
+button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
+input, textarea, select { min-width: 0; }
+a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
+svg { flex: none; }
+.lucide { stroke-width: 1.65; }
+[hidden] { display: none !important; }
+::selection { background: var(--accent-soft); color: var(--ink); }
+.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
+.app { --sidebar-space: 0px; --files-space: 0px; height: 100dvh; min-height: 0; display: grid; position: relative; grid-template-columns: var(--rail-width) var(--sidebar-space) minmax(0,1fr) var(--files-space); background: var(--canvas); transition: grid-template-columns 260ms var(--ease); }
+.app-sidebar-open { --sidebar-space: var(--sidebar-width); }
+.app-files-open { --files-space: var(--files-width); }
+.navigation-rail { grid-column: 1; grid-row: 1; z-index: 40; border-right: 1px solid var(--line); display: flex; align-items: center; flex-direction: column; min-height: 0; padding: 20px 0 18px; background: var(--canvas); animation: rail-enter 420ms var(--ease) both; }
+.rail-brand { width: 44px; height: 44px; padding: 2px; margin-bottom: 24px; display: grid; place-items: center; }
+.rail-brand img { width: 42px; height: 42px; object-fit: contain; }
+.rail-links, .rail-bottom { display: flex; align-items: center; flex-direction: column; gap: 10px; }
+.rail-bottom { margin-top: auto; gap: 20px; }
+.rail-button { width: 40px; height: 40px; position: relative; display: grid; place-items: center; border-radius: 9px; color: var(--muted); }
+.rail-button:hover { background: var(--surface-2); color: var(--ink); }
+.rail-button[aria-current], .rail-button[aria-expanded='true'] { color: var(--accent); background: var(--accent-soft); }
+.rail-button[aria-current]::before { content: ''; position: absolute; left: -12px; top: 12px; width: 3px; height: 16px; border-radius: 0 3px 3px 0; background: var(--accent); }
+.rail-tooltip { position: absolute; z-index: 50; left: calc(100% + 10px); padding: 6px 10px; background: var(--button-ink); color: var(--button-text); font-size: 12px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transform: translateX(-3px); transition: opacity 120ms, transform 120ms; }
+.rail-button:hover .rail-tooltip, .rail-button:focus-visible .rail-tooltip { opacity: 1; transform: translateX(0); }
+.rail-account { position: relative; }
+.rail-avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; border: 1px solid var(--line); }
+.account-popover { position: absolute; z-index: 65; left: calc(100% + 18px); bottom: -1px; width: 240px; padding: 7px; background: var(--canvas); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--popover-shadow); animation: popover-enter 180ms var(--ease); }
+.rail-account-heading { display: grid; padding: 10px 9px 14px; margin-bottom: 5px; border-bottom: 1px solid var(--line); gap: 3px; }
+.rail-account-heading strong { overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
+.rail-account-heading span { font-size: 11px; color: var(--muted); }
+.account-popover button { display: flex; align-items: center; gap: 10px; width: 100%; border-radius: 7px; padding: 10px; text-align: left; font-size: 13px; }
+.account-popover button:hover { background: var(--surface-2); }
+.account-popover .stop-host { color: var(--danger); }
+.sidebar-slot { grid-column: 2; grid-row: 1; min-height: 0; min-width: 0; overflow: hidden; visibility: hidden; transition: visibility 0s 260ms; }
+.app-sidebar-open .sidebar-slot { visibility: visible; transition-delay: 0s; }
+.sidebar { display: flex; flex-direction: column; height: 100%; width: var(--sidebar-width); min-height: 0; padding: 23px 14px 16px; border-right: 1px solid var(--line); background: var(--surface); opacity: 0; transform: translateX(-14px); transition: opacity 180ms, transform 260ms var(--ease); }
+.sidebar.drawer-open { opacity: 1; transform: translateX(0); }
+.sidebar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; padding-left: 8px; }
+.sidebar-header h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; font-weight: 580; }
+.new-chat { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--canvas); box-shadow: 0 1px 2px #17172404; font-size: 13px; font-weight: 500; }
+.new-chat:hover { background: var(--surface-2); }
+.section-heading { font-size: 11px; color: var(--muted); margin: 26px 9px 10px; font-weight: 500; }
+.session-list { min-height: 0; overflow: auto; scrollbar-width: thin; flex: 1; }
+.chat-row { position: relative; border-radius: 8px; display: flex; align-items: center; margin: 3px 0; }
+.chat-row:hover { background: var(--surface-2); }
+.chat-row.selected { background: var(--accent-soft); }
+.chat-link { display: flex; align-items: flex-start; gap: 9px; min-width: 0; flex: 1; text-align: left; padding: 12px 9px; font-size: 12px; line-height: 1.55; }
+.chat-link > svg { margin-top: 2px; color: var(--muted); }
+.chat-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
+.chat-label small { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; }
+.row-actions { opacity: 0; margin-right: 2px; width: 26px !important; height: 28px !important; }
+.chat-row:hover .row-actions, .chat-row:focus-within .row-actions { opacity: 1; }
+.session-attention { color: var(--danger) !important; display: flex !important; align-items: center; gap: 5px; }
+.session-attention > span { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
+.sidebar-feedback { font-size: 12px; padding: 8px; color: var(--muted); }
+.more { width: 100%; margin-top: 8px; }
+.workspace, .model-settings { grid-column: 3; grid-row: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--canvas); }
+.workspace-header { height: 68px; flex: none; padding: 0 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 18px; background: var(--canvas); z-index: 10; }
+.workspace-header-start { display: flex; align-items: center; gap: 8px; min-width: 0; }
+.workspace-label { font-size: 14px; font-weight: 550; }
+.workspace-breadcrumb { display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; flex: 1; color: var(--muted); font-size: 12px; white-space: nowrap; }
+.workspace-breadcrumb strong { overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-weight: 500; }
+.workspace-header-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
+.icon-button { border: 0; border-radius: 7px; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
+.icon-button:hover { color: var(--ink); background: var(--surface-2); }
+.icon-button[aria-expanded='true'] { background: var(--accent-soft); color: var(--accent); }
+.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); background: transparent; border: 0; padding: 6px 2px; font-size: 12px; border-radius: 4px; }
+.text-button:hover { color: var(--accent); }
+.language-picker { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; }
+.language-picker > svg { display: none; }
+.language-picker select { border: 0; padding: 7px 3px; background: transparent; border-radius: 6px; font-size: inherit; max-width: 90px; cursor: pointer; }
+.language-picker select:hover { background: var(--surface-2); }
+.feedback, .account-error { color: var(--danger); font-size: 12px; line-height: 1.6; }
+.preparation-banner { position: fixed; z-index: 15; top: 77px; right: 20px; max-width: min(420px,calc(100vw - 90px)); padding: 9px 13px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas); box-shadow: var(--shadow); font-size: 11px; color: var(--muted); }
+.primary-button, .account-submit { background: var(--button-ink); color: var(--button-text); border: 1px solid transparent; border-radius: 8px; padding: 10px 16px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; font-weight: 500; font-size: 13px; min-height: 38px; }
+.primary-button:hover, .account-submit:hover { opacity: .88; }
+.context-menu { position: fixed; z-index: 80; min-width: 165px; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas); box-shadow: var(--popover-shadow); }
+.context-menu button { width: 100%; text-align: left; display: flex; align-items: center; gap: 8px; padding: 9px 11px; font-size: 12px; color: var(--danger); border-radius: 6px; }
+.context-menu button:hover { background: var(--danger-soft); }
+.archive-dialog, .model-required-dialog, .extension-confirm { width: min(420px,calc(100vw - 36px)); border: 1px solid var(--line); border-radius: 16px; padding: 26px; background: var(--canvas); color: var(--ink); box-shadow: var(--popover-shadow); }
+dialog::backdrop { background: #15151d45; backdrop-filter: blur(3px); }
+.archive-dialog h2, .model-required-dialog h2, .extension-confirm h2 { margin: 0 0 12px; font-size: 20px; font-weight: 560; letter-spacing: -.025em; }
+.archive-dialog p, .model-required-dialog p { font-size: 13px; line-height: 1.8; color: var(--muted); }
+.dialog-actions, .model-required-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 24px; }
+.dialog-actions button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; }
+.dialog-actions button.danger { background: var(--danger); color: var(--canvas); border-color: transparent; }
+.model-required-close { position: absolute; right: 9px; top: 9px; }
+.model-required-dialog > svg { margin: 5px 0 16px; color: var(--accent); }
+.model-required-dialog small { color: var(--muted); font-size: 11px; }
+.scrim { display: none; }
+.spinner { animation: spin 1s linear infinite; }
+.page-enter { animation: surface-enter 380ms var(--ease) both; }
+@keyframes surface-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
+@keyframes popover-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
+@keyframes rail-enter { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
+@keyframes spin { to { transform: rotate(360deg); } }
+@media (max-width: 1199px) {
+ .app-files-open { --files-space: 0px; }
+ .workspace-breadcrumb > span, .workspace-breadcrumb > svg { display: none; }
+}
+@media (max-width: 1000px) {
+ .workspace-header { gap: 8px; padding: 0 16px; }
+ .workspace-breadcrumb { display: none; }
+ .workspace-header-start { flex: 1; }
+ .app-sidebar-open .workspace-header .permission-trigger > span { display: none; }
+}
+@media (max-width: 760px) {
+ :root { --rail-width: 56px; }
+ .app-sidebar-open { --sidebar-space: 0px; }
+ .navigation-rail { padding-top: 15px; }
+ .rail-brand { margin-bottom: 20px; }
+ .rail-button[aria-current]::before { left: -8px; }
+ .sidebar-slot { position: fixed; left: var(--rail-width); top: 0; bottom: 0; width: var(--sidebar-width); z-index: 35; pointer-events: none; overflow: visible; }
+ .sidebar { transform: translateX(-100%); }
+ .app-sidebar-open .sidebar-slot { pointer-events: auto; }
+ .sidebar.drawer-open { transform: translateX(0); }
+ .scrim { position: fixed; inset: 0 0 0 var(--rail-width); z-index: -1; display: block; background: #18182238; border: 0; backdrop-filter: blur(2px); }
+ .workspace-header { height: 58px; padding: 0 10px; gap: 3px; }
+ .workspace-header-start { gap: 2px; }
+ .workspace-header-actions { gap: 0; }
+ .workspace-header .header-files, .workspace-header .drawer-toggle { display: none; }
+ .workspace-header .language-picker select { max-width: 64px; padding: 6px 0; font-size: 10px; }
+ .permission-trigger > span, .permission-trigger > svg:last-child { display: none; }
+ .permission-trigger { padding: 5px !important; }
+ .account-popover { width: min(240px,calc(100vw - 80px)); }
+}
+@media (prefers-reduced-motion: reduce) {
+ *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
+}
diff --git a/frontend/src/styles/tasks.css b/frontend/src/styles/tasks.css
new file mode 100644
index 0000000..3f87cb9
--- /dev/null
+++ b/frontend/src/styles/tasks.css
@@ -0,0 +1,25 @@
+.tasks-page { flex: 1; min-height: 0; overflow: auto; width: min(100%,1180px); margin: 0 auto; padding: 34px 38px; scrollbar-width: thin; }
+.page-intro { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; gap: 15px; }
+.page-intro h1 { font-size: 27px; font-weight: 550; letter-spacing: -.035em; margin: 0 0 6px; }
+.page-intro p { font-size: 12px; color: var(--muted); margin: 0; }
+.task-tabs { display: inline-flex; align-items: center; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 9px; margin-bottom: 26px; }
+.task-tabs button { display: inline-flex; align-items: center; gap: 7px; border-radius: 6px; padding: 9px 12px; font-size: 12px; color: var(--muted); }
+.task-tabs button[aria-selected='true'] { background: var(--canvas); color: var(--ink); box-shadow: 0 1px 4px #1414200d; }
+.task-tabs button > span { font-size: 10px; background: var(--surface-2); border-radius: 4px; padding: 0 5px; color: var(--muted); }
+.tasks-body { display: grid; grid-template-columns: minmax(240px,.85fr) minmax(0,1.3fr); gap: 25px; align-items: start; }
+.task-list { display: grid; gap: 9px; }
+.task-row { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 15px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); }
+.task-row:hover { background: var(--surface); border-color: var(--line-strong); }.task-row.selected { background: var(--accent-soft); border-color: color-mix(in srgb,var(--accent) 24%,var(--line)); }
+.task-row-icon { display: grid; place-items: center; width: 31px; height: 34px; color: var(--accent); }
+.task-row-copy { flex: 1; min-width: 0; display: grid; gap: 5px; }.task-row-copy strong { font-size: 13px; font-weight: 550; line-height: 1.5; }.task-row-copy span { color: var(--muted); font-size: 11px; }.task-row-copy small { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }.task-row > svg { color: var(--quiet); margin-top: 3px; }
+.task-detail { border: 1px solid var(--line); border-radius: 13px; padding: 25px; background: var(--surface); min-width: 0; }
+.task-detail-header { position: relative; margin-bottom: 23px; }.task-detail-icon { display: grid; place-items: center; width: 45px; height: 45px; border: 1px solid var(--line); border-radius: 11px; background: var(--canvas); color: var(--accent); margin-bottom: 18px; }.task-detail-header h2 { font-size: 21px; line-height: 1.5; font-weight: 550; letter-spacing: -.025em; margin: 0; overflow-wrap: anywhere; }.task-detail-header .status-badge { position: absolute; right: 0; top: 12px; }
+.status-badge { padding: 4px 8px; border-radius: 5px; font-size: 10px; color: var(--muted); background: var(--surface-2); }.status-active { color: var(--accent); background: var(--accent-soft); }.status-ended { color: #5c8c72; background: color-mix(in srgb,#6ba380 12%,var(--canvas)); }.status-paused { color: #9a7950; background: color-mix(in srgb,#c8a06d 12%,var(--canvas)); }
+.task-facts { display: grid; gap: 9px; margin: 0; }.task-facts > div { display: grid; grid-template-columns: 20px minmax(0,1fr); column-gap: 9px; row-gap: 4px; background: var(--canvas); border: 1px solid var(--line); padding: 13px; border-radius: 9px; }.task-facts svg { grid-row: 1/3; margin-top: 1px; color: var(--muted); }.task-facts dt { font-size: 10px; color: var(--muted); }.task-facts dd { margin: 0; font-size: 12px; overflow-wrap: anywhere; line-height: 1.7; font-variant-numeric: tabular-nums; }.task-facts small { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }
+.task-prompt { margin-top: 22px; }.task-prompt h3 { font-size: 11px; color: var(--muted); font-weight: 500; margin: 0 0 8px; }.task-prompt p { font-size: 13px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
+.task-open-chat { margin-top: 23px; }.subtle-notice { font-size: 11px; color: var(--muted); }.task-back { display: none; }
+.page-empty { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; min-height: 300px; color: var(--muted); text-align: center; }.page-empty h2 { font-size: 17px; color: var(--ink); font-weight: 500; margin: 0; }.page-empty p { font-size: 12px; margin: 0; max-width: 300px; line-height: 1.7; }.page-empty svg { color: var(--quiet); }
+@media (max-width: 900px) {
+ .tasks-page { padding: 27px 22px; }.tasks-body { grid-template-columns: minmax(0,1fr); }.task-detail { display: none; }.task-detail-open .task-list { display: none; }.task-detail-open .task-detail { display: block; }.task-back { display: inline-flex; margin-bottom: 17px; }.task-row.selected { background: var(--canvas); border-color: var(--line); }
+}
+@media (max-width: 760px) { .tasks-page { padding: 24px 17px; }.task-detail { padding: 18px; }.page-intro h1 { font-size: 24px; }.task-tabs button { padding: 8px 10px; } }
diff --git a/frontend/src/tasks/Tasks.tsx b/frontend/src/tasks/Tasks.tsx
new file mode 100644
index 0000000..407aa95
--- /dev/null
+++ b/frontend/src/tasks/Tasks.tsx
@@ -0,0 +1,65 @@
+import { useCallback, useEffect, useRef, useState } from 'react'
+import { ArrowLeft, ArrowUpRight, CalendarClock, CalendarDays, CheckCheck, Clock3, FolderOpen, MessageSquare, RefreshCw, Repeat2, Send, type LucideIcon } from 'lucide-react'
+import { request } from '../api/controller'
+import { useLocale } from '../locale'
+import type { TranscriptCache } from '../chat/transcriptCache'
+import { scheduleGroup, scheduleRule, scheduleSession, scheduleTime, type Schedule } from './schedules'
+
+export function Tasks({ userId, cache, onChat }: { userId: string; cache: TranscriptCache; onChat: (id: string) => void }) {
+ const { t, language } = useLocale()
+ const [tasks, setTasks] = useState<Schedule[]>([])
+ const [tab, setTab] = useState<'upcoming' | 'completed'>('upcoming')
+ const [selected, select] = useState<string>()
+ const [busy, setBusy] = useState(true)
+ const [error, setError] = useState('')
+ const inFlight = useRef<AbortController | undefined>(undefined)
+ const load = useCallback(async () => {
+ inFlight.current?.abort()
+ const controller = new AbortController()
+ inFlight.current = controller
+ setBusy(true)
+ try {
+ const page = await request<{ tasks: Schedule[] }>('/v1/host/schedules', { signal: controller.signal }, userId)
+ if (!controller.signal.aborted) { setTasks(page.tasks ?? []); setError('') }
+ } catch { if (!controller.signal.aborted) setError('Could not load tasks. Try again.') }
+ finally { if (!controller.signal.aborted) setBusy(false) }
+ }, [userId])
+ useEffect(() => {
+ void load()
+ const off = cache.subscribe('@schedule', () => { void load() })
+ return () => { off(); inFlight.current?.abort() }
+ }, [cache, load])
+ const shown = tasks.filter(task => scheduleGroup(task) === tab).sort((a, b) => a.record.scheduledAt.localeCompare(b.record.scheduledAt))
+ const task = shown.find(task => task.record.id === selected) ?? shown[0]
+ const linked = task && scheduleSession(task)
+ const status = { active: 'Active', paused: 'Paused', ended: 'Completed' }
+ return <section className={'tasks-page page-enter' + (selected ? ' task-detail-open' : '')}>
+ <div className="page-intro"><div><h1>{t('Tasks')}</h1><p>{t('Scheduled work, all in one place.')}</p></div><button className="icon-button" title={t('Refresh tasks')} aria-label={t('Refresh tasks')} disabled={busy} onClick={() => void load()}><RefreshCw size={18} className={busy ? 'spinner' : ''} /></button></div>
+ <div className="task-tabs" role="tablist" aria-label={t('Tasks')}>{(['upcoming', 'completed'] as const).map(value => <button key={value} type="button" role="tab" aria-selected={tab === value} onClick={() => { setTab(value); select(undefined) }}>
+ {value === 'upcoming' ? <CalendarClock size={16} /> : <CheckCheck size={16} />}{t(value === 'upcoming' ? 'Upcoming' : 'Completed')}<span>{tasks.filter(task => scheduleGroup(task) === value).length}</span>
+ </button>)}</div>
+ {error && <p className="feedback" role="alert">{t(error)}</p>}
+ {!tasks.length && busy ? <div className="page-empty"><CalendarClock size={30} /><p>{t('Loading tasks…')}</p></div> : !shown.length ? <div className="page-empty"><CalendarDays size={32} strokeWidth={1.3} /><h2>{t(tab === 'upcoming' ? 'No upcoming tasks' : 'No completed tasks')}</h2><p>{t('Ask your agent to schedule something in a conversation.')}</p></div> : <div className="tasks-body">
+ <div className="task-list" role="group" aria-label={t(tab === 'upcoming' ? 'Upcoming' : 'Completed')}>{shown.map(item => <button type="button" key={item.record.id} className={'task-row' + (item === task ? ' selected' : '')} onClick={() => select(item.record.id)}>
+ <span className="task-row-icon"><CalendarClock size={18} strokeWidth={1.65} /></span><span className="task-row-copy"><strong>{item.record.title}</strong><span>{scheduleRule(item, language, t)}</span><small>{item.status === 'active' ? scheduleTime(item.record.scheduledAt, language, item.record.timeZone) : t(status[item.status])}</small></span><ArrowUpRight size={15} />
+ </button>)}</div>
+ {task && <article className="task-detail page-enter" key={task.record.id}>
+ <button type="button" className="task-back text-button" onClick={() => select(undefined)}><ArrowLeft size={16} />{t('Tasks')}</button>
+ <header className="task-detail-header"><span className="task-detail-icon"><CalendarClock size={25} strokeWidth={1.5} /></span><span className={'status-badge status-' + task.status}>{t(status[task.status])}</span><h2>{task.record.title}</h2></header>
+ <dl className="task-facts">
+ <TaskFact Icon={Clock3} label={t('Next run')} value={task.status === 'active' ? scheduleTime(task.record.scheduledAt, language, task.record.timeZone) : '—'} note={task.record.timeZone} />
+ <TaskFact Icon={Repeat2} label={t('Schedule')} value={scheduleRule(task, language, t)} note={task.record.expression || task.record.rrule} />
+ <TaskFact Icon={MessageSquare} label={t('Delivery target')} value={t(task.target?.kind === 'new' ? 'New conversation each time' : task.target?.kind === 'new_once' ? 'Create a conversation once' : 'Existing conversation')} />
+ <TaskFact Icon={Send} label={t('Last delivery')} value={scheduleTime(task.lastDelivery?.deliveredAt, language, task.record.timeZone)} />
+ {task.target?.create?.cwd && <TaskFact Icon={FolderOpen} label={t('Working directory')} value={task.target.create.cwd} />}
+ </dl>
+ <div className="task-prompt"><h3>{t('Instructions')}</h3><p>{task.record.prompt}</p></div>
+ {task.executionActive && <p className="subtle-notice">{t('The last delivery is queued or running.')}</p>}
+ {linked && <button type="button" className="primary-button task-open-chat" onClick={() => onChat(linked)}>{t('Open conversation')}<ArrowUpRight size={16} /></button>}
+ </article>}
+ </div>}
+ </section>
+}
+function TaskFact({ Icon, label, value, note }: { Icon: LucideIcon; label: string; value: string; note?: string }) {
+ return <div><Icon size={17} strokeWidth={1.6} /><dt>{label}</dt><dd>{value}{note && <small>{note}</small>}</dd></div>
+}
diff --git a/frontend/src/tasks/schedules.ts b/frontend/src/tasks/schedules.ts
new file mode 100644
index 0000000..5bfa72c
--- /dev/null
+++ b/frontend/src/tasks/schedules.ts
@@ -0,0 +1,32 @@
+export type Schedule = {
+ record: { id: string; title: string; prompt: string; kind: 'after' | 'at' | 'every' | 'daily' | 'weekly' | 'cron' | 'rrule'; scheduledAt: string; time?: string; timeZone?: string; weekdays?: number[]; expression?: string; everySeconds?: number; rrule?: string }
+ status: 'active' | 'paused' | 'ended'
+ target?: { kind: 'session' | 'new' | 'new_once'; sessionId?: string; create?: { cwd?: string; agentPreset?: string } }
+ sessionId?: string
+ lastDelivery?: { scheduledAt: string; deliveredAt: string; targetSessionId?: string; messageId: string }
+ executionActive?: boolean
+ deliveryFloorEndsAt?: string
+}
+export function scheduleGroup(task: Schedule) { return task.status === 'ended' ? 'completed' : 'upcoming' }
+export function scheduleSession(task: Schedule) {
+ return task.target?.kind === 'session' ? task.target.sessionId : task.lastDelivery?.targetSessionId ?? task.sessionId
+}
+export function scheduleTime(value: string | undefined, language: string, timeZone?: string) {
+ const date = value ? new Date(value) : null
+ return date && Number.isFinite(date.getTime()) && date.getFullYear() > 1
+ ? date.toLocaleString(language, { timeZone, month: 'short', day: 'numeric', year: 'numeric', hour: '2-digit', minute: '2-digit' }) : '—'
+}
+export function scheduleRule(task: Schedule, language: string, t: (value: string) => string) {
+ const rule = task.record
+ if (rule.kind === 'after' || rule.kind === 'at') return t('One time')
+ if (rule.kind === 'every') {
+ const seconds = rule.everySeconds ?? 0
+ const unit = seconds % 3600 === 0 ? ['hours', 3600] as const : seconds % 60 === 0 ? ['minutes', 60] as const : ['seconds', 1] as const
+ return t('Every') + ' ' + seconds / unit[1] + ' ' + t(unit[0])
+ }
+ if (rule.kind === 'daily' || rule.kind === 'weekly') {
+ const dayNames = language === 'zh-CN' ? ['一', '二', '三', '四', '五', '六', '日'] : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
+ return [t(rule.kind === 'daily' ? 'Daily' : 'Weekly'), rule.weekdays?.map(day => dayNames[day - 1]).join(' · '), rule.time?.slice(0, 5)].filter(Boolean).join(' · ')
+ }
+ return t('Custom rule')
+}
diff --git a/frontend/tests/schedules.test.ts b/frontend/tests/schedules.test.ts
new file mode 100644
index 0000000..1e9ac3d
--- /dev/null
+++ b/frontend/tests/schedules.test.ts
@@ -0,0 +1,21 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import { scheduleGroup, scheduleSession, scheduleTime, scheduleRule, type Schedule } from '../src/tasks/schedules.ts'
+const task: Schedule = {record:{id:'task',title:'Review',prompt:'Review report',kind:'weekly',scheduledAt:'2026-11-23T01:00:00Z',time:'09:00:00.000',timeZone:'Asia/Shanghai',weekdays:[1,3,5]},status:'active',target:{kind:'session',sessionId:'original'}}
+test('paused schedules remain upcoming; only ended schedules are completed',()=>{
+ assert.equal(scheduleGroup(task),'upcoming')
+ assert.equal(scheduleGroup({...task,status:'paused'}),'upcoming')
+ assert.equal(scheduleGroup({...task,status:'ended'}),'completed')
+})
+test('delivery target opens fixed or last dynamically created conversation',()=>{
+ assert.equal(scheduleSession(task),'original')
+ assert.equal(scheduleSession({...task,target:{kind:'new'}}),undefined)
+ assert.equal(scheduleSession({...task,target:{kind:'new'},lastDelivery:{scheduledAt:'',deliveredAt:'',messageId:'m',targetSessionId:'delivered'}}),'delivered')
+})
+test('task time uses its saved timezone and does not show zero-date as a real run',()=>{
+ assert.match(scheduleTime(task.record.scheduledAt,'en','Asia/Shanghai'),/09:00/)
+ assert.equal(scheduleTime(undefined,'en'),'—')
+ assert.equal(scheduleTime('0001-01-01T00:00:00Z','en'),'—')
+ assert.equal(scheduleTime('invalid','en'),'—')
+ assert.equal(scheduleRule(task,'en',x=>x),'Weekly · Mon · Wed · Fri · 09:00')
+})
diff --git a/frontend/tests/textPlayback.test.ts b/frontend/tests/textPlayback.test.ts
new file mode 100644
index 0000000..8c6a190
--- /dev/null
+++ b/frontend/tests/textPlayback.test.ts
@@ -0,0 +1,176 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import { TextPlayback } from '../src/chat/textPlayback.ts'
+import { applySessionEvent, applyStreamEvent, emptyTranscript, attemptMessage, messageText, textMessage, type Message } from '../src/chat/transcript.ts'
+
+const assistant = (text: string, id = 'draft', step = 1): Message => ({ ...textMessage(id, text, 'assistant'), turn: 1, step })
+const texts = (player: TextPlayback) => player.view().messages.map(messageText)
+function tick(player: TextPlayback, from: number, duration: number) {
+ for (let at = from + 32; at <= from + duration; at += 32) player.advance(at)
+}
+function ready(history: Message[] = []) {
+ const player = new TextPlayback()
+ player.sync(history, true, 0, 0)
+ return player
+}
+
+test('a later delta appends to the target without restarting the visible prefix', () => {
+ const player = ready()
+ const start = '这是一个连续展示的回答。'.repeat(8)
+ player.sync([assistant(start)], true, 0, 0)
+ tick(player, 0, 128)
+ const prefix = texts(player)[0]
+ assert.ok(prefix.length > 0 && prefix.length < start.length)
+ player.sync([assistant(start + '下一段增量。')], true, 0, 128)
+ assert.equal(texts(player)[0], prefix)
+ tick(player, 128, 5000)
+ assert.deepEqual(texts(player), [start + '下一段增量。'])
+ assert.equal(player.pending, false)
+})
+
+test('actual reducer draft → committed message → turn/end keeps the display position and stable keys', () => {
+ let transcript = emptyTranscript()
+ const player = ready()
+ transcript = applyStreamEvent(transcript, 'assistant-stream', { frame: {
+ type: 'start', attemptId: 'attempt', turn: 1, step: 1, revision: 1, startedAfterSeq: 0,
+ } })
+ const full = '持续输出,不被完整消息跳过。'.repeat(10)
+ transcript = applyStreamEvent(transcript, 'assistant-stream', { frame: {
+ type: 'chunk', attemptId: 'attempt', index: 0, revision: 2, chunk: { type: 'text-delta', text: full },
+ } })
+ player.sync([attemptMessage(transcript.draft!)], true, 0, 0)
+ tick(player, 0, 128)
+ const before = player.view()
+ assert.ok(before.pending)
+ transcript = applySessionEvent(transcript, { seq: 1, type: 'assistant/message', data: {
+ turn: 1, step: 1, message: { id: 'committed', blocks: [{ id: 'settled-text', type: 'text', text: full }] },
+ } })
+ transcript = applySessionEvent(transcript, { seq: 2, type: 'turn/end', data: { turn: 1, reason: { kind: 'completed' } } })
+ player.sync(transcript.messages, true, 0, 128)
+ assert.equal(transcript.activeTurn, null)
+ assert.deepEqual(player.view().messages.map(message => ({ id: message.id, blocks: message.blocks })),
+ before.messages.map(message => ({ id: message.id, blocks: message.blocks })))
+ assert.ok(player.pending)
+ tick(player, 128, 5000)
+ assert.equal(texts(player)[0], full)
+})
+
+test('a fast complete message is also played; later blocks and steps retain their order', () => {
+ const player = ready()
+ const one = assistant('前面的文字。'.repeat(15), 'committed')
+ one.blocks.push({ id: 'tool', type: 'tool', callId: 'call', name: 'bash' },
+ { id: 'image', type: 'image', attachment: { attachmentId: 'image' } },
+ { id: 'file', type: 'file', file: { source: 'presented', path: '/root/harness/report.docx' } })
+ const two = assistant('后面的结果。'.repeat(10), 'next-step', 2)
+ player.sync([one, two], true, 0, 0)
+ tick(player, 0, 96)
+ assert.equal(player.view().messages.length, 1)
+ assert.deepEqual(player.view().messages[0].blocks.map(block => block.type), ['text'])
+ tick(player, 96, 5000)
+ assert.deepEqual(player.view().messages.flatMap(message => message.blocks.map(block => block.type)), ['text', 'tool', 'image', 'file', 'text'])
+})
+
+test('user messages stay immediate while an earlier assistant text is still playing', () => {
+ const player = ready()
+ const user = textMessage('steer', '请继续')
+ player.sync([assistant('正在生成的文字。'.repeat(20)), user], true, 0, 0)
+ assert.deepEqual(player.view().messages, [user])
+ assert.ok(player.pending)
+})
+
+test('initial history and prepended older pages do not replay', () => {
+ const history = assistant('已有历史', 'old', 2)
+ const player = ready([history])
+ assert.equal(player.pending, false)
+ player.sync([assistant('更早的内容', 'older', 1), history], true, 0, 32)
+ assert.deepEqual(texts(player), ['更早的内容', '已有历史'])
+ assert.equal(player.pending, false)
+ player.sync([assistant('更早的内容', 'older', 1), history, assistant('新消息'.repeat(50), 'new', 3)], true, 0, 64)
+ assert.equal(player.pending, true)
+})
+
+test('restored baseline, hidden view and reduced motion snap to the received content', () => {
+ const player = ready()
+ const message = assistant('长内容'.repeat(80))
+ player.sync([message], true, 0, 0)
+ assert.ok(player.pending)
+ player.sync([message], true, 1, 32)
+ assert.equal(player.pending, false)
+ player.sync([assistant(messageText(message) + '更多'.repeat(80))], true, 1, 64)
+ assert.ok(player.pending)
+ player.sync([message], false, 1, 96)
+ assert.equal(player.pending, false)
+ player.sync([assistant('后台新到的完整内容')], true, 1, 128)
+ assert.deepEqual(texts(player), ['后台新到的完整内容'])
+ assert.equal(player.pending, false)
+ const otherSession = new TextPlayback()
+ otherSession.sync([assistant('另一个会话的历史')], true, 0, 0)
+ assert.equal(otherSession.pending, false)
+})
+
+test('cancellation removes an uncommitted draft and retries do not concatenate abandoned content', () => {
+ const player = ready()
+ player.sync([assistant('旧尝试'.repeat(40))], true, 0, 0)
+ tick(player, 0, 128)
+ player.sync([], true, 0, 128)
+ assert.equal(player.pending, false)
+ assert.deepEqual(player.view().messages, [])
+ player.sync([assistant('全新尝试'.repeat(40), 'retry')], true, 0, 160)
+ tick(player, 160, 5000)
+ assert.deepEqual(texts(player), ['全新尝试'.repeat(40)])
+})
+
+test('non-prefix correction preserves only the already visible common prefix', () => {
+ const player = ready()
+ player.sync([assistant('相同前缀,然后是旧内容。'.repeat(10))], true, 0, 0)
+ tick(player, 0, 128)
+ player.sync([assistant('相同前缀,新的答案。'.repeat(10), 'replacement')], true, 0, 128)
+ assert.ok('相同前缀,'.startsWith(texts(player)[0] ?? ''))
+ tick(player, 128, 5000)
+ assert.deepEqual(texts(player), ['相同前缀,新的答案。'.repeat(10)])
+})
+
+test('Unicode clusters are not split, even when a delta completes a combined emoji', () => {
+ const player = ready()
+ const full = '👩🏽‍💻🇨🇳e\u0301你好'.repeat(20)
+ player.sync([assistant(full)], true, 0, 0)
+ const validEnds = new Set(Array.from(new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(full), part => part.index + part.segment.length))
+ for (let at = 32; at < 3000; at += 32) {
+ player.advance(at)
+ const length = (texts(player)[0] ?? '').length
+ assert.ok(length === 0 || validEnds.has(length))
+ }
+ player.sync([assistant(full + '👩')], true, 0, 3000)
+ tick(player, 3000, 100)
+ player.sync([assistant(full + '👩‍💻')], true, 0, 3100)
+ assert.ok((texts(player)[0] ?? '').endsWith('👩‍💻'))
+})
+
+test('large backlog accelerates but cannot turn a long frame suspension into an instant jump', () => {
+ const player = ready()
+ player.sync([assistant('字'.repeat(3000))], true, 0, 0)
+ player.advance(10000)
+ assert.ok(texts(player)[0].length > 0 && texts(player)[0].length <= 36)
+ tick(player, 10000, 960)
+ assert.ok(texts(player)[0].length > 300)
+})
+
+test('a next-step draft can arrive before the previous step commit without losing its playback position', () => {
+ const player = ready()
+ const first = { ...assistant('第一步的说明。'.repeat(30)), streaming: true }
+ const second = { ...assistant('第二步的结论。'.repeat(20), 'next-attempt', 2), streaming: true }
+ player.sync([first], true, 0, 0)
+ tick(player, 0, 128)
+ const prefix = texts(player)[0]
+ player.sync([{ ...second, blocks: [] }], true, 0, 128)
+ assert.equal(texts(player)[0], prefix)
+ player.sync([second], true, 0, 128)
+ assert.equal(texts(player)[0], prefix)
+ player.sync([assistant(messageText(first), 'committed'), second], true, 0, 160)
+ assert.equal(texts(player)[0], prefix)
+ tick(player, 160, 10000)
+ assert.deepEqual(texts(player), [messageText(first), messageText(second)])
+ player.sync([], true, 0, 10200)
+ assert.deepEqual(player.view().messages, [])
+ assert.equal(player.pending, false)
+})
diff --git a/frontend/tests/transcript.test.ts b/frontend/tests/transcript.test.ts
index e49ffdc..3598581 100644
--- a/frontend/tests/transcript.test.ts
+++ b/frontend/tests/transcript.test.ts
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
-import { applySessionEvent, applyStreamEvent, attemptMessage, emptyTranscript, groupAssistantReplies, groupDisplayBlocks, messageText, textMessage, visibleQueue } from '../src/chat/transcript.ts'
+import { applySessionEvent, applyStreamEvent, attemptMessage, emptyTranscript, groupAssistantReplies, groupDisplayBlocks, messageBlocksForDisplay, messageText, textMessage, visibleQueue } from '../src/chat/transcript.ts'
test('replays history and replaces the in-flight text once its durable event arrives', () => {
let state = applySessionEvent(emptyTranscript(), {
@@ -133,3 +133,47 @@ test('renders a delivered file immediately and updates a repeated declaration',
assert.deepEqual(groupAssistantReplies(history.messages), groupAssistantReplies(updated.messages))
assert.deepEqual(groupAssistantReplies(updated.messages)[0].blocks[1], latest.data.message.blocks[0])
})
+
+test('consecutive image tools form their own group and preserve call order as results arrive', () => {
+ const tools = ['a', 'b', 'c'].map(id => ({ id, type: 'tool' as const, name: 'readimage', callId: id }))
+ const image = (id: string) => ({ id, type: 'image' as const, attachment: { attachmentId: id, name: id + '.png' } })
+ const blocks = [tools[0], tools[1], { id: 'break', type: 'text' as const, text: 'A new comparison' }, tools[2]]
+ const pending = groupDisplayBlocks(blocks, {})
+ assert.deepEqual(pending.map(block => block.type), ['image-tools', 'text', 'image-tools'])
+ const groups = groupDisplayBlocks(blocks, {
+ b: { status: 'succeeded', images: [image('second')] }, a: { status: 'succeeded', images: [image('first')] },
+ })
+ assert.equal(groups[0].type, 'image-tools')
+ if (groups[0].type !== 'image-tools') throw new Error('missing image tool group')
+ assert.deepEqual(groups[0].tools.map(tool => tool.callId), ['a', 'b'])
+ assert.deepEqual(groups[0].images.map(image => image.id), ['first', 'second'])
+ assert.deepEqual(groups[0].images[0].file, { source: 'attachment', attachmentId: 'first' })
+ assert.equal(blocks.length, 4)
+})
+
+test('other tools break image tool groups; only explicit presented raster files get image previews', () => {
+ const read = (id: string) => ({ id, type: 'tool' as const, name: 'readimage', callId: id })
+ const file = (name: string) => ({ id: name, type: 'file' as const, name, file: { source: 'presented' as const, path: '/root/harness/' + name } })
+ const grouped = groupDisplayBlocks([
+ read('a'), { id: 'shell', type: 'tool', callId: 'shell', name: 'shellexecute' }, read('b'),
+ file('first.PNG'), file('second.jpg'), file('report.docx'), file('third.webp'), file('vector.svg'),
+ { id: 'upload', type: 'file', name: 'upload.png', file: { source: 'attachment', attachmentId: 'upload' } },
+ ], {})
+ assert.deepEqual(grouped.map(block => block.type), ['image-tools', 'tool', 'image-tools', 'image-row', 'file', 'image-row', 'file', 'file'])
+ assert.equal(grouped[3].type, 'image-row')
+ if (grouped[3].type !== 'image-row') throw new Error('missing delivered images')
+ assert.deepEqual(grouped[3].images.map(image => image.name), ['first.PNG', 'second.jpg'])
+ assert.deepEqual(grouped[3].images[0].file, { source: 'presented', path: '/root/harness/first.PNG' })
+})
+
+test('user attachments retain mixed upload order before text; assistant interleaving is unchanged', () => {
+ const message = { ...textMessage('message', 'Explain these'), blocks: [
+ ...textMessage('message', 'Explain these').blocks,
+ { id: 'file', type: 'file' as const, file: { source: 'attachment' as const, attachmentId: 'file' } },
+ { id: 'image', type: 'image' as const, attachment: { attachmentId: 'image' } },
+ ] }
+ assert.deepEqual(messageBlocksForDisplay(message).map(block => block.type), ['file', 'image', 'text'])
+ assert.deepEqual(message.blocks.map(block => block.type), ['text', 'file', 'image'])
+ const assistant = { ...message, role: 'assistant' as const }
+ assert.equal(messageBlocksForDisplay(assistant), assistant.blocks)
+})
diff --git a/internal/httpapi/native_message_parts.go b/internal/httpapi/native_message_parts.go
index 200af1a..c22e5d3 100644
--- a/internal/httpapi/native_message_parts.go
+++ b/internal/httpapi/native_message_parts.go
@@ -23,7 +23,8 @@ var errInputTooLarge = errors.New("input file exceeds limit")
var errInvalidInputUpload = errors.New("invalid input upload")
// A native multipart request keeps explicit image and verbatim file parts in
-// submission order. The text field precedes attachments in the public API.
+// submission order. The text field is read first for admission; the final message
+// puts attachments first and appends the user text.
type stagedNativePart struct {
file *os.File
name string
diff --git a/internal/httpapi/native_worker_http.go b/internal/httpapi/native_worker_http.go
index 68830b2..e3cb952 100644
--- a/internal/httpapi/native_worker_http.go
+++ b/internal/httpapi/native_worker_http.go
@@ -345,9 +345,6 @@ func nativeWorkerMessage(c *gin.Context, worker NativeWorkerHTTPRuntime, options
}
return
}
- if content != "" {
- blocks = append(blocks, map[string]any{"type": "text", "text": content})
- }
if !options.ImageInputEnabled {
for _, item := range staged {
if item.kind == "image" {
@@ -389,6 +386,10 @@ func nativeWorkerMessage(c *gin.Context, worker NativeWorkerHTTPRuntime, options
files = append(files, ref)
blocks = append(blocks, map[string]any{"type": "file", "attachment": ref})
}
+ // Keep mixed attachments in upload order, then append the user instruction.
+ if content != "" {
+ blocks = append(blocks, map[string]any{"type": "text", "text": content})
+ }
} else {
c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, maxMessageContentBytes)
var request struct {
diff --git a/internal/httpapi/native_worker_http_test.go b/internal/httpapi/native_worker_http_test.go
index f413d19..751e9d3 100644
--- a/internal/httpapi/native_worker_http_test.go
+++ b/internal/httpapi/native_worker_http_test.go
@@ -315,10 +315,10 @@ func TestNativeWorkerHTTPAdmitsMultipartAsDurableFileBlocks(t *testing.T) {
if err := json.Unmarshal(worker.messages[0], &message); err != nil {
t.Fatal(err)
}
- if message.ID == "" || message.Role != "user" || len(message.Content) != 2 || message.Content[0].Text != "Read the attached report" || message.Content[1].Type != "file" {
+ if message.ID == "" || message.Role != "user" || len(message.Content) != 2 || message.Content[1].Text != "Read the attached report" || message.Content[0].Type != "file" {
t.Fatalf("invalid native file message: %s", worker.messages[0])
}
- ref := message.Content[1].Attachment
+ ref := message.Content[0].Attachment
if ref.Name != "report.txt" || !strings.HasPrefix(ref.ID, "sha256:") || ref.Bytes != int64(len("verbatim file bytes")) {
t.Fatalf("invalid native file ref: %+v", ref)
}
@@ -440,7 +440,7 @@ func TestNativeWorkerHTTPAdmitsMixedImageAndFileBlocks(t *testing.T) {
if err := json.Unmarshal(worker.messages[0], &message); err != nil {
t.Fatal(err)
}
- if len(message.Content) != 3 || message.Content[0].Type != "text" || message.Content[1].Type != "image" || message.Content[2].Type != "file" {
+ if len(message.Content) != 3 || message.Content[0].Type != "image" || message.Content[1].Type != "file" || message.Content[2].Type != "text" || message.Content[2].Text != "Compare these attachments" {
t.Fatalf("multipart order was not preserved: %s", worker.messages[0])
}
var imageRef struct {
@@ -451,7 +451,7 @@ func TestNativeWorkerHTTPAdmitsMixedImageAndFileBlocks(t *testing.T) {
Height int `json:"height"`
Name string `json:"name"`
}
- if err := json.Unmarshal(message.Content[1].Attachment, &imageRef); err != nil {
+ if err := json.Unmarshal(message.Content[0].Attachment, &imageRef); err != nil {
t.Fatal(err)
}
if !strings.HasPrefix(imageRef.AttachmentID, "sha256:") || imageRef.MediaType != "image/png" || imageRef.Bytes != int64(len(imageSource)) || imageRef.Width != 2 || imageRef.Height != 1 || imageRef.Name != "chart.png" {
diff --git a/mobile/package-lock.json b/mobile/package-lock.json
index 7e6bf24..aaa3380 100644
--- a/mobile/package-lock.json
+++ b/mobile/package-lock.json
@@ -8,9 +8,11 @@
"name": "go-bot-mobile",
"version": "0.0.1",
"dependencies": {
+ "@react-native-masked-view/masked-view": "0.3.2",
"eventsource-parser": "4.1.3",
"expo": "~58.0.25",
"expo-build-properties": "~58.0.12",
+ "expo-clipboard": "~58.0.4",
"expo-document-picker": "~58.0.5",
"expo-file-system": "~58.0.13",
"expo-image-manipulator": "~58.0.16",
@@ -1696,6 +1698,16 @@
"url": "https://github.com/sponsors/oxc-project"
}
},
+ "node_modules/@react-native-masked-view/masked-view": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/@react-native-masked-view/masked-view/-/masked-view-0.3.2.tgz",
+ "integrity": "sha512-XwuQoW7/GEgWRMovOQtX3A4PrXhyaZm0lVUiY8qJDvdngjLms9Cpdck6SmGAUNqQwcj2EadHC1HwL0bEyoa/SQ==",
+ "license": "MIT",
+ "peerDependencies": {
+ "react": ">=16",
+ "react-native": ">=0.57"
+ }
+ },
"node_modules/@react-native/asset-utils": {
"version": "0.88.1",
"resolved": "https://registry.npmjs.org/@react-native/asset-utils/-/asset-utils-0.88.1.tgz",
@@ -3024,6 +3036,17 @@
"expo": "*"
}
},
+ "node_modules/expo-clipboard": {
+ "version": "58.0.4",
+ "resolved": "https://registry.npmjs.org/expo-clipboard/-/expo-clipboard-58.0.4.tgz",
+ "integrity": "sha512-b2eEJMwdWXLTrmrkg/otsmL2OV6s9D90tytSNBsY87UswrWf6JwxcB2OaWegyUWD9XnvtBVNeVK7lej0zZh+5A==",
+ "license": "MIT",
+ "peerDependencies": {
+ "expo": "*",
+ "react": "*",
+ "react-native": "*"
+ }
+ },
"node_modules/expo-document-picker": {
"version": "58.0.5",
"resolved": "https://registry.npmjs.org/expo-document-picker/-/expo-document-picker-58.0.5.tgz",
diff --git a/mobile/package.json b/mobile/package.json
index 11d0ba1..cbee7d9 100644
--- a/mobile/package.json
+++ b/mobile/package.json
@@ -10,9 +10,11 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
+ "@react-native-masked-view/masked-view": "0.3.2",
"eventsource-parser": "4.1.3",
"expo": "~58.0.25",
"expo-build-properties": "~58.0.12",
+ "expo-clipboard": "~58.0.4",
"expo-document-picker": "~58.0.5",
"expo-file-system": "~58.0.13",
"expo-image-manipulator": "~58.0.16",
diff --git a/mobile/src/Chat.tsx b/mobile/src/Chat.tsx
index 417b018..f0387c4 100644
--- a/mobile/src/Chat.tsx
+++ b/mobile/src/Chat.tsx
@@ -1,6 +1,6 @@
import { useLocale } from './locale'
-import { useEffect, useRef, useState, type ComponentRef } from 'react'
-import { ActivityIndicator, Alert, Animated, Easing, Image, Keyboard, Pressable, ScrollView, StyleSheet, Text, TextInput, View } from 'react-native'
+import { useEffect, useMemo, useRef, useState, type ComponentRef } from 'react'
+import { ActivityIndicator, Alert, Animated, AppState, Easing, Image, Keyboard, Pressable, ScrollView, StyleSheet, Text, TextInput, View } from 'react-native'
import { ArrowUp, ChevronDown, FileText, ImagePlus, Images, ListFilter, MessageCircle, MessageCircleQuestion, Plus, Shield, ShieldAlert, Square, X } from 'lucide-react-native'
import { attemptMessage, groupAssistantReplies, messageText, visibleQueue, type Message } from '../../frontend/src/chat/transcript'
import type { TranscriptCache } from '../../frontend/src/chat/transcriptCache'
@@ -17,6 +17,7 @@ import { accent, Button, edge, glass, Hint, IconButton, ink, logo, muted, Panel,
import { ApprovalSheet, PermissionSheet, permissionNames } from './PermissionSheets'
import type { PermissionMode } from '../../frontend/src/chat/permissions'
import { useTranscript } from './useTranscript'
+import { useTextPlayback } from '../../frontend/src/chat/useTextPlayback'
type Props = {
api: Controller; cache: TranscriptCache; id: string; active: boolean
@@ -311,14 +312,26 @@ function Conversation({ api, cache, id, pending, active, sending, onUnavailable,
const following = useRef(true)
const turn = state.activeTurn
const question = state.questions[0]
- const draft = state.draft ? attemptMessage(state.draft) : null
- const messages = state.messages.slice()
- const awaiting = pending && !messages.some(message => message.id === pending.id) && !state.queue.some(item => item.id === pending.id)
- if (draft?.blocks.length) messages.push(draft)
- const replies = groupAssistantReplies(messages)
+ const messages = useMemo(() => {
+ const messages = state.messages.slice()
+ const draft = state.draft ? attemptMessage(state.draft) : null
+ if (draft) messages.push(draft)
+ return messages
+ }, [state.messages, state.draft])
+ const reduced = useReducedMotion()
+ const [foreground, setForeground] = useState(AppState.currentState === 'active')
+ useEffect(() => {
+ const listener = AppState.addEventListener('change', state => setForeground(state === 'active'))
+ return () => listener.remove()
+ }, [])
+ const playback = useTextPlayback(api.profile.account + '/' + id, messages,
+ active && foreground && !reduced && !loading && !connecting, state.streamEpoch)
+ const awaiting = pending && !state.messages.some(message => message.id === pending.id) && !state.queue.some(item => item.id === pending.id)
+ const replies = groupAssistantReplies(playback.messages)
const idle = turn === null && !state.queue.length
- const generating = turn !== null
- const hasReply = generating && replies.some(message => message.role === 'assistant' && message.turn === turn)
+ const generating = turn !== null || playback.pending
+ const displayTurn = turn ?? playback.pendingTurn
+ const hasReply = generating && replies.some(message => message.role === 'assistant' && message.turn === displayTurn)
const waiting = awaiting || generating && !hasReply
const title = waiting ? t('正在等待回复…') : t('生成中')
const queue = visibleQueue(state, state.messages)
@@ -328,7 +341,7 @@ function Conversation({ api, cache, id, pending, active, sending, onUnavailable,
try { await work() } catch (e) { setFailed(problem(e)) }
}
function message(item: Message) {
- return <MessageView api={api} id={id} key={item.id} message={item} generating={generating && item.role === 'assistant' && item.turn === turn} results={state.toolResults} openImage={setPreview} />
+ return <MessageView api={api} id={id} key={item.id} message={item} generating={generating && item.role === 'assistant' && item.turn === displayTurn} results={state.toolResults} openImage={setPreview} />
}
return <>
@@ -347,8 +360,8 @@ function Conversation({ api, cache, id, pending, active, sending, onUnavailable,
</View>}
{replies.map(message)}
{awaiting && <View style={styles.pending}>
- {!!pending.text && <Text style={s.body}>{pending.text}</Text>}
{pending.files.map(file => <Text key={file.id} numberOfLines={1} style={s.caption}>{file.name}</Text>)}
+ {!!pending.text && <Text style={s.body}>{pending.text}</Text>}
</View>}
{waiting && !hasReply && <View style={s.row}>
<Image source={logo} style={{ width: 36, height: 36 }} />
@@ -364,7 +377,7 @@ function Conversation({ api, cache, id, pending, active, sending, onUnavailable,
</View>)}
</View>}
{!!failed && <View style={{ paddingHorizontal: 20 }}><Hint error>{t(failed)}</Hint></View>}
- {!loading && !unavailable && renderComposer({ idle, generation: generating, cancel: () => { if (turn !== null) void action(() => api.stopTurn(id, turn)) },
+ {!loading && !unavailable && renderComposer({ idle, generation: turn !== null, cancel: () => { if (turn !== null) void action(() => api.stopTurn(id, turn)) },
livePermission: state.permission?.mode,
questionButton: question && <Button label={t(question.approval ? '查看执行审批' : '回答助手的问题')}
onPress={() => { Keyboard.dismiss(); hideQuestion('') }}>
diff --git a/mobile/src/ImageViewer.tsx b/mobile/src/ImageViewer.tsx
index 9ae508b..31b23fb 100644
--- a/mobile/src/ImageViewer.tsx
+++ b/mobile/src/ImageViewer.tsx
@@ -21,7 +21,7 @@ export function ImageViewer({ preview, close }: { preview: Preview; close: () =>
setSaving(true)
setFeedback('')
try {
- const item = await saveRemote(preview, 'image')
+ const item = await saveRemote(preview, 'image', preview.workspace)
try {
if (!await saveToDevicePhotos(item)) {
setFeedback('已保存到本地图片。请在系统设置中允许添加到图库。')
diff --git a/mobile/src/MarkdownText.tsx b/mobile/src/MarkdownText.tsx
new file mode 100644
index 0000000..7b74ee1
--- /dev/null
+++ b/mobile/src/MarkdownText.tsx
@@ -0,0 +1,137 @@
+import { createContext, memo, useContext, useEffect, useRef, useState } from 'react'
+import { Linking, Platform, Pressable, ScrollView, StyleSheet, Text, View, useWindowDimensions } from 'react-native'
+import Markdown, { MarkdownIt, type ASTNode } from 'react-native-markdown-display'
+import * as Clipboard from 'expo-clipboard'
+import { Check, Copy } from 'lucide-react-native'
+import { useLocale } from './locale'
+import { accent, ink, muted } from './ui'
+
+const mono = Platform.OS === 'ios' ? 'Menlo' : 'monospace'
+const border = '#e1e3e8', paper = '#f6f7f9'
+type SourceNode = ASTNode & { sourceMeta?: { markdownSource?: string }; sourceInfo?: string }
+const parser = new MarkdownIt({ typographer: true })
+// Keep the original source with the parser token before the library creates AST nodes.
+parser.core.ruler.after('block', 'copy-markdown-source', (state: { src: string; tokens: { map: [number, number] | null; type: string; meta?: Record<string, unknown> }[] }) => {
+ const lines = state.src.split('\n')
+ for (const token of state.tokens) {
+ if (token.map && ['table_open', 'fence', 'code_block'].includes(token.type)) {
+ token.meta = { ...token.meta, markdownSource: lines.slice(token.map[0], token.map[1]).join('\n').replace(/\n$/, '') }
+ }
+ }
+})
+
+function CopyButton({ raw, kind }: { raw: string; kind: 'table' | 'code' }) {
+ const { t } = useLocale()
+ const [status, setStatus] = useState<'idle' | 'copied' | 'failed'>('idle')
+ const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
+ useEffect(() => () => clearTimeout(timer.current), [])
+ const label = status === 'copied' ? '已复制' : status === 'failed' ? '复制失败,重试' : kind === 'table' ? '复制表格' : '复制代码'
+ return <Pressable accessibilityRole="button" accessibilityLabel={t(label)} style={({ pressed }) => [styles.copy, pressed && { opacity: .55 }]} onPress={async () => {
+ clearTimeout(timer.current)
+ try { await Clipboard.setStringAsync(raw); setStatus('copied') } catch { setStatus('failed') }
+ timer.current = setTimeout(() => setStatus('idle'), 2200)
+ }}>{status === 'copied' ? <Check size={14} color={muted} /> : <Copy size={14} color={muted} />}<Text accessibilityLiveRegion="polite" style={styles.action}>{t(label)}</Text></Pressable>
+}
+
+const MarkdownWidth = createContext<number | undefined>(undefined)
+function InlineCode({ text, cellWidth }: { text: string; cellWidth?: number }) {
+ const { width } = useWindowDimensions()
+ const contentWidth = useContext(MarkdownWidth)
+ const available = Math.max(48, cellWidth ?? contentWidth ?? width - 60)
+ const [size, setSize] = useState({ width: available, height: 24 })
+ // Android Text background spans do not clip to borderRadius. A measured inline
+ // view gives both platforms the same rounded pill without estimating glyphs.
+ return <View style={[styles.inline, { width: Math.min(available, size.width), height: size.height }]}>
+ <Text selectable style={styles.inlineText} onTextLayout={({ nativeEvent: { lines } }) => {
+ if (!lines.length) return
+ const next = { width: lines.length > 1 ? available : Math.min(available, Math.ceil(lines[0].width) + 12), height: Math.ceil(lines.reduce((sum, line) => sum + line.height, 0)) + 4 }
+ setSize(old => old.width === next.width && old.height === next.height ? old : next)
+ }}>{text}</Text>
+ </View>
+}
+
+function CodePanel({ node }: { node: SourceNode }) {
+ const { t } = useLocale()
+ return <View style={styles.panel}>
+ <View style={styles.toolbar}><Text style={styles.caption}>{node.sourceInfo?.trim().split(/\s/)[0] || t('代码')}</Text><CopyButton raw={node.sourceMeta?.markdownSource ?? node.content} kind="code" /></View>
+ <ScrollView horizontal nestedScrollEnabled directionalLockEnabled showsHorizontalScrollIndicator accessibilityLabel={t('代码,可左右滚动')} contentContainerStyle={styles.codeContent}>
+ <Text selectable style={styles.code}>{node.content.replace(/\n$/, '')}</Text>
+ </ScrollView>
+ </View>
+}
+
+function rows(node: ASTNode): ASTNode[] { return node.type === 'tr' ? [node] : node.children.flatMap(rows) }
+function plain(node: ASTNode): string { return node.type === 'softbreak' || node.type === 'hardbreak' ? '\n' : node.children.length ? node.children.map(plain).join('') : node.content || '' }
+function columnWidths(table: ASTNode) {
+ const result: number[] = []
+ for (const row of rows(table)) row.children.forEach((cell, index) => {
+ const length = Array.from(plain(cell)).reduce((width, char) => width + (/[^\x00-\x7f]/.test(char) ? 16 : 8), 0)
+ result[index] = Math.max(result[index] || 112, Math.min(240, length + 28))
+ })
+ return result
+}
+
+export const MarkdownText = memo(function MarkdownText({ text }: { text: string }) {
+ const { t } = useLocale()
+ const [width, setWidth] = useState<number>()
+ return <View onLayout={({ nativeEvent: { layout } }) => setWidth(old => old === layout.width ? old : layout.width)}><MarkdownWidth.Provider value={width}><Markdown markdownit={parser} style={markdown} rules={{
+ image: node => <Text key={node.key} selectable>{'![' + (node.attributes.alt ?? '') + '](' + node.attributes.src + ')'}</Text>,
+ code_inline: (node, _children, parents) => {
+ const table = parents.find(parent => parent.type === 'table')
+ const cell = parents.find(parent => parent.type === 'td' || parent.type === 'th')
+ return <InlineCode key={node.key} text={node.content} cellWidth={table && cell ? columnWidths(table)[cell.index] - 28 : undefined} />
+ },
+ fence: node => <CodePanel key={node.key} node={node} />,
+ code_block: node => <CodePanel key={node.key} node={node} />,
+ table: (node: SourceNode, children) => <View key={node.key} style={[styles.panel, { backgroundColor: '#ffffff80' }]}>
+ <View style={styles.toolbar}><Text style={styles.caption}>{t('表格')}</Text><CopyButton raw={node.sourceMeta?.markdownSource || ''} kind="table" /></View>
+ <ScrollView horizontal nestedScrollEnabled directionalLockEnabled showsHorizontalScrollIndicator accessibilityLabel={t('表格,可左右滚动')}>
+ <View style={{ width: columnWidths(node).reduce((a, b) => a + b, 0) }}>{children}</View>
+ </ScrollView>
+ </View>,
+ th: (node, children, parents) => {
+ const table = parents.find(parent => parent.type === 'table')
+ return <View key={node.key} style={[styles.cell, styles.headerCell, { width: table ? columnWidths(table)[node.index] : 140 }]}>{children}</View>
+ },
+ td: (node, children, parents) => {
+ const table = parents.find(parent => parent.type === 'table')
+ return <View key={node.key} style={[styles.cell, { width: table ? columnWidths(table)[node.index] : 140 }]}>{children}</View>
+ },
+ }} onLinkPress={url => { if (/^https?:\/\//i.test(url)) void Linking.openURL(url).catch(() => {}); return false }}>{text}</Markdown></MarkdownWidth.Provider></View>
+})
+
+const styles = StyleSheet.create({
+ panel: { alignSelf: 'stretch', minWidth: 0, marginTop: 8, marginBottom: 18, borderWidth: StyleSheet.hairlineWidth, borderColor: border, borderRadius: 10, backgroundColor: paper, overflow: 'hidden' },
+ toolbar: { minHeight: 44, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingLeft: 14, paddingRight: 6, borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: border, backgroundColor: '#f4f5f8' },
+ inline: { borderRadius: 5, backgroundColor: '#eef0f4', borderWidth: StyleSheet.hairlineWidth, borderColor: border, paddingHorizontal: 5, paddingVertical: 1, overflow: 'hidden' },
+ inlineText: { fontFamily: mono, color: '#414756', fontSize: 13, lineHeight: 20 },
+ caption: { fontSize: 11, fontWeight: '500', color: muted },
+ copy: { minHeight: 44, minWidth: 72, paddingHorizontal: 8, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 6 },
+ action: { fontSize: 11, color: muted },
+ codeContent: { padding: 15, flexGrow: 1 },
+ code: { fontFamily: mono, fontSize: 13, lineHeight: 22, color: '#313747', flexShrink: 0 },
+ cell: { paddingHorizontal: 14, paddingVertical: 12, justifyContent: 'center', flexGrow: 0, flexShrink: 0 },
+ headerCell: { backgroundColor: '#f4f5f8' },
+})
+const markdown = StyleSheet.create({
+ body: { color: ink, fontSize: 16, lineHeight: 27 },
+ paragraph: { marginTop: 0, marginBottom: 16 },
+ heading1: { fontSize: 25, lineHeight: 33, fontWeight: '700', marginTop: 24, marginBottom: 14 },
+ heading2: { fontSize: 22, lineHeight: 30, fontWeight: '700', marginTop: 22, marginBottom: 12 },
+ heading3: { fontSize: 19, lineHeight: 27, fontWeight: '600', marginTop: 20, marginBottom: 12 },
+ heading4: { fontSize: 17, lineHeight: 26, fontWeight: '600', marginTop: 18, marginBottom: 10 },
+ heading5: { fontSize: 16, lineHeight: 25, fontWeight: '600', marginTop: 18, marginBottom: 10 },
+ heading6: { fontSize: 15, lineHeight: 24, fontWeight: '600', marginTop: 16, marginBottom: 8 },
+ strong: { fontWeight: '600' },
+ bullet_list: { marginBottom: 12 }, ordered_list: { marginBottom: 12 },
+ list_item: { marginBottom: 6 },
+ link: { color: accent, textDecorationLine: 'underline' },
+ code_inline: { fontFamily: mono, backgroundColor: '#eef0f4', color: '#414756', fontSize: 13, lineHeight: 20, borderWidth: 0, borderRadius: 4 },
+ blockquote: { marginTop: 6, marginBottom: 18, paddingHorizontal: 15, paddingTop: 12, paddingBottom: 0, borderLeftWidth: 3, borderColor: '#d4d7e0', backgroundColor: '#f5f6f980' },
+ tr: { flexDirection: 'row', borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: border },
+ thead: { backgroundColor: '#f4f5f8' },
+ th: { fontSize: 14, lineHeight: 22, fontWeight: '600' },
+ td: { fontSize: 14, lineHeight: 22 },
+ text: { color: ink },
+ hr: { height: StyleSheet.hairlineWidth, backgroundColor: border, marginVertical: 22 },
+})
diff --git a/mobile/src/Message.tsx b/mobile/src/Message.tsx
index de2f432..aa8b884 100644
--- a/mobile/src/Message.tsx
+++ b/mobile/src/Message.tsx
@@ -1,23 +1,13 @@
import { useLocale } from './locale'
import { useState } from 'react'
-import { ActivityIndicator, Image, Linking, Pressable, StyleSheet, Text, View } from 'react-native'
-import Markdown from 'react-native-markdown-display'
-import { ChevronDown, CircleCheck, CircleX, Download, ImageOff, Layers2 } from 'lucide-react-native'
-import { groupDisplayBlocks, type Message as Item, type ToolBlock, type Transcript } from '../../frontend/src/chat/transcript'
+import { ActivityIndicator, Image, Pressable, StyleSheet, Text, View } from 'react-native'
+import { MarkdownText } from './MarkdownText'
+import { ChevronDown, CircleCheck, CircleX, Layers2 } from 'lucide-react-native'
+import { groupDisplayBlocks, messageBlocksForDisplay, type Message as Item, type ToolBlock, type Transcript } from '../../frontend/src/chat/transcript'
import { Controller } from './api'
-import { FileIcon } from './FileIcon'
-import { saveRemote, shareDownload, shareLibraryItem, type RemoteFile, type WorkspaceFileSource } from './library'
-import { accent, edge, glass, Hint, ink, line, logo, muted, s, wash } from './ui'
-
-export type Preview = RemoteFile & { width?: number; height?: number }
-function formatted(text: string) {
- return <Markdown style={markdown} rules={{
- image: node => <Text key={node.key} selectable>{'![' + (node.attributes.alt ?? '') + '](' + node.attributes.src + ')'}</Text>,
- }} onLinkPress={url => {
- if (/^https?:\/\//i.test(url)) void Linking.openURL(url).catch(() => {})
- return false
- }}>{text}</Markdown>
-}
+import { FileTile, Images, ImageTools, type Preview } from './MessageMedia'
+export type { Preview } from './MessageMedia'
+import { accent, edge, glass, Hint, ink, logo, muted, s } from './ui'
export function MessageView({ api, id, message, results, openImage, generating = false }: { api: Controller; id: string; message: Item; results: Transcript['toolResults']; openImage: (image: Preview) => void; generating?: boolean }) {
const { t } = useLocale()
@@ -29,8 +19,8 @@ export function MessageView({ api, id, message, results, openImage, generating =
{generating && <><ActivityIndicator size="small" color={accent} /><Text accessibilityLiveRegion="polite" style={s.caption}>{t('生成中')}</Text></>}
</View>}
<View style={[styles.content, user && styles.bubble]}>
- {groupDisplayBlocks(message.blocks, results).map(block => {
- if (block.type === 'text') return <View key={block.id}>{formatted(block.text)}</View>
+ {groupDisplayBlocks(messageBlocksForDisplay(message), results).map(block => {
+ if (block.type === 'text') return <View key={block.id}><MarkdownText text={block.text} /></View>
if (block.type === 'file') {
const delivery = block.file.source === 'presented'
? { account: api.profile.account, path: block.file.path }
@@ -39,53 +29,13 @@ export function MessageView({ api, id, message, results, openImage, generating =
}
if (block.type === 'tool') return <Tools key={block.id} tools={[block]} results={results} />
if (block.type === 'tool-group') return <Tools key={block.id} tools={block.tools} results={results} />
- return <View key={block.id} style={styles.images}>
- {block.images.map(({ id: key, attachment }) => {
- const preview = { uri: api.fileURL(id, { source: 'attachment', attachmentId: attachment.attachmentId }),
- headers: api.headers, name: attachment.name || t('图片'), mimeType: attachment.mediaType, width: attachment.width, height: attachment.height }
- return <Thumb key={key} preview={preview} open={() => openImage(preview)} />
- })}
- </View>
+ if (block.type === 'image-tools') return <ImageTools key={block.id} tools={block.tools} images={block.images} results={results} api={api} sessionId={id} openImage={openImage} />
+ return <Images key={block.id} images={block.images} api={api} sessionId={id} openImage={openImage} />
})}
</View>
</View>
}
-function Thumb({ preview, open }: { preview: Preview; open: () => void }) {
- const [failed, setFailed] = useState(false)
- return <Pressable accessibilityRole="imagebutton" accessibilityLabel={preview.name} onPress={open} style={styles.thumb}>
- {failed ? <ImageOff color={muted} size={21} /> : <Image source={preview} onError={() => setFailed(true)} style={{ width: '100%', height: '100%' }} resizeMode="cover" />}
- </Pressable>
-}
-
-function FileTile({ preview, delivery }: { preview: Preview; delivery?: WorkspaceFileSource }) {
- const { t } = useLocale()
- const [busy, setBusy] = useState(false)
- const [failed, setFailed] = useState(false)
- return <View>
- <Pressable accessibilityRole="button" accessibilityLabel={t('下载') + ' ' + preview.name} disabled={busy} style={styles.tile} onPress={async () => {
- setBusy(true)
- setFailed(false)
- try {
- if (delivery) {
- const saved = await saveRemote(preview, 'file', delivery)
- await shareLibraryItem(saved)
- } else await shareDownload(preview.uri, preview.headers, preview.name)
- }
- catch { setFailed(true) }
- finally { setBusy(false) }
- }}>
- <FileIcon name={preview.name} />
- <View style={{ flex: 1, gap: 2 }}>
- <Text style={{ color: ink, fontSize: 15, fontWeight: '600' }} numberOfLines={2}>{preview.name}</Text>
- <Text style={{ color: muted, fontSize: 12 }}>{t(delivery ? '已交付' : '附件')}</Text>
- </View>
- {busy ? <ActivityIndicator color={accent} /> : <Download size={17} color={muted} />}
- </Pressable>
- {failed && <Hint error>{t('文件暂不可用。')}</Hint>}
- </View>
-}
-
function Tools({ tools, results }: { tools: ToolBlock[]; results: Transcript['toolResults'] }) {
const { t, language } = useLocale()
const [expanded, setExpanded] = useState(false)
@@ -111,27 +61,7 @@ const styles = StyleSheet.create({
avatar: { width: 36, height: 36 },
content: { flexShrink: 1, minWidth: 0, gap: 8 },
bubble: { maxWidth: '83%', borderRadius: 20, backgroundColor: '#fff', borderColor: edge, borderWidth: StyleSheet.hairlineWidth, paddingHorizontal: 14, paddingVertical: 6, boxShadow: '0 3px 12px rgba(45,35,70,0.055)' },
- images: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
- thumb: { width: '48%', maxWidth: 160, aspectRatio: 1, overflow: 'hidden', borderRadius: 15, borderColor: '#fff', borderWidth: 1.5, backgroundColor: '#e8ecfa', alignItems: 'center', justifyContent: 'center' },
- tile: { minHeight: 60, flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 11, paddingVertical: 8, borderRadius: 15, backgroundColor: glass, borderColor: edge, borderWidth: 1 },
tools: { alignSelf: 'stretch', backgroundColor: glass, borderRadius: 14, borderColor: edge, borderWidth: 1, overflow: 'hidden' },
toolHeader: { minHeight: 46, flexDirection: 'row', alignItems: 'center', paddingHorizontal: 12, gap: 8 },
toolRow: { minHeight: 38, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 8, borderTopColor: edge, borderTopWidth: StyleSheet.hairlineWidth },
})
-
-const markdown = StyleSheet.create({
- body: { color: ink, fontSize: 16, lineHeight: 25 },
- paragraph: { marginTop: 4, marginBottom: 5 },
- heading1: { fontSize: 24, lineHeight: 30, fontWeight: '700', marginVertical: 4 },
- heading2: { fontSize: 21, lineHeight: 27, fontWeight: '700', marginVertical: 4 },
- heading3: { fontSize: 18, lineHeight: 24, fontWeight: '600' },
- table: { borderColor: line, borderWidth: 1, borderRadius: 6 },
- tr: { borderBottomColor: line },
- th: { backgroundColor: wash, padding: 5 },
- td: { minWidth: 0, padding: 5 },
- link: { color: accent, textDecorationLine: 'underline' },
- code_inline: { backgroundColor: '#eff1ed', color: ink, fontSize: 13 },
- code_block: { backgroundColor: '#eff1ed', borderColor: line, color: ink, fontSize: 13 },
- fence: { backgroundColor: '#eff1ed', borderColor: line, color: ink, fontSize: 13 },
- blockquote: { backgroundColor: '#f6f7f3', borderColor: '#c3d3ca' },
-})
diff --git a/mobile/src/MessageMedia.tsx b/mobile/src/MessageMedia.tsx
new file mode 100644
index 0000000..5fff7a0
--- /dev/null
+++ b/mobile/src/MessageMedia.tsx
@@ -0,0 +1,109 @@
+import { useRef, useState, type ComponentType, type ReactElement } from 'react'
+import { ActivityIndicator, Image, Pressable, ScrollView, StyleSheet, Text, View, type ViewProps } from 'react-native'
+import MaskedView from '@react-native-masked-view/masked-view'
+import { LinearGradient } from 'expo-linear-gradient'
+import { Check, ChevronDown, CircleAlert, Download, Image as Picture, ImageOff } from 'lucide-react-native'
+import type { ChatImage, ToolBlock, Transcript } from '../../frontend/src/chat/transcript'
+import type { Controller } from './api'
+import { useLocale } from './locale'
+import { saveRemote, shareDownload, shareLibraryItem, type RemoteFile, type WorkspaceFileSource } from './library'
+import { FileIcon } from './FileIcon'
+import { accent, edge, glass, Hint, muted, ink, s } from './ui'
+
+// The library's legacy NativeMethods class intersection predates React 19 types.
+// Keep its documented props at this boundary; the native component is unchanged.
+const ImageMask = MaskedView as unknown as ComponentType<ViewProps & { maskElement: ReactElement; androidRenderingMode?: 'software' | 'hardware' }>
+
+export type Preview = RemoteFile & { width?: number; height?: number; workspace?: WorkspaceFileSource }
+type ImagesProps = { images: ChatImage[]; api: Controller; sessionId: string; openImage: (preview: Preview) => void; compact?: boolean; pending?: number }
+
+export function Images({ images, api, sessionId, openImage, compact, pending = 0 }: ImagesProps) {
+ const { t } = useLocale()
+ const size = compact ? 118 : 146
+ const metrics = useRef({ width: 0, content: 0, offset: 0 })
+ const [edges, setEdges] = useState({ left: 1, right: 1, width: 0 })
+ const measure = () => {
+ const { width, content, offset } = metrics.current
+ const left = Math.round((1 - Math.min(1, Math.max(0, offset - 2) / 24)) * 100) / 100
+ const right = Math.round((1 - Math.min(1, Math.max(0, content - width - offset - 2) / 24)) * 100) / 100
+ setEdges(old => old.left === left && old.right === right && old.width === width ? old : { left, right, width })
+ }
+ const fade = Math.min(.25, 26 / Math.max(104, edges.width))
+ return <ImageMask style={{ height: size, alignSelf: 'stretch' }} androidRenderingMode="software"
+ maskElement={<LinearGradient colors={[`rgba(0,0,0,${edges.left})`, '#000', '#000', `rgba(0,0,0,${edges.right})`]}
+ locations={[0, fade, 1 - fade, 1]} start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }} style={{ flex: 1 }} />}>
+ <ScrollView horizontal showsHorizontalScrollIndicator={false} nestedScrollEnabled directionalLockEnabled
+ accessibilityLabel={t('图片,可左右滑动')} contentContainerStyle={styles.images} scrollEventThrottle={16}
+ onLayout={({ nativeEvent: { layout } }) => { metrics.current.width = layout.width; measure() }}
+ onContentSizeChange={width => { metrics.current.content = width; measure() }}
+ onScroll={({ nativeEvent: { contentOffset } }) => { metrics.current.offset = contentOffset.x; measure() }}>
+ {images.map(image => {
+ const preview: Preview = { uri: api.fileURL(sessionId, image.file, image.name), headers: api.headers,
+ name: image.name || t('图片'), mimeType: image.mediaType, width: image.width, height: image.height,
+ workspace: image.file.source === 'presented' ? { account: api.profile.account, path: image.file.path } : undefined }
+ return <Thumb key={image.id} preview={preview} size={size} open={() => openImage(preview)} />
+ })}
+ {Array.from({ length: Math.min(3, pending) }, (_, index) => <View key={'pending/' + index} accessibilityLabel={t('正在加载图片')} style={[styles.thumb, { width: size, height: size }]}><ActivityIndicator color={muted} /></View>)}
+ </ScrollView>
+ </ImageMask>
+}
+
+export function ImageTools({ tools, images, results, ...props }: Omit<ImagesProps, 'compact' | 'pending'> & { tools: ToolBlock[]; results: Transcript['toolResults'] }) {
+ const { t } = useLocale()
+ const [expanded, setExpanded] = useState(true)
+ const running = tools.filter(tool => !results[tool.callId]?.status).length
+ const failed = tools.some(tool => results[tool.callId]?.status === 'failed' || results[tool.callId]?.status === 'cancelled')
+ const count = images.length + running || tools.length
+ return <View style={styles.imageTools}>
+ <Pressable accessibilityRole="button" accessibilityState={{ expanded }} accessibilityLabel={t(tools[0].name === 'readimage' ? '查看图片' : '生成图片')}
+ style={styles.imageToolHeader} onPress={() => setExpanded(old => !old)}>
+ <Picture size={16} color={muted} strokeWidth={1.7} /><Text style={styles.imageToolLabel}>{t(tools[0].name === 'readimage' ? '查看图片' : '生成图片')}</Text>
+ <Text style={styles.imageToolCount}>{count === 1 ? t('1 张') : t('{count} 张', { count })}</Text>
+ <View style={{ marginLeft: 'auto' }}>{running ? <ActivityIndicator size="small" color={muted} /> : failed ? <CircleAlert size={13} color={muted} /> : <Check size={13} color={muted} />}</View>
+ <ChevronDown size={15} color={muted} style={{ transform: [{ rotate: expanded ? '0deg' : '-90deg' }] }} />
+ </Pressable>
+ <View style={!expanded && { display: 'none' }}>
+ {(images.length > 0 || running > 0) ? <Images images={images} {...props} compact pending={running} /> : <Text style={s.meta}>{t('没有可显示的图片。')}</Text>}
+ </View>
+ </View>
+}
+
+function Thumb({ preview, size, open }: { preview: Preview; size: number; open: () => void }) {
+ const { t } = useLocale()
+ const [failed, setFailed] = useState(false)
+ const [loaded, setLoaded] = useState(false)
+ const [retry, setRetry] = useState(0)
+ if (failed && preview.workspace) return <View style={{ width: 230 }}><FileTile preview={preview} delivery={preview.workspace} /></View>
+ return <Pressable accessibilityRole="imagebutton" accessibilityLabel={preview.name} onPress={failed ? () => { setFailed(false); setRetry(value => value + 1) } : open} style={[styles.thumb, { width: size, height: size }]}>
+ {failed ? <><ImageOff color={muted} size={20} /><Text style={styles.imageToolCount}>{t('图片暂不可用,重试')}</Text></>
+ : <><Image key={retry} source={preview} onLoad={() => setLoaded(true)} onError={() => setFailed(true)} style={{ width: '100%', height: '100%' }} resizeMode="cover" />
+ {!loaded && <ActivityIndicator style={{ position: 'absolute' }} size="small" color={muted} />}</>}
+ </Pressable>
+}
+
+export function FileTile({ preview, delivery }: { preview: Preview; delivery?: WorkspaceFileSource }) {
+ const { t } = useLocale()
+ const [busy, setBusy] = useState(false)
+ const [failed, setFailed] = useState(false)
+ return <View>
+ <Pressable accessibilityRole="button" accessibilityLabel={t('下载') + ' ' + preview.name} disabled={busy} style={styles.tile} onPress={async () => {
+ setBusy(true); setFailed(false)
+ try {
+ if (delivery) { const saved = await saveRemote(preview, 'file', delivery); await shareLibraryItem(saved) }
+ else await shareDownload(preview.uri, preview.headers, preview.name)
+ } catch { setFailed(true) } finally { setBusy(false) }
+ }}>
+ <FileIcon name={preview.name} /><View style={{ flex: 1, gap: 2 }}><Text style={{ color: ink, fontSize: 15, fontWeight: '600' }} numberOfLines={2}>{preview.name}</Text><Text style={{ color: muted, fontSize: 12 }}>{t(delivery ? '已交付' : '附件')}</Text></View>
+ {busy ? <ActivityIndicator color={accent} /> : <Download size={17} color={muted} />}
+ </Pressable>
+ {failed && <Hint error>{t('文件暂不可用。')}</Hint>}
+ </View>
+}
+const styles = StyleSheet.create({
+ images: { flexDirection: 'row', gap: 10 },
+ thumb: { overflow: 'hidden', borderRadius: 11, backgroundColor: 'rgba(255,255,255,0.45)', alignItems: 'center', justifyContent: 'center', gap: 6 },
+ imageTools: { alignSelf: 'stretch', gap: 3, marginBottom: 4 },
+ imageToolHeader: { minHeight: 44, flexDirection: 'row', alignItems: 'center', gap: 7 },
+ imageToolLabel: { fontSize: 12, color: muted }, imageToolCount: { fontSize: 10, color: muted },
+ tile: { minHeight: 60, flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 11, paddingVertical: 8, borderRadius: 15, backgroundColor: glass, borderColor: edge, borderWidth: 1 },
+})
diff --git a/mobile/src/locale.tsx b/mobile/src/locale.tsx
index c1b14c1..3c97397 100644
--- a/mobile/src/locale.tsx
+++ b/mobile/src/locale.tsx
@@ -7,6 +7,7 @@ import { proactiveChinese } from '../../frontend/src/settings/proactiveState'
const extensionEnglish = Object.fromEntries(Object.entries(extensionChinese).map(([en, zh]) => [zh, en]))
const english: Record<string, string> = {
+ '复制表格': 'Copy table', '复制代码': 'Copy code', '已复制': 'Copied', '复制失败,重试': 'Copy failed. Retry', '代码': 'Code', '表格': 'Table', '表格,可左右滚动': 'Table — scroll horizontally', '代码,可左右滚动': 'Code — scroll horizontally',
'主会话': 'Main chat', '配置模型': 'Configure model', '查看插件': 'View plugins',
'主会话未能准备完成。': 'The main chat could not be prepared.',
'正在准备浏览器与 Office 能力…': 'Preparing browser and Office capabilities…',
@@ -106,6 +107,9 @@ const english: Record<string, string> = {
'将从 App 的本地库中删除所选项目。': 'Remove the selected items from the app library.',
'部分项目无法删除,请重试。': 'Some items could not be deleted. Try again.',
'无法分享所选项目,请重试。': 'Could not share the selected items. Try again.',
+ '查看图片': 'View images', '生成图片': 'Generate images', '{count} 张': '{count} images', '1 张': '1 image',
+ '图片,可左右滑动': 'Images — scroll horizontally', '正在加载图片': 'Loading image',
+ '没有可显示的图片。': 'No images to display.', '图片暂不可用,重试': 'Image unavailable. Retry',
'下载': 'Download', '文件暂不可用。': 'File unavailable.', '工具调用': 'Tool calls', '已交付': 'Delivered',
'收起': 'Dismiss', '关闭': 'Close', '保存语言失败,请重试。': 'Could not save the language. Try again.',
'新建任务': 'New task', '编辑任务': 'Edit task', '创建任务': 'Create task', '任务名称': 'Task name', '任务指令': 'Task instructions',