Skip to content

claudecast: add cmux support, update cost calculation, new usage dashboard, fix ooms, etc. - #27693

Merged
raycastbot merged 3 commits into
raycast:mainfrom
qazi0:ext/claudecast
May 8, 2026
Merged

raycastbot merged 3 commits into
raycast:mainfrom
qazi0:ext/claudecast

Conversation

@qazi0

@qazi0 qazi0 commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

ClaudeCast 1.8.0

Cost calculation correctness, OOM crash fixes, dashboard rewrite, cmux terminal support, broadened auth gate, Git Actions rewrite, and a sync of upstream PR #27154.

Cost calculation (correctness)

  • Streaming-chunk dedup. streamSessionUsage dedups by (message.id, requestId) and keeps the last cumulative value per key. Anthropic's message_delta events emit cumulative usage; the CLI persists one JSONL line per chunk, so naive summing inflated session totals 2-4x. Verified on real sessions: one went 440K -> 114K, another 242K -> 95K.
  • Sonnet 4.x 200K-token tier. Above 200K input tokens per message, rates double ($3/$15 -> $6/$22.50, cache scaled). MODEL_PRICING rows accept an optional tier block applied per-message (per-request), not per-session.
  • Opus 4.7 pricing row at the $5/$25 tier. Without it, Opus 4.7 sessions matched the older opus substring and were billed at the deprecated $15/$75 tier (3x overcharge).
  • Opus 4.1 pricing row at the older $15/$75 tier.
  • Daily chart bucketing. getDailyStats now buckets per-entry timestamps via streamSessionUsage(..., { bucketByDay: true }) instead of stamping a session's full cost on its file mtime date.
  • calculateStatsWithUsage no longer mutates input. Costs computed into a local Map<string, number>. Top sessions returned as a lightweight TopSessionSummary so cached UsageStats does not alias SessionMetadata references the menu bar holds.

OOM crash fixes (menu-bar-monitor, usage-dashboard, browse-sessions)

  • Persistent today-stats cache. getTodayStats writes/reads claudecast-today-stats-v1 in LocalStorage with a 30s TTL.
  • environment.launchType differentiation in menu bar. Background ticks fetch only isClaudeActive() + cached today stats. The full-history getMostRecentProject() scan only runs on LaunchType.UserInitiated.
  • Bounded newest-first iterator in listAllSessions. When a limit is provided, maintains a sorted top-N array and skips files older than the current N-th-oldest, instead of statting every file then sorting.
  • Message and content caps in getSessionDetail (defaults: last 200 messages, 5KB per message). Returns SessionDetail.totalMessageCount so the UI can show the truncation notice.
  • Defensive stream cleanup in streamSessionUsage mirrors the pattern from parseSessionMetadataFast.

Usage Dashboard rewrite

  • Single Detail page with range tabs (Today / This Week / This Month / All Time) that drive both the chart bin granularity and the rest of the page (Today/Week: 7 daily bars, Month: 4-5 weekly bars, All Time: up to 12 monthly bars).
  • Real SVG bar chart embedded via file:// URL, generated by new src/lib/svg-chart.ts. White text fill with a stacked feDropShadow halo so labels read on both Raycast themes.
  • Sidebar metadata shows range-specific totals, token breakdowns, top 5 projects as colored tags, and the most expensive session.
  • Range-switch flicker fixed: chart aggregator runs against dailyRange (the range the loaded data was fetched for), not the current range. Stale fetches are cancelled.

cmux terminal support

  • New entry in the terminalApp preference dropdown.
  • Tab mode: open -a cmux <cwd> + AppleScript perform action ("text:" & "<cmd>" & (ASCII character 10)) via cmux's own input pipeline. No Accessibility permission needed.
  • Window mode: cmux's AppleScript new window verb + typed cd "<cwd>" && <cmd>.
  • Honors the global Open In preference.

Auth gate for Claude API commands

ensureClaudeApiAuth() preflights authentication before spawning claude. Accepts:

  • Raycast preferences (anthropicApiKey or oauthToken)
  • Env vars ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, or CLAUDE_CODE_OAUTH_TOKEN
  • Existing credentials reported by claude auth status --json (covers claude auth login)

When none are configured the user gets a Failure toast with an "Open Preferences" action instead of a hung claude process waiting on its /login prompt. Wired into ask-claude, git-actions, transform-selection, prompt-library.

Git Actions rewrite

  • Entry now shows a project picker from recent Claude Code projects (favorites -> recent -> all, deduplicated, mtime-sorted via discoverClaudeProjects()).
  • Empty states for "no Claude projects yet" and "picked path is not a git repo."
  • executePrompt default timeout extended from 2 to 10 minutes; git review actions scale further (3-15 min) based on diff size, with a "Large diff (NNN KB). This may take a few minutes." toast when >50KB.

Session prompt extraction (Browse Sessions, Deep Search Sessions)

  • New cleanUserMessageContent(raw) helper applied wherever firstMessage is derived (parseSessionMetadataFast, searchSingleSession, parseFullSession):
    • Returns null for any <local-command-*> wrapper (catches both <local-command-caveat> boilerplate and <local-command-stdout> echo from /model, /effort, etc.).
    • Returns null for short slash-only prompts (/model, /effort high, /clear, anything /-prefixed under 30 chars). Long slash commands with substantive args (/review https://github.com/.../pull/123 ...) are kept.
    • Detects <command- prefix in any leading order and unwraps to /cmd args.
  • New extractUserText(content) helper centralizes the "string vs array-of-blocks" content shape handling.

Detail view: last 20 messages

Browse Sessions and Deep Search Sessions detail views now render the most recent 20 messages with a "Showing last N of M messages" notice keyed to the rendered count. The banner now also appears for any session over 20 messages, not just sessions over 200.

Kitty window mode

Restored --single-instance on the kitty window-mode fallback so launches reuse the running kitty instance instead of spawning a separate process.

Synced from upstream PR #27154

  • Global openIn: "window" | "tab" preference (default window). Each terminal honors it: Terminal/iTerm send Cmd+T via System Events for tab; kitty uses kitten @ launch --type=tab (falls back to window if remote-control disabled); Ghostty uses new tab vs new window AppleScript verbs; cmux gets both modes; Warp ignores the preference.
  • Continue with Prompt shortcut in Launch Project changed Cmd+P -> Cmd+Shift+P (Cmd+P is Raycast-reserved).
  • Author user_675a985a803f8cc8105b added back to contributors.

Other fixes

  • $ escape bug in openInTerminalApp and openInITerm. Removed the .replace(/\$/g, "\\$") that converted bash -c 'echo $SHELL' into the literal text $SHELL. Centralized into a shared escapeAppleScriptDoubleQuoted() helper.
  • Ask Claude Code Cmd+G captures only selected text + clipboard.

Test plan

  • npm run lint, npx tsc --noEmit, and npm run build clean.
  • Cost numbers in usage-dashboard match expectations after the dedup + tier fixes.
  • Range tabs in the dashboard update chart, project table, top-sessions table, and sidebar atomically with no flicker.
  • Browse Sessions detail loads large sessions without OOM and shows the "Showing last N of M messages" notice on any session over 20 messages.
  • Menu bar updates over a 5+ minute window without crashing.
  • cmux selected as terminal: tab mode opens new workspace via open-handler; window mode via AppleScript new window verb. Both run the typed command.
  • Auth missing in prefs but ANTHROPIC_AUTH_TOKEN exported in shell: Ask Claude Code works; auth toast does not appear.
  • Auth missing everywhere: friendly "Add token in preferences" toast; claude is not spawned.
  • Git Actions opens to the project picker; review on a large diff runs to completion within the scaled timeout.
  • kitty with openIn = "window" reuses the running kitty instance.

- Merge contributions: keep local 1.8.0 state with cmux + auth gate broadening
- Pull contributions
- chore(gitignore): also ignore PR_*.md naming variant
- fix(1.8.0): broaden auth gate, restore detail-view recency, fix kitty window mode
- chore(release): v1.8.0
- Merge branch \'contributions/merge-pr27154\'
- Pull contributions: PR raycast#27154 (open-in tab/window preference for all terminal apps)
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: claudecast Issues related to the claudecast extension platform: macOS OP is author The OP of the PR is the author of the extension labels May 6, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

Thank you for the update! 🎉

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days.

@qazi0
qazi0 marked this pull request as ready for review May 6, 2026 13:10
@qazi0 qazi0 changed the title Update claudecast extension claudecast: add cmux support, update cost calculation, new usage dashboard, fix ooms, etc. May 6, 2026
@greptile-apps

greptile-apps Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

ClaudeCast 1.8.0 is a substantial quality release addressing cost calculation accuracy, OOM crashes, a usage dashboard rewrite, cmux terminal support, an auth gate for Claude API commands, and a Git Actions project-picker rewrite.

  • Cost correctness: streaming-chunk dedup by (message.id, requestId), tier-aware per-message pricing for Sonnet 4.x 200K threshold and new Opus 4.7/4.1 rows, timestampless-entry exclusion from date-range filters, and per-day cost attribution fix for the daily chart.
  • OOM fixes: two-tier today-stats cache (in-memory + LocalStorage), LaunchType.Background skip of the expensive project-discovery scan in the menu bar, bounded newest-first file collector in listAllSessions, and message/content caps in getSessionDetail.
  • New features: cmux terminal (tab via macOS open-handler, window via AppleScript), SVG bar chart in the usage dashboard, ensureClaudeApiAuth() preflight across all Claude API commands, diff-size-scaled timeouts in Git Actions, and the cleanUserMessageContent helper that suppresses /model//effort/<local-command-*> noise from session first-message extraction.

Confidence Score: 5/5

Safe to merge — the correctness fixes are well-scoped and the OOM mitigations are additive. The only nit is a hardcoded date in the changelog entry.

The cost calculation, OOM, and UI changes are all carefully structured: dedup logic is keyed on stable IDs, tier pricing matches Anthropic's documented per-request semantics, the bounded file collector is correct, and the auth preflight adds safety without breaking existing flows. No logic errors or data integrity concerns were identified.

No files require special attention beyond the CHANGELOG date placeholder.

Important Files Changed

Filename Overview
extensions/claudecast/CHANGELOG.md 1.8.0 entry uses a hardcoded date (2026-05-08) instead of the required {PR_MERGE_DATE} placeholder.
extensions/claudecast/src/lib/session-parser.ts Streaming dedup by (message.id, requestId), afterDate guard now excludes timestampless entries, bounded newest-first collector for listAllSessions, message/content caps in getSessionDetail, and cleanUserMessageContent helper for filtering slash-command noise from firstMessage.
extensions/claudecast/src/lib/usage-stats.ts Tier-aware per-message cost calculation, two-tier today-stats cache, lightweight TopSessionSummary projection, and per-day bucketing for the daily chart. No-mutation guarantee on input sessions correctly enforced.
extensions/claudecast/src/lib/terminal.ts Adds cmux support, centralises AppleScript escaping into escapeAppleScriptDoubleQuoted(), removes the erroneous $ escape from Terminal/iTerm, and restores --single-instance for kitty window mode.
extensions/claudecast/src/lib/svg-chart.ts New SVG bar chart generator with content-hash-keyed temp file caching and proper XML escaping.
extensions/claudecast/src/lib/claude-cli.ts Adds configurable timeoutMs to executePrompt and ensureClaudeApiAuth() preflight checking prefs, env vars, and claude auth status.
extensions/claudecast/src/usage-dashboard.tsx Full rewrite with parallel range loading, SVG chart, per-range aggregation, cancellation tokens, and range-switch flicker fix.
extensions/claudecast/src/menu-bar-monitor.tsx Background ticks skip the expensive getMostRecentProject() scan; only cheap signals fetched on background ticks.
extensions/claudecast/src/git-actions.tsx Rewritten with project picker, ensureClaudeApiAuth() preflight, diff-size-scaled timeout, and large-diff toast warning.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
extensions/claudecast/CHANGELOG.md:3
The 1.8.0 entry uses a hardcoded date instead of the `{PR_MERGE_DATE}` placeholder required by the repository's changelog convention. Raycast's build pipeline populates the placeholder automatically at merge time; a literal date may be wrong if the PR lands on a different day.

```suggestion
## [1.8.0] - {PR_MERGE_DATE}
```

Reviews (3): Last reviewed commit: "Update CHANGELOG.md" | Re-trigger Greptile

@0xdhrv 0xdhrv self-assigned this May 8, 2026

@0xdhrv 0xdhrv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, approved ✅

@raycastbot
raycastbot merged commit 6327605 into raycast:main May 8, 2026
3 checks passed
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

@raycastbot

Copy link
Copy Markdown
Collaborator

🎉 🎉 🎉

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

@qazi0
qazi0 deleted the ext/claudecast branch August 24, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension: claudecast Issues related to the claudecast extension extension fix / improvement Label for PRs with extension's fix improvements OP is author The OP of the PR is the author of the extension platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants