Skip to content

feat(zed): support hosted Zed agent threads - #509

Merged
junhoyeo merged 1 commit into
junhoyeo:mainfrom
makoMakoGo:feat/zed-agent-support
May 5, 2026
Merged

junhoyeo merged 1 commit into
junhoyeo:mainfrom
makoMakoGo:feat/zed-agent-support

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented May 5, 2026

Copy link
Copy Markdown
Contributor

Closes #498

Summary

  • add a Zed parser for threads/threads.db with json and zstd payload support
  • only count Zed-hosted built-in agent threads (provider == "zed.dev") to avoid double-counting external ACP agents
  • estimate Zed hosted cost from token usage using existing pricing data plus Zed's 10% hosted markup
  • wire Zed through scanner discovery, CLI filters, TUI labels/hotkeys, wrapped metadata, frontend constants, and README
  • ship a local Zed logo asset and reuse it across README, wrapped output, and frontend constants

Testing

  • cargo test -p tokscale-core zed && rtk cargo test -p tokscale-cli zed

@vercel

vercel Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tokscale Ready Ready Preview, Comment May 5, 2026 9:45am

Request Review

@makoMakoGo

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@makoMakoGo
makoMakoGo force-pushed the feat/zed-agent-support branch from 2df6ff2 to baa37d6 Compare May 5, 2026 08:49
@makoMakoGo
makoMakoGo marked this pull request as ready for review May 5, 2026 09:41

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 16 files

@junhoyeo junhoyeo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed via parallel audit β€” see thread. MERGE WITH NITS verdict; nits will be addressed in a follow-up PR (cfg-gate macOS path block, regression test for Zed markup vs Zed pricing, doc TODO for reasoning tokens). New SQLite parser is schema-flexible, read-only opens, 32 MiB cap, all 16 files coherently scoped to Zed support. tests + clippy green.

@junhoyeo
junhoyeo merged commit ff66145 into junhoyeo:main May 5, 2026
15 checks passed
junhoyeo added a commit that referenced this pull request May 10, 2026
…rage (#514)

chore: address audit nits across #509, #511, #512

Consolidated follow-up for audit findings on three recently-merged
PRs. None are correctness blockers; this is hardening + coverage.

# PR #509 β€” feat(zed): support hosted Zed agent threads

scanner.rs: cfg-gate the macOS Zed `Library/Application Support`
fallback path with `#[cfg(target_os = "macos")]`. Without it the
block ran on Linux too β€” harmless because the path can't exist
there, but inconsistent with the Windows branch which is already
cfg-gated. Pure hygiene.

lib.rs: document a future-risk in `pricing_multiplier`. Today the
+10% Zed-hosted markup is keyed on `message.client == "zed" AND
message.provider_id == "zed.dev"`, which is correct because tokscale
bundles upstream-provider LiteLLM rows (anthropic/openai/google) for
the underlying models. If LiteLLM ever ships rows under provider
`zed.dev` that already include the markup, this would double-bill β€”
a comment now warns the next maintainer to thread matched-price
provenance through `apply_pricing_if_available` before relying on
that case.

lib.rs: two negative regression tests for the markup gate, locking
in the existing positive test:
- non-zed client + provider_id="zed.dev" β†’ no markup (e.g., a
  claudecode message that mentions the provider should pay base
  rate, not Zed's hosted rate).
- zed client + non-zed provider (BYOK path with provider_id
  pointing directly at "anthropic", etc.) β†’ no markup. Important
  forward-compat: if Zed adds BYOK support and the parser switches
  to upstream provider IDs, the markup must NOT fire.

# PR #511 β€” fix(codex): deduplicate forked token count history

lib.rs: add a negative test that locks in two turns whose
`last_token_usage` deltas are byte-identical but emitted at distinct
timestamps both survive dedup. The fork-dedup key includes
timestamp, so this is correct today; without the test, a future
selectivity tightening (e.g. dropping timestamp from the key) could
silently erase legitimate usage.

# PR #512 β€” feat(auth): support non-interactive API token auth

SettingsClient.tsx: clear `createdToken` from React state after the
user copies it. The raw token is shown once and only once; once
copied it should leave the component tree so it no longer lives in
DevTools / extension snapshots of React state. Users who haven't
copied yet still have the value in the reveal panel until they
click copy or navigate away.

authToken.test.ts: add an expired-token test asserting `GET
/api/auth/token` returns 401 with `{ error: "API token has expired"
}` when `authenticatePersonalToken` resolves with `status: "expired"`.
The branch existed in route.ts but was uncovered.

README.md: document the auth-token precedence (env
`TOKSCALE_API_TOKEN` > saved credentials file) and the revocation
flow (Settings > API Tokens > Revoke; takes effect immediately,
returns 401 thereafter).

# Out of scope (intentionally not addressed)

- Import-path consistency in `route.ts` (audit nit N1): `@/lib/auth
  /bearerToken` does not resolve under vitest because the frontend
  has no vitest config to mirror tsconfig path aliases. Switching
  the import to the alias breaks `npx vitest run`. The fix is to
  add a `vitest.config.ts` with `resolve.alias`, which is a wider
  surface change than this nit-cleanup PR warrants. The relative
  import stays as it was on main.
- Legacy plaintext OR-clause in personalTokens.ts (audit M2): a
  pre-existing migration affordance, not introduced by #512;
  removal should be paired with a one-shot data migration that
  rehashes any remaining plaintext rows.
- Dead `session_id_from_meta`/`session_forked_from_id` fields on
  `CodexParseState` (audit nit on #511): looks like deliberate
  groundwork by the original author. Removing it without their
  consent is overreach.

# Validation

- `cargo test -p tokscale-core` β€” 662 passed (3 new tests)
- `cargo clippy -p tokscale-core --all-features -- -D warnings` β€” clean
- `cargo fmt --all -- --check` β€” clean
- `npx vitest run __tests__/api/authToken.test.ts __tests__/lib/bearerToken.test.ts` β€” 8/8 pass

Constraint: All fixes must lock in current behavior (negative tests,
  cfg gates, doc comments) without changing observed behavior of any
  shipped feature
Constraint: No vitest config changes β€” the import-style nit yields
  to that constraint
Confidence: high
Scope-risk: narrow β€” 5 files, +188/-0, no behavior change
@makoMakoGo
makoMakoGo deleted the feat/zed-agent-support branch May 10, 2026 18:44
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.

feat: support Zed Agent

2 participants