比较提交

..

没有共同的提交。6a1eeabea882da2a862a40fd617751cb0a1cc4ae 和 b3420e485af1636e76632c44a8c286aa461efadb 的历史完全不同。

共有 11 个文件被更改,包括 49 次插入 和 504 次删除

查看文件

@ -18,10 +18,6 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
- Provisional desktop-v1alpha1 Rust types, TypeScript exports, ten JSON Schemas, drift checks, and two loopback-only Mock Gateway instances.
- Frontend, browser, Rust, integration, Windows provider, soak, and Forgejo CI test entry points.
- P00 dependency review and durable Spike result records.
- Persistent SQLite application-data initialization with transactional `user_version` migration and future-version rejection.
- Strict Zod validation for the Rust bootstrap IPC payload, including the active database schema version.
- Redacting tracing output writer with structured-field, bearer-token, URL-credential, private-key, and known-secret coverage.
- P01 migration, logging, IPC validation, real Tauri startup, and production-build verification.
### Security

查看文件

@ -50,15 +50,3 @@
- Implementation: the identity is configured only in this repository.
- Result: two Conventional Commit baseline commits were created on `main`, pushed normally, and followed by scoped feature-branch commits.
- Safety impact: no global Git identity was changed.
## PD-0008: Profile CRUD stage ownership
- Status: unresolved; blocks Profile CRUD implementation only
- Conflict: `docs/01_Architecture_Design.md` lists Profile CRUD in stage 1, while `docs/02_Codex_Implementation_Tasks.md` lists ConnectionProfile CRUD in Batch 2.
- Impact: resolving this changes the database schema, Tauri IPC surface, frontend state model, and the acceptance boundary between `feat/p01-foundation` and `feat/p02-dual-connections`.
- Safe current action: complete only the unambiguous P01 foundation work<72><6B>persistent migrations, validated bootstrap IPC, redacted logging, tray, single-instance, exit flow, and tests.
- Paused work: profile tables, Profile CRUD commands, profile forms, and profile-to-slot assignment.
- Required decision:
- Option A: architecture document wins; implement basic Profile CRUD in P01 and leave slot assignment/connection behavior for P02.
- Option B: implementation task batching wins; keep all ConnectionProfile CRUD in P02.
- Recommendation: Option A is the literal higher-priority document, but the implementation remains paused because AGENTS.md requires explicit reporting for conflicts affecting database structure or public interfaces.

查看文件

@ -1,6 +1,4 @@
# Implementation Plan
## P00 Bootstrap (completed)
# P00 Bootstrap Implementation Plan
## Objective
@ -32,28 +30,7 @@ Establish a reproducible Tauri 2 + React + TypeScript + Rust baseline and comple
- Rust/MSVC/Tauri are verified and no longer block local work.
- Git Credential Manager reauthentication succeeded and the non-forced HTTP push created the remote `main` baseline at `0d12b94`.
- Forgejo PR #1 merged P00 into `main` at `b3420e4`; development now continues on `feat/p01-foundation`.
- Development is active on `feat/p00-bootstrap`; the remaining repository handoff step is a normal push of this feature branch.
- The configured SSH fetch endpoint still refuses connections and the LAN SSH endpoint rejects the available key, but the approved HTTP push URL is operational.
- Forgejo runner labels/jobs remain unverified, so the committed workflow is not claimed successful.
- Real UNC execution still requires a user-authorized disposable fixture.
## P01 Foundation (active)
### Objective
Turn the P00 Spike skeleton into a durable application foundation without pulling Batch 2 connection-profile behavior forward across an unresolved document boundary.
### Ordered work
1. Initialize a persistent SQLite database in the Tauri application-data directory.
2. Apply versioned, transactional, idempotent migrations and refuse unknown future schema versions.
3. Validate Rust-to-TypeScript bootstrap payloads at runtime.
4. Ensure tracing output passes through the shared redaction rules before it reaches a writer.
5. Re-verify tray, single-instance, explicit exit, frontend, Rust, E2E, development startup, and production build behavior.
6. Record the Profile CRUD stage conflict before changing its schema or IPC.
### Paused boundary
- `docs/01_Architecture_Design.md` places Profile CRUD in stage 1.
- `docs/02_Codex_Implementation_Tasks.md` places ConnectionProfile CRUD in Batch 2.
- Because this changes database structure and public IPC, Profile CRUD remains paused under PD-0008 until the stage boundary is explicitly resolved.

查看文件

@ -2,7 +2,7 @@
## Current phase
P01 foundation is active on `feat/p01-foundation`; unambiguous foundation work is implemented, while Profile CRUD is paused on a documented stage-boundary conflict.
P00 bootstrap implementation and high-risk Spike verification is complete; the feature branch is published and awaiting user PR review.
## Completed
@ -21,23 +21,15 @@ P01 foundation is active on `feat/p01-foundation`; unambiguous foundation work i
- Added frontend, Playwright, Rust, integration, Windows-provider, soak, and Forgejo CI entry points.
- Built the Windows release executable and SHA-256-recorded NSIS installer.
- Added dependency, Spike, progress, changelog, and pending-decision records.
- Verified Forgejo PR #1 merged into `main` as `b3420e4`.
- Fast-forwarded local `main` and created `feat/p01-foundation` from the merged baseline.
- Added persistent SQLite startup initialization with WAL, busy timeout, transactional `user_version` migration, idempotent reopen, and future-version rejection.
- Added strict Zod validation for the Rust bootstrap IPC payload and exposed the active database schema version.
- Added a redacting tracing writer that sanitizes structured fields and rendered message content before output.
- Verified a real Tauri development start created the application database in the Windows app-data directory.
- Built the P01 Windows release executable and NSIS installer.
- Committed the implementation, test, and CI increments with Conventional Commit subjects.
## In progress
- Recording the Profile CRUD stage conflict and preparing the verified P01 foundation increment for remote review.
- Preparing the final PR draft and handoff report without merging `main`.
## Remaining
- Resolve whether Profile CRUD belongs in P01 (architecture document) or P02/Batch 2 (implementation task document) before changing its database schema or public IPC.
- After resolution, complete the selected stage scope and open a PR without automatically merging `main`.
- Open and review the Forgejo PR from `feat/p00-bootstrap` to `main`; do not merge automatically.
- Run the Forgejo workflow when a compatible runner is available.
- Execute a real UNC transaction only after an authorized disposable fixture is supplied.
- Add the combined end-to-end test that keeps configured streams active while the real Tauri window is hidden to tray.
@ -47,26 +39,24 @@ P01 foundation is active on `feat/p01-foundation`; unambiguous foundation work i
- Configured Forgejo SSH `localhost:18086` refuses connections.
- LAN SSH `192.168.31.210:18086` responds but rejects the available public key.
- HTTP Git push is operational after Git Credential Manager reauthentication and is no longer a blocker.
- Profile CRUD stage ownership conflicts between the architecture and implementation task documents; implementation is paused because it affects database structure and public IPC.
- Forgejo runner labels/jobs could not be verified; the jobs API endpoint returned 404.
## Test status
- `npm run check:frontend`: passed; 2 Vitest tests and production Vite build.
- `pnpm check:frontend`: passed; 1 Vitest test and production Vite build.
- `pnpm test:e2e`: passed; 1 Chromium smoke test.
- Rust fmt/check/Clippy with warnings denied: passed.
- `cargo test --workspace`: 44 passed, 2 explicit manual tests ignored.
- `cargo test --workspace`: 40 passed, 2 explicit manual tests ignored.
- Controlled Windows UIA/PrintWindow smoke: 1 passed.
- Corrected dual-SSE soak: 1800.02 seconds, 1800 companion events, 1801 operations events, passed.
- Protocol Schema drift check: passed.
- P01 Tauri development startup and application-data SQLite creation: passed.
- P01 release executable and NSIS installer: passed after repairing the missing official `libsqlite3-sys` binding cache; installer SHA-256 `B8858CBE2F4673FAF40799C1243BCAB0748D194FA3AD67FBD33DDCF26CF27189`.
- Tauri development smoke, release executable, and NSIS installer build: passed.
- pnpm 11.9.0 frozen lockfile-only validation: passed using a local temporary store to avoid the pnpm UNC project-registry limitation.
- Forgejo CI and a real UNC transaction were not executed and are not claimed successful.
## Current branch
`feat/p01-foundation`
`feat/p00-bootstrap`
## Recent commits
@ -75,11 +65,8 @@ P01 foundation is active on `feat/p01-foundation`; unambiguous foundation work i
- `01607c6 feat(p00): add Tauri desktop spike foundation`
- `69b432b test(p00): add frontend browser rust and windows checks`
- `d4af979 ci(forgejo): add portable and windows quality workflows`
- `72a16cb docs(p00): record Forgejo branch publication`
- `b3420e4 Merge pull request 'feat(p00): bootstrap Tauri desktop and validate high-risk spikes' (#1)`
- `ed74342 feat(foundation): add persistent bootstrap safeguards`
- `353a439 docs(p00): record spike results and unresolved boundaries`
## Next step
Obtain an explicit decision for PD-0008 before implementing Profile CRUD. Continue other P01 work only if it does not change the disputed profile database or public IPC boundary.
Provide the verified test report and PR draft. The user can then review the Forgejo diff and decide whether to merge; `main` remains unchanged by this workflow.

查看文件

@ -1,61 +0,0 @@
# P01 Foundation Progress Report
Date: 2026-07-18
## Status
P01 foundation work is partially complete on `feat/p01-foundation`. The unambiguous Batch 1 foundation items are implemented and verified. Profile CRUD is intentionally paused under PD-0008 because the architecture and implementation task documents assign it to different stages.
## Completed
- Verified P00 PR #1 merged into `main` at `b3420e4`.
- Fast-forwarded local `main` and created `feat/p01-foundation`.
- Added a persistent SQLite database under the Tauri application-data directory.
- Added WAL mode, a bounded busy timeout, foreign-key enforcement, and transactional `user_version` migration.
- Added idempotent reopen/persistence tests and rejection of databases newer than the supported schema.
- Added the database schema version to the bootstrap IPC response.
- Added strict frontend Zod validation for the IPC payload and a malformed-payload test.
- Added a tracing writer that redacts output before writing.
- Retained the existing tray menu, close-to-tray, explicit quit, and single-instance focus behavior.
## Verification
| Check | Result |
| ------------------------------------------------------- | ------------------------------------------------------------------ |
| Frontend format, ESLint, TypeScript, Vitest, Vite build | Passed; 2 Vitest tests |
| Playwright Chromium | Passed; 1 test |
| Rust fmt, Clippy with warnings denied, check | Passed |
| Rust tests | Passed; 44 normal tests, 2 explicit manual tests ignored |
| Persistent SQLite reopen and migration tests | Passed |
| Logging redaction writer test | Passed |
| Tauri development startup | Passed |
| Windows application-data SQLite creation | Passed; database created at startup |
| Tauri release executable | Passed |
| NSIS installer | Passed; 3,793,884 bytes |
| NSIS SHA-256 | `B8858CBE2F4673FAF40799C1243BCAB0748D194FA3AD67FBD33DDCF26CF27189` |
## Build environment note
The first release attempts failed because the `libsqlite3-sys` release output directory did not contain `bindgen.rs`, although the crate build script had produced the SQLite static library. Cleaning only that package did not restore the file.
The official pre-generated `bindgen_bundled_version.rs` from the installed `libsqlite3-sys 0.38.1` crate source was copied to the exact `OUT_DIR/bindgen.rs` location expected by the crate's own `build.rs`. Source and destination SHA-256 values matched:
`5B5A37A74DC728FB0BCD041867EB577C03C95E2FE46285262C589A3B1CD4BBAC`
The production build and NSIS bundle then completed. This is recorded as an environment cache repair, not a repository or dependency change.
## Paused boundary
Profile CRUD is not implemented in this increment.
- Architecture stage 1 includes Profile CRUD.
- Implementation Batch 2 includes ConnectionProfile CRUD.
- The conflict affects database structure and public IPC.
- PD-0008 requires an explicit stage-boundary decision before work resumes.
## Not claimed
- P01 is not declared complete while PD-0008 is unresolved.
- Forgejo CI has not run.
- No Profile CRUD, profile UI, or slot assignment was added.
- No real credential or destructive file operation was used.

查看文件

@ -1,55 +1,33 @@
use std::{path::Path, sync::Mutex, time::Duration};
use rusqlite::{Connection, OptionalExtension, params};
use thiserror::Error;
pub const CURRENT_SCHEMA_VERSION: u32 = 1;
pub struct ApplicationDatabase {
store: Mutex<ProfileMessageStore>,
}
impl ApplicationDatabase {
pub fn open(path: impl AsRef<Path>) -> Result<Self, DatabaseError> {
Ok(Self {
store: Mutex::new(ProfileMessageStore::open(path)?),
})
}
pub fn schema_version(&self) -> Result<u32, DatabaseError> {
self.store
.lock()
.map_err(|_| DatabaseError::LockPoisoned)?
.schema_version()
}
}
pub struct ProfileMessageStore {
connection: Connection,
}
impl ProfileMessageStore {
pub fn open(path: impl AsRef<Path>) -> Result<Self, DatabaseError> {
Self::from_connection(Connection::open(path)?, true)
}
pub fn in_memory() -> Result<Self, DatabaseError> {
Self::from_connection(Connection::open_in_memory()?, false)
let connection = Connection::open_in_memory()?;
let store = Self { connection };
store.migrate()?;
Ok(store)
}
fn from_connection(
mut connection: Connection,
persistent: bool,
) -> Result<Self, DatabaseError> {
configure_connection(&connection, persistent)?;
migrate(&mut connection)?;
Ok(Self { connection })
}
pub fn schema_version(&self) -> Result<u32, DatabaseError> {
Ok(self
.connection
.pragma_query_value(None, "user_version", |row| row.get(0))?)
fn migrate(&self) -> Result<(), DatabaseError> {
self.connection.execute_batch(
"
PRAGMA foreign_keys = ON;
CREATE TABLE IF NOT EXISTS messages (
profile_id TEXT NOT NULL,
server_instance_id TEXT NOT NULL,
conversation_id TEXT NOT NULL,
message_id TEXT NOT NULL,
content TEXT NOT NULL,
PRIMARY KEY (profile_id, server_instance_id, conversation_id, message_id)
);
",
)?;
Ok(())
}
pub fn insert_message(
@ -106,128 +84,16 @@ impl ProfileMessageStore {
}
}
fn configure_connection(connection: &Connection, persistent: bool) -> Result<(), DatabaseError> {
connection.pragma_update(None, "foreign_keys", "ON")?;
connection.busy_timeout(Duration::from_secs(5))?;
if persistent {
connection.pragma_update(None, "journal_mode", "WAL")?;
}
Ok(())
}
fn migrate(connection: &mut Connection) -> Result<(), DatabaseError> {
let found: u32 = connection.pragma_query_value(None, "user_version", |row| row.get(0))?;
if found > CURRENT_SCHEMA_VERSION {
return Err(DatabaseError::UnsupportedSchemaVersion {
found,
supported: CURRENT_SCHEMA_VERSION,
});
}
if found == 0 {
let transaction = connection.transaction()?;
transaction.execute_batch(
"
CREATE TABLE messages (
profile_id TEXT NOT NULL,
server_instance_id TEXT NOT NULL,
conversation_id TEXT NOT NULL,
message_id TEXT NOT NULL,
content TEXT NOT NULL,
PRIMARY KEY (profile_id, server_instance_id, conversation_id, message_id)
);
PRAGMA user_version = 1;
",
)?;
transaction.commit()?;
}
Ok(())
}
#[derive(Debug, Error)]
pub enum DatabaseError {
#[error("SQLite operation failed")]
Sqlite(#[from] rusqlite::Error),
#[error("database schema version {found} is newer than supported version {supported}")]
UnsupportedSchemaVersion { found: u32, supported: u32 },
#[error("database state lock is unavailable")]
LockPoisoned,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn creates_and_reopens_a_persistent_migrated_database() {
let directory = tempfile::tempdir().expect("temporary directory");
let path = directory.path().join("desktop.sqlite3");
{
let store = ProfileMessageStore::open(&path).expect("open database");
assert_eq!(
store.schema_version().expect("schema version"),
CURRENT_SCHEMA_VERSION
);
store
.insert_message(
"profile-a",
"server-a",
"conversation-a",
"message-a",
"persisted",
)
.expect("insert message");
}
let reopened = ProfileMessageStore::open(&path).expect("reopen database");
assert_eq!(
reopened.schema_version().expect("schema version"),
CURRENT_SCHEMA_VERSION
);
assert_eq!(
reopened
.message_content("profile-a", "server-a", "conversation-a", "message-a")
.expect("query message")
.as_deref(),
Some("persisted")
);
}
#[test]
fn refuses_a_database_from_a_newer_schema_version() {
let directory = tempfile::tempdir().expect("temporary directory");
let path = directory.path().join("future.sqlite3");
let connection = Connection::open(&path).expect("create database");
connection
.pragma_update(None, "user_version", CURRENT_SCHEMA_VERSION + 1)
.expect("set future version");
drop(connection);
assert!(matches!(
ProfileMessageStore::open(path),
Err(DatabaseError::UnsupportedSchemaVersion {
found: 2,
supported: CURRENT_SCHEMA_VERSION
})
));
}
#[test]
fn repeated_migration_is_idempotent() {
let store = ProfileMessageStore::in_memory().expect("store");
assert_eq!(
store.schema_version().expect("schema version"),
CURRENT_SCHEMA_VERSION
);
assert_eq!(
store.schema_version().expect("schema version"),
CURRENT_SCHEMA_VERSION
);
}
#[test]
fn identical_remote_ids_remain_isolated_by_profile_and_server() {
let store = ProfileMessageStore::in_memory().expect("store");

查看文件

@ -1,14 +1,11 @@
pub mod database;
pub mod diagnostics;
pub mod file_transfer;
pub mod logging;
pub mod networking;
pub mod secure_store;
pub mod windows;
use database::ApplicationDatabase;
use serde::Serialize;
use tauri::{
Manager, WindowEvent,
menu::{Menu, MenuItem},
@ -19,31 +16,30 @@ use tauri::{
#[serde(rename_all = "camelCase")]
struct BootstrapStatus {
app_version: &'static str,
database_schema_version: u32,
platform: &'static str,
rust_core: &'static str,
protocol_version: &'static str,
}
#[tauri::command]
fn bootstrap_status(
database: tauri::State<'_, ApplicationDatabase>,
) -> Result<BootstrapStatus, String> {
let database_schema_version = database
.schema_version()
.map_err(|_| "database status is unavailable".to_owned())?;
Ok(BootstrapStatus {
fn bootstrap_status() -> BootstrapStatus {
BootstrapStatus {
app_version: env!("CARGO_PKG_VERSION"),
platform: "windows",
rust_core: "ready",
protocol_version: desktop_protocol::PROTOCOL_VERSION,
database_schema_version,
})
}
}
pub fn run() {
logging::init();
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
)
.with_target(false)
.compact()
.init();
tauri::Builder::default()
.plugin(tauri_plugin_single_instance::init(|app, _, _| {
@ -53,12 +49,6 @@ pub fn run() {
}
}))
.setup(|app| {
let app_data_dir = app.path().app_data_dir()?;
std::fs::create_dir_all(&app_data_dir)?;
app.manage(ApplicationDatabase::open(
app_data_dir.join("astrbot-desktop.sqlite3"),
)?);
let show = MenuItem::with_id(app, "show", "Show AstrBot Desktop", true, None::<&str>)?;
let quit = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&show, &quit])?;

查看文件

@ -1,170 +0,0 @@
use std::io::{self, Write};
use tracing_subscriber::fmt::MakeWriter;
use crate::diagnostics::redaction::Redactor;
#[derive(Clone)]
pub struct RedactingMakeWriter<M> {
inner: M,
redactor: Redactor,
}
impl<M> RedactingMakeWriter<M> {
pub fn new(inner: M) -> Self {
Self {
inner,
redactor: Redactor::default(),
}
}
#[cfg(test)]
fn with_redactor(inner: M, redactor: Redactor) -> Self {
Self { inner, redactor }
}
}
impl<'writer, M> MakeWriter<'writer> for RedactingMakeWriter<M>
where
M: MakeWriter<'writer>,
M::Writer: Write,
{
type Writer = RedactingWriter<M::Writer>;
fn make_writer(&'writer self) -> Self::Writer {
RedactingWriter {
inner: self.inner.make_writer(),
redactor: self.redactor.clone(),
buffer: Vec::new(),
}
}
}
pub struct RedactingWriter<W: Write> {
inner: W,
redactor: Redactor,
buffer: Vec<u8>,
}
impl<W: Write> RedactingWriter<W> {
fn flush_redacted(&mut self) -> io::Result<()> {
if self.buffer.is_empty() {
return Ok(());
}
let rendered = String::from_utf8_lossy(&self.buffer);
let redacted = self.redactor.redact(&rendered);
self.inner.write_all(redacted.as_bytes())?;
self.buffer.clear();
Ok(())
}
}
impl<W: Write> Write for RedactingWriter<W> {
fn write(&mut self, buffer: &[u8]) -> io::Result<usize> {
self.buffer.extend_from_slice(buffer);
Ok(buffer.len())
}
fn flush(&mut self) -> io::Result<()> {
self.flush_redacted()?;
self.inner.flush()
}
}
impl<W: Write> Drop for RedactingWriter<W> {
fn drop(&mut self) {
let _ = self.flush_redacted();
let _ = self.inner.flush();
}
}
pub fn init() {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
)
.with_target(false)
.compact()
.with_writer(RedactingMakeWriter::new(std::io::stderr))
.init();
}
#[cfg(test)]
mod tests {
use std::sync::{Arc, Mutex};
use super::*;
#[derive(Clone, Default)]
struct SharedMakeWriter {
output: Arc<Mutex<Vec<u8>>>,
}
impl SharedMakeWriter {
fn contents(&self) -> String {
String::from_utf8(self.output.lock().expect("output lock").clone())
.expect("UTF-8 output")
}
}
struct SharedWriter {
output: Arc<Mutex<Vec<u8>>>,
}
impl Write for SharedWriter {
fn write(&mut self, buffer: &[u8]) -> io::Result<usize> {
self.output
.lock()
.expect("output lock")
.extend_from_slice(buffer);
Ok(buffer.len())
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
impl<'writer> MakeWriter<'writer> for SharedMakeWriter {
type Writer = SharedWriter;
fn make_writer(&'writer self) -> Self::Writer {
SharedWriter {
output: self.output.clone(),
}
}
}
#[test]
fn redacts_structured_fields_and_message_content_before_writing() {
let sink = SharedMakeWriter::default();
let known_secret = format!("canary-{}", uuid::Uuid::new_v4());
let subscriber = tracing_subscriber::fmt()
.without_time()
.with_ansi(false)
.with_target(false)
.with_writer(RedactingMakeWriter::with_redactor(
sink.clone(),
Redactor::new([&known_secret]),
))
.finish();
tracing::subscriber::with_default(subscriber, || {
tracing::info!(
password = "test-password",
authorization = "Bearer abcdefghijklmnop",
endpoint = "https://alice:password@example.test/path",
"known={known_secret}"
);
});
let output = sink.contents();
assert!(!output.contains("test-password"));
assert!(!output.contains("abcdefghijklmnop"));
assert!(!output.contains("alice:password"));
assert!(!output.contains(&known_secret));
assert!(output.contains(crate::diagnostics::redaction::REDACTED));
}
}

查看文件

@ -15,7 +15,6 @@ describe("App", () => {
platform: "windows",
rustCore: "ready",
protocolVersion: "desktop-v1alpha1",
databaseSchemaVersion: 1,
});
});
@ -25,19 +24,4 @@ describe("App", () => {
expect(await screen.findByText("ready")).toBeInTheDocument();
expect(screen.getByText("desktop-v1alpha1")).toBeInTheDocument();
});
it("rejects an invalid Rust IPC payload", async () => {
vi.mocked(invoke).mockResolvedValueOnce({
appVersion: "0.1.0-alpha.0",
platform: "windows",
rustCore: "unexpected",
protocolVersion: "desktop-v1alpha1",
databaseSchemaVersion: 1,
});
render(<App />);
expect(await screen.findByText(/IPC unavailable:/)).toBeInTheDocument();
expect(screen.queryByText("unexpected")).not.toBeInTheDocument();
});
});

查看文件

@ -1,14 +1,13 @@
import { invoke } from "@tauri-apps/api/core";
import { useCallback, useEffect, useState } from "react";
import { bootstrapStatusSchema, type BootstrapStatus } from "./types/bootstrap";
import type { BootstrapStatus } from "./types/bootstrap";
const initialStatus: BootstrapStatus = {
appVersion: "unknown",
platform: "unknown",
rustCore: "pending",
protocolVersion: "desktop-v1alpha1",
databaseSchemaVersion: 1,
};
export function App() {
@ -17,8 +16,8 @@ export function App() {
const refreshStatus = useCallback(async () => {
try {
const result = await invoke<unknown>("bootstrap_status");
setStatus(bootstrapStatusSchema.parse(result));
const result = await invoke<BootstrapStatus>("bootstrap_status");
setStatus(result);
setError(null);
} catch (reason) {
setError(reason instanceof Error ? reason.message : String(reason));
@ -45,10 +44,6 @@ export function App() {
<StatusCard label="App Version" value={status.appVersion} />
<StatusCard label="Protocol" value={status.protocolVersion} />
</section>
<StatusCard
label="Database Schema"
value={String(status.databaseSchemaVersion)}
/>
{error ? <p className="error-banner">IPC unavailable: {error}</p> : null}

查看文件

@ -1,13 +1,6 @@
import { z } from "zod";
export const bootstrapStatusSchema = z
.object({
appVersion: z.string().min(1),
platform: z.string().min(1),
rustCore: z.enum(["ready", "pending"]),
protocolVersion: z.string().min(1),
databaseSchemaVersion: z.number().int().positive(),
})
.strict();
export type BootstrapStatus = z.infer<typeof bootstrapStatusSchema>;
export interface BootstrapStatus {
appVersion: string;
platform: string;
rustCore: "ready" | "pending";
protocolVersion: string;
}