You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor: isolate frontend sessions and stabilize async lifecycle tests - #66
验收标准:维护者已明确同意使用当前 PR HEAD 的仓库现有 Ubuntu CI 完整后端结果继续本轮验收、全量复审和稳定观察;该标准不覆盖或关闭上述 Windows 失败。
Ubuntu CI(当前 HEAD 59acb855b89ccc01a7f51d1d669f3f9d7d0d2750)已通过:CI #39396489407。包括完整 go test ./...、vet、JSON policy,以及前端测试、typecheck 和生产构建;PR Check 也已通过。Windows 全套失败继续保持未解决状态。
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
Prevented stale responses from overwriting current dialog, profile, wallet, subscription, and usage-log data.
Improved session handling so outdated authentication errors no longer sign users out or display incorrect expiration messages.
Dialog drafts and selections now reset reliably when switching records, sessions, or reopening dialogs.
Improved OAuth, balance, verification, and loading behavior during cancellation, refreshes, and delayed responses.
Preserved user-entered values, including zero and empty inputs, across rerenders.
Accessibility
Added an accessible label to the system settings editor-mode control.
Tests
Expanded coverage for lifecycle handling, stale responses, authentication sessions, dialogs, wallet flows, and settings forms.
The pull request updates relay stream tests and web application state handling. It adds session-aware API behavior, reusable hooks for resettable state and scoped reads, and lifecycle protections across dialogs, profile data, and wallet data. It also adds runtime tests and smaller UI, accessibility, and test-runner updates.
Changes: Relay stream test coordination
Layer / File(s)
Summary
Deterministic stream and timeout tests relay/channel/openai/first_result_test.go, relay/helper/stream_scanner_test.go, relay/responses_first_result_settlement_test.go
Stream tests replace fixed sleeps with coordinated release, bounded request contexts, and cancellation checks. The scanner test verifies read-ahead, ordered delivery of 50 chunks, and normal stream completion.
Web application session and UI lifecycle
Layer / File(s)
Summary
Authentication session and verification web/default/src/stores/auth-store.ts, web/default/src/lib/api.ts, web/default/src/lib/auth-errors.ts, web/default/src/main.tsx, web/default/src/features/auth/*
Authentication state tracks a session revision. API requests record that revision, and stale 401 responses do not reset authentication. Verification identity and secure-verification context access use the updated session and hook contracts.
Shared state and subscription hooks web/default/src/hooks/*, web/default/src/lib/theme-radius.ts, web/default/src/test/react*, web/default/scripts/run-tests.mjs
New hooks provide resettable state and read-scope guards. External-store subscriptions replace effect-managed mobile and theme-radius values, and minimum loading uses cycle tracking. Tests cover the hooks and React test environment; the test runner emits stage timing metadata.
Profile and wallet read lifecycles web/default/src/features/profile/hooks/*, web/default/src/features/profile/components/*, web/default/src/features/wallet/*, web/default/src/hooks/state-lifecycle.runtime.test.tsx
Profile and wallet reads are scoped to the active user or authentication session. Stale responses do not update active state. Wallet subscription status also uses a shared reactive time value and expiry-boundary timers.
Dialog reads and async results web/default/src/features/channels/components/dialogs/*, web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx, web/default/src/features/usage-logs/components/dialogs/*, web/default/src/features/users/components/dialogs/user-binding-dialog.tsx
Dialog state resets when its scope changes, and guarded reads ignore stale results. Codex OAuth operations check dialog lifecycle and session revision. Runtime tests cover delayed and out-of-order responses.
Resettable forms and settings web/default/src/components/ai-elements/web-preview.tsx, web/default/src/components/risk-acknowledgement-dialog.tsx, web/default/src/features/models/components/dialogs/*, web/default/src/features/profile/components/*, web/default/src/features/subscriptions/components/dialogs/*, web/default/src/features/system-settings/*
Form drafts reset from their current inputs through resettable state. Settings context and its header hook move to dedicated modules. Form submission callbacks, settings initialization, channel-affinity reads, and endpoint derivation are updated, with runtime tests for submission and editor behavior.
Filter, chart, and test updates web/default/src/features/usage-logs/*, web/default/src/features/dashboard/components/*, web/default/src/features/keys/components/api-key-routing-editor.test.tsx, web/default/src/features/smart-ops/*, web/default/src/features/pricing/components/model-details.runtime.test.tsx, web/default/src/components/long-text.tsx, web/default/src/features/channels/components/dialogs/fetch-models-dialog.tsx
Quota-filter types and validation move to a shared module. Chart prop synchronization and test queries are updated. SmartOps tests scope controls to their dialogs, and channel-health error handling uses a fixed fallback message.
sequenceDiagram
participant AuthStore
participant api.ts
participant API
participant main.tsx
AuthStore->>api.ts: Provide current session revision
api.ts->>API: Send request with recorded session revision
API-->>api.ts: Return response or 401
api.ts->>api.ts: Compare request revision with current revision
api.ts-->>main.tsx: Reject stale 401 without resetting auth
main.tsx->>AuthStore: Reset auth for handled current-session 401
Loading
Merge Risk:⚪ Minimal · up to 59acb
This change makes the web app discard responses from a previous login session or a previously selected item, so outdated data no longer overwrites what the user is viewing. It also resets dialog and form drafts when the underlying item changes. Relay stream tests become deterministic, and no production relay code changed. No concrete defect was identified, so the change appears ready to merge after normal CI, including the Ubuntu cross-check the author noted for service tests.
Pre-merge checks: 4 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 6.35% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 50 files. (38 skipped:…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly summarizes the primary changes: isolating frontend sessions and stabilizing asynchronous lifecycle tests.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The pull request description directly matches the changeset. It describes frontend session and asynchronous lifecycle handling, stale-response prevention, dialog and form state resets, and test-fixtur…
Full details: Description check
Explanation
The pull request description directly matches the changeset. It describes frontend session and asynchronous lifecycle handling, stale-response prevention, dialog and form state resets, and test-fixture stabilization.
Full details: Docstring Coverage
Explanation
Docstring coverage is 6.35% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 50 files. (38 skipped: 38 over the file limit.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
I’m a rabbit watching drafts reset, While old replies are gently checked. The stream runs on; each chunk arrives, Fresh session state keeps reads in line. I twitch my nose and hop away.
Comment @coderabbitai help to get the list of available commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 变更描述 / Description
完成该分支剩余的前端状态和异步生命周期整理:登录会话或读取范围改变时使旧响应失效,弹窗切换与表单草稿按当前实体恢复,避免过期读取覆盖当前状态。
合入当前 main 后,PR 差异集中在前端及测试维护。保留 main 已有的 SQLite 运维、TLS 和插件校验实现;三处新增夹具修正分别隔离模型指标 API、确认真实请求取消状态,以及保持元数据测试流开启至清理,消除人为 EOF 与 watchdog 的竞争。产品超时和资金结算断言保持。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
延续 sqlite-operations-acceptance 分支验收;后端 SQLite 功能已包含于 main。本 PR 聚焦剩余前端与测试维护。
✅ 提交前检查项 / Checklist
📸 运行证明 / Proof of Work
本地环境:Windows、Go 1.25.1、Bun 1.3.14。验证候选 tree:aefb3bbaebed2a0646a824de7bc411c0cc329493。
未覆盖真实 MySQL/PostgreSQL、Redis 故障、外部支付/真实渠道与浏览器 E2E;本 PR 没有相关数据库或资金 mutation 改动。
验收标准:维护者已明确同意使用当前 PR HEAD 的仓库现有 Ubuntu CI 完整后端结果继续本轮验收、全量复审和稳定观察;该标准不覆盖或关闭上述 Windows 失败。
Ubuntu CI(当前 HEAD
59acb855b89ccc01a7f51d1d669f3f9d7d0d2750)已通过:CI #39396489407。包括完整go test ./...、vet、JSON policy,以及前端测试、typecheck 和生产构建;PR Check 也已通过。Windows 全套失败继续保持未解决状态。