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

Remove upstream synthetic.new source - #41

Merged
makoMakoGo merged 3 commits into
personal/local-clientsfrom
codex/remove-synthetic-source
Jun 7, 2026
Merged

Remove upstream synthetic.new source#41
makoMakoGo merged 3 commits into
personal/local-clientsfrom
codex/remove-synthetic-source

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented Jun 6, 2026

Copy link
Copy Markdown
Owner

关联 issue:Closes #34

依赖关系:建议先合入 #40。这个 PR 的实现语义与 #40 中的 ADR 一致,但 base 仍按要求指向 personal/local-clients

变更

  • 删除 upstream synthetic.new source/client/filter/session reader。
  • 删除 Octofriend SQLite scan/parse 路径和 Synthetic gateway re-attribution。
  • 删除 CLI/TUI 里的 --client synthetic、隐藏 --synthetic legacy flag、source picker Synthetic entry、TUI cache includeSynthetic key。
  • 删除 frontend source type/logo/color 中的 Synthetic source。
  • 删除 README 多语言文档中的 Synthetic 平台说明。
  • 保留 Claude Code model = "<synthetic>" placeholder drop logic。
  • 将有用的 gateway model path normalization 从 sessions::synthetic 迁到 custom pricing helper,不再依赖 Synthetic source/client vocabulary。

原因

synthetic.new source/client 与 Claude Code 的 <synthetic> placeholder 只是名字撞车,语义完全不同。把 synthetic.new 做成 first-class source 会污染 core、CLI、TUI、frontend 和文档,并让调用方误以为存在一个真实 client。

本分支选择删除这个 source/client 概念,而不是保留 fallback、compat flag 或 silent re-attribution。

验证

  • cargo check -p tokscale-cli
  • cargo test -p tokscale-core
  • cargo test -p tokscale-cli
  • bun run --cwd packages/frontend lint
  • bun run --cwd packages/frontend build

bun run --cwd packages/frontend lint 仅有既有 warning,没有 error。

Summary by Sourcery

Remove the Synthetic meta-client/source and its associated parsing, filtering, and documentation, while preserving gateway model path normalization for pricing overrides.

Enhancements:

  • Simplify client filtering, scanning, and TUI data loading by treating only real clients as first-class and removing the synthetic include flag and cache key handling.
  • Refactor custom pricing to use a generic gateway model path normalizer instead of Synthetic-specific naming.
  • Clean up CLI and TUI client filter definitions, hotkeys, and cache schemas to match the updated client set without Synthetic.

Documentation:

  • Update README and localized documentation to remove Synthetic as a supported platform and adjust examples and descriptions accordingly.

Tests:

  • Update and remove tests around the Synthetic meta-client, ensuring remaining tests validate gateway handling and default client behavior without Synthetic.

Summary by CodeRabbit

  • Documentation

    • 更新多个README文档,移除Synthetic平台相关说明。
  • Changes

    • 移除Synthetic客户端支持,简化相关过滤和数据处理逻辑。
    • 新增Zed、Trae、Warp客户端类型支持。

@sourcery-ai

sourcery-ai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Reviewer's Guide

Removes the upstream synthetic.new source/meta-client across core, CLI, TUI, frontend, and docs, while preserving generic gateway model path normalization for pricing and updating filters, scanners, cache keys, and tests to no longer treat synthetic as a first-class client id.

File-Level Changes

Change Details Files
Remove synthetic client handling from core parsing, scanning, and tests while keeping gateway model normalization in pricing.
  • Drop synthetic-specific filtering paths and Octofriend SQLite ingestion from parse and reporting code, simplifying retain_for_requested_clients to only check real clients and cc-mirror aliases.
  • Remove the synthetic_db field and associated discovery of Octofriend SQLite from ScanResult and scanner logic, so scanning only tracks real client sources.
  • Move the model-id normalization previously in sessions::synthetic into a new normalize_gateway_model_path helper used by custom pricing, decoupling gateway path handling from synthetic vocabulary.
  • Update or remove tests that depended on synthetic filters, rewriting expectations to assert behavior under real client filters and gateway-normalized model/provider ids.
  • Unexport and delete the synthetic sessions module so no synthetic source/client concept remains in core.
crates/tokscale-core/src/lib.rs
crates/tokscale-core/src/scanner.rs
crates/tokscale-core/src/pricing/custom.rs
crates/tokscale-core/src/pricing/aliases.rs
crates/tokscale-core/src/sessions/mod.rs
crates/tokscale-core/src/sessions/synthetic.rs
Remove synthetic as a CLI/TUI client filter and cache dimension, simplifying default client sets and data loading APIs.
  • Drop the Synthetic variant from ClientFilter, the hidden --synthetic legacy flag, and any conversion or ordering logic that treated synthetic as a meta-client without a ClientId.
  • Remove include_synthetic booleans from DataLoader::load and related helpers, so enabled client sets are represented purely as Vec derived from ClientFilter.
  • Simplify TUI cache keys and serialization by removing include_synthetic from CachedTUIData and cache_clients_match_exact, matching on enabled client ids only.
  • Update TUI app initialization, source picker, and hotkey handling to operate only on real ClientFilter variants and to project them directly to core ClientId lists without a synthetic special case.
  • Adjust tests and settings serialization/round-trips to reflect the new client universe (e.g., defaultClients examples now use real ids like "zed" instead of "synthetic").
crates/tokscale-cli/src/main.rs
crates/tokscale-cli/src/tui/cache.rs
crates/tokscale-cli/src/tui/data/mod.rs
crates/tokscale-cli/src/tui/app.rs
crates/tokscale-cli/src/tui/ui/dialog/source_picker.rs
crates/tokscale-cli/src/tui/mod.rs
crates/tokscale-cli/src/tui/settings.rs
Strip synthetic from wrapped/warm CLI outputs and frontend source metadata so it is no longer exposed as a selectable source.
  • Remove synthetic from CLI wrapped view client-display name and logo mappings so wrapped summaries never show Synthetic as a source.
  • Delete synthetic entries from frontend SOURCE_DISPLAY_NAMES, SOURCE_LOGOS, SOURCE_COLORS, and SUPPORTED_CLIENT_TYPES, and drop the synthetic logo case from the SourceLogo component.
  • Ensure any remaining references to synthetic in the frontend type system or constants are removed so the UI cannot select or render Synthetic as a source.
crates/tokscale-cli/src/commands/wrapped.rs
packages/frontend/src/lib/constants.ts
packages/frontend/src/components/SourceLogo.tsx
packages/frontend/src/lib/types.ts
Update documentation in all locales to remove Synthetic as a supported platform and to describe gateway normalization generically.
  • Remove Synthetic from client tables, multi-platform support lists, CLI example sections, and path tables so docs match the actual supported client set.
  • Update descriptive text and examples for defaultClients and source filtering to use only real client ids (e.g., opencode/claude/zed) and not mention synthetic.
  • Rewrite the custom pricing section to describe generic gateway /models/ path normalization instead of synthetic-specific normalization behavior, aligning with the new normalize_gateway_model_path helper.
README.md
README.ja.md
README.ko.md
README.zh-cn.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b18a1137-63a7-4da4-af7f-603eabf91c62

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/remove-synthetic-source

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 and usage tips.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="crates/tokscale-core/src/pricing/custom.rs" line_range="252" />
<code_context>
         }

-        let normalized_key = normalize_synthetic_model(model_id).to_lowercase();
+        let normalized_key = normalize_gateway_model_path(model_id).to_lowercase();
         if normalized_key != raw_key {
             if let Some(pricing) = self.models.get_key_value(&normalized_key) {
</code_context>
<issue_to_address>
**suggestion (performance):** Avoid double-lowercasing in model id normalization to reduce unnecessary allocation.

`normalize_gateway_model_path` already lowercases its input (it begins with `let lower = model_id.to_lowercase();` and only uses substrings of that), so the extra `.to_lowercase()` here just adds an unnecessary allocation. You can set `normalized_key` to `normalize_gateway_model_path(model_id)` directly to keep behavior identical while avoiding the extra work.

```suggestion
        let normalized_key = normalize_gateway_model_path(model_id);
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread crates/tokscale-core/src/pricing/custom.rs Outdated

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request completely removes the "Synthetic" (synthetic.new) client integration, including its meta-client filters, SQLite parsing, documentation, and frontend assets across the codebase. In crates/tokscale-core/src/pricing/custom.rs, the normalize_synthetic_model function was replaced with normalize_gateway_model_path. A review comment correctly points out a redundant .to_lowercase() call on the result of normalize_gateway_model_path which can be removed to avoid unnecessary heap allocations.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/tokscale-core/src/pricing/custom.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
crates/tokscale-cli/src/main.rs (1)

1143-1157: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

不要把已移除的 client 配置静默回退成“全部客户端”。

如果用户的 settings.json 里还残留 defaultClients: ["synthetic"],这里会先把它当作 unknown 丢掉,然后把“解析后为空”解释成“未配置默认值”,最终让 tokscale tui / tokscale models / warm-cache 都退回到全量 client。Issue #34 明确要求移除 Synthetic 时不要引入 silent fallback;这里至少需要把“配置里引用了已移除 client”变成用户可见的错误或迁移提示,而不是悄悄扩大结果集。build_client_filter_with_defaults()resolve_default_tui_filter_set_with() 需要一起修,不然两条路径还会继续同步地做错事。

Also applies to: 5116-5124, 6033-6038

crates/tokscale-cli/src/tui/cache.rs (1)

614-667: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

移除 includeSynthetic 后需要升级缓存 schema。

现在这里把客户端精确匹配完全收敛到 enabledClients,但旧 JSON 里的 includeSynthetic 会被 serde 静默忽略。这样旧的 v13 缓存如果是 enabledClients=["claude"]includeSynthetic=true,本次读取会被当成精确命中,直接把已经删除的 Synthetic 数据和统计值展示出来,直到后台刷新覆盖。既然磁盘键语义已经变了,这里至少应该 bump CACHE_SCHEMA_VERSION,并补一个“旧 v13 + includeSynthetic => Miss”的回归测试。

Also applies to: 720-747

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tokscale-cli/src/tui/cache.rs` around lines 614 - 667, Bump the disk
cache schema version and add a regression test so old v13 JSONs that contained
the removed includeSynthetic field do not falsely hit the cache: increment
CACHE_SCHEMA_VERSION, update any schema constants, and modify
load_cache/CachedTUIData expectations so that caches serialized with the old
includeSynthetic are treated as CacheResult::Miss (you can detect this in tests
by deserializing a v13 JSON string containing enabledClients=["claude"] plus
includeSynthetic=true and asserting load_cache returns Miss); also add a unit
test covering the same scenario referenced near the logic that calls
cache_clients_match_exact to ensure the old payloads are rejected.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/tokscale-cli/src/tui/mod.rs`:
- Around line 176-180: The bg_clients vector is built directly from
enabled_clients (HashSet<ClientFilter>) which yields an arbitrary order, causing
cold-start ordering to differ from the stable order produced by
App::scan_clients() and thus causing DataLoader::aggregate_messages (which uses
first-seen ordering) to produce inconsistent client orderings; fix by
constructing bg_clients using the same stable ordering as App::scan_clients()
(e.g., call or reuse App::scan_clients() result or apply the same sort/ordering
routine used there and then filter by enabled_clients) so bg_clients is
deterministic and matches the reload path used by
DataLoader::aggregate_messages.

In `@crates/tokscale-core/src/pricing/custom.rs`:
- Around line 320-324: The current normalization only strips
"accounts/.../models/..." so router gateway paths like
"accounts/fireworks/routers/kimi-k2p6-turbo" never resolve to the base model id;
update the logic in the same function that uses lower.strip_prefix("accounts/")
to also check rest.split_once("/routers/") and return the segment after
"/routers/" when present (mirroring the existing "/models/" branch), and add a
unit/regression test that calls
lookup("accounts/fireworks/routers/kimi-k2p6-turbo") and asserts it matches the
base key "kimi-k2p6-turbo".

---

Outside diff comments:
In `@crates/tokscale-cli/src/tui/cache.rs`:
- Around line 614-667: Bump the disk cache schema version and add a regression
test so old v13 JSONs that contained the removed includeSynthetic field do not
falsely hit the cache: increment CACHE_SCHEMA_VERSION, update any schema
constants, and modify load_cache/CachedTUIData expectations so that caches
serialized with the old includeSynthetic are treated as CacheResult::Miss (you
can detect this in tests by deserializing a v13 JSON string containing
enabledClients=["claude"] plus includeSynthetic=true and asserting load_cache
returns Miss); also add a unit test covering the same scenario referenced near
the logic that calls cache_clients_match_exact to ensure the old payloads are
rejected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b03224f8-acd5-417e-a021-e86e77d95993

📥 Commits

Reviewing files that changed from the base of the PR and between 93ffff3 and eb6d072.

📒 Files selected for processing (21)
  • README.ja.md
  • README.ko.md
  • README.md
  • README.zh-cn.md
  • crates/tokscale-cli/src/commands/wrapped.rs
  • crates/tokscale-cli/src/main.rs
  • crates/tokscale-cli/src/tui/app.rs
  • crates/tokscale-cli/src/tui/cache.rs
  • crates/tokscale-cli/src/tui/data/mod.rs
  • crates/tokscale-cli/src/tui/mod.rs
  • crates/tokscale-cli/src/tui/settings.rs
  • crates/tokscale-cli/src/tui/ui/dialog/source_picker.rs
  • crates/tokscale-core/src/lib.rs
  • crates/tokscale-core/src/pricing/aliases.rs
  • crates/tokscale-core/src/pricing/custom.rs
  • crates/tokscale-core/src/scanner.rs
  • crates/tokscale-core/src/sessions/mod.rs
  • crates/tokscale-core/src/sessions/synthetic.rs
  • packages/frontend/src/components/SourceLogo.tsx
  • packages/frontend/src/lib/constants.ts
  • packages/frontend/src/lib/types.ts
💤 Files with no reviewable changes (6)
  • crates/tokscale-core/src/sessions/synthetic.rs
  • packages/frontend/src/lib/constants.ts
  • packages/frontend/src/lib/types.ts
  • packages/frontend/src/components/SourceLogo.tsx
  • crates/tokscale-cli/src/commands/wrapped.rs
  • crates/tokscale-core/src/sessions/mod.rs

Comment thread crates/tokscale-cli/src/tui/mod.rs
Comment thread crates/tokscale-core/src/pricing/custom.rs
@makoMakoGo
makoMakoGo merged commit 0bf77cc into personal/local-clients Jun 7, 2026
4 checks passed
@makoMakoGo
makoMakoGo deleted the codex/remove-synthetic-source branch June 7, 2026 06:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant