Skip to content

Show weekly usage chips and a Weekly Usage popover in the web sidebar - #162

Merged
yansfil merged 4 commits into
mainfrom
quick/153-weekly-usage
Sep 26, 2026
Merged

yansfil merged 4 commits into
mainfrom
quick/153-weekly-usage

Conversation

@yansfil

@yansfil yansfil commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #153

Summary

웹 셸은 core가 이미 계산하는 주간 사용량을 보여주지 않았고, 갱신 힌트도 보내지 않아 웹만 쓰는 세션은 첫 읽기 뒤로 값이 멈췄습니다.
이제 사이드바 하단 device picker 오른쪽에 provider별 chip(마크 + 반올림 퍼센트)이 있고, 누르면 Swift와 같은 구조의 Weekly Usage / 7 days popover가 열립니다.
색은 70 미만 success, 70부터 warning, 90부터 destructive이고, loading과 unavailable은 흐린 마크만 남기며 이유는 popover 행에 적습니다(배너 없음, 원칙 #13).
웹은 페이지 가시성과 popover 열림을 ui_state_update의 두 힌트로 보내고, 계약(providerUsage, uiStateUsageHints)과 생성 타입, Pen Component 시트와 사이드바 Screen 시트를 함께 갱신했습니다.

Dark: Claude Code 62%와 Fable 6%, codex 행은 로그인 없음으로 Unavailable

첫 읽기: Claude Code 행은 loading(…)과 Checking usage…, chip은 흐린 마크만

Light: 93%는 destructive, Fable 74%는 warning

Pen Screen / Main 사이드바 footer의 chip, Light와 Dark

Review

  • 판단해 주세요: Settings는 웹 헤더에 그대로 두고 chip만 footer에 넣었습니다. Swift처럼 Settings도 footer로 옮길지.
  • 판단해 주세요: 정각 경계에서 카운트다운이 in 3h 0m으로 읽힙니다. Swift 코드는 분을 항상 1 이상으로 올려 in 3h 1m입니다. 웹은 실제 남은 분을 택했습니다.
  • 판단해 주세요: popover 폭은 새 토큰 대신 --size-agent-children-popover(280px)를 재사용했습니다. 병렬 브랜치와 tokens.json, 두 .pen 변수 블록 충돌을 피하려는 선택입니다.
  • 판단해 주세요: stale과 fallback 행의 메시지(Last checked 7m ago · offline, From last Codex session)를 Swift의 툴팁 대신 막대 아래에 보입니다.
  • 조심해서 볼 파일: web/src/components/weekly-usage.tsx - ownership: 힌트는 UI state 전체를 되보내는 updateUiState echo로 갑니다(연결될 때, 가시성이 바뀔 때, popover를 열고 닫을 때 한 번씩).
  • 조심해서 볼 파일: web/scripts/gen-types.mjs - snapshot wire: 생성기는 frame이 닿는 타입만 내므로, 웹이 읽는 snapshot $def을 이름으로 나열합니다.
  • 조심해서 볼 파일: web/e2e/wire.ts, web/e2e/hided-fixture.ts - 공유 e2e helper: 힌트 전용 ui_state_update를 ui_state_update.usage_hint로 따로 세고, fixture에 env override와 log pipe race 수정이 들어갔습니다.
  • 질문: core는 힌트를 값 하나로 들고 있어 웹 페이지가 여럿이면 마지막 보고가 이깁니다. hided가 ai_settings.observing처럼 연결별 demand로 모으는 후속 이슈를 열까요?

Evidence

  • 확인한 것: pnpm --dir web typecheck, lint, test(40 files, 327 tests, 새 usage.test.ts 6개 포함).
  • 확인한 것: 최종 head에서 pnpm --dir web e2e 전체 61개 통과, 0개 실패(10.8분). 격리된 pinned Herdr 0.9.1(private socket)과 새로 빌드한 hided로 실행했습니다.
  • 확인한 것: 새 weekly-usage.spec.ts는 daemon PATH의 claude shim(해제 전까지 대기)과 codex 로그인이 없는 HOME으로 loading에서 available(62%, Fable 6%, in 5d 4h)로 넘어가는 행과 unavailable 행, 접근성 이름, popover 열고 닫힘, hidden 페이지 힌트를 확인합니다.
  • 확인한 것: 로컬 전용 실행에서 shim 인자를 기록해 claude -p /usage가 시작 시 1회, 62초 뒤 popover를 다시 열 때 1회, 곧바로 다시 열 때 0회 실행됨을 확인했습니다.
  • 확인한 것: node scripts/check-design-contract.mjs, design node test 4종(51개), python3 -m unittest discover -s scripts/tests(39개), check-no-workstation-identity.sh, check-hide-design-enforcement.mjs, check-no-attribution.py.
  • 확인한 것: Pen 시트를 headless pen interactive로 열어 Light와 Dark PNG로 렌더하고 앱 캡처(Light, Dark)와 대조했습니다.
  • 확인한 것: 첫 전체 e2e에서 s2 등록 테스트(연결 시 힌트가 ui_state_update 수를 하나 늘림)와 overview 재시작 단계(fixture log의 write after end)가 실패했고, 두 helper를 고친 뒤 전체를 다시 통과시켰습니다.
  • 확인한 것: CI 첫 실행에서 s7.spec.ts:270(Open to the side)이 383행 더블클릭 뒤 탭이 preview(@(>keep.txt*))로 남아 한 번 실패했습니다. 힌트는 연결, 가시성 변경, popover 열고 닫을 때만 나가 이 단계와 겹치지 않고, 로컬에서 같은 head로 4회 반복해 4회 통과했으며, 실패한 job 재실행에서 web shell을 포함한 전체 check가 통과했습니다. main에서도 매번 다른 e2e 한 개가 떨어지는 같은 유형(s7:516, s6:27, desktop:117)이 있습니다.
  • 확인하지 못한 것: desktop lane과 cargo, Swift lane은 로컬에서 돌리지 않았고 CI(desktop app, rust workspace, swift shell)에서 통과했습니다. Rust, Swift, desktop 소스는 바뀌지 않았고, desktop은 같은 web/dist를 띄웁니다.
  • 확인하지 못한 것: hidden 페이지에서 5분 주기 갱신이 멈추는지는 5분을 기다려 보지 않았습니다. 웹이 usage_window_visible: false를 보내는 것은 e2e가, core 스케줄은 refresh_schedule_stops_hidden_ticks_and_observes_popover_age가 확인합니다.
  • 확인하지 못한 것: 같은 계정의 Swift 앱과 나란히 퍼센트를 대조하지 않았습니다. 임계값, 반올림, 카운트다운 규칙은 Swift 코드를 기준으로 단위 테스트로 맞췄습니다.
  • 생성물: design/hide-ui.lib.pen(+904줄, 새 시트 하나만 추가), design/hide-screens.pen(Main, Workspace 사이드바 footer 노드만), web/src/generated/hided-ws.ts(+34줄)는 스크립트 출력입니다.

AI tooling: 대부분 AI 도구로 작성. Swift 참조 화면과 웹 및 Pen 캡처를 대조하고, 생성된 .pen diff가 새 시트와 footer 노드만 바꾸는지 노드 id로 확인했습니다.

…ract

The core has published navigator.provider_usage and read two refresh
hints off ui_state_update since the Swift shell, but the WebSocket
contract declared neither, so the web had no type for them.

The schema now declares providerUsage with its buckets and the two
uiStateUsageHints fields. The type generator emits only what a frame
reaches, so it names each snapshot $def the web reads and emits it
beside the frames; the snapshot's navigator type takes ProviderUsage
from the generated file.
Component / Weekly usage adds a Usage chip and a Usage row master with
their states: a chip under 70, from 70, from 90 and without a reading;
the popover with the `claude` row, its indented Fable bucket and the `codex` row; the
first read with a loading and an unsigned row; and a stale, a nearly
spent, a fallback and an unavailable bucket row.

The sidebar footer on Screen / Main and Screen / Workspace now carries
the chips beside the device picker, as refs of the library master.
The fixture piped the daemon's stdout and stderr into one log file with
the default end-on-finish, so whichever stream ended first closed the
file under the other's last write. A daemon restart with the run
directory set then failed the spec with "write after end" (the Project
Overview spec's restart step). The file now closes when the daemon's
output has ended on both.
The web shell showed no provider usage although the core computes it,
and it never sent the refresh hints, so a web-only session got its
first read and no more.

The sidebar footer now carries a chip per provider beside the device
picker: the provider mark and the rounded percent, in the success color
below 70, warning from 70 and destructive from 90, and a dimmed mark
with no percent while a provider is loading or unavailable. The chips
open a Weekly Usage popover with each provider's reset countdown,
percent and bar, and scoped buckets such as Fable indented under it; a
row with no reading shows the core's message in place of its bar, and
no usage state becomes a banner.

The page reports its visibility on every live connection and on each
change, and the popover reports opening and closing, through the two
ui_state_update hints. The e2e spec runs a `claude` shim on the daemon's
PATH and no `codex` login to cover a loading, an available and an
unavailable row; the event counter keeps these hint updates apart from
an action's own ui_state_update.
@yansfil
yansfil merged commit ba447f8 into main Sep 26, 2026
11 of 13 checks passed
@yansfil
yansfil deleted the quick/153-weekly-usage branch September 26, 2026 02:46
yansfil added a commit that referenced this pull request Sep 26, 2026
Brings in the ⌘K palette (#161), weekly usage (#162) and the desktop
app's macOS pane chords (#160).

The desktop bridge keeps both sides: `reportBindings` from #160 beside
`browser`, the channels of both, and the e2e's bridge keys list all
four. The bindings listener now uses the host's one shell-frame check,
`fromShell`, which the browser channels already use. main's new
shortcut import test no longer names the removed `chromux_enabled`.
The contract carries both sides and web/src/generated/hided-ws.ts is
the generator's output; the design library holds both parents' boards,
the browser toolbars sheet from this branch and the weekly usage sheet
from main.
yansfil added a commit that referenced this pull request Sep 26, 2026
…own width (#165)

Related: #153, #162

## Summary

#162 리뷰에서 남은 두 결정을 반영합니다.
Settings 톱니를 사이드바 헤더에서 footer로 옮겨, footer가 Swift utility bar처럼 왼쪽 device
picker, 오른쪽 사용량 chip과 Settings로 읽힙니다.
Weekly Usage popover는 빌려 쓰던 `--size-agent-children-popover`(280) 대신 새 토큰
`--size-usage-popover`(Swift와 같은 250)를 씁니다.
헤더 줄에는 Agents, Projects, ⌘E만 남습니다.

![Dark: footer의 This Mac, chip, Settings 톱니와 250 폭
popover](https://github.com/yansfil/pr-assets/blob/main/hide/usage-footer-settings/2e7c72b/footer-popover-dark.png?raw=true)

![Light: 93%는 destructive, Fable 74%는 warning, 같은 footer
순서](https://github.com/yansfil/pr-assets/blob/main/hide/usage-footer-settings/2e7c72b/footer-popover-light.png?raw=true)

## Review

- **판단해 주세요**: Pen의 Main과 Workspace 화면 시트는 사이드바를
220(`--size-sidebar-min`)으로 그려 footer에 톱니가 들어가지 않았습니다. 웹이 실제로 쓰는
`--size-sidebar-ideal`(292)로 바꿨고, 두 시트의 폭이 그만큼 넓어졌습니다.
- **조심해서 볼 파일**: `scripts/pen-screens.mjs` - 생성기: `screenSidebar`가
tokens를 받아 폭을 읽고, Palette 시트 사이드바 헤더의 톱니를 지웠습니다.

## Evidence

- **확인한 것**: `pnpm --dir web typecheck`, `lint`, `test`(40 files, 338
tests).
- **확인한 것**: 이 worktree에서 hided를 새로 빌드하고 격리된 pinned Herdr(private
socket)로 `pnpm --dir web e2e` 전체 62개 통과, 0개 실패(10.9분).
- **확인한 것**: 로컬 전용 캡처 spec에서 footer의 톱니(`data-open-settings`)를 눌러
Settings를 열고 Appearance에서 Light로 바꾼 뒤 chip과 popover를 캡처했습니다.
- **확인한 것**: `node scripts/check-design-contract.mjs`, design node test
4종(51개), `python3 -m unittest discover -s scripts/tests -p 'test_*.py'`,
`check-no-workstation-identity.sh`, `check-hide-design-enforcement.mjs`,
`check-no-attribution.py`.
- **확인한 것**: headless `pen interactive`로 Main 사이드바(Light, Dark),
Workspace 시트, Weekly usage popover 상태를 렌더해 footer 세 요소가 잘리지 않고 popover가
250 폭인지 봤습니다.
- **확인하지 못한 것**: desktop, cargo, Swift lane은 로컬에서 돌리지 않았습니다. Rust와
Swift, desktop 소스는 바뀌지 않았고 CI(desktop app, rust workspace, swift
shell)에서 통과했습니다.
- **생성물**: `design/hide-ui.lib.pen`(새 변수와 Weekly usage 시트의 폭),
`design/hide-screens.pen`(변수 블록, Main, Workspace, Palette 사이드바),
`web/src/tokens.css`는 스크립트 출력입니다.

**AI tooling**: 대부분 AI 도구로 작성. Swift 참조 화면과 웹, Pen 캡처를 대조하고 `.pen` diff가
폭, 변수, 사이드바 노드만 바꾸는지 확인했습니다.
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.

web: weekly usage chips and popover in the sidebar footer

1 participant