Refine WebUI routing, appearance and account automation - #19
Conversation
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.
Reviewer's GuideThis 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 automationsequenceDiagram
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
Sequence diagram for independent credential maintenance actionssequenceDiagram
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
Entity relationship diagram for independent model mappings and account automationerDiagram
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
Flow diagram for hourly dashboard granularity and truthful trendsflowchart 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]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
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
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.
Changes
uvsource startup and document prebuilt GHCR images. Synchronize English/Chinese guides and rollback requirements without changing the release version.Verification
0b60768: settings and account inventory preserved, asset hashes matched, authentication checked, LAN access verified, and real inference returned HTTP 200 with text.Operational notes
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:
Bug Fixes:
Enhancements:
Build:
Deployment:
Documentation:
Tests:
Chores: