Skip to content

Show a Bot's last 7 days on the mobile profile, with an Activity screen for the detail - #1903

Merged
DoodleBears merged 7 commits into
mainfrom
claude/project-thread-anbtuc
Oct 15, 2026
Merged

DoodleBears merged 7 commits into
mainfrom
claude/project-thread-anbtuc

Conversation

@DoodleBears

@DoodleBears DoodleBears commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Vain · project thread

Why the change

From the phone the Human could not see how much a Bot costs or how active it is. Now the Bot profile shows a light "Last 7 days" card, like a health app's summary, and tapping it opens an Activity screen with the detail.

Closes #1895 (part of #1893). Stacked on #1899 (it shares that PR's Segmented switch and the DayBars chart that #1899 took from this branch); review only this PR's own commits, not the merges from #1899. Once #1899 merges this PR retargets to main.

Special things to note

  • Merge risk: mobile-only and read-only. It calls the existing profileActivity bridge method with { channelId, weeks, before }; no Host change and no new bridge method, so CLI parity is unchanged (deepseekbot bot-activity-history already exists). Revert is a plain revert.
  • Review focus:
    • src/host/bot-activity.ts: defensive parsing (a bad answer fails only this section, like the other profile parts), the 7-day slice (weeks: 1 covers a little of an eighth day, which is left out), and paging by whole windows with before.
    • The 7-day total is the sum of modelUsageRows[].totalTokens, the same number the Web profile's Token usage card shows; unknown buckets show as "Partially known" with the Web's partial-data note, never as zero.
    • New visual elements: DayBars (one bar per day or week, optionally stacked) and DayHeat (weeks × weekdays heatmap) in primitives/, with tones derived from the Bot's colour in design/chart.ts. No existing primitive drew a chart; no chart library.
  • Verification:
    • Automated: tsc --noEmit (root), pnpm --filter @botharness/mobile typecheck, pnpm vitest run apps/mobile (43 files, 333 tests), pnpm lint, oxfmt --check all pass locally.
      • test/bot-activity.test.ts: parsing, 7-day slicing, quiet week, unknown vs zero, token split, by model, by reason, weekly buckets, paging.
      • test/bot-profile.test.ts: the profile calls profileActivity through the DM with weeks: 1, and a failed call leaves the other sections. It uses an answer recorded from a real isolated Host (test/fixtures/host-wire.json → rpc.profileActivity): 207,439 tokens, 2 events and 2 Memory commits today.
      • test/bot-profile-sheet.test.tsx and test/activity-detail.test.tsx (jsdom + RN shim): the card shows the total and opens Activity; a quiet week; Try again; switching windows refetches; Earlier/Later paging; the Memory heatmap layout.
      • The wire type is asserted against the Host's in test/wire-contract.ts.
    • Runtime: the recorded answer came from a fresh isolated Host (DSH 0.2.0-rc.2) where the Bot answered two DMs. The OpenCode Go DeepSeek quota is used up this week and no free DeepSeek model is reachable, so the recording used the free opencode-go/step-5-preview-free; the Bot-side numbers (tokens, usage row, events, Memory commits) are real Host output.
    • Visual: the screenshots below are the web export at 390 × 844, rendered from a throwaway preview route with synthetic activity data so the charts have shape. They are not live Host data.
    • Not run: native check on a development build (cloud session has no simulator). Queued for the simulator batch.
  • CI test plan: affected. New tests live under apps/mobile/test/, already covered by the plan. Note for .ts tests there: the root tsc includes them, so they must not import React Native UI files (that pulls RN globals into Node packages); the heatmap test therefore lives in the .tsx screen test.

Change outline

  • Bot profile: a new first section, Last 7 days: token total in display, a 7-day bar row, then a smaller row of events plus Memory commits with weekday initials. A Bot with no activity shows a quiet week; a failed read shows "Could not read this section" with Try again.
  • New route app/bot/[slug]/activity.tsx → ActivityDetailView:
    • 7 days / 4 weeks / 6 months (weeks 1 / 4 / 26) with ‹ › paging.
    • Token usage: stacked cache read / input / output bars, by day up to 31 days and by week beyond, with legend and shares.
    • By model rows.
    • Events by reason.
    • Memory commit heatmap.
  • DESIGN.md describes both levels; change fragment changes/1895-mobile-bot-activity.md.

Before: the profile went straight from the actions to Identity. After:

Bot profile, Last 7 days

Profile, light Profile, dark

Activity, 7 days

Activity 7 days, light Activity 7 days, dark

Events, light Events, dark

Activity, 4 weeks

Activity 4 weeks, light Activity 4 weeks, dark

Activity, 6 months (weekly bars, Memory heatmap)

Activity 6 months, light Activity 6 months, dark

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGYM4VZHNRXNUap8oQMGdA

…creen with the detail

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGYM4VZHNRXNUap8oQMGdA
…t activity views; add PR screenshots

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGYM4VZHNRXNUap8oQMGdA
@DoodleBears DoodleBears self-assigned this Oct 15, 2026
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 65dd0d97-053d-409f-8afe-64e48d7e6234
📥 Commits

Reviewing files that changed from the base of the PR and between b408325 and abe6d1e.

⛔ Files ignored due to path filters: 10
  • .github/pr-screenshots/1895-bot-activity/1-profile-dark.png is excluded by !**/*.png
  • .github/pr-screenshots/1895-bot-activity/1-profile-light.png is excluded by !**/*.png
  • .github/pr-screenshots/1895-bot-activity/2-detail-7d-dark.png is excluded by !**/*.png
  • .github/pr-screenshots/1895-bot-activity/2-detail-7d-light.png is excluded by !**/*.png
  • .github/pr-screenshots/1895-bot-activity/3-detail-7d-events-dark.png is excluded by !**/*.png
  • .github/pr-screenshots/1895-bot-activity/3-detail-7d-events-light.png is excluded by !**/*.png
  • .github/pr-screenshots/1895-bot-activity/4-detail-4w-dark.png is excluded by !**/*.png
  • .github/pr-screenshots/1895-bot-activity/4-detail-4w-light.png is excluded by !**/*.png
  • .github/pr-screenshots/1895-bot-activity/5-detail-6m-memory-dark.png is excluded by !**/*.png
  • .github/pr-screenshots/1895-bot-activity/5-detail-6m-memory-light.png is excluded by !**/*.png
📒 Files selected for processing: 19
  • apps/mobile/DESIGN.md
  • apps/mobile/app/bot/[slug]/_layout.tsx
  • apps/mobile/app/bot/[slug]/activity.tsx
  • apps/mobile/app/bot/[slug]/index.tsx
  • apps/mobile/src/host/bot-activity.ts
  • apps/mobile/src/host/bot-profile.ts
  • apps/mobile/src/host/wire.ts
  • apps/mobile/src/ui/chat/activity-detail.tsx
  • apps/mobile/src/ui/chat/activity-glance.tsx
  • apps/mobile/src/ui/chat/bot-profile.tsx
  • apps/mobile/src/ui/primitives/day-bars.tsx
  • apps/mobile/src/ui/strings.ts
  • apps/mobile/test/activity-detail.test.tsx
  • apps/mobile/test/bot-activity.test.ts
  • apps/mobile/test/bot-profile-sheet.test.tsx
  • apps/mobile/test/bot-profile.test.ts
  • apps/mobile/test/fixtures/host-wire.json
  • apps/mobile/test/wire-contract.ts
  • changes/1895-mobile-bot-activity.md
  • 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

… heatmap layout with the screen tests

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGYM4VZHNRXNUap8oQMGdA
…s, so token counts are real

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGYM4VZHNRXNUap8oQMGdA
@DoodleBears
DoodleBears changed the base branch from claude/project-thread-55eh0x to main October 15, 2026 16:05
@DoodleBears
DoodleBears marked this pull request as ready for review October 15, 2026 16:05
@DoodleBears
DoodleBears merged commit b06df3a into main Oct 15, 2026
9 checks passed
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.

Mobile: token usage, event and memory commit activity cards on the Bot profile

2 participants