diff --git a/docs/reports/fix-queue-2026-07-26.md b/docs/reports/fix-queue-2026-07-26.md index 37066e6..7f6121b 100644 --- a/docs/reports/fix-queue-2026-07-26.md +++ b/docs/reports/fix-queue-2026-07-26.md @@ -282,6 +282,39 @@ AstrBot 在一次回复中**交错**投递两类 `plain` 帧: | **F-44** | 发送后不滚动到底部,流式生成发生在视口外 | `ChatPanel.tsx` 全文件无 scroll 代码 | 已归档于 R6,用户 2026-07-27 反馈确认 | | **N-8** | 消息进入列表无过渡动画,生硬出现 | `ChatPanel.tsx` 消息列表渲染 | 新记录,用户要求类 TG 的淡入过渡 | +### 桌宠两项(2026-07-27 真机反馈) + +| ID | 问题 | 根因 | 状态 | +| --- | --- | --- | --- | +| **N-10** | 应用内桌宠周边是不透明深色卡片 | `styles.css:1621` 的 `.app-pet-overlay .pet-window-embedded` 画了 92%/88% 不透明渐变 + 边框 + 投影。基类 `.pet-window` 本是 `transparent`,但该规则特异度更高(0,2,0)。**这是同一样式表第四次因重复/覆盖定义产生真实故障** | 已修 | +| **N-11** | 切到「桌面悬浮」模式桌宠直接消失 | `close_pet_window`(`lib.rs:394`)用 `destroy()` 而非隐藏;应用启动时默认 `app-ui` 模式会立刻销毁配置创建的窗口。此后 `open_pet_window` 必走 `WebviewWindowBuilder::from_config` 重建分支,而配置声明 `"visible": false` —— **窗口建出来了但从未 `show()`**。已存在窗口的分支有 `.show()` 与定位,重建分支两者皆无 | 已修(抽出 `reveal_pet_window` 供两条路径共用) | + +## 功能空缺盘点(2026-07-27) + +用户询问语音聊天、窗口感知、游戏陪伴是否已有。三项**均在既定产品范围内** +(`AGENTS.md:9-14`,版本节点 `v0.3.0-alpha.1`),架构文档 §14 有设计边界。实际成色如下, +均为**逐条 grep 验证**,非文档声称: + +| 能力 | 实际状态 | +| --- | --- | +| **语音聊天** | `ChatPanel.tsx:647` 用浏览器 Web Speech API。**WebView2 不提供 `SpeechRecognition`**,故语音输入在应用内大概率恒不可用;朗读(`speechSynthesis`)可用。而架构 §14.1 定的是「按键录音 → 上传音频 → 服务端 STT → 文本回复 → 可选 TTS」,**方向与现实现不一致**。麦克风绑定聚焦实例、双面板目标显示与快捷键切换:**均未实现** | +| **窗口感知** | Rust 侧已完成:`foreground_window.rs`(191行)、`uia.rs`(339行)、`capture.rs`(363行)。但**只有 `inspect_foreground_window` 与 `inspect_process` 注册为命令**,`uia` 与 `capture` 无任何出口。前端仅 `SettingsPages.tsx:136` 的诊断按钮手动调用,**没有任何通路把结果送给陪伴实例** | +| **游戏陪伴** | 仅有 `pet-game-mode-toggle` 事件与 `gameMode` 状态,**只改窗口偏好**,不截图、不读窗口、不产生事件。架构 §14.2 的隔离规则(运维槽位不得自动接收游戏截图/窗口状态/事件)目前无从违反,因为没有数据流 | + +**实施前必须先定的三处硬约束**: + +1. **截图不等于读画面。** `capture.rs` 是「用户选定单窗口的一次性内存捕获」(架构 §739), + 而 §259 明确排除「原始截图捕获」,`AGENTS.md:33` 禁止「无限制桌面控制」。 + 持续读取游戏画面属于连续录屏,**超出当前安全模型**,需先定采样策略并写入 ADR。 +2. **依赖附件双向通路。** 截帧要作为附件发给模型,而上传端点 2026-07-27 才首次指对 + (此前是 `/api/v1/file` 单数),**零验证**。 +3. **语音要换路线。** 按架构走服务端 STT,需录音 + 上传 + AstrBot 语音接口; + 而该服务端媒体能力至今只验证过图片,`record` / `file` / `video` 在 + `astrbot.rs:373` 仍被直接丢弃(F-33)。 + +**结论**:三项均**不建议现在启动**。前置依赖是附件双向通路与非图片媒体帧支持(F-33)。 +合理顺序:N-8 / N-9 → 验证附件双向通路 → F-33 → 再开语音与游戏陪伴专项。 + ### 待抓帧定论 已加 `trace_frame_shape()`(`astrbot_client.rs`,`RUST_LOG=astrbot_desktop=debug` 开启,只记结构不记内容)。 diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 51fc93c..238e8b9 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -305,14 +305,7 @@ fn open_main_window(app: AppHandle) -> Result<(), String> { #[tauri::command] fn open_pet_window(app: AppHandle) -> Result<(), String> { if let Some(window) = app.get_webview_window(PET_WINDOW_ID) { - window - .set_always_on_top(true) - .map_err(|error| error.to_string())?; - if let Some(monitor) = available_monitor_info(&app)?.first() { - place_pet_on_monitor(&window, monitor, pet::PetPositionMode::Edge)?; - } - window.show().map_err(|error| error.to_string())?; - return Ok(()); + return reveal_pet_window(&app, &window); } let config = app .config() @@ -321,11 +314,30 @@ fn open_pet_window(app: AppHandle) -> Result<(), String> { .iter() .find(|window| window.label == PET_WINDOW_ID) .ok_or_else(|| "pet window config is unavailable".to_owned())?; - WebviewWindowBuilder::from_config(&app, config) + let window = WebviewWindowBuilder::from_config(&app, config) .map_err(|error| error.to_string())? .build() - .map(|_| ()) - .map_err(|error| error.to_string()) + .map_err(|error| error.to_string())?; + // The rebuild path used to stop here. `close_pet_window` destroys the + // window rather than hiding it, and the app closes it on startup whenever + // the pet is set to render inside the UI, so switching to the floating pet + // always took this path — and the config declares `visible: false`, so the + // window was built and never shown. It simply did not appear. + reveal_pet_window(&app, &window) +} + +/// Places the pet window on a monitor and shows it. +/// +/// Shared by both paths so a rebuilt window is treated exactly like one that +/// was only hidden. +fn reveal_pet_window(app: &AppHandle, window: &tauri::WebviewWindow) -> Result<(), String> { + window + .set_always_on_top(true) + .map_err(|error| error.to_string())?; + if let Some(monitor) = available_monitor_info(app)?.first() { + place_pet_on_monitor(window, monitor, pet::PetPositionMode::Edge)?; + } + window.show().map_err(|error| error.to_string()) } #[tauri::command] diff --git a/src/styles.css b/src/styles.css index efa6bbf..43a2324 100644 --- a/src/styles.css +++ b/src/styles.css @@ -1584,14 +1584,13 @@ select:focus { border-radius: 1rem; background: rgb(7 18 34 / 55%); } +/* No backdrop. The base `.pet-window` is transparent and this variant used to + paint a radial gradient over it, which read as an opaque card sitting behind + the sprite rather than a pet standing on the page. */ .pet-window-embedded { min-height: 260px; border-radius: 0.8rem; - background: radial-gradient( - circle at center, - rgb(24 54 96 / 45%), - rgb(7 18 34 / 20%) - ); + background: transparent; } .pet-render-error, .pet-render-loading { @@ -1619,14 +1618,17 @@ select:focus { .app-pet-overlay:active { cursor: grabbing; } +/* The overlay carries no card of its own. It used to paint a 92%-opaque + gradient with a border and a drop shadow, which put an opaque panel behind + the sprite instead of letting the pet stand on the page. The fixed box keeps + the drag target stable; the sprite is the only thing that should be visible. */ .app-pet-overlay .pet-window-embedded { width: 188px; height: 226px; min-height: 0; - border: 1px solid rgb(137 175 232 / 40%); - border-radius: 1rem; - background: linear-gradient(160deg, rgb(18 41 74 / 92%), rgb(7 18 34 / 88%)); - box-shadow: 0 16px 40px rgb(0 0 0 / 35%); + border: 0; + background: transparent; + box-shadow: none; } .app-pet-overlay .aemeath-pet-frame { transform: scale(0.78);