比较提交

...

5 提交

作者 SHA1 备注 提交日期
30d273517a docs(progress): record the R3.5 real-machine feedback batch
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Three fixes with provable root causes, and two defects left open on
purpose. The double reply bubble and the missing plugin images each have
two plausible causes in our own code, and picking one without evidence
would produce a fix that holds until a different conversation path hits
the other. Record both candidate chains, the frame trace added to settle
them, and the fact that the bubbles collapsing at the end is only the
session filter hiding an orphan that is still in state and in SQLite.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:01:22 +08:00
3c7960d1ba chore(git): ignore machine-local claude config
Nothing under .claude is tracked, and it holds per-machine settings and
launch configuration. Placed with the existing .idea and .vscode
entries.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:59:55 +08:00
e01cb5a3ba feat(astrbot): trace sse frame shapes at debug level
Two reported defects cannot be diagnosed from the code alone. A reply
sometimes renders as two bubbles during generation, which happens when a
streaming frame carries no message_id — the client then keys it by
event_id, which is unique per event. And images sent by plugins never
appear, which happens when an image frame is not followed by the
attachment_saved frame the mapper waits for. Both depend on what the
server actually sends, and picking the wrong one would produce a fix
that looks right until another conversation path hits the other.

Log the shape of every SSE frame: its type, whether message_id and
session_id are present, the streaming flag, and the key names inside
data. No payload text is recorded, so this is safe to leave enabled in
the field. Off unless RUST_LOG selects debug, and gated on
tracing::enabled! so a disabled level costs one atomic read rather than
a JSON parse.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:59:31 +08:00
0bfd12ed1a fix(pet): surface context menu failures instead of swallowing them
Right-clicking the pet showed the native WebView menu and never the
application's own menu. The handler was a bare void invoke(...) with no
catch, so any failure to build or pop the menu was completely invisible
and indistinguishable from preventDefault not taking effect.

Report the error in the pet window and stop propagation as well as the
default action. This does not yet explain which of the two is happening
— it makes the difference observable, which is the prerequisite for
fixing the right one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:59:20 +08:00
fa48a21e65 fix(chat): repair the message row layout and action buttons
Three defects reported from real-machine testing, all rooted in the same
few conflicting CSS blocks, so they are fixed together — separating them
would leave intermediate states that render worse than either end.

The action buttons showed wrapped vertical text inside a 2rem box.
styles.css already defined .message-action-label, a clip-rect
screen-reader-only class clearly written for these buttons, but nothing
in the tree ever used it: ChatPanel rendered a bare span. Wire the class
up so the buttons are icon-only, and drop the border so they read as
plain icons rather than pills.

.chat-message-actions and its buttons were defined five times across the
stylesheet, three of those styling them as bordered pills that the final
block then partially overrode. Remove .chat-message-actions button from
the three pill rule groups and the small-screen grid rule, leaving one
definition next to .message-action-icon. .chat-runtime-actions and
.chat-stop-button keep the pill treatment; they are different controls.

The avatar rendered below its bubble instead of beside it.
.chat-message-row used align-items: flex-end, and .chat-message-content
is taller than the bubble because the action bar reserves a row, so the
avatar was pinned to the bottom of that taller box. Align to the top.

Removing visibility: hidden from the hidden action bar also closes F-40
(audit P2-24): visibility removed the buttons from the tab order, so
:focus-within could never fire and a keyboard user could never reveal
them. Opacity alone keeps them focusable.

Verified against the real stylesheet in a browser: avatar and bubble
tops differ by 0px, the button computes to 34x34 with 0px border, the
label measures 1x1, and focusing a button takes the bar from opacity 0
to 1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:59:11 +08:00
共有 8 个文件被更改,包括 180 次插入 和 34 次删除

1
.gitignore Vendored
查看文件

@ -23,6 +23,7 @@ src-tauri/target/
*.secrets.*
# IDE and operating system
.claude/
.idea/
.vscode/
!.vscode/extensions.json

查看文件

@ -8,6 +8,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
### Added
- Debug-level tracing of AstrBot SSE frame shapes: frame type, which identity fields are present, and the key names inside `data`. No payload text is recorded. Enable with `RUST_LOG`.
- Q10-Q15 chat experience increment: lightweight Markdown rendering, message actions, generation controls, session actions, connection controls, and responsive chat layout.
- AstrBot OpenAPI adapter foundation: SSE mapper, dual-slot runtime skeleton, credential enrollment IPC, transport-aware profiles (ADR-0005).
- Authoritative architecture, implementation, and repository workflow documents.
@ -40,6 +41,13 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
### Fixed
- Message action buttons render as borderless icons again. Their labels were being laid out inside
a 32px button, which wrapped them into vertical strips of single characters.
- The avatar sits beside its message bubble again instead of below it.
- Message actions can now be reached with the keyboard. They were hidden with `visibility`, which
removed them from the tab order, so the focus rule that reveals them could never fire.
- A failure to open the desktop pet's context menu is now reported instead of silently doing
nothing.
- One unreachable connection no longer freezes the whole application. The reachability probe now
runs outside the runtime lock, so a slot that is connecting cannot block status, sending,
cancelling or disconnecting on the other slot, and the attempt itself can be interrupted.

查看文件

@ -606,3 +606,47 @@ Real-hardware acceptance for R3 has not been performed; the steps are listed in
Next: batch R4 (data and credential boundaries) or R5 (protocol hardening). Neither depends on R3,
so they can be dispatched in parallel.
## 2026-07-27: batch R3.5, first real-machine feedback
First real use of the application surfaced five defects, none of them in the 2026-07-26 audit.
Three had provable root causes and are fixed; two depend on what the server actually sends and are
deliberately left open rather than guessed at. Full detail in `docs/reports/fix-queue-2026-07-26.md`
under "R3.5".
### Fixed
- Message action buttons rendered their labels inside a 32px box, wrapping them into vertical
strips. `styles.css` already contained `.message-action-label`, a screen-reader-only class written
for exactly this, that no component ever used. The buttons were also defined five times across the
stylesheet, three of those as bordered pills.
- The avatar rendered below its bubble because the row aligned to `flex-end` while the content
column is taller than the bubble by the reserved action bar.
- Removing `visibility: hidden` from the hidden action bar closes **F-40** (audit P2-24) early: it
had removed the buttons from the tab order, so the focus rule that reveals them could never fire.
- The pet's context-menu handler was a bare `void invoke(...)` with no catch, so a failure was
indistinguishable from the native menu winning. The error is now visible; the root cause is not
yet established.
Verified against the real stylesheet in a browser rather than by inspection: avatar and bubble tops
differ by 0px, the button computes to 34x34 with a 0px border, the label box measures 1x1, and
focusing a button takes the bar from opacity 0 to 1.
### Open, pending a frame capture
A reply sometimes renders as two bubbles during generation, and images sent by plugins never
appear. Each has two plausible root causes in our own code, and choosing wrong would produce a fix
that appears to work until a different conversation path hits the other cause. Added
`trace_frame_shape` to record the structure of every SSE frame — type, presence of `message_id` and
`session_id`, and the key names inside `data`, with no payload text — behind
`RUST_LOG=astrbot_desktop=debug`.
Note that the two bubbles collapsing to one at the end is not self-healing: `activeMessages` filters
by session id and merely hides the orphan, which remains in React state and in SQLite.
### Test status
Rust 107 passed / 2 ignored. Frontend 24 passed / 5 files. Playwright 5 passed. Build passes.
Next: capture the frames, then batch R3.6 (message identity, pulling F-34 forward) and R3.7
(attachment chain, pulling F-33 forward).

查看文件

@ -214,6 +214,36 @@
* * *
## R3.5 · 真机反馈批(2026-07-27 追加)
2026-07-27 首次真机使用暴露 5 个问题,编号 `N-*`(新发现,不在 2026-07-26 审计中)。
其中 3 项根因确凿并已修复;2 项的根因取决于服务端实际发的帧,**不猜**,待抓帧后再定。
### 已完成
| ID | 位置 | 根因 | 状态 |
| --- | --- | --- | --- |
| **N-1** | `styles.css:2183/2456/2655/2735/3134`;`ChatPanel.tsx:822,834,846` | `.message-action-label`(`clip-rect` 屏幕阅读器类)**定义了却从未被任何组件使用**,组件用的是裸 `<span>`;同时按钮被 5 处重复定义中的 3 处当作胶囊按钮,与最终块冲突。文字塞进 2rem 方框后竖排折行 | 已修 |
| **N-2** | `styles.css:509` + `:3106` | `.chat-message-row{align-items:flex-end}` 把头像对齐到 `.chat-message-content` 底边,而该盒子因操作条占位比气泡高一行 → 头像掉到气泡下方 | 已修 |
| **F-40** | `styles.css:3113` | 顺带关闭:`visibility:hidden` 把按钮移出 tab 序,`:focus-within` 永远无法触发。改为仅 `opacity` | 已修(原属 R6) |
| **N-3** | `DesktopPetView.tsx:222-225` | 右键处理是裸 `void invoke(...)`,**无 `.catch`**,Rust 侧任何失败都不可见,与「原生菜单赢了」无法区分 | 已让错误可见;根因待定 |
**验证**:在真实样式表下用浏览器实测——头像与气泡顶部差 0px,按钮 34×34 / `border-width: 0px`,
标签盒 1×1(已裁剪),聚焦后操作条 opacity 由 0 变 1。
### 待抓帧定论
已加 `trace_frame_shape()`(`astrbot_client.rs`,`RUST_LOG=astrbot_desktop=debug` 开启,只记结构不记内容)。
| ID | 问题 | 候选根因 | 判据 |
| --- | --- | --- | --- |
| **N-4** | 生成中概率出现两个回复气泡,结束后恢复成一个 | **候选 A = F-34(P2-13)**:`ChatPanel.tsx:976` 与 `commands.rs:412` 同用 `messageId \|\| eventId` 回退,`event_id` 每事件唯一,任一 delta 缺 `message_id` 即自成一条消息。**候选 B**:`ChatPanel.tsx:74-75` 的 `historySessionId` 回退到 `storedSessions[0]`,会加载**另一个会话**的历史并合并 | 日志中 `plain` 帧的 `has_message_id` 是否恒为 true |
| **N-5** | 「恢复成一个」不是自愈 | `activeMessages`(`ChatPanel.tsx:116`)按 sessionId 过滤,只是**遮住**孤儿气泡;React state 与 SQLite 中它仍在 | 需随 N-4 一并清理 |
| **N-6** | 插件发的图片不显示 | `map_media()`(`astrbot.rs:339`)只记 `pending_media` 不产出事件,必须等后续 `attachment_saved` 配对;**若插件的 image 帧自带 id/URL 且无该后续帧,图片被静默丢弃**。另:非图片媒体全丢(F-33)、`pending_media` 单槽位(F-33)、id 字符集限 `[A-Za-z0-9._-]` 挡掉 URL 形态 | 日志中 image 帧的 `data_keys`,以及其后是否出现 `attachment_saved` |
| **N-7** | 图片即便拿到也可能被 CSP 拦 | `tauri.conf.json:45` 的 `img-src 'self' asset: http://asset.localhost data: blob:` 不含任意 http 源 | 若插件走 URL,**倾向代理下载转 blob**,不放宽 `img-src`——放宽等于让渲染层直连任意外部主机 |
* * *
## R4 · 数据与凭据安全批
| ID | 来源 | 位置 | 动作 | 验证 |

查看文件

@ -614,6 +614,7 @@ impl AstrBotClient {
.await;
}
while let Some(line) = buffer.next_line() {
trace_frame_shape(&line);
match mapper.push_line(&line) {
Ok(events) => self.dispatch_events(events, sender).await?,
Err(error) => {
@ -632,6 +633,7 @@ impl AstrBotClient {
}
if let Some(remainder) = buffer.take_remainder() {
trace_frame_shape(&remainder);
match mapper.push_line(&remainder) {
Ok(events) => self.dispatch_events(events, sender).await?,
Err(error) => {
@ -720,6 +722,56 @@ impl AstrBotClient {
}
}
/// Records the *shape* of one SSE frame at debug level.
///
/// Deliberately logs no payload text — only the frame type, which identity
/// fields are present, and the key names inside `data`. That is enough to
/// answer the two questions the mapper cannot answer on its own: whether every
/// streaming frame carries a `message_id` (if not, the client cannot key a
/// reply to a single message and splits it), and what shape a plugin's
/// attachment frames actually take.
///
/// Enable with `RUST_LOG=astrbot_desktop=debug`. Off by default.
fn trace_frame_shape(line: &str) {
if !tracing::enabled!(tracing::Level::DEBUG) {
return;
}
let Some(body) = line.strip_prefix("data:") else {
return;
};
let Ok(value) = serde_json::from_str::<Value>(body.trim()) else {
return;
};
let data = value.get("data");
let data_keys = match data {
Some(Value::Object(map)) => map.keys().cloned().collect::<Vec<_>>().join(","),
Some(Value::Array(_)) => "<array>".to_owned(),
Some(Value::String(_)) => "<string>".to_owned(),
Some(Value::Null) | None => "<none>".to_owned(),
Some(_) => "<scalar>".to_owned(),
};
let frame_type = value
.get("type")
.and_then(|field| field.as_str())
.unwrap_or("<absent>");
let has_message_id = value
.get("message_id")
.is_some_and(|field| !field.is_null());
let has_session_id = value
.get("session_id")
.is_some_and(|field| !field.is_null());
let streaming = value.get("streaming").and_then(|field| field.as_bool());
tracing::debug!(
target: "astrbot::frame",
frame_type,
has_message_id,
has_session_id,
?streaming,
data_keys = data_keys.as_str(),
"astrbot sse frame"
);
}
fn protocol_slot(slot: SlotKind) -> desktop_protocol::ActiveSlotKind {
match slot {
SlotKind::Companion => desktop_protocol::ActiveSlotKind::Companion,

查看文件

@ -819,7 +819,7 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
className="message-action-icon icon-copy"
aria-hidden="true"
/>
<span>复制</span>
<span className="message-action-label">复制</span>
</button>
<button
type="button"
@ -831,7 +831,7 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
className="message-action-icon icon-retry"
aria-hidden="true"
/>
<span>重试</span>
<span className="message-action-label">重试</span>
</button>
<button
type="button"
@ -843,7 +843,7 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) {
className="message-action-icon icon-read"
aria-hidden="true"
/>
<span>朗读</span>
<span className="message-action-label">朗读</span>
</button>
</div>
) : null}

查看文件

@ -3,6 +3,7 @@ import { listen } from "@tauri-apps/api/event";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { useEffect, useRef, useState } from "react";
import { errorMessage } from "../../lib/errorMessage";
import {
boundRuntimeEventSchema,
connectionRuntimeStatusSchema,
@ -31,6 +32,7 @@ export function DesktopPetView({ embedded = false }: { embedded?: boolean }) {
const [frameIndex, setFrameIndex] = useState(0);
const [spriteReady, setSpriteReady] = useState(false);
const [spriteError, setSpriteError] = useState<string | null>(null);
const [menuError, setMenuError] = useState<string | null>(null);
const [gameMode, setGameMode] = useState(false);
const spriteImageRef = useRef<HTMLImageElement | null>(null);
const spriteCanvasRef = useRef<HTMLCanvasElement | null>(null);
@ -221,7 +223,13 @@ export function DesktopPetView({ embedded = false }: { embedded?: boolean }) {
}}
onContextMenu={(event) => {
event.preventDefault();
void invoke("show_pet_context_menu");
event.stopPropagation();
// Previously a bare `void invoke(...)`, so a failure to build or pop
// the menu was invisible and looked like the native WebView menu had
// simply won. Surface it instead.
void invoke("show_pet_context_menu").catch((reason) => {
setMenuError(errorMessage(reason));
});
}}
>
<div
@ -238,6 +246,11 @@ export function DesktopPetView({ embedded = false }: { embedded?: boolean }) {
aria-label={`pet-${state}`}
/>
</div>
{menuError ? (
<span className="pet-render-error" role="alert">
{menuError}
</span>
) : null}
{spriteError ? (
<span className="pet-render-error">{spriteError}</span>
) : null}

查看文件

@ -508,7 +508,11 @@ select:focus {
.chat-message-row {
display: flex;
align-items: flex-end;
/* Aligns the avatar with the top of the bubble. It used to be `flex-end`,
which pinned the avatar to the bottom of `.chat-message-content` — and that
box is taller than the bubble because the action bar reserves a row, so the
avatar rendered below the bubble instead of beside it. */
align-items: flex-start;
gap: 0.55rem;
width: min(82%, 46rem);
justify-self: start;
@ -2176,14 +2180,10 @@ body,
}
.chat-runtime-actions,
.chat-message-actions {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
/* `.chat-message-actions button` is intentionally absent from these pill rules.
Message actions are borderless icon buttons; their single definition lives
further down next to `.message-action-icon`. */
.chat-runtime-actions button,
.chat-message-actions button,
.chat-stop-button {
border: 1px solid var(--line, #c8d8ea);
border-radius: 999px;
@ -2195,7 +2195,6 @@ body,
}
.chat-runtime-actions button:hover,
.chat-message-actions button:hover,
.chat-stop-button:hover {
background: var(--soft-accent, #eaf3ff);
color: var(--accent, #2f6fb2);
@ -2266,10 +2265,6 @@ body,
color: var(--accent, #2f6fb2);
}
.chat-message-actions {
margin-top: 8px;
}
.chat-stop-button {
margin-top: 8px;
border-color: #d88d8d;
@ -2459,7 +2454,6 @@ textarea:focus-visible,
}
.chat-runtime-actions button,
.chat-message-actions button,
.chat-stop-button {
min-height: 2rem;
border: 1px solid var(--ui-line);
@ -2469,7 +2463,6 @@ textarea:focus-visible,
}
.chat-runtime-actions button:hover,
.chat-message-actions button:hover,
.chat-stop-button:hover {
border-color: var(--ui-line-strong);
color: var(--ui-ink);
@ -2659,7 +2652,6 @@ textarea:focus-visible,
}
.chat-runtime-actions button,
.chat-message-actions button,
.chat-stop-button,
.voice-button,
.file-picker,
@ -2668,6 +2660,10 @@ textarea:focus-visible,
touch-action: manipulation;
}
.chat-message-actions button {
touch-action: manipulation;
}
.chat-runtime-actions button:disabled {
border-color: var(--ui-line);
color: var(--ui-subtle);
@ -2738,17 +2734,11 @@ textarea:focus-visible,
}
.chat-runtime-actions button,
.chat-message-actions button,
.chat-stop-button,
.voice-button,
.file-picker {
width: 100%;
}
.chat-message-actions {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
:root {
@ -3125,27 +3115,31 @@ button:disabled {
transform: translateY(-0.2rem);
transition:
opacity 150ms ease,
transform 150ms ease,
visibility 150ms ease;
visibility: hidden;
transform 150ms ease;
}
/* Deliberately no `visibility: hidden`. It removed the buttons from the tab
order, so `:focus-within` could never fire and a keyboard user could never
reveal them. Opacity alone keeps them focusable. */
.chat-message-row:hover .chat-message-actions,
.chat-message-row:focus-within .chat-message-actions {
opacity: 1;
pointer-events: auto;
transform: translateY(0);
visibility: visible;
}
/* The single definition of a message action button: borderless, icon only.
The visible label is carried by `.message-action-label`, which is clipped for
screen readers, so the button must never be sized for text. */
.chat-message-actions button {
display: inline-flex;
align-items: center;
justify-content: center;
width: 2rem;
height: 2rem;
min-height: 2rem;
padding: 0;
border: 1px solid transparent;
border: 0;
border-radius: 0.55rem;
color: var(--ui-subtle);
background: transparent;
@ -3154,11 +3148,15 @@ button:disabled {
.chat-message-actions button:hover:not(:disabled),
.chat-message-actions button:focus-visible {
border-color: var(--ui-line);
color: var(--ui-ink);
background: var(--ui-surface-soft);
}
.chat-message-actions button:hover:not(:disabled) .message-action-icon,
.chat-message-actions button:focus-visible .message-action-icon {
color: var(--ui-ink);
}
.message-action-label {
position: absolute;
width: 1px;
@ -3285,11 +3283,12 @@ button:disabled {
}
.chat-message-actions button {
width: 2.1rem;
height: 2.1rem;
min-height: 2.1rem;
}
}
/* Stable chat session pills and native-style window controls. */
.chat-session-list {
flex: 0 0 auto;
@ -3364,7 +3363,6 @@ button:disabled {
}
}
.message-attachment-image {
display: block;
max-width: min(22rem, 100%);