提交图

56 提交

作者 SHA1 备注 提交日期
7aead6fa48 feat(policy): gate screen reading behind consent, a rate limit, and a switch
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
implementation-queue.md:129 requires an authorization prompt, a frequency
limit, and a privacy switch to exist before screenshots or window
summaries are wired to anything. None of the three existed anywhere in
the repository, so this is them, plus ADR-0008 recording what the
authoritative documents actually permit.

The ADR corrects a mis-reading that would have decided the feature the
wrong way. 01_Architecture_Design.md:250-261 is titled 「不应放在前端的
能力」, so the 「原始截图捕获」 at :259 forbids screenshot capture in
React — it is not a product-level ban, which is how an earlier audit read
it before concluding screen reading was out of scope. The product
affirmatively permits 「用户授权的单次窗口截图」 (:739) and, for phase 7,
「手动和低频截图」 (:1424). What it does exclude is 「实时全双工语音」,
「唤醒词」 and 「高频视频分析」 (:1349-1351).

The module owns all three gates so none of them depends on the frontend
being correct. Reading takes a closure, so the window handle never leaves
the module and there is no accessor that skips the switch, the session,
the expiry check, or the budget. The switch defaults to off and clearing
it drops live sessions, so flipping it mid-capture stops the next read
rather than only preventing new authorizations. `now` is a parameter to
the budget rather than read inside it, which is what makes the interval
testable without sleeping.

Two decisions worth naming. The pixel interval defaults to two seconds
with a 500ms floor no caller can lower — three orders of magnitude away
from a video frame rate, because high-frequency video analysis is out of
scope and what phase 7 asks for is manual, low-frequency capture. And a
session cannot be bound to the operations slot at all, refused at
creation rather than at each read, because :1077 says the operations slot
does not automatically receive game screenshots, window state, or game
events — and a session is exactly that automatic delivery. The slot rule
is a free function so it is asserted directly rather than through a live
window.

Also recorded, not worked around: capture.rs uses PrintWindow over GDI,
which does not capture a hardware-accelerated game surface. Game
companionship needs Windows.Graphics.Capture before it works on the case
it exists for, and a black frame delivered to the model would be worse
than an error.

Rust tests 101 -> 110.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 06:22:15 +08:00
5b518d1181 feat(chat): carry voice and other non-image attachments end to end
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
F-33. A voice reply produced nothing at all: no marker, no event, no
error. Four independent gates each dropped it, and fixing any one alone
would have changed nothing observable.

The mapper reached `map_media` for image, record, file and video alike,
but its only emitting branch was gated on the frame being an image, and
the `attachment_saved` fallback rejected every other type outright. Both
now carry whatever type arrived, with the frame type as the marker's alt
text so the renderer knows what to expect before any bytes exist.
`pending_media` was also a single slot, so a second attachment in one
reply overwrote the first before it was paired; it is a bounded queue
now, and an `attachment_saved` with no id no longer consumes the media
frame still waiting for one.

The download judged a candidate path successful only if the bytes sniffed
as an image — this server answers unknown paths with its own text under
HTTP 200, so sniffing is load-bearing and cannot simply be dropped.
Audio and video signatures are recognised now, and a declared
Content-Type is trusted when it names media rather than only images.
SILK is included deliberately: it is what AstrBot relays for QQ and
WeChat voice, no browser decodes it, and recognising it is what lets the
UI say so instead of rendering a player whose play button does nothing.

The CSP had no `media-src`, so it fell back to `default-src 'self'` and
an `<audio src="blob:">` was refused — in release builds only, since the
dev server serves no CSP at all. That is the same divergence as F-04 and
the inline-script trap in pet.html, so the policy now has a test of its
own that pins each directive the app depends on, including that
script-src still refuses inline.

The renderer chose `<img>` unconditionally. The element now follows the
media type of the bytes that actually arrived, falling back to the
marker's declared kind for the placeholder and the failure message.

`map_media` also kept a private copy of the message-id handling that
included the reopen-suffix overwrite fixed earlier in `adopt_message_id`;
it shares the one implementation now.

Protocol tests 22 -> 26, Rust client 99 -> 101, frontend 35 -> 43. All
six mutations of the new assertions were confirmed to fail.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 06:16:55 +08:00
21d85be4fa fix(protocol): send attachments where AstrBot reads them
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
Attachments went out under a top-level `attachments` key holding
camelCase objects. AstrBot's `OpenApiChatRequest` has no such field —
its properties are message, session_id, conversation_id, username,
config_id, config_name, platform_id, enable_streaming and flags,
read from the live server's own /api/v1/openapi.json — and FastAPI
ignores unknown keys instead of rejecting them. So every attachment this
client ever sent was discarded in silence while the request reported
success. The same is true of `nickname`, now removed.

Attachments belong inside `message`, which AstrBot accepts either as a
bare string or as a list of segments: {"type":"plain","text":...} and
{"type":"image"|"record"|"file"|"video","attachment_id":...}, per the
documented format at docs.astrbot.app/en/dev/openapi.html. Segment type
now follows the uploaded media type, with `file` as the fallback so an
unrecognised type still travels rather than being dropped.

This closes the outbound half of P1-9, which the queue had recorded as
externally blocked on a real container. It did not need one: the schema
is public and the server serves it unauthenticated.

It also settles how voice input will be sent — an audio upload is a
`record` segment — so B4 no longer has to guess at the contract.

Text-only requests keep the bare-string shape they always had. A test
now asserts the serialized request carries no key outside the nine the
server declares, since anything else fails by being ignored rather than
by erroring.

Protocol tests 19 -> 22. All three new assertions confirmed to fail
under a deliberate regression.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 06:04:57 +08:00
1e9d1c1e77 fix(net): bound an attachment download while it runs
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
F-70. The body was read to completion with `bytes()` and only then
measured against a 16 MiB ceiling, so a server answering an image request
with gigabytes — by fault or by design — was held in memory in full
before anything rejected it. Now read in chunks and abandoned the moment
the ceiling would be crossed, with a declared Content-Length over the
ceiling refused before the body is touched at all.

Promoted from a theoretical bound to a real one by the voice work ahead:
audio replies are far larger than the stickers this path was built for,
so the ceiling becomes reachable in ordinary use rather than only under
attack.

The fake server for this serves its body with `Connection: close` and no
length rather than chunked framing, so the test cannot pass or fail on
the fixture's own framing. It counts the blocks it managed to write, which
is what distinguishes a download that stopped early from one that was read
in full and measured afterwards — confirmed by reverting to `bytes()`,
which fails the test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 05:55:40 +08:00
9b2ec64502 fix(pet): read stored preferences and stop the pet from stealing focus
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
An audit of the destroy→hide change across four lenses raised 17
findings; 14 survived adversarial verification. Two of them were
regressions that change introduced, and both had the same shape: code
that only worked because the pet window used to not exist.

  show_pet_context_menu picked the pet window and fell back to main.
  While the pet rendered inside the app its window had been destroyed at
  startup, so the fallback happened to select the visible main window.
  Now that the window merely hides, the menu was being anchored to a
  hidden HWND, which Win32 cannot bring to the foreground. The
  visibility test is explicit now rather than incidental.

  DesktopPetView read the connection state in a mount effect and nothing
  emitted connection events, so destroy-and-rebuild was what re-read it.
  Without a remount the floating pet showed whatever was true at startup
  for the rest of the session. reveal_pet_window now emits
  pet-window-revealed and the view re-reads on it.

The rest were already there. Every pet setting was decorative: the
preferences were applied and then dropped, so reveal_pet_window had to
invent an answer and hard-coded the first monitor, the safe edge and
always-on-top — reverting the user's choices on every show. The pet view
re-sent a fully hard-coded payload whenever game mode toggled, and the
settings page initialised its controls from literals, so returning to
the page and changing one thing pushed three stale defaults back onto
the window. There is a session-scoped store now, a command to read it,
and both frontends read before they write. Persisting it across restarts
is F-75.

Always-on-top is off by default, which is what the Q6 acceptance
criterion asked for (F-35), and the window no longer takes focus when
shown — it was activating on show and swallowing keystrokes meant for
the main window. focusable is left alone on purpose: clearing it adds
WS_EX_NOACTIVATE, which would re-break the context menu now anchored to
that window. That is F-79.

The pet also painted a solid dark rectangle before its assets arrived.
The transparency rule is gated on a class that an effect inside the
5.2 MB lazy chunk added, so until that chunk ran the app's opaque
background won. This is why the earlier hunt for "the rule that beats
!important" found nothing: the class was not applied yet, so specificity
was never the question. The pet now has its own entry document carrying
the class statically. An inline script would not do — tauri-utils only
nonces script[src^='http'], so it would pass in dev and be blocked by
script-src 'self' in a release build.

Rust tests 92 → 97, frontend 30 → 35. All 11 mutations of the new
assertions were confirmed to fail.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 05:25:27 +08:00
4f73c0819d fix(pet): hide the pet window instead of destroying it
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
The desktop-floating pet never appeared. The log established that
open_pet_window ran, took the rebuild branch, and then produced neither
the success log nor the failure log — so it returned Err somewhere in
the config lookup, from_config, or build(), all three of which used a
bare `?` with no log of their own.

Two changes. close_pet_window now hides the window rather than
destroying it, so every later open takes the branch that demonstrably
works instead of the rebuild branch; hiding also keeps the pet's
listeners and animation state, which the mode switch wants back
immediately anyway. And open_pet_window is wrapped so any failure on
any path is logged with the error, rather than only the reveal step.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 04:39:20 +08:00
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
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
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
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
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
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
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
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
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
d100da324d fix(chat): prevent duplicate history on session switch
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-22 02:52:31 +08:00
5de8bfab03 fix(chat): flatten runtime event payloads
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-21 14:55:49 +08:00
ceb7512bf2 feat(desktop): complete Q9 chat and stability increment
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-21 14:43:14 +08:00
92ad44d327 fix(pet): add stable desktop rendering and context menu
一些检查失败了
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
ci / Portable quality checks (pull_request) Has been cancelled
ci / Windows Tauri build (pull_request) Has been cancelled
2026-07-20 20:50:27 +08:00
e0ef4230ff fix(tray): make quit action terminate app
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 17:51:09 +08:00
74fe19f7e4 feat(auth): handle jwt expiry and relogin state
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 16:52:29 +08:00
7dae4898cb feat(pet): separate remote identity and add paper pet window
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 16:28:42 +08:00
b2856ce075 feat(auth): add dashboard jwt login
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 16:12:11 +08:00
058bfc7029 feat(identity): add jwt and paper pet actions
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 15:55:36 +08:00
9f61578a73 fix(window): allow quick chat to close
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 15:06:05 +08:00
e28614ad6a feat(window): persist quick chat geometry
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 14:59:55 +08:00
06e0b411ea feat(chat): add remote session navigation
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 14:32:07 +08:00
bcaebee6f3 feat(chat): add model and attachment interfaces
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 13:30:29 +08:00
4f13581809 feat(desktop): configure quick chat and bubble routing
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 12:34:56 +08:00
e0b48c0a5c feat(chat): persist sessions and unread state
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 12:25:08 +08:00
5dfac5960f fix(sse): add bounded chat retry and cancellation
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 12:08:06 +08:00
2e84ea52e9 feat(connection): auto-connect configured slots
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 12:01:18 +08:00
3d1d962461 feat(chat): add AstrBot dual-slot chat foundation
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
2026-07-20 11:31:41 +08:00
34a563c65b feat(connection): validate auto-connect and guard operations switches
Add configuration-only auto-connect rules, runtime operations slot lock
while tasks are active, and duplicate server-instance warnings without
silent Profile merge. Surface policy status to the settings UI and cover
the new boundaries with Rust and Vitest checks.
2026-07-20 00:49:15 +08:00