提交图

105 提交

作者 SHA1 备注 提交日期
6e7d51841d feat(pet): log both pet window commands on entry
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Switching to the floating pet produced no log line at all, which was
ambiguous: the command may never have been invoked, or it may have failed
before reaching the only log statement, which sat after placement and
show().

Log both open and close on entry, with whether the window already
existed, and log the error on each failure path. A missing line now means
the command was not invoked, which points at the shell rather than the
window.

The pairing also makes the order readable. The shell closes the pet on
startup whenever it renders inside the UI, and that destroy is what
forces every later open through the rebuild path.

Refs: N-11.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 04:33:44 +08:00
b5e3acbb72 feat(pet): log where the floating pet window actually ended up
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The floating pet still does not appear, and the two explanations offered
so far are not sufficient. The rebuild path genuinely never called
show(), which is fixed and correct on its own reading of the code, but it
did not resolve the symptom. A missing Suspense boundary around the lazy
pet view looked like a second cause and is not one: removing the wrapper
still renders the pet, so React 19 tolerates it. That claim is retracted
in the comment rather than left standing.

The window is transparent and undecorated, so "did not appear" covers a
window placed off-screen, a window that reports hidden, and a window
present with nothing painted in it. Log the monitor work area, the
position and size after placement, and the visibility the window
reports, at default level so no filter is needed to read it.

The Suspense wrapper stays. Relying on React tolerating a lazy component
with no boundary is not a contract, and the bubble and quick views
already have their own.

Refs: N-11, F-61.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 04:25:37 +08:00
50c75b1105 fix(pet): show the floating pet, and take the card out from behind it
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Switching the pet to the floating desktop mode made it vanish.
close_pet_window destroys the window rather than hiding it, and the app
closes it on startup whenever the pet renders inside the UI, so opening
the floating pet always went through the rebuild path — which honours
the config's `visible: false` and never showed what it had just built.
Only the already-exists path called show() and placed the window. Both
paths now share one helper.

The in-app pet also sat on an opaque card: .app-pet-overlay
.pet-window-embedded painted a 92% gradient with a border and a drop
shadow over a base class that is transparent. Verified against the real
stylesheet — the backdrop now computes to no image, no colour, no
border and no shadow, with the drag box unchanged at 188x226.

Also record the state of voice chat, window awareness and game
companionship, all three of which are in the declared product scope but
largely unwired: the voice path uses a Web Speech API that WebView2 does
not provide and points away from the architecture's server-side STT
design, the window capture and UI automation modules exist in Rust with
no command registered and no route to the companion, and game mode
toggles a window preference and produces no data at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 04:13:32 +08:00
1eba70d292 feat(chat): give the conversation the height the header was using
一些检测仍在等待运行
ci / Windows Tauri build (push) Waiting to run
ci / Portable quality checks (push) Waiting to run
The chat panel opened with three stacked blocks above the messages: a
title and subtitle naming the panel, a strip repeating the profile id,
session id and connection state, and the session pills. Only the last
carried anything the reader needed.

Move the slot tabs into the window title bar and delete the rest. The
tabs go there through a portal rather than by lifting state into the
shell, which keeps the slot selection and its status polling in the
panel that owns them; the quick chat and bubble windows have no title
bar, and they are slot-fixed already, so the tabs simply do not render
there.

The connection actions move onto the session row, which costs no height
because that row already exists. 刷新 is dropped: the status refreshes on
a 500ms poll, so the button did nothing the panel was not already doing.
重连, 断开 and 新对话 stay, since losing them would leave no way to
recover a dropped connection or start a conversation.

The panel now puts 82px above the messages instead of three blocks. The
title-bar rules carry [role="tab"] on purpose — the panel's own
.chat-slot[role=tab] rule sets a 2.75rem minimum and sits later in the
sheet, so an unqualified selector loses to it and the tabs overflow a
44px bar.

Verified against the real stylesheet: tabs 33px inside a 44px bar,
vertically centred, clear of both the title text and the window
controls; the removed blocks are absent from the DOM.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 03:59:29 +08:00
809f530486 fix(astrbot): try the current file API before the legacy one
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The server was upgraded and now routes /api/v1/files: an unknown
/api/v1 path answers 404 "Not Found" where it previously answered 401,
and both /api/v1/files/content and /api/v1/files/{id}/content answer 401
"Missing API key", which is a route that exists rather than a catch-all.

Order the candidates accordingly. By name first, since that is what a
media frame carries; by id second, because markers already written to
local history hold the id from attachment_saved and can now resolve. The
/api/chat pair moves last, where it still serves a server that has not
been upgraded.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 03:43:12 +08:00
4063215b0a fix(astrbot): let one rejected attachment path fall through to the next
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The candidate search returned on the first 401, so only the first of the
three addresses was ever tried — the log shows ten requests to
/api/chat/get_file and not a single download record.

A rejection is per-endpoint here rather than per-connection.
/api/chat/* is the dashboard's own API and wants a dashboard JWT, while
/api/v1/* accepts the API key the connection already holds, so a 401
from one says nothing about the others.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 03:28:34 +08:00
7a6877d7cc fix(astrbot): fetch chat attachments from the paths this server serves
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The request trace showed the app talks to 192.168.31.210:26185, not the
host I had been probing, so the endpoint list I read from a dashboard
bundle belonged to a different AstrBot build. This server's own bundle
resolves a chat attachment as:

  /api/chat/get_attachment?attachment_id=...   when an id is known
  /api/chat/get_file?filename=...              otherwise

There is no /api/v1/files at all here. Asking for it returned AstrBot's
"404 Not found" page under HTTP 200, which is why the status check
passed it through as a successful download of an undecodable file.

Try each address in turn — the stream supplies a file name in the media
frame and an id in the frame after, and different builds expose
different paths. Because an unknown path answers 200 with that text
page, a candidate counts as found only when the bytes are recognisably
an image; the status alone proves nothing here. Trying all three also
recovers attachments in existing history, whose markers hold the id
rather than the name.

Refs: N-6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 03:24:11 +08:00
d5dfcd465e feat(astrbot): record the attachment request and the server's reply
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Probing the server settled that the endpoints exist: unauthenticated,
/api/v1/files/content?filename= and /api/v1/files/{id}/content both
answer 401 JSON, while an unknown /api/v1 path answers 404 JSON. AstrBot
does not serve an HTML shell for API paths at all.

Our authenticated request nevertheless logs 200 with text/html and 201
bytes, and 201 bytes is exactly the length of AstrBot's plain-text 404
body. That combination cannot be explained from the code: the base URL
has its trailing slashes stripped and is written back, redirects are not
followed, and a non-2xx status returns before the log line.

So record the URL actually requested, the status before the status
checks, and — when the body is not an image — the first 160 bytes of it,
which is the server explaining itself rather than anything the user
wrote.

Refs: N-6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 03:10:14 +08:00
d1e4cdf471 feat(astrbot): compare stream blocks ignoring formatting
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Exact containment cannot separate "the same text formatted differently"
from "content the stream never carried". A capture had a 278-character
block against 286 streamed characters and reported no containment either
way, which is the reading the segmentation fix depends on.

Report containment with whitespace removed alongside the exact result.
Both are logged: a block that matches only once whitespace is dropped is
the same content, while a block that matches under neither is genuinely
separate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 03:03:10 +08:00
5c064acf6c fix(astrbot): fetch attachments the way AstrBot addresses them
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Reading the dashboard's own bundle settled where the file endpoints
are. It exposes upload as POST /api/v1/files, fetch-by-name as
GET /api/v1/files/content?filename=, and fetch-by-id as
GET /api/v1/files/{id}/content, and it fetches a chat image by name.

Both of our endpoints were wrong in different ways. Upload posted to
/api/v1/file, singular. Download used the by-id form with the id from
the attachment_saved frame, which does not address the file — asking for
it returned the dashboard's HTML shell with HTTP 200, which is what
surfaced as a broken image.

The name was there all along: the media frame carries [IMAGE]{uuid}.jpg
and the mapper discarded it, waiting for the id in the frame after.
Emit the marker from the media frame instead, naming the file, and keep
the saved id as a fallback for a media frame that names nothing usable.
A reference carrying a path or a scheme is refused rather than guessed
at, since the by-name fetch cannot express either.

Refs: N-6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 02:53:43 +08:00
f666a3a041 fix(astrbot): give each stream its own frame trace
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The trace lived in a thread_local, but the SSE read loop is a tokio task
that moves between worker threads across await points, so the
accumulated text was split across several copies. It reported 139 and 57
streamed characters for replies that the raw frames show as 417 and 266,
which made every containment result from it unusable — including the
ones the segmentation question depends on.

Own it in the stream instead. The raw frame lines were unaffected, so
the frame-shape findings still hold; only the per-stream summary was
wrong.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 02:45:27 +08:00
2ba07bda9d fix(astrbot): name the wrong-endpoint case instead of calling it a bad image
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The capture settled why an attachment rendered as a broken image:
HTTP 200, Content-Type text/html, 201 bytes. AstrBot answers an unknown
/api/v1 path with its dashboard shell rather than a 404, so a wrong
download endpoint arrives looking like a successful download of an
undecodable file. The status check passed it and the type sniffer
correctly refused to call it an image, which left the user reading
"not a decodable image format" for what is really a wrong URL.

Reject an HTML body outright and say so. GET /api/v1/files/{id}/content
is a guess — upload posts to /api/v1/file, singular — and the protocol
review records the file endpoints as never tested.

Also trace the shape of the reference the media frame carries, which
the client currently discards in favour of the id from
attachment_saved. Scheme, whether it looks like a path, and the file
extension are recorded; the reference itself is not.

Refs: N-6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 02:37:52 +08:00
ca65c465b9 refactor(chat): drop the speaker name from the message bubble
The bubble header repeated what the avatar and the side of the bubble
already say. Removing it leaves the header holding only the generating
indicator, so it is rendered only while a reply is streaming.

The name moves into the avatar as a clipped label rather than
disappearing: the avatar's glyph is aria-hidden, so without it a screen
reader would announce nothing at all for the speaker.

Verified against the real stylesheet: avatar and bubble tops differ by
0px for both roles, the glyph stays centred in a 32px avatar, the label
measures 1x1, and the bubble no longer contains the name.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 02:37:36 +08:00
0b4a7de62a fix(astrbot): resolve an attachment's type from its bytes when needed
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
An attachment downloaded and then rendered as a broken image. A blob URL
is decoded according to the blob's type, so handing the webview
application/octet-stream makes img refuse bytes that are a perfectly
good PNG — and octet-stream is exactly what the client substitutes when
the server names no type.

Prefer a concrete image type from the server, otherwise identify the
format from its leading bytes. Every signature checked is a fixed marker
at a fixed offset, so this reads no user content, and a JSON error body
served with HTTP 200 is deliberately not mistaken for an image.

Whether that was the cause is not yet established, so the alternative is
made self-diagnosing rather than guessed at. The download outcome —
status, the type the server gave, the type the bytes indicate, and the
length — is now traced, and the frontend reports why an attachment did
not render instead of leaving a bare broken-image icon: a failed
download shows its error, and a payload the browser cannot decode says
so. Both paths were previously swallowed.

Refs: N-6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 02:29:33 +08:00
529357523c feat(chat): follow the newest message in the conversation
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The message list had no scroll code at all. Opening a conversation
landed at the top of the history, and every message sent or received
appeared below the fold, so reading a reply meant scrolling down by
hand each time.

Scroll to the tail when the rendered messages change and when the slot
or session changes. Following stops as soon as the reader scrolls more
than 80px away from the bottom and resumes when they return, so reading
back through history is not interrupted by an arriving delta.

scrollTo carries the smooth behaviour but is not universally available —
jsdom has none — so it falls back to assigning scrollTop.

Refs: F-44 (audit P2-28).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 02:21:30 +08:00
3a221a22d6 fix(astrbot): stop late content from overwriting a finished reply
A captured stream ended complete(272 chars) → image → attachment_saved
→ end, all under one message id. complete emptied the accumulation, the
attachment marker re-accumulated onto it, and end emitted a second
completion for the same message whose body was the marker alone. The
client assigns completed content over the existing message, so 272
characters of reply were replaced by an image tag — the reply visibly
vanished behind a broken image placeholder.

Mark a message as completed when its completion is emitted, and open a
new message on the next delta rather than reusing the finished id. The
reopened id carries a #part- suffix so the client reads it as a separate
message; frame comparisons use the base id so a later frame bearing the
server's original id is not treated as a different message.

The regression test replays the captured frame order and was checked
against a mutation that drops the completed flag, where it fails with
the attachment reusing the finished id.

Refs: F-32 (audit P2-17), which predicted this as "content arriving
after complete overwrites the full text".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 02:21:15 +08:00
03b99efda8 feat(astrbot): summarise how stream blocks relate to the final text
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The first capture identified the real cause of a reply appearing twice,
and it was neither candidate. All 524 frames carried a message_id and
each reply used exactly one, so the event_id fallback is not involved
and neither is the history session fallback.

AstrBot interleaves two kinds of plain frame in one reply. Frames with
streaming true are incremental deltas whose total matches the complete
frame exactly. Frames with streaming false carry whole finished blocks —
one reply had five of them totalling 915 characters against 173
streamed. map_plain appends both, so the blocks show up inline during
generation, and map_complete then replaces the accumulation with the
streamed text alone, discarding them. That is the reply appearing twice
and then collapsing, and the collapse loses content.

One thing lengths cannot settle: whether a block repeats streamed text
or carries its own. One reply had 133 block characters against 142
streamed, which looks like a repeat; another had 915 against 173, which
cannot be. The two need opposite fixes, so this adds a per-stream
summary reporting how many blocks appear in the final text and in the
streamed text, as counts and lengths only.

Also records that plugin images were never sent: no media or attachment
frame appeared in any capture, and no plain frame carried a message
chain array. The attachment path has still never received data.

Refs: N-9 (new), N-4 (root cause found), N-6 (not a client defect).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 02:08:36 +08:00
6060b968a7 feat(astrbot): record the message id value in the frame trace
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The first capture answered the question the trace was built for and
eliminated it: all 77 plain frames of one reply carried a message_id, so
a reply splitting into two bubbles is not the event_id fallback in
F-34.

What remains depends on the value rather than its presence. If the id
changes partway through a reply then the client is correctly showing two
messages the server sent; if it stays the same then the split is ours,
in the historySessionId fallback that loads another session's history.
The id is an opaque row identifier, not content.

Also record the length of a string data payload. It separates "the
server streamed many small chunks" from "the server sent the reply in
one piece" without recording any text.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:54:17 +08:00
06316a3240 docs(progress): record the window control and form simplification work
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Note the two findings worth carrying forward: a missing capability has
now surfaced as a silent no-op twice, and three profile fields were
collected for a path that never read them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:42:20 +08:00
79dbb40a25 feat(profiles): reduce the connection form to what a connection needs
Adding an AstrBot connection asked for eleven fields. Three of them
reach nothing: the SSE URL has no consumer anywhere in networking (the
desktop transport builds its own endpoint and AstrBot never reads it),
the certificate fingerprint is stored but TLS pinning is not
implemented, and the role only decides a word in the profile list.

The form is now the four things an activation actually requires — server
address, adapter id, API key, slot — with everything else behind a
collapsed advanced section.

The adapter id is the remote username. It was previously entered twice,
once in the profile form and again in the credential card, and it is
what keeps two slots on one server from sharing a conversation, so the
field now says that.

Three values are derived rather than asked for. The display name falls
back to identity@host. The role follows the chosen slot. The insecure
HTTP approval appears only for an http:// address and is required there,
because normalize_url rejects such an address without it — showing it
unconditionally invited enabling it for an https:// endpoint that never
needed it.

Choosing a slot now does the whole job: it assigns the slot, sets the
role, and points startup auto-connect at it, replacing a separate slot
card interaction and a separate auto-connect slot dropdown that could
disagree with each other. The API key is enrolled in the same submit.
Both steps need the profile to exist, so they run after the save and
report their own failures rather than failing the save.

Verified in a browser against the real stylesheet: four fields plus a
collapsed advanced section, the insecure checkbox appears only for
http:// and carries required, and the display name placeholder resolves
to identity@host.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:41:42 +08:00
ef8bc430d9 chore(format): normalize ProfileManager line endings
The file held 603 CRLF and 85 LF-only lines, while .editorconfig and
prettier both pin LF. Any substantive edit therefore produced a
whole-file diff that buried the actual change, which is why the fix
queue carries a standing warning about this file.

Isolated on purpose: `git diff --ignore-cr-at-eol` on this commit is
empty, so it can be reviewed as whitespace and the form rework that
follows reads as logic alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:33:49 +08:00
779ffc3d55 fix(tauri): grant the window controls the permissions they call
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The minimize, maximize and close buttons did nothing. They were wired
correctly; the ACL rejected them. core:default resolves to
core🪟default, which grants only read-only queries — is-maximized
is in it, which is why the maximize icon tracked state correctly, but
minimize, toggle-maximize, close and start-dragging are not. Both
windows are decorations: false, so with close denied the main window
could not be closed at all except through the tray.

Add two capabilities rather than widening the shared one: the main
window gets the four controls it draws, and the pet window gets dragging
alone, since it is moved by dragging its body and must not be able to
close or resize itself.

Every one of these calls was a bare void expression, so the rejection
was swallowed and looked identical to an unwired button. Route them
through a helper that reports the failure in the shell error banner.

This is the second time a missing capability has surfaced as a silent
no-op — the pet window previously had no entry at all. Add tests that
read the shipped capability files and assert each permission the UI
calls is granted to the window that calls it.

Also translate the TypeError the Tauri shim throws outside the
application into a sentence a user can act on. The dev server is
reachable at 127.0.0.1:1420, so opening it in a browser and hitting save
produced "Cannot read properties of undefined (reading 'invoke')".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:19:42 +08:00
bc0948731c fix(astrbot): make the frame trace reachable by its documented filter
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The event set an explicit target of astrbot::frame while the enabled!
guard used the default module-path target. A filter naming either one
therefore failed: naming the crate did not reach the event, and naming
the target left the guard returning false. Either way the trace emitted
nothing, which would have looked like the application producing no logs
at all and wasted a reproduction cycle.

Give the guard the same target, hoist it into a constant, and add a test
that drives the exact RUST_LOG value printed in the acceptance
instructions. The test was checked against the broken guard and fails
with empty output. A second test asserts the trace stays silent at the
default level, and both assert no payload text or attachment URL reaches
the log.

Document the capture procedure in the acceptance checklist.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 01:06:03 +08:00
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
178fba70ea docs(progress): record the R3 batch and its gate results
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Batch R3 (F-14 through F-19) is implemented and gate-verified. Record
what changed, the measured test counts, and the two things it did not
cover: auto_connect_configured_slots is still serial, and the
operations switch guard still has no production writer.

Also record that the new tests for F-14, F-15 and F-16 were each run
against a mutation restoring the old behaviour and each fails under it,
so they are known not to be tautological.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:31:18 +08:00
49dccc5eac fix(chat): scope draft, attachments, and errors per slot
The composer draft, the pending attachment list and the error banner
were single values shared by both slots. Uploading on companion and
then switching to operations routed the companion instance's
attachment ids into the operations instance, the operations error
banner stayed visible on the companion tab, and a half-typed message
followed the user across tabs.

Make all three Record<ChatSlot, ...>, mirroring the sending,
unreadCounts and storedSessions state that was already per slot. Every
asynchronous action now pins its slot at the start, so an upload or a
send that resolves after the user switched tabs still lands on the slot
it belonged to.

Splitting the error state is required rather than incidental. refresh()
runs every 500ms and wrote the shared error on failure and cleared it on
success, so any send or upload error was silently wiped within half a
second. The polling failure describes the IPC channel rather than a
slot, so it keeps its own runtimeError; slotError is owned solely by
user actions and takes precedence when both are present.

All three new tests were checked against a mutation that reads the
companion slot regardless of selection, and all three fail under it.

Refs: F-16 (audit P1-11).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:28:27 +08:00
124cf32fa2 fix(ui): release tauri event listeners on unmount
All four listen() call sites assigned the resolved unregister function
unconditionally. When the effect was cleaned up before the promise
settled, that assignment landed on a dead closure and the listener was
never unregistered. React StrictMode mounts, cleans up and mounts again,
so the first listener leaked on every development mount. In ChatPanel
that meant applyRuntimeEvents ran twice per event and, because a delta
is appended to the existing content, every character of a streamed reply
was doubled.

Track whether the effect is still live and unregister immediately when
the promise settles late. Each site also gains a catch, since these were
all bare void listen(...).then(...) chains — a rejected listen, such as
the missing desktop-pet capability, became an unhandled rejection rather
than anything observable.

The listener mock in src/test/setup.ts resolved eagerly, which made the
race impossible to express. Replace it with a controllable double in
src/test/tauriEvent.ts that defers resolution until the test asks for
it, tracks each registration separately, and only dispatches to handlers
that have not been unregistered. The registry is plain module state, so
setup.ts resets it after each test.

ChatPanel had no test file; this adds one. Both new tests were checked
against a mutation restoring the old assignment, and both fail under it.

Refs: F-15 (audit P1-10).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:23:42 +08:00
02ac2046d6 fix(chat): validate slot sends before writing history
send_connection_slot_message wrote the optimistic user row from the
runtime snapshot alone, then called send_slot_message, which can still
refuse the send for an empty message, a busy slot or a disconnected
slot. The rejected question stayed in history with no failure marker,
and because each attempt minted a fresh local- id, retrying appended a
second copy rather than replacing the first.

Add a read-only pre-flight, ensure_slot_can_send, and run it before any
database write. The conditions it checks are extracted into
slot_send_precondition, which send_slot_message now uses inside its own
critical section, so the two cannot drift. Mint the message id once so
the failure path can address the row it wrote.

A send that fails after AstrBot accepted it must keep its question:
cancelled and streamInterrupted both mean the message is already in the
remote conversation and a partial reply may already be stored. Those
two keep the row; every other code marks it failed. server_received
encodes that rule and is covered by a test that walks every
AstrBotClientError variant through astrbot_send_error, so a future
rename of an R2 error code cannot silently change the classification.

Marking rather than deleting keeps chat_sessions.last_message_id valid,
re-uses the idempotent upsert, and leaves unread counts alone since they
already ignore user rows. The queue sanctions either choice.

The R2 retry loop and its error mapping are untouched; all five R2
transport sentinels still pass.

Refs: F-18 (audit P2-3).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:20:09 +08:00
0fadc699e2 fix(net): reject one profile occupying both runtime slots
probe_connection_slot never consulted the slot assignment table, so the
same profile could be activated into both runtime slots at once. That
bypasses the ProfileAlreadyAssigned policy the database enforces, and
both slots then race to overwrite the same sticky_session_id.

Enforce it in three places. The runtime invariant lives inside
activate_slot's claim phase, so it also covers startup auto-connect,
which calls activate_slot directly and would bypass a command-layer
check. The command adds a cross-check against connection_slots. And the
operations switch guard now covers probe and disconnect, not just slot
assignment.

Both rules are deliberately negative — they ask whether the profile is
bound to the *other* slot, never whether it is bound to this one.
auto_connect_configured_slots activates from profile.auto_connect_slot
and never writes connection_slots, so a positive rule would break
reconnect for every auto-connected profile. For the same reason the
probe guard only refuses a change of profile, so reconnecting the
profile the operations slot already holds still works during a task.

The operations guard has no production writer yet (F-74, audit P3-7),
so it is inert at runtime. It ships with a test that flips the guard
directly rather than as an unexercised branch.

Refs: F-19 (audit P2-4).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:16:33 +08:00
06312447aa fix(net): reject stale session switches by generation
switch_slot_session released the slot lock while set_session_id ran and
then re-acquired it to write active_session_id, with no check that the
slot still belonged to the same activation. A deactivation or
re-activation in that window put the old session id onto the new
occupant's snapshot, and persist_session_identity then copied it into
that profile's sticky session.

Capture the generation alongside the client in the first critical
section and compare before writing. The write-back is extracted into
commit_session_id so the invariant can be tested directly rather than
raced.

Refs: F-17 (audit P2-1).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:12:32 +08:00
b2ecd1f3a4 fix(net): probe connection slots outside the runtime lock
activate_slot held the single mutex that covers both slots across
health() and probe(). Those go through the REST client, whose total
timeout is 120s, so one unreachable address froze every runtime command
on both slots for that long: status polling, sending, cancelling and
disconnecting all blocked on the same lock. The cancellation token was
also only created after a successful probe, so the activation itself
could not be interrupted.

Split the function into three phases. Validation and client
construction happen first with no lock held; a short critical section
then bumps the generation, installs the cancellation token up front and
publishes the Connecting snapshot; the probe runs outside the lock
inside a biased select against that token; and a final critical section
writes the result back only if the slot still belongs to this
activation.

The listener receives the same token that phase one installed. Creating
a second one there would leave deactivate_slot cancelling a token no
listener observes, so the desktop-v1 reconnect loop would outlive the
disconnect.

This also fixes a stuck-slot bug the queue did not name. Validation used
to run after the Connecting snapshot had been written, so a rejected
request tore down a working connection and left the slot in Connecting
forever, with no client and no last_error to explain it.

The three new tests were checked against a mutation that re-acquires
the lock across the probe; the two concurrency tests fail under it.

Refs: F-14 (audit P1-4).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:11:19 +08:00
1a18a8ac85 docs(acceptance): record r1/r2 gate closure and pending hardware steps
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The R1 and R2 batches were recorded as gate-verified, but the Tauri
release build and the Playwright suite had never been run against them.
Both were executed here and pass, together with the rest of the stage
gate. Record the measured numbers rather than the previously estimated
ones, and name every step that still needs a live AstrBot container.

F-04 is now verified at the packaging level: the production CSP
containing blob: is present in the release binary. Dev builds do not
inject the CSP, so this was the only automated evidence available for
it; rendering an actual attachment remains a manual step.

Also record two things this run surfaced. Prettier reports 25 files
repo-wide, not the 20 previously written down, and the Playwright 680px
case passes only because that viewport sits exactly on the second CSS
breakpoint, leaving the 681px to 900px icon-only band untested and
without accessible nav labels. The latter is tracked as F-62.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:06:17 +08:00
25f41ff50f docs(reports): assign f-ids to five untracked audit findings
The 2026-07-26 audit records 68 findings, but five of them never
received an F-id and belonged to no batch: P2-6 (download_attachment
buffers the whole body before checking the 16 MiB cap), P2-7 (health()
omits the bearer that SSE sends), P2-8 (the reconnect backoff resets to
100ms on a graceful close, giving a hot loop), P2-29 (JWT exp is
checked with no clock skew margin), and P3-7 (the operations switch
guard has no production writer).

Assign F-70 to F-73 into R5, which already owns gateway_client.rs and
astrbot_client.rs through F-26 and F-30, so the queue's own
same-file-same-batch rule holds and R4 and R5 do not contend for one
file. Assign F-74 into R8 with a note that R3's F-19 extends only the
guard's read side. F-69 stays permanently unassigned because it was
retracted.

Also correct the Rust test count. The queue said 67 to 73 and the
status summary said 67 to 76; a real cargo test --workspace run gives
76 unit tests in astrbot-desktop and 96 passed with 2 ignored across
the workspace, so 73 was stale.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:05:00 +08:00
566744a025 docs(changelog): repair keep-a-changelog structure
Commit 3d1d962 inserted an unreleased heading between the H1 and the
preamble without a blank line, so Markdown absorbed the "all notable
changes" preamble as a lazy continuation of a list item, and it also
prepended a UTF-8 BOM. Commit ceb7512 then inserted the 0.1.0-alpha.2
section directly under the H1, which is why the file began
mid-document, and indented the preamble to cement it inside the
bullet.

Restore the canonical order (title, preamble, single [Unreleased] with
one Added/Changed/Fixed/Security group, then the released section),
strip the BOM, and move the duplicate-optimistic-messages entry from
Changed to Fixed. Entry text is otherwise unchanged; the R1 and R2
Fixed groups were verified to be disjoint before merging. The file now
passes prettier --check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:02:51 +08:00
8646a064dd chore(prettier): ignore machine-local claude settings
`.claude/settings.local.json` is untracked but still scanned by
`prettier --check .`, so `check:frontend` fails for any developer who
has local Claude Code settings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:00:48 +08:00
5ecfaa433b fix(pet): restore prettier formatting in the sprite error branch
Commit 41592e2 shortened the localized fallback string but left the
ternary wrapped across three lines, which prettier now collapses. This
file passed `prettier --check` at 785f125 and failed afterwards, so it
is the only formatting regression introduced by the R1/R2 batch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 00:00:33 +08:00
573f9f793b docs(reports): add the R1/R2 status summary
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Records what was completed, what was not, and how far verification actually
got, so the next session does not have to reconstruct it from the queue and the
commit log.

Notably it separates the local gate (which passed) from the batch acceptance
criteria that were not run: the Tauri release build, Playwright, and every
real-device check. F-04 in particular cannot be considered verified until a
release build is exercised, because development does not inject a CSP.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 23:17:04 +08:00
58a98d3c94 docs(reports): record the source audit, fix queue, and R1/R2 results
Adds the 2026-07-26 full-source audit and the execution-ordered fix queue, and
records what actually happened when R1 and R2 were verified:

- R1 had never been compiled. The gate found a type error introduced by its own
  `.nullish()` widening and a lint failure from a non-component export, plus one
  acceptance test that was specified but never written.
- R2 landed F-10 through F-13, and an adversarial review of it surfaced three
  defects the batch had itself introduced, all fixed in the same batch.
- The review subagents ran against the live working tree and left mutations
  behind, including a deliberate duplicate POST inside the stream error path.
  That injected code was briefly mistaken for a real HTTP-stack defect. It has
  been removed and the process note recorded so review runs are isolated next
  time.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 23:12:57 +08:00
c4c40bd561 fix(astrbot): do not resend messages after the response starts
`should_retry_astrbot` treated every `reqwest::Error` as retryable, but that
class covers both "the POST never left" and "the response body broke". `POST
/api/v1/chat` carries no idempotency key, so retrying the second case appended
the user's message to the remote conversation a second time, produced a second
answer, and interleaved the two attempts' deltas into one garbled bubble.

Retries are now limited to connect-phase failures, the one case where the
request provably never reached the server. Anything after that surfaces a
`streamInterrupted` code so the UI can offer a manual retry instead.

Also stops a send from checking the client out of its slot. The other five slot
commands read the client and report "not connected" when it is absent, so a
send disabled sessions, capabilities, upload, download, and session switching
for its whole duration. That window used to be bounded by the client's 120s
total timeout; now that streaming has no total deadline it would last as long
as the reply, so an ordinary long answer would disable the rest of the slot.
The client is cloned instead and concurrent sends are rejected with `slotBusy`.
(P2-13 / F-49, pulled forward from batch R7 because this batch is what made it
user-visible.)

Refs P1-2 / F-12.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 23:12:57 +08:00
6e81a3a7ae fix(astrbot): scope stream event ids and fix the transport layer
Combines the P0 event-id fix with the three transport fixes that rewrite the
same stream loop; they are not separable in these two files.

fix(astrbot): scope stream event ids per request (P0-1 / F-01)
  `AstrBotStreamMapper` restarts its sequence at zero for every stream, but
  `seen_event_ids` lives on the client and outlives a request. Event ids were
  built from `server_instance_id + sequence` alone, so the second message on a
  connection replayed the first message's ids and every one of its events was
  discarded as a duplicate: the assistant's reply never reached the UI or the
  database. Ids now carry a per-request `stream_id`.

fix(protocol): serialize model options in camelCase (P1-7b / F-07)
  `AstrBotModelOption` had no `rename_all`, so the frontend's `isDefault` was
  always undefined and no model was preselected.

fix(net): stop total timeouts from killing streams (P1-1 / F-10)
  `Client::timeout` runs from the start of the request until the body is
  finished and keeps counting while `bytes_stream()` is consumed. The 30s
  desktop-v1 budget therefore tore the long-lived SSE connection down every 30
  seconds no matter how healthy it was — heartbeats could not keep it alive —
  and the 120s AstrBot budget cut off any generation longer than two minutes.
  Streaming now uses a separate client with no total deadline, detecting a
  stalled peer with `read_timeout` (which resets on every successful read) plus
  a TCP keepalive. REST endpoints keep their total deadline.

fix(astrbot): decode sse bytes on line boundaries (P1-3 / F-11)
  Decoding each network chunk with `String::from_utf8_lossy` corrupted any
  character straddling a chunk boundary. For CJK text that is one replacement
  character per unlucky chunk, persisted into the message. The stream is now
  split into lines at the byte level and only complete lines are decoded.

fix(astrbot): finalize streams on cancel and error (P2-2 / F-13)
  Cancellation and every error path returned without a `MessageCompleted`
  event, leaving the row `streaming = 1` so it rendered as "generating" again
  after a restart. All exit paths now finalize with `Cancelled` or `Error` and
  keep the text received so far. Cancelling also no longer flips the connection
  to Disconnected and back, which was a visible flicker (P3-4 / F-56).

Hardening found while reviewing the above: a 64 MiB per-response ceiling
(removing the total timeout removed the only bound on a response, and
`read_timeout` cannot replace it), and a cursor-based line buffer instead of
draining from the front, which was quadratic in the chunk size.

Tests drive a real `AstrBotClient` against a hand-rolled HTTP/1.1 chunked-SSE
server on a raw `TcpListener`: byte-exact control over chunk boundaries and
dropping a socket mid-body without the terminal chunk are not expressible
through an HTTP framework, and both are needed here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 23:12:56 +08:00
41592e2504 fix(ui): restore corrupted localized strings
Historical UTF-8 corruption left question-mark runs in user-visible copy and in
one accessible name: the sprite load failure message, the canvas context
failure message, the pet window's `aria-label`, and the page loading state.
A separate spot had the "desktop floating" option label hard-coded as numeric
HTML entities.

Refs P1-17 / F-09.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 22:31:44 +08:00
828f7c586d fix(chat): accept null in runtime event contracts
Rust serializes `Option<String>` without `skip_serializing_if`, so absent
fields arrive as `null`. Zod's `.optional()` accepts only `undefined`, so
`safeParse` failed and three chains silently died:

- `boundRuntimeEventSchema.sessionId/messageId`: desktop-v1 and mock events
  carry no session id, so every one of them was discarded; AstrBot error and
  heartbeat frames were discarded too.
- `remoteChatSessionSchema.displayName/updatedAt`: one null field threw for
  the whole array, leaving the remote session list permanently empty.
- `astrbotModelOptionSchema.name`: a null name failed capability parsing,
  which permanently disabled the file upload button.

The sibling `slotRuntimeSnapshotSchema` in the same file already used
`.nullish()` throughout, which is what makes this look like a miss during the
de-enveloping change rather than a deliberate choice.

`formatSessionTime` widens with it: `updatedAt` is now `string | null` and the
existing falsy guard already handled null.

Refs P1-7a / F-06.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 22:31:44 +08:00
e8d9dbc8f6 refactor(ui): share ipc error formatting
Tauri rejects `invoke` with the deserialized Rust error value, which for
`RuntimeCommandError { code, message }` is a plain object rather than an
`Error`. Nine call sites used `reason instanceof Error ? reason.message :
String(reason)`, so every send, reconnect, stop, and settings failure showed
the user `[object Object]`.

`ProfileManager` already had a correct implementation; this lifts it into
`src/lib/errorMessage.ts` and routes the other call sites through it. The
module also exports `isCancelledError`, which a later batch needs to tell a
deliberate stop apart from a real failure.

Refs P1-16 / F-08.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 22:31:16 +08:00
051b9ced6a fix(chat): restrict markdown link protocols
Assistant messages come from a remote AstrBot instance and are untrusted, but
the markdown renderer passed the href through verbatim, so `javascript:` and
`data:` URLs reached an anchor. Inside this webview, script execution has
access to the full Tauri IPC surface.

Links are now resolved with `new URL()` and only http/https/mailto survive;
anything else renders as the original plain text. Relative hrefs are rejected
too rather than being presented as absolute links against the placeholder base.
`rel` gains `noopener`.

The helper lives in `src/lib/` rather than beside the component because a
non-component export in a component module fails `react-refresh` under the
repository's `--max-warnings 0` lint gate.

Refs P1-15 / F-05.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 22:28:46 +08:00
78f03e378e fix(tauri): allow blob images in production csp
Attachment images are rendered from `URL.createObjectURL`, but the production
CSP `img-src` list had no `blob:` entry. Development does not inject a CSP, so
this only broke release builds.

Refs P1-14 / F-04.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 22:28:35 +08:00
def5e92802 fix(tauri): grant desktop-pet capability
The `desktop-pet` window is created at startup but was absent from the
capability window list, so every IPC call and event listener it made was
rejected by the Tauri ACL. Because those calls are issued as `void invoke(...)`
the rejections were swallowed, and the pet silently lost its runtime status
link, dragging, context menu, and preference handling.

Refs P1-13 / F-03.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 22:28:35 +08:00