Skip to content

Refine WebUI routing, appearance and account automation - #19

Merged
maiphucgiang merged 5 commits into
mainfrom
feat/webui-routing-glass
Sep 15, 2026
Merged

maiphucgiang merged 5 commits into
mainfrom
feat/webui-routing-glass

Conversation

@maiphucgiang

@maiphucgiang maiphucgiang commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Changes

  • Add independent public/upstream model IDs, strict account-versus-region routing, and hourly dashboard granularity with interactive trend values.
  • Improve glass surfaces, collapsible navigation, OAuth completion, structured details, modal accessibility and enter/exit motion; add light palettes and dark/system appearance modes.
  • Separate Token refresh, check-in and balance synchronization by account. Persist independent automation switches: domestic check-in and Buddy travel default on; international check-in defaults off and remains opt-in.
  • Gate rewards on official state: claim arrivals, recheck before dispatch, respect daily limits and credential generations, and never blindly replay writes. Keep partial/uncertain outcomes visible.
  • Add locked uv source startup and document prebuilt GHCR images. Synchronize English/Chinese guides and rollback requirements without changing the release version.

Verification

  • Backend: full-suite baseline with 757 passing tests and 2500 subtests, plus 2 passing targeted deployment/README checks after aligning the prebuilt-image assertions; no repeated full run. CI will verify the current head end-to-end.
  • Frontend: 102 tests, type/lint/format checks and production build; isolated browser flow plus live authenticated UI verification.
  • Local frozen deployment of 0b60768: settings and account inventory preserved, asset hashes matched, authentication checked, LAN access verified, and real inference returned HTTP 200 with text.

Operational notes

  • One domestic travel dispatch was not confirmed; a subsequent read-only query still showed idle. No write was replayed, and this is not counted as a successful live dispatch. International check-in records remained unchanged.
  • Automation changes apply without restart but do not claim immediately or retract sent requests. Rolling back to an older reader requires the matching control-database backup; it cannot undo upstream rewards or dispatches.
  • No release/tag publication. Local deployment remains at 0b60768; the following commit only updates a deployment test assertion.

Summary by Sourcery

Refine WebUI routing, account automation, statistics, appearance, and deployment safety while preserving truthful handling of uncertain upstream operations.

New Features:

  • Add independent public and upstream model mappings with strict account-versus-region routing and CRUD/preview management APIs.
  • Add per-account check-in and Buddy travel automation with separate controls and scoped maintenance actions.
  • Add hourly dashboard statistics with interactive trend inspection and explicit partial-history reporting.
  • Add configurable light, dark, system appearance modes, palettes, collapsible navigation, and improved accessible modal/OAuth workflows.

Bug Fixes:

  • Prevent unconfirmed check-ins, rewards, and travel dispatches from being treated as successful or blindly replayed.
  • Isolate refresh, synchronization, catalog, usage, and automation results by account while preserving partial and uncertain outcomes.
  • Fail closed when credentials, routing policies, upstream responses, or automation state change during an operation.

Enhancements:

  • Separate token refresh, check-in, balance synchronization, catalog updates, usage synchronization, and trial claims into independent operations.
  • Improve structured detail rendering, responsive WebUI surfaces, modal focus and scroll handling, OAuth validation, and trend interactions.

Build:

  • Adopt pyproject.toml and uv.lock as the dependency sources, enforce locked no-build startup, and generate compatibility requirement files.
  • Update deployment guidance to use prebuilt GHCR images by default and document reproducible source deployments.

Deployment:

  • Document backup and rollback requirements for the control database and clarify that upstream side effects cannot be undone.

Documentation:

  • Synchronize English and Chinese README, WebUI, advanced, and deployment guides with the new routing, automation, appearance, statistics, and deployment behavior.

Tests:

  • Expand backend, frontend, browser, routing, automation, travel, statistics, build-lock, and deployment coverage for the new behavior.

Chores:

  • Keep the release version unchanged while aligning dependency metadata and generated lock files.

Separate public and upstream model IDs, enforce account-or-region routing, and preserve policy ownership through protocol conversion. Reuse persistent hourly aggregates for selectable overview granularity without inventing missing history.

Add icon-only navigation, structured diagnostics, translucent glass surfaces and scroll-safe dismissible drawers. Complete OAuth enrollment by closing the management drawer and refreshing credentials while retaining isolation of the official tab. Synchronize bilingual usage and rollback guidance.
@sourcery-ai

sourcery-ai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR refines routing and model identity semantics, adds guarded per-account automation with truthful uncertain outcomes, expands hourly dashboard and interactive WebUI behavior, modernizes appearance and modal UX, and standardizes locked uv/prebuilt-image deployment documentation without changing the release version.

Sequence diagram for guarded per-account check-in and Buddy travel automation

sequenceDiagram
    participant Scheduler
    participant CredentialActions
    participant Checkin
    participant CreditsAPI
    participant Travel
    participant BuddyAPI
    participant Ledger

    Scheduler->>CredentialActions: _sync_credits(checkin=true, claim_trial=true)
    CredentialActions->>Checkin: perform(access_token, uid, domain, can_claim)
    Checkin->>CreditsAPI: fetch_checkin_status(access_token, uid, domain)
    CreditsAPI-->>Checkin: activity state
    alt activity available and credential current
        Checkin->>CreditsAPI: daily_checkin(access_token, uid, domain)
        CreditsAPI-->>Checkin: normalized result
        Checkin->>Ledger: mark_checkin(cid, day, ok, code, message, state)
    else unavailable, uncertain, or changed
        Checkin-->>CredentialActions: cancelled or non-success state
    end
    opt domestic auto_travel enabled
        CredentialActions->>Travel: perform(token, profile, can_write)
        Travel->>BuddyAPI: status
        BuddyAPI-->>Travel: idle, traveling, or arrived
        opt arrived
            Travel->>BuddyAPI: claim
            BuddyAPI-->>Travel: claim receipt
            Travel->>BuddyAPI: status
        end
        opt confirmed idle and daily limit not reached
            Travel->>BuddyAPI: depart
            BuddyAPI-->>Travel: dispatch receipt
        end
        Travel->>Ledger: remember(ledger, cid, result)
    end
Loading

Sequence diagram for independent credential maintenance actions

sequenceDiagram
    actor Admin
    participant WebUI
    participant ManagementAPI
    participant CredentialActions
    participant CredentialPool
    participant AccountServices
    participant Ledger

    Admin->>WebUI: Select account action
    WebUI->>ManagementAPI: POST /admin/credentials/{identity}/{action}
    ManagementAPI->>CredentialActions: run(gateway, action, identity)
    CredentialActions->>CredentialPool: _rescan()
    CredentialActions->>CredentialPool: apply_if_current(cm, generation, callback)
    alt refresh
        CredentialActions->>AccountServices: _refresh_locked()
    else checkin
        CredentialActions->>AccountServices: checkin.perform(...)
    else sync
        CredentialActions->>AccountServices: _sync_credits(..., checkin=false, claim_trial=false)
        CredentialActions->>AccountServices: _sync_usage(...)
    else travel-status
        CredentialActions->>AccountServices: travel.perform(..., read_only=true)
    else travel
        CredentialActions->>AccountServices: travel.perform(..., read_only=false)
    end
    CredentialActions->>Ledger: audit.event(...)
    CredentialActions-->>WebUI: per-account result with partial or uncertain state
    WebUI-->>Admin: Show confirmed, skipped, partial, or failed outcome
Loading

Entity relationship diagram for independent model mappings and account automation

erDiagram
    MODEL_RULE {
        string id PK
        string public_id
        string upstream_id
        boolean custom
        string region
        string profile
    }
    CREDENTIAL {
        string account_key PK
        boolean enabled
        boolean auto_checkin
        boolean auto_travel
    }
    CHECKIN_RECORD {
        string credential_id FK
        string state
        string date
        boolean ok
    }
    TRAVEL_RECORD {
        string credential_id FK
        string state
        boolean claimed
        boolean departed
        boolean stale
    }
    MODEL_RULE }o--o{ CREDENTIAL : routes_with
    CREDENTIAL ||--o{ CHECKIN_RECORD : records
    CREDENTIAL ||--o{ TRAVEL_RECORD : records
Loading

Flow diagram for hourly dashboard granularity and truthful trends

flowchart TD
    Dashboard[GET /admin/dashboard] --> Validate[Validate days and granularity]
    Validate --> Select{Requested grain}
    Select -->|hour| Hourly[Read stats_hourly]
    Select -->|day| Daily[Read daily global stats]
    Select -->|auto| Auto{days equals 1?}
    Auto -->|yes| Hourly
    Auto -->|no| Daily
    Hourly --> Partial[Compare hourly requests with summary]
    Daily --> Fill[Fill missing daily buckets when complete]
    Partial --> Response[Return series, granularity, partial]
    Fill --> Response
    Response --> Trend[Interactive hover, touch, keyboard values]
Loading

File-Level Changes

Change Details Files
Reworked model policy and routing to distinguish client-facing mappings from upstream model identifiers while enforcing strict account-or-region scope boundaries.
  • Added CRUD and preview APIs for custom model mappings with revision checks and deletion guards.
  • Updated routing, capability publication, bindings, and request policy validation to resolve public IDs to upstream IDs without out-of-scope fallback.
  • Preserved legacy combined scopes until an explicit edit converts them.
app/admin_api.py
app/control_store.py
app/model_policy.py
app/gateway_management.py
tests/test_admin_api.py
tests/test_control_store.py
tests/test_webui_integration.py
web/src/api.ts
web/src/pages/Models.tsx
web/src/models.test.tsx
web/e2e/backend.integration.ts
web/e2e/experience.spec.ts
Introduced account-scoped maintenance and guarded automation for check-in, Buddy travel, credential refresh, and balance synchronization.
  • Persisted independent per-account check-in and travel switches with domestic defaults and international check-in opt-in behavior.
  • Split manual and batch refresh, check-in, sync, travel-status, and travel actions behind concurrency, CSRF, identity, credential-generation, and stale-result checks.
  • Added preflight activity checks, daily-limit handling, claim rechecks, non-replayed uncertain writes, and visible partial outcomes.
app/checkin.py
app/credential_actions.py
app/credits.py
app/travel.py
app/control_store.py
app/model_policy.py
app/gateway_management.py
app/admin_api.py
app/converter.py
tests/test_credential_actions.py
tests/test_credential_automation.py
tests/test_credits.py
tests/test_travel.py
web/src/pages/Credentials.tsx
web/src/automation.test.tsx
web/e2e/automation.spec.ts
Expanded dashboard statistics and WebUI interaction capabilities for hourly trends and richer operational feedback.
  • Added validated hourly or daily granularity with UTC ranges, sparse buckets, and partial-history signaling.
  • Added interactive trend selection via pointer, touch, keyboard, tooltip, and accessible data tables.
  • Improved structured detail rendering, OAuth completion handling, and operation-result reporting.
app/admin_api.py
app/audit_store.py
app/runtime_management.py
tests/test_dashboard_granularity.py
web/src/Trend.tsx
web/src/pages/Dashboard.tsx
web/src/values.tsx
web/src/OAuth.tsx
web/src/dashboard.test.tsx
web/src/enhancements.test.tsx
web/src/oauth.test.tsx
Refined the WebUI shell, modal lifecycle, appearance system, and responsive visual design.
  • Added persistent collapsible navigation and light, dark, system, and light-palette preferences.
  • Added modal scroll locking, focus restoration, backdrop/Escape behavior, exit animations, reduced-motion handling, and pending-operation dismissal protection.
  • Applied glass surfaces with solid fallbacks for unsupported blur or reduced transparency and improved responsive layouts.
web/src/App.tsx
web/src/appearance.tsx
web/src/components.tsx
web/src/modal.ts
web/src/presence.tsx
web/src/theme.scss
web/src/ui.module.scss
web/src/interaction.test.tsx
web/src/enhancements.test.tsx
Moved source setup to locked uv project metadata and documented prebuilt-image deployment and rollback constraints.
  • Added pyproject and uv lock sources plus a requirements export script and locked startup commands.
  • Changed README deployment instructions to pull GHCR images without building locally.
  • Synchronized English and Chinese deployment, API, WebUI, and rollback guidance.
pyproject.toml
uv.lock
scripts/export_requirements.py
requirements.in
requirements.txt
README.md
README.zh-CN.md
docs/deployment.md
docs/deployment.zh-CN.md
docs/advanced.md
docs/advanced.zh-CN.md
docs/webui.md
docs/webui.zh-CN.md
tests/test_build_lock.py
tests/test_deployment.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-15T02:48:46.277718Z aa68803 PR opened
🔒 Security Review Completed 2026-09-15T02:52:18.371080Z aa68803 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="app/credits.py" line_range="114" />
<code_context>
-    inactive = bool(_INACTIVE_RE.search(text))
-    already = ncode == 10001 and not inactive and bool(_ALREADY_RE.search(text))
+    inactive = ncode == 1003 or bool(_INACTIVE_RE.search(text))
+    already = not inactive and (ncode == 1001 or (ncode == 10001 and bool(_ALREADY_RE.search(text))))
     ok = not inactive and ((ncode == 0 and http_ok) or already)
-    return {"ok": ok, "already": already, "inactive": inactive, "code": ncode, "message": text}
+    state = ("already" if already else "success" if ok else "inactive" if inactive else
+             "not_eligible" if ncode == 1002 else "error")
+    return {"ok": ok, "already": already, "inactive": inactive, "state": state, "code": ncode, "message": text}

</code_context>
<issue_to_address>
**issue (bug_risk):** `classify_checkin_result` treats business code `1001` as `already` even when `http_ok` is false, so a failed 401/403/500 response carrying code `1001` is normalized as a successful idempotent check-in. `daily_checkin` then returns `ok: true`, and callers persist the account as checked in without a confirmed claim.

**Triggers:** When the check-in endpoint returns a non-2xx response with business code `1001`.

**Suggested fix:** Require `http_ok` before accepting `1001` as `already`, or handle transport/HTTP failures before applying business-code classification.

```suggestion
    already = not inactive and http_ok and (ncode == 1001 or (ncode == 10001 and bool(_ALREADY_RE.search(text))))
```
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and this enables automatic check-in reward claims and Buddy travel dispatches for domestic accounts, creating external side effects and credit changes that can occur across all configured accounts. Reverting the code stops future runs but cannot undo claims or travel requests already sent upstream.

Blocking findings: app/credits.py:114


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread app/credits.py
@maiphucgiang
maiphucgiang merged commit 720b433 into main Sep 15, 2026
8 of 9 checks passed
@maiphucgiang
maiphucgiang deleted the feat/webui-routing-glass branch September 15, 2026 03:12
szbfwdy added a commit to szbfwdy/codebuddy2api that referenced this pull request Sep 15, 2026
The base moved to `720b433` (PR maiphucgiang#19: scoped model mappings, glass dashboard,
per-account check-in, and a pyproject + `uv.lock` dependency regime), which made
this branch unmergeable. Everything auto-merged except `requirements.in`, where
d045bf1's `anyio` line was already obsolete: f63285c dropped that dependency in
favour of a stdlib teardown, so the generated file keeps upstream's content and
`requirements.txt` is byte-identical to the base again.

836 passed, 2772 subtests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant