Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,11 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Test frontend flows
run: npm test

- name: Build frontend
run: npm run build

- name: Build Storybook
run: npm run build-storybook
179 changes: 170 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,71 @@ The interface reference is the Hub in the neighboring `thinker` repository:
`crates/ff-hub/hub-ui/src/modules/App.tsx` (agent order and divider) and
`packages/coreinfra-ui/src/hub-sidebar-footer.tsx` (account menu and theme controls).

### UI design system

Wizard uses neutral Catalyst surfaces, shared typography and spacing, and
restrained state colors. Startup, overview drawing, and download progress
animations remain part of the interface. Navigation and dialog transitions must
not reset ongoing operations.

`src/design-system/tokens.css` owns surface, text, border, spacing, radius, and
motion values. `src/components/ui` owns page headings, panels, action bars,
identities, notices and transfer cards; accessible controls and focus trapping
continue to use Catalyst / Headless UI. Connection forms use unframed panels
inside dialogs. Version rows share column alignment; on narrow screens their
actions move below the version and stay together.

Body/control text is 14/24 px, metadata 12/20 px, section titles 16/24 px and page
titles 22/32 px. Text inputs retain 16 px below 640 px to avoid mobile auto-zoom.
Do not use page-wide `!important` typography overrides or make a portal inherit
typography from the page behind it. Preserve heading order, keyboard focus,
contrast in both themes and reduced-motion support. Download progress uses a
labeled progressbar instead of announcing every percentage tick.

Run the application checks from the repository root:

```sh
npm test --prefix crates/wizard-gui/wizard-ui
npm run build --prefix crates/wizard-gui/wizard-ui
```

The flow tests cover background downloads, cancellation, explicit installation,
version changes, first launch, connection plans and Hub balance states. Browser
mocks do not exercise native archive installation or OS proxy changes.

### Storybook

```sh
npm run storybook --prefix crates/wizard-gui/wizard-ui
npm run build-storybook --prefix crates/wizard-gui/wizard-ui
```

Open <http://127.0.0.1:6006/>. The catalog contains design tokens, Catalyst controls,
reusable product blocks, actual application screens and interaction flows. It
includes Controls, component docs, accessibility checks, isolated light/dark
themes, reduced motion, and 360/640/800/1100/1440 px viewports. The static catalog
builds to `wizard-ui/storybook-static`; CI runs the frontend tests and builds both
the application and catalog. The Catalyst license remains attached to its sources.

`src/test/stories.test.tsx` runs the stories' actual play functions. The virtualized
Combobox story is browser-only because JSDOM has no layout; verify it in the
catalog. Check geometry, contrast, overflow and focus at the catalog's viewports.

Useful stories:

- `overview-transition--installation-into-control-panel` shows the installation
card folding into the management button, with replay/reset controls.
- `сценарии-переходы--agent-update` exercises download, installation and version change.
- `сценарии-переходы--setup-configuration` opens connection settings from management.
- `сценарии-переходы--subscription-key` selects and saves a demo key across API and subscription modes.
- `сценарии-переходы--narrow-activity` opens a download from the narrow sidebar menu.

The scoped override of `@joshwooding/vite-plugin-react-docgen-typescript` to 0.9.1
avoids the vulnerable glob/minimatch chain selected by Storybook 10.6.7's older
range. `.storybook/main.ts` skips virtual story-index HMR events for this plugin,
which otherwise reads null-prefixed module IDs as files. Remove the override and
guard when upstream supports the updated dependency and filters virtual updates.

### Overview and initial setup

**Обзор** is the default full-window page, above **Агенты** in the sidebar.
Expand All @@ -96,11 +161,13 @@ The three action cards use the live account and detection state:
- **Установите агентов** becomes available after sign-in.
- **Настройте агентов** requires sign-in and at least one detected agent.

On first launch, navigation is hidden. «Пропустить быструю настройку» beside
«Начало работы» reveals it and remembers the choice across launches. Overview
remains accessible from the sidebar. Configuration reuses the regular agent form
and plan confirmation; multiple installed agents always show a selection first.
The final action launches the configured desktop app or CLI.
First launch shows a brief Wizard logo animation, then automatically opens the
full interface with navigation, even before sign-in or setup. The animation is
remembered across launches and skipped for reduced motion or completed legacy
onboarding. Update checks run in the background without blocking navigation.
Configuration reuses the regular agent form and plan confirmation; multiple
installed agents always show a selection first. The final action launches the
configured desktop app or CLI.

Connection options are ordered API access, subscription, then without CoreInfra.
The default token is selected automatically: reuse the configured token if it belongs to the
Expand All @@ -116,10 +183,104 @@ changing an agent's API token does not change either listener's credential.
«Завершить настройку» opens the change plan before the launch step. Regular agent
pages use «Применить», enabled for pending mode/token changes or a stopped proxy.

Downloads run in the backend and preserve explicit pauses across dialog closes.
Installing requires a separate «Установить» confirmation; «Отмена» retains the
archive. Installed apps show their version and offer an update check. Completed
installs and checks close with «Готово».
Downloads run in the backend independently of the current page or dialog. The
action beside an agent's installed version is «Обновить» («Скачать» for a missing
desktop app). It only opens that agent's installation panel. Download, install
and cancel actions live in the expanded panel; the picker also only opens it.
The version row keeps the installed version until installation completes, then
animates the new number and removes the update action. Release checks run
automatically, without a manual check button or an up-to-date message.
Closing the dialog (outside click, Escape, or cross) keeps downloads running in
a stack of compact widgets in the left sidebar, directly above the Hub divider,
with a logo, percentage and downloaded/total MB. Clicking
a widget restores that operation. «Назад» appears only after choosing an app in
the picker and returns there without stopping downloads. Direct openings from
a version action or sidebar widget have no Back button. «Отменить» stops the selected
transfer and deletes its cached archive; downloading again starts from zero.
Network interruptions still retain resumable progress. Installation always needs
a separate confirmation, including notices about closing running applications.

Wizard itself also checks for updates automatically, including at launch. Its
sidebar update action opens a dialog without changing the installed application.
«Скачать обновление» downloads and verifies the signed archive; «Установить» then
replaces Wizard and restarts it. Downloads survive closing the dialog and remain
visible in the sidebar. «Отменить» aborts the download and discards its bytes.
The main interface stays mounted throughout; only the explicit installation step
prepares the proxy service for replacement.

### Browser preview with mocks

Run from the repository root:

```sh
npm run dev:mock --prefix crates/wizard-gui/wizard-ui
```

Open <http://127.0.0.1:1422/preview.html>. This uses the actual application
components with local Tauri IPC mocks. It does not install applications, download
archives, or contact Hub. The separate preview entry is excluded from the desktop
production bundle. Reloading the preview resets all simulated operations.

The «UI-превью · Моки» panel switches scenarios: first launch, background checks,
failed checks, available update, missing agents,
current version, downloaded archive, failed download with retry, reconnection,
unknown size, required confirmation/running apps, signed-out account, and an
unsupported platform. It also changes download speed, finishes downloads, resets
the scene, and switches themes. A normal simulated download takes 36 seconds.
For example, `preview.html?scenario=missing` opens the first-install scenario.
`preview.html?scenario=downloads` starts two slower downloads to inspect the sidebar
stack above the Hub divider in light and dark themes.
`mixed_ready`, `mixed_progress` and `mixed_error` combine different states in
neighboring cards to check alignment and independent actions.
`all_agents` shows the daily overview with two illustrated cards: Hub balance and
agent management. Its only action, «Панель управления», opens the list of agents.
Each update opens its installation panel. Clicking an agent's connection status
opens its settings inside management; «Назад» discards the draft and returns to
the list. There are no generic install/setup buttons in management.
The agent summary shows two names with logos and an overflow count. Drawings on
enabled overview cards animate and turn blue on hover or keyboard focus, both
during onboarding and after setup. The marker introduction is limited to
onboarding; reduced motion keeps the color feedback without movement. The video
banner is shared. Installation and update panels separate their actions with
whitespace, without a horizontal rule.
`unconfigured` shows the first connection flow. `onboarding_merge` demonstrates
the installation card folding into the «Панель управления» button after
setup finishes. The mock toolbar's «Показать переход» also plays it directly.
Reduced-motion preferences skip the fold. `wizard_update` exercises the separate
Wizard download/install dialog with simulated progress and no actual replacement.
`balance_empty`, `balance_guest`, and `balance_error` cover the top-up prompt,
guest access and unavailable balance. Guests see the Hub identity and its action,
without a balance block or a replacement access label. In the mock preview, «Пополнить» simulates
returning from Hub with 1,500 ₽; no real payment occurs. The native application
reads `/hub/api/hub/info` and opens `/payments` for the selected Hub. Balance
refreshes on window focus and every 30 seconds; missing data never means zero.
Agent pages always show the connection form, aligned with the page content and
without an outer frame, collapsed summary or cancel action. «Применить» stays on
the right and is enabled only for pending changes; after saving, the form stays
open with the saved values and the action becomes disabled. Missing CLI agents
offer a copyable installation command. Connection modes share one framed radio
group. Connected agents show «CoreInfra AI Hub» as their status.
The mock preview offers two demo keys in both «API-доступ» and «Своя подписка»;
the selected key persists when switching modes and is saved with the mock plan.
This subscription key selection is preview-only: native Claude Desktop still
uses the shared Wizard proxy key. No proxy authorization changes are simulated
outside the mock environment.
Settings have their own navigation item. Downloads appear only at the bottom of
the left sidebar, above Hub; below 1024 px, open the navigation menu to access
the same widgets. There is no download indicator in the top bar.
Each app keeps its own progress indicator, so completing one transfer does not
change the other's percentage. `chatgpt_error` shows a nested detection failure
with details inside management; `unconfigured` also covers a stopped, unused proxy.
`preview.html?scenario=startup` replays the first-launch animation on each reload,
then opens Overview with all navigation and a signed-out account. Other scenarios
retain the startup preference. `preview.html?scenario=checking` keeps the interface
usable while releases are checked automatically and appear after three seconds.

To verify the interaction: open the installation picker from onboarding, choose
an app, then download from its expanded panel. Choose «Назад», select the other
app, start its download, then close the dialog. Both widgets should keep progressing.
Reopen one and cancel: only that download resets. Finish the other from the mock
panel and verify that installation starts only after clicking its confirmation.

Choosing a subscription offers to enable the system proxy if it is off.
Only «Включить» changes OS settings; cancel keeps the selected mode. The prompt
Expand Down
33 changes: 33 additions & 0 deletions crates/wizard-core/src/agents/desktop_install/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ pub fn saved_download(app: DesktopApp, release: Option<&Release>) -> Result<Opti
}))
}

/// Explicit cancellation removes both the archive and its resume metadata. Call only after
/// dropping the download future, so no writer can recreate them while they are being removed.
pub fn discard_download(app: DesktopApp) -> Result<()> {
remove_download(&Slot::new(app)?.directory)
}

fn remove_download(directory: &Path) -> Result<()> {
match fs::remove_dir_all(directory) {
Ok(()) => Ok(()),
Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(()),
Err(error) => Err(error).context("Не удалось удалить скачанную часть. Повторите отмену"),
}
}

/// Downloads and verifies the release archive, continuing a saved download of it. What was
/// received stays saved when the download fails or is dropped; failed verification discards it.
pub async fn download_release(
Expand Down Expand Up @@ -864,4 +878,23 @@ mod tests {
assert!(saved(&directory, None).is_none());
assert!(!directory.exists());
}

#[test]
fn cancelled_download_restarts_without_a_range_request() {
let archive = archive();
let server = serve(archive.clone(), vec![Plan::CutAfter(1_000_000)]);
let release = release(&server.url, &archive);
let root = tempfile::tempdir().unwrap();
let directory = root.path().join("claude");
assert!(run(&directory, &release, &[]).0.is_err());
assert!(saved(&directory, Some(&release)).is_some());

remove_download(&directory).unwrap();
assert!(!directory.exists());
remove_download(&directory).unwrap(); // A second cancellation is harmless.
let (_, progress) = run(&directory, &release, &[]);
assert_eq!(progress.first().unwrap().received, 0);
assert!(server.requests().last().unwrap().range.is_none());
assert_eq!(fs::read(directory.join(DOWNLOAD_NAME)).unwrap(), archive);
}
}
4 changes: 3 additions & 1 deletion crates/wizard-core/src/agents/desktop_install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ mod download;
mod requests;
mod running;

pub use download::{DownloadProgress, SavedDownload, download_release, saved_download};
pub use download::{
DownloadProgress, SavedDownload, discard_download, download_release, saved_download,
};
pub(crate) use running::with_closed;
pub use running::{open_existing, open_first_install, running_apps};

Expand Down
44 changes: 44 additions & 0 deletions crates/wizard-core/src/hub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,34 @@ impl HubProfile {
}
}

/// The selected hub's displayable balance and membership, without its agent tokens.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct HubSummary {
pub hub_id: String,
pub role_in_hub: String,
pub balance_rub: Option<f64>,
}

pub async fn fetch_hub_summary(
client: &Client,
session: &str,
hub_id: &str,
) -> (SessionUpdate, Result<HubSummary, HubError>) {
#[derive(Serialize)]
struct Request<'a> {
hub_id: &'a str,
}
let (update, summary) =
post::<HubSummary>(client, session, HUB_INFO_PATH, &Request { hub_id }).await;
let summary = summary.and_then(|summary| {
if summary.hub_id != hub_id || summary.role_in_hub.is_empty() {
return Err(HubError::Response);
}
Ok(summary)
});
(update, summary)
}

/// Agent token of a Hub hub. `token` is a secret: no `Debug`, never logged.
#[derive(Clone, Serialize, Deserialize)]
pub struct AgentToken {
Expand Down Expand Up @@ -338,6 +366,22 @@ fn session_from_headers(headers: &HeaderMap) -> Result<Option<String>, ()> {
mod tests {
use super::*;

#[test]
fn summary_preserves_hidden_and_zero_balances_without_exposing_tokens() {
let hidden: HubSummary = serde_json::from_value(serde_json::json!({
"hub_id": "team", "role_in_hub": "member", "agent_tokens": [{"token": "secret"}]
}))
.expect("valid hub response");
assert_eq!(hidden.balance_rub, None);
let zero: HubSummary = serde_json::from_value(serde_json::json!({
"hub_id": "personal", "role_in_hub": "owner", "balance_rub": 0
}))
.expect("valid zero balance");
assert_eq!(zero.balance_rub, Some(0.0));
let exposed = serde_json::to_value(hidden).expect("serializable summary");
assert!(exposed.get("agent_tokens").is_none());
}

fn profile() -> HubProfile {
HubProfile {
personal_hub_id: "personal".into(),
Expand Down
3 changes: 3 additions & 0 deletions crates/wizard-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ wizard-proxy-daemon.workspace = true
wizard-settings.workspace = true
wizard-system-proxy.workspace = true

[dev-dependencies]
tauri = { workspace = true, features = ["test"] }

[target.'cfg(any(target_os = "macos", target_os = "windows"))'.dependencies]
tauri = { workspace = true, features = ["tray-icon"] }
tauri-plugin-autostart.workspace = true
21 changes: 20 additions & 1 deletion crates/wizard-gui/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
fn main() {
tauri_build::build();
let mut attributes = tauri_build::Attributes::new();
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows")
&& std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc")
{
// Tauri's resource manifest is linked to binaries only. Library test executables
// also need Common Controls v6 once IPC tests retain Tauri's native menu code,
// otherwise the Windows loader exits with STATUS_ENTRYPOINT_NOT_FOUND.
let manifest = std::path::PathBuf::from(
std::env::var_os("CARGO_MANIFEST_DIR").expect("Cargo package directory"),
)
.join("windows/app.manifest");
println!("cargo:rerun-if-changed={}", manifest.display());
println!("cargo:rustc-link-arg=/MANIFEST:EMBED");
println!("cargo:rustc-link-arg=/MANIFESTINPUT:{}", manifest.display());
// Embed the same manifest through the linker for every executable, without
// a second manifest in the application's icon/version resources.
attributes = attributes
.windows_attributes(tauri_build::WindowsAttributes::new_without_app_manifest());
}
tauri_build::try_build(attributes).expect("failed to build Tauri resources");
}
Loading
Loading