Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

AiUsageIndicator:识别免费版新的 resetKind 'weekly' 与 resetsAt(cloud#1843 周额度的消费侧跟进) #7371

Closed

Description

@hotlong

背景(cloud#1843 / PR cloud#1852 的消费侧跟进)

免费版 AI 额度改为 7 天滚动窗口后,objectos 运行时的用量端点与 429 信封有两处形状增量:

  • /api/v1/ai/usage:resetKind 新增值 'weekly'(原只有 'daily' | 'monthly'),并带 resetsAt(ISO,= 窗口内最早一笔计入用量的时间 + 7 天,即用量开始滚出的时刻)。
  • 429 AI_DESIGN_QUOTA_EXHAUSTED 的 error.details:新增 resetsAt(ISO);免费用户 resetsTonight=false。

cloud 侧 dev 核对:chatbotQuota.* 四个键与窗口无关(「明天会重置」那句一直是服务端下发的 message/messageEn,已在服务端改成带日期的文案);需要改的是 AiUsageIndicator(packages/app-shell/src/layout/AiUsageIndicator.tsx),它按 resetKind 渲染「今晚重置 / 下个周期」,收到 'weekly' 会落到未知分支。

要求

  1. AiUsageIndicator 识别 resetKind: 'weekly':显示「N 天后重置」(由 resetsAt 算,≤1 天时显示小时),中英文都走 @object-ui/i18n;D5:不显示 token 数。
  2. 类型:usage 响应类型里 resetKind 联合加 'weekly',resetsAt?: string;未知 kind 回落到不显示重置时间(而不是崩或显示错的话)。
  3. 测试:weekly + resetsAt 渲染;未知 kind 回落。

前提 re-check

gh pr diff 1852 --repo objectstack-ai/cloud | grep -n "weekly\|resetsAt";objectui grep -rn "resetKind" packages/app-shell/src/layout/AiUsageIndicator.tsx。

Activity

  1. added
    domain:uiobjectui ui stream: fix lands on the published library or apps — objectui execution seat
    on Sep 2, 2026
  2. self-assigned this
    on Sep 2, 2026
  3. hotlong commented on Sep 2, 2026

    @hotlong
    ContributorAuthor

    Claim: PM loop round 3 (epic objectstack-ai/cloud#1841)
    Session: session_c5c0ce54-bb9c-478c-9e5b-cf44b80d4569
    Branch: claude/issue-7371-usage-indicator-weekly
    Worktree: objectui-issue-7371
    Domain: domain:ui
    File surface: packages/app-shell/src/layout/AiUsageIndicator.tsx + its tests, the usage response type, packages/i18n/** zh/en keys for the new sentence (stop on breach; explain in the report)
    Container & model: S, mode:subagent, model: sonnet (PM judgement)
    Clause-②: no
    Serial constraints cleared: objectui#7273 (merged) touched AiUsageIndicator — base on current main; #7256 (in flight) owns console home/logo, not this file; #7366 (enqueued) touches i18n packs — different keys, rebase before pushing

  4. hotlong commented on Sep 2, 2026

    @hotlong
    ContributorAuthor

    os-dev-report
    {
    "issue": 7371,
    "status": "done",
    "branch": "claude/issue-7371-usage-indicator-weekly",
    "pr": "#7374",
    "premise_still_valid": true,
    "summary": "AiUsageIndicator (packages/app-shell/src/layout/AiUsageIndicator.tsx) now recognizes resetKind: 'weekly' from the free plan's rolling 7-day AI quota window (cloud PR #1852), rendering 'Resets in N days' (or N hours inside the final day) computed from resetsAt via new @object-ui/i18n keys (real plural family, base + _one/_other, all ten locale packs). AiUsageResetKind gained 'weekly'; resetsAt was already string | null on this side and needed no shape change. Contract-first: resetsAt is read verbatim, never guessed client-side, so a weekly meter with resetsAt: null and any unrecognized resetKind both render no reset line (fail-soft, no crash, no stale copy). Tests cover both weekly branches, the resetsAt: null fallback, and the unknown-resetKind fallback.",
    "tests": "All from repo root against merge-base 20c04b2 (rebased after #7366/#7367 landed touching i18n), commit 1b7793e: pnpm --filter '@object-ui/app-shell^...' build exit 0; pnpm exec vitest run packages/app-shell/src/layout/ packages/i18n/ --maxWorkers=2 -> 'Test Files 91 passed (91) / Tests 1152 passed (1152)'; pnpm --filter @object-ui/app-shell type-check exit 0; node scripts/check-i18n-call-site-keys.mjs exit 0 -> 'Every in-scope call-site key resolves against the en pack (2959 keys)...'; node scripts/check-i18n-en-drift.mjs exit 0 -> '0 en value(s) changed (6 key(s) added...)'; node scripts/check-i18n-dead-keys.mjs (report-only) exit 0, new keys absent from its dead-key report; node scripts/check-changeset-presence.mjs exit 0 -> '13 source file(s) of 2 released package(s) changed, and this change declares 1 changeset(s)'; node scripts/check-changeset-no-major.mjs and node scripts/check-control-bytes.mjs exit 0. No ablation applicable to this change.",
    "mcp_calls": 0,
    "open_questions": [],
    "out_of_scope_findings": []
    }

  5. hotlong commented on Sep 2, 2026

    @hotlong
    ContributorAuthor

    ACCEPT — reviewer of record: PM (epic objectstack-ai/cloud#1841), verified against GitHub.

    Generated by Claude Code

  6. hotlong commented on Sep 2, 2026

    @hotlong
    ContributorAuthor

    os-dev-report
    {
    "issue": 7371,
    "status": "done",
    "branch": "claude/issue-7371-usage-indicator-weekly",
    "pr": "#7374",
    "premise_still_valid": true,
    "summary": "Patch round on PM's report: CI's package-level pnpm lint (unlike my earlier targeted run) hit react-hooks/purity — weeklyResetLabel called Date.now() directly in AiUsageIndicator's render body. Moved the clock read out of render: a useState<number | null>(null) populated by a mount effect (refreshed every 60s), with the render body only reading that state and doing pure day/hour math from resetsAt/now. now === null (the one frame before the effect fires) renders no reset line, same treatment as any other not-yet-known input. No behavior change otherwise; existing weekly tests pass unmodified since RTL flushes the mount effect before assertions run.",
    "tests": "New head 3003f23 (on top of 1b7793e, same branch, fast-forward push, no force). All from repo root: pnpm --filter @object-ui/app-shell lint -> before the fix reproduced CI's exact failure ('133:51 error Cannot call impure function during render' / react-hooks/purity, 1 error + 2876 pre-existing warnings, exit 1); after the fix -> exit 0, '0 errors, 2877 warnings' (warning count pre-existing/unrelated, not gated by --max-warnings). pnpm --filter '@object-ui/app-shell^...' build exit 0. pnpm --filter @object-ui/app-shell type-check (tsc --noEmit && tsc -p tsconfig.test.json) exit 0. pnpm exec vitest run packages/app-shell/src/layout/ --maxWorkers=2 -> 'Test Files 33 passed (33) / Tests 225 passed (225)', including the weekly-reset tests added in the prior round, unmodified. Re-ran node scripts/check-i18n-call-site-keys.mjs, node scripts/check-changeset-presence.mjs, node scripts/check-control-bytes.mjs — all exit 0, unaffected (this round touched only AiUsageIndicator.tsx, no i18n/changeset files). Remote CI on 3003f23 was still in_progress at report time (Lint/Type Check/Test shards running, everything else already green) — not polled further per the no-CI-polling rule; local reproduction of the exact CI failure signature going 1 error -> 0 is the evidence.",
    "mcp_calls": 0,
    "open_questions": [],
    "out_of_scope_findings": []
    }

  7. hotlong commented on Sep 2, 2026

    @hotlong
    ContributorAuthor

    Patch round accepted (head 3003f23): the clock read moved out of render into a mount effect refreshed every 60s, render does pure math from resetsAt/state; the CI react-hooks/purity signature reproduced locally (1 error → 0), layout suite 33 files / 225 tests, type-check clean. Enqueuing when every check on the new head is green. Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

domain:uiobjectui ui stream: fix lands on the published library or apps — objectui execution seatpm:dispatched

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions