Commit Graph

3637 Commits

Author SHA1 Message Date
Jason 0a77d82808 chore(presets): point 9527CODE website and sign-up links to the CC Switch channel
Replace the affiliate sign-up link (register?aff=e5zI) with
https://9527.codes/register?channel=ccs in the eight READMEs and in the
apiKeyUrl and websiteUrl of all nine 9527CODE presets. API base URLs and
endpoint candidates are unchanged.
2026-11-14 03:59:30 -08:00
Jason 6f6671c1e8 feat(updater): download updates in the background and ask before installing
Add an opt-in "Auto-download updates" switch to Settings > About (off by
default, stored per device as autoUpdateEnabled). When it is on, CC Switch
checks one minute after launch and then every six hours, downloads and
verifies the new version in the background, and shows a small prompt in the
bottom-right corner of the main content area asking whether to install now.
Installing restarts CC Switch, which cuts requests going through the local
route, so it never happens without the user's click; the prompt says so when
the route is in use. The tray menu and tray panel also get a "Restart to
update to vX" entry.

The downloaded package is kept in a process-level cache in Rust
(app_update::PENDING), not in React state: lightweight mode destroys the
main window, and the download must survive that. It lives in memory only.

- install_update_and_restart checks again first and reuses the cached bytes
  when the version matches; offline it falls back to the cached package; if
  the server no longer offers an update the cache is dropped and the prompt
  and tray entry are withdrawn (app-update-ready with null).
- The cache is copied, never taken, so a failed install can be retried.
- The prompt, About page and tray share one install lock. begin_install uses
  an explicit if: then_some would build the guard eagerly and its Drop would
  release a lock held by another entry point.
- Portable builds and Linux installs other than AppImage cannot self-install;
  the switch is disabled there with the reason. Debug builds skip the
  background loop because dev shares settings.json with the release app.
- "Later" hides the prompt for that version only; the settings dot, the About
  button and the tray entry still offer the install.

Tested: new unit tests for the install lock, the tray item, the prompt and
UpdateContext (a downloaded package counts as an update when the online
check fails; rechecks run once per version). End to end on macOS with a
4.0.30 build in a sandboxed HOME: the switch downloaded and verified 4.0.31
in about 9 s, the prompt, tray entry and "Later" behaved as intended, and
installing from the cache restarted into 4.0.31.
2026-11-14 03:59:30 -08:00
Jason 24eb40c695 fix(proxy): rectify Codex streams rejected for replayed ciphertext after HTTP 200
Resuming a Codex thread on another native Responses upstream replays the
previous upstream's reasoning items and encrypted function-output parts. Some
relays accept the request with HTTP 200 and then fail the stream before any
output ("Encrypted function output content could not be decrypted or
decoded."). The stream had already been handed to Codex, so the opaque-state
rectifier never saw the rejection; Codex reconnected five times with the same
history and the turn was lost (proxy logs showed status 200, zero tokens).

The stream was only held until its first output event when the request ended
with an encrypted sub-agent task. Hold it whenever the request carries
upstream-issued state the rectifier can strip (reasoning items, encrypted
parts in function outputs or agent messages, compaction items). A rejection
before output then returns to the retry loop as an upstream 400, is
rectified, and is retried once on the same provider. Requests without such
state are not held and stream exactly as before; request bodies are never
changed on the working path.

Also recognise the function-output wording when a relay prefixes it with its
own text.

Verified end to end with codex-cli 0.167.0 against an isolated debug build:
A answers with encrypted reasoning, then returns a quota 403; failover hands
the resumed turn to B, which fails the stream before output. With the fix the
turn and the next one succeed on B; the previous build reproduces the five
reconnects and the same error.

Refs #9476
2026-11-14 03:59:13 -08:00
SaladDay 1863149fc5 refactor(apps): derive app capability lists from one AppSpec table (#9495)
Each app's capabilities now live in one table on each side: APP_SPECS in src/config/appSpecs.ts and AppType::spec() in app_config.rs. Every app must declare every capability, so adding an app without one fails to compile. The hand-written app lists, aliases and guards they replace are deleted.

The Rust test app_specs_match_shared_fixture writes tests/config/appSpecs.json from AppType::spec, and tests/config/appSpecs.test.ts checks that APP_SPECS lists the same apps in the same order and agrees on the four shared capabilities. Route-mode apps keep their old order, with Claude Desktop last. Behavior does not change.
2026-11-14 03:52:35 -08:00
SaladDay 8c76bfe1e2 fix(database): recover the connection lock after a task panics while holding it (#9472)
A panic while holding the shared connection lock poisoned the Mutex for the rest of the process, so every later read and write failed: the tray menu came up empty, providers could not switch, and the exit handler could not restore direct mode. Locking now takes the poisoned value back, rolls back a transaction the panicking task left open, clears the poison and continues. If the connection is still in a transaction afterwards because the rollback failed, the lock stays poisoned and an error is returned. The five direct lock sites in the proxy DAO go through the same path. The request-log count cache, locked through the same macro, is simply cleared.

Builds on the recovery approach from #8107.

Fixes #8058

Co-authored-by: Yanxcyan <yanxsir@gmail.com>
2026-11-13 07:28:34 -08:00
Thefool 761b4c0244 fix: recover configuration locks and caches after panics (#9483)
Recover the settings RwLock, file-operation locks and session caches after a panic instead of failing until restart, and roll back interrupted configuration writes.

Co-authored-by: Allen Xu <171831965+allenxu09@users.noreply.github.com>
2026-11-13 07:14:25 -08:00
SaladDay 7dec90e982 chore: remove unused code, dependencies, and files (#9492)
Delete Rust items marked #[allow(dead_code)] that nothing in src/ or
tests/ references: get_opencode_env_path, get_provider_config_path and
its only helper sanitize_provider_name, OpenClawAgents, categorize_error,
HandlerConfig with its four constants, update_proxy, is_proxy_enabled,
and CODEX_CLIENT_REGEX.

Drop dependencies no code imports: tower-http and http-body in
Cargo.toml, and @radix-ui/react-accordion, react-checkbox,
react-scroll-area, and react-tabs in package.json.

Delete files nothing imports: ListItemRow, the accordion, card,
scroll-area, table, tabs, and toggle-row UI components,
useDebouncedValue, and scripts/measure-renderer.mjs.

Delete 54 one-line doc comments in src-tauri/src/commands that only
repeat the function name, and the step labels in
ClaudeAdapter::is_github_copilot. The note on why the base_url
fallback exists stays.
2026-11-13 02:59:29 -08:00
SaladDay 86c749b98e fix(proxy): route responses-only Copilot models through Responses for Claude (#9473)
Claude and Claude Desktop requests through a GitHub Copilot provider picked the upstream protocol by vendor, so a non-OpenAI model that only advertises /responses (such as xAI grok) was sent to /chat/completions and rejected by Copilot. Such models now use the Responses bridge; models that also support chat completions keep their current protocol. The check reuses the Codex path's transport_for, which now takes the advertised endpoint list instead of the whole model, so /v1-prefixed paths and query strings are recognized the same way.
2026-11-13 01:28:28 -08:00
Jason 0bb502cb60 ci: allow any two maintainers to approve and merge PRs
Relax CODEOWNERS so only `.github/` still requires the owner's approval;
everything else can be merged once two maintainers approve, by any
maintainer pressing merge.

Add a `CI gate` job that aggregates every CI job (success or skipped
passes, anything else fails). Jobs are skipped by the path filter, so
they cannot be required individually; this single job will be the only
required status check on `main`.
2026-11-13 00:31:37 -08:00
anysdk2023 db7a0e755a fix(providers): show bound GitHub account on Copilot provider cards (#9228) 2026-11-12 19:19:23 -08:00
Jason 3c76d3bda6 docs(release): add v4.0.31 release notes v4.0.31 2026-11-12 07:35:55 -08:00
Jason c3cf24ca6f chore(release): v4.0.31 2026-11-12 07:35:55 -08:00
Jason e91114fe21 fix(proxy): log final usage for Gemini Native streams converted to Anthropic
Two stages of the Gemini -> Anthropic streaming usage path could leave
the request log with stale counts:

- streaming_gemini only refreshed latest_usage inside candidates.first(),
  so a terminal usage-only frame (empty or absent candidates, often the
  only frame carrying cachedContentTokenCount) was dropped once an earlier
  frame had reported usage. Usage is now taken from every frame that
  carries a usageMetadata object.
- The usage collector parsed the converted SSE with the generic Claude
  parser, which only adopts a message_delta input_tokens smaller than the
  message_start one. Gemini can grow promptTokenCount in its final frame,
  so the smaller early count was kept. Gemini-converted streams now use
  from_converted_claude_stream_events, which treats the last message_delta
  usage as the authoritative final snapshot for input, cache read and
  output. Other formats keep the existing parser.

Refs #9464
2026-11-12 07:26:36 -08:00
Jason da830bfd1a fix(proxy): keep mid-conversation system messages in place for Gemini Native
anthropic_to_gemini collected every role=system message in `messages`
into the leading systemInstruction. Claude Code appends a fresh
`<total_tokens>N tokens left</total_tokens>` system message every turn,
so the instruction ahead of the whole history changed on each request
and the upstream implicit prefix cache missed everything after it
(about 21% hit rate on long sessions). #6941 fixed the same hoisting for
the OpenAI Chat conversion.

Only system messages that lead the conversation are still hoisted into
systemInstruction. Later ones stay at their position as a user content
(Gemini contents have no system role), so the converted request is
append-only across turns. A system message wedged between a function
call turn and its function response is emitted right after the
response, keeping the call/response turns adjacent as Gemini requires.

Refs #9450
2026-11-12 07:26:36 -08:00
Jason 86aeb47a6a fix(skills): include the OS error when creating a skill symlink fails
The command layer hands errors to the UI with `to_string()`, which only
prints the outermost anyhow context. `create_symlink` attached its
"failed to create symlink" message with `with_context`, so the underlying
io::Error (e.g. Windows `os error 5`) never reached the user, and reports
like #9439 had no way to tell a permission problem from a third-party
hook or a path issue.

Build the message with the io::Error inlined so the OS error code is
visible, and fold the unix/windows variants into one function. Behavior
of callers is unchanged; a failure reported by the OS is still a failure.

Refs #9439
2026-11-12 07:26:36 -08:00
Jason 72fe4edf0c feat(usage): list common gateway error codes in the request log status filter
The status filter only offered 200/400/401/429/500, so errors that
gateways and upstreams return themselves (502/503/504, Cloudflare 520,
Anthropic 529, 403/404) could not be filtered for.

Extend the preset list with those codes instead of adding a free-form
input inside the dropdown menu, which would fight Radix's menu keyboard
handling for a long-tail need.

Refs #9425
2026-11-12 07:26:35 -08:00
Jason 457f898c77 fix(usage): import Codex forks numbered from the parent cutoff ordinal
Codex 0.167 (Desktop 26.1103) resumes or forks a finished thread into a
new single-UUID rollout whose root session_meta carries forked_from_id
and forked_from_ordinal_exclusive, and whose own records continue from
that ordinal without copying the parent history. CC Switch treated it as
an ordinary fork and waited for the parent timeline to reach the child's
session_meta time before stripping replayed events. A finished parent
never writes past that point, so the child stayed deferred forever and
none of the resumed thread's usage was imported.

Accept such a child without parent replay alignment when its root meta
ordinal equals a positive forked_from_ordinal_exclusive and every
billable event has exact last_token_usage and a timestamp after the fork
(the per-event check shared with the bounded-history fork path). Any
other shape keeps the existing timestamp-aligned or deferred path.

Refs #9420
2026-11-12 07:26:35 -08:00
Jason 18f856159b feat(skills): add "Resync now" to the Skills page more menu
Resyncing enabled Skills to the apps was only reachable from inside the
"Storage and sync" dialog (more menu -> Storage and sync -> Resync now),
which takes several clicks for an action people repeat after changing
Skills by hand.

Add the same action directly to the Skills page more menu, next to
"Storage and sync", like the MCP page already has. The resync call and
its success / partial-failure toasts move into a shared useSkillsResync
hook used by both the menu and the dialog. The menu entry takes the
page write lock, and both entries share one in-flight state through a
mutation key so a resync started from one cannot run concurrently with
one started from the other.

Refs #9417
2026-11-12 07:26:35 -08:00
Jason c1bf062d21 feat(sessions): fold Codex desktop project-less chats into one group
Codex desktop creates a fresh working directory for every chat that is
not attached to a project, at <Documents>/Codex/<YYYY-MM-DD>/<slug>, and
lists them together under "Recent" in its sidebar. The session manager's
"By project" view grouped sessions strictly by projectDir, so each of
those chats became its own one-session group and buried the real
projects.

groupSessionsByProject now recognises that directory shape (Windows or
POSIX separators, case-insensitive) and puts the matches into a single
"Codex chats" group whose path is the <Documents>/Codex root. Deeper
subdirectories and everything else keep grouping by their own directory.
Adds the sessionManager.codexChats label in all eight locales.

Refs #9415
2026-11-12 07:26:35 -08:00
Jason 36041067b1 fix(copilot): label the unbound account option as following Copilot CLI's login
On the official GitHub Copilot CLI card the account dropdown's empty option
read "Use default account", so users with a single Auth Center account
(shown as "Default") left it unbound expecting that account to be used.
Unbound actually means copilot runs with its own GitHub login and the quota
footer follows ~/.copilot/config.json, which reported "Copilot CLI isn't
signed in" for anyone who had only signed in through CC Switch.

CopilotAuthSection now accepts a noneOptionLabel (same pattern as
CodexOAuthSection's "Follow Codex login"), and the Copilot CLI form passes
"Follow Copilot CLI's own sign-in" in all eight locales. Claude, Codex and
Claude Desktop Copilot cards, where unbound really is the Auth Center
default account, keep the old label.

Refs #9408
2026-11-12 07:26:35 -08:00
Jason 3706cac35f fix(clipboard): try the WebView clipboard first on Linux
On KDE Plasma Wayland every copy button that goes through copyText
reported success while the clipboard stayed empty or kept the old text.
copyText called the copy_text_to_clipboard command first, which creates
an arboard Clipboard, writes and drops it right away. On Linux the
selection owner goes away with it, and when no clipboard manager takes
the content over nothing is left to paste. The command still returns
Ok, so the web fallback never ran. The reporter confirmed the one button
that calls navigator.clipboard.writeText directly (copy resume command)
works on the same machine while every copyText button fails, also with
GDK_BACKEND=x11.

On Linux copyText now writes through the WebView first, which GTK keeps
owning, and falls back to the native command if the WebView refuses.
macOS and Windows keep the native-first order. The backend and its
dependencies are unchanged.

Refs #9384
2026-11-12 07:26:35 -08:00
Jason 6463262c7c fix(apps): require Claude.app on macOS to count Claude Desktop as installed
After Claude Desktop is uninstalled on macOS (Claude.app dragged to the
Trash), ~/Library/Application Support/Claude stays behind. The installed
check accepted that data directory as proof of an install, so the Apps
page kept listing Claude Desktop under "Installed" (as "Not connected").

On macOS the check now looks only for the app bundle in /Applications or
~/Applications; the leftover data directory no longer counts. Windows and
Linux have no fixed install location to probe, so they still rely on the
`Claude` data directory. A connected Desktop is still counted as
installed, as before.

Refs #9383
2026-11-12 07:26:35 -08:00
Jason f1d438e0aa fix(codex): use the configured display name on mirrored official GPT rows
Rows of a third-party Codex provider whose model id matches an official
OpenAI entry (exactly or by longest prefix) are generated by mirroring the
official catalog entry. That path ignored the row's displayName, so
cc-switch-model-catalog.json carried the official name or the raw slug and
the Codex model picker never showed the configured name.

codex_official_model_entry now takes the row's display name and uses it
for display_name; prompts, tools and reasoning levels stay official. The
reverse parse restores displayName next to the model and explicit window.
A renamed mirror is still recognised as a mirror because it keeps the
official description, while old ProxyChat template clones (description =
display name) keep falling through to the full restore so their user
values survive.

Refs #9380
2026-11-12 07:26:35 -08:00
Jason f6423b5d84 fix(codex): apply the keep-official-login toggle to the current third-party provider
Turning "Keep official login for direct switches" off while Codex was
already on a direct third-party provider changed nothing: auth.json kept
the ChatGPT login and the custom table kept requires_openai_auth = true.
save_settings only stored the flag, and the flag is read only when a
provider is switched or applied, so users had to switch to the official
card and back before it took effect.

When the flag changes, save_settings now re-applies the current direct
third-party Codex provider under the switch lock (new
reapply_current_codex_third_party_live, modelled on the unified-history
reapply). Turning it off stashes the login and writes
requires_openai_auth = false right away. Proxy mode, official cards and
an empty pointer are no-ops. If the rewrite fails the flag is rolled
back and the save reports an error, like the neighbouring Codex toggles.

Refs #9367
2026-11-12 07:26:35 -08:00
Jason 063c22d8df fix(tray): show the macOS quick panel over full-screen apps
Clicking the menu-bar icon while another app was in a full-screen Space
showed nothing; outside full screen the panel appeared normally. The
panel window is built with `visible_on_all_workspaces(true)`, which tao
implements by only adding NSWindowCollectionBehaviorCanJoinAllSpaces.
That flag lets the window follow ordinary desktops but not join another
app's full-screen Space, so the panel was ordered in on a Space the user
could not see.

Add NSWindowCollectionBehaviorFullScreenAuxiliary to the panel window's
collection behavior in the macOS platform init, on the main thread and
before the window is first shown (also re-applied when lightweight mode
recreates the window). tao's set_focus already activates the app, so no
extra activation is needed.

Refs #9331
2026-11-12 07:26:35 -08:00
Jason cf319bcf35 fix(dsh): offer the compatibility editor on custom models
DeepSeek Harness's pi-ai adapter sends the system prompt as
role "developer" to reasoning models unless the model declares
compat.supportsDeveloperRole: false. Endpoints such as DashScope's
compatible mode reject that role with a 400.

CC Switch already writes a model-level compat object to the DSH
profile, and the presets carry the switches they need, but the
provider form only rendered the compatibility editor when the model
already had a compat object. Models added by hand (custom provider,
fetched or typed model ids) had no way to set it outside the raw JSON
editor.

Render the editor for DSH models without compat too, starting empty.
Nothing is written until an option is added; non-object compat values
keep falling back to the generic model-properties editor.

Refs #9330
2026-11-12 07:26:35 -08:00
Jason c0a8d87b19 docs(readme): add Traditional Chinese, Korean, Turkish and Russian READMEs
The app ships eight UI languages but the README existed in four, so a
Korean, Turkish, Russian or Traditional Chinese reader found the app in
their language and no README in it. Add README_ZH-TW, README_KO,
README_TR and README_RU, translated from the English README. UI names
quoted in each follow that language's locale file, so they match what
the app shows. Every language switcher now lists all eight READMEs, the
feature list names German among the UI languages, and README_DE quotes
the German UI labels instead of the English ones.

A README has no per-line fallback, so a missed edit leaves a stale page.
readmeParity.test.ts checks each README against the English one: the
language switcher links the other seven, the heading structure matches,
the sponsor table has the same number of rows, and HTML links and
images appear in the same order. README_ZH is the mainland edition with
its own sponsor landing pages and banners, so only its row count is
checked. The traditional Chinese edition uses the international links.

README*.md now triggers the frontend CI job, so a README-only change
still runs this test.
2026-11-12 07:26:35 -08:00
Jason 51a96e24ba feat(i18n): add German as an eighth UI language
German joins the language picker and is chosen on first launch when the
system language is German. Only whole subtags match, so dsb or del stay
on English. Dates and provider sorting use de-DE, the backend accepts
"de" as a saved language and answers JSON/TOML format errors in German,
and localized backend errors show their English half. The native tray
menu and the tray panel get a full German block of their own.

de.json covers every English key and is checked by localeParity with
the other locales. Wording was reviewed in a debug build: labels that
did not fit their slots use shorter German (Woche/Monat for usage tiers,
"Routing nötig", "Drittanbieter", "Kontingent unbekannt"), and the
sidebar's Settings entry is "Optionen" because "Einstellungen" does not
fit next to Apps. Hints that point to the Settings page use the same
name. "Listen-Adresse" replaces the misleading "Lauschadresse".

Privacy filter placeholders stay English for German, as for Korean and
Russian; they only appear in prompts sent to the model.

Tests that used de-DE as an example of an unsupported system language
now use it-IT.
2026-11-12 07:26:35 -08:00
Jason 0f593e9fd6 fix(sidebar): size the bottom Apps and Settings items by their labels
The two items at the bottom of the sidebar each took exactly half of the
row, so a short label like "Apps" kept space it did not need while the
other label was cut off. Even an eight-letter German "Optionen" showed
as "Optio…", and Turkish and Russian labels were truncated the same way.

Let both items start from their own text width and split the leftover
space, so a short label leaves room for a longer one next to it.
2026-11-12 07:26:35 -08:00
Jason 29aed90404 feat(workbuddy): label models by vendor and flag duplicate model IDs
WorkBuddy shows a custom model as "name:id", so preset models named
"Kimi K3.1 Pro" read as "Kimi K3.1 Pro:kimi-k3.1-pro" in its picker.
Presets no longer carry model names; when a model has no name, the
models.json writer fills in the vendor label, so the picker reads
"Kimi:kimi-k3.1-pro". The filled-in name is dropped on read-back, so
renaming the vendor label follows through.

WorkBuddy uses the model ID both as the lookup key and as the model name
sent upstream, and has no field for a separate upstream name, so one ID
can only live in one card. A new workbuddy_model_owners command lists
the IDs already in models.json and who owns them. Choosing a preset now
skips models another card holds and says which; an ID typed into a row
that is taken elsewhere is marked and blocks saving. The messages say
up front that WorkBuddy doesn't support adding the same model twice yet,
and the backend conflict error is now bilingual.

Checked on WorkBuddy 5.9.3: adding OpenCode Go skips glm-5.3,
glm-5.3-flash and kimi-k3.1-pro (held by the Zhipu GLM and Kimi cards),
the remaining four models are written with the name "OpenCode Go", and
models.json keeps unique IDs.
2026-11-12 07:26:35 -08:00
Jason fd97942138 fix(proxy): merge Gemini tool results split across user messages
Anthropic treats consecutive user messages as one turn, so results of
parallel tool calls may arrive spread over several user messages. The
Gemini Native converter turned each message into its own user content,
leaving fewer functionResponse parts after the functionCall turn than
there were calls, and Gemini rejected the request with "the number of
function response parts is equal to the number of function call parts".

Merge a run of consecutive user messages when two or more of them carry
tool_result blocks, so every function response lands in one content and
the remaining parts in the next. Runs without split results keep the
original messages untouched, so already working histories convert to
the same bytes and the prompt cache prefix is preserved.

Fixes #9453
2026-11-12 07:26:35 -08:00
Jason acdab9c9a6 feat(workbuddy): offer thinking effort levels for preset models
WorkBuddy custom models only showed a thinking on/off switch. Its model
picker lists effort levels from a model's `reasoning` block, and its CLI
translates the chosen level through `thinkingLevelMap` with the same
semantics as Pi.

Derive both from the reviewed Pi thinking maps when building WorkBuddy
presets: null levels are unsupported, xhigh/max must be explicit, and
`off` decides whether thinking can be turned off. Default to `high`
when available, else the highest supported level. Models whose Pi map
is empty (Pi runtime defaults) get no effort list and keep the switch.

Verified in WorkBuddy 5.9.3: Kimi K3.1 Pro lists low/high/max without a
switch, DeepSeek V4.1 Flash lists high/max behind the switch, and
choosing max sends reasoning_effort=max upstream.
2026-11-12 07:26:35 -08:00
Jason 61bd4d4220 fix(workbuddy): word the quit-first prompt as switching, not adding
The prompt shown when WorkBuddy is still running said "Quit WorkBuddy
before adding" and "click Add again". It now also appears when switching
from the Auth Center menu, so it talks about switching accounts, which
is what the official card's Add does as well.
2026-11-12 07:26:35 -08:00
Jason f2420dc855 feat(workbuddy): switch accounts from the Auth Center menu
Each WorkBuddy account's menu gets "Switch WorkBuddy to this account",
like Kimi and Antigravity. It runs the same switch as adding an
official card in the provider list (shared useWorkBuddySwitch hook),
so it still asks to quit WorkBuddy first, and the official cards follow
because their Added state is derived from the signed-in account.

Kimi, agy and WorkBuddy now share one in-use badge and one switch label
(authCenter.inUseBy / authCenter.switchAppTo with {{app}}) instead of
per-app keys that had drifted apart, e.g. Kimi's "Use this account" and
the Turkish and Russian badge wording. Korean and Turkish use phrasings
that read correctly with any app name.
2026-11-12 07:26:35 -08:00
Jason 4587b5c0a7 feat(workbuddy): show when credits expire
The resource summary only carries totals, so expiry dates were missing.
After the summary, also query the free/paid package details over the
same WBIPC session (the read-only requests WorkBuddy itself sends, paid
only when the summary lists a paid package) and record each package's
remaining credits and expiry: the earlier of the resource end and the
current cycle end, since unused monthly credits lapse at cycle end.
Billing date strings are Beijing time; far-future placeholders count as
no expiry; daily slice resources and used-up packages are skipped.
A failed detail query keeps the totals.

The card's second line now shows the earliest expiry (orange within
three days, taking precedence over the stale note only then) with a
per-date breakdown, and the auth center gets an Expires row.
2026-11-12 07:26:35 -08:00
Jason 4151bc33d6 fix(proxy): retry Claude Responses requests rejected for replayed reasoning
Claude Code routed to an OpenAI Responses upstream replays the upstream's
reasoning items (rs_ id + encrypted_content), which the bridge carries in
thinking-block signatures. A relay that load-balances one session across
several Azure OpenAI resources then gets HTTP 400 "The requested item was
created under a different Azure OpenAI resource"; switching provider mid
session gets invalid_encrypted_content instead. Once the history holds
items from two resources no request can succeed, so the session is stuck.

The opaque-state rectifier already recognises both rejections, but its
retry was gated to Codex / Grok Build native Responses, and it rewrites
the Responses `input`, while the Claude retry loop still holds the
Anthropic Messages body (conversion happens inside forward()).

- Let Claude / Claude Desktop through the opaque-state retry and rectify
  on the Anthropic body: drop thinking / redacted_thinking blocks that
  carry a Responses reasoning envelope (plain thinking is left alone, it
  is never replayed), and only for the foreign-resource rejection also
  drop hosted web search call/result pairs, whose ws_ id cannot be
  removed on its own. Messages left empty are removed. Retry once.
- A rejection reported after HTTP 200 (response.failed / error before
  output, or a 2xx failed Response object) is now surfaced as an upstream
  400 on the Claude Responses path, so it is rectified like the HTTP case
  instead of failing over as a transform error.
- Skip the thinking-signature rectifier after the opaque retry: its broad
  "invalid request" fallback would resend the unrectified body as a third
  request.

The working request path is unchanged; this only runs after the upstream
has rejected the request.

Refs #9424
2026-11-12 07:26:35 -08:00
Jason 60a68363f6 chore(clippy): fix lints in test code flagged by clippy --all-targets
Build the language-normalization test settings with struct update syntax
(field_reassign_with_default) and borrow the single DSH profile path with
std::slice::from_ref instead of cloning it (cloned_ref_to_slice_refs).
CI runs clippy without --all-targets, so these #[cfg(test)] lints slipped in.
2026-11-12 07:26:35 -08:00
Allen Xu 664a46ab88 feat(privacy-filter): filter at the forwarder egress and speed up detection (#9460)
Move the privacy filter from the handler entry points into the forwarder so it runs on every attempt: on the client-format body, after Copilot cleanup/merging, on a temporary copy of local body overrides, and on the final upstream body. This also covers CC Switch's own compaction summaries, Gemini countTokens wrappers and Alpha Search queries. Tool definitions are left untouched, and content-derived IDs keep plain SHA-256 over the filtered body. Keyword prefiltering for gitleaks rules now uses a single Aho-Corasick automaton with identical output.
2026-11-12 07:16:59 -08:00
Allen Xu 4376e5dfa9 perf(codex): reduce rollout parsing allocations and redundant scans (#9400)
Keep only timestamp, event type and token info when loading parent
timelines, validating skipped values without building Value trees and
accepting legacy non-object payloads in one pass. Reuse the line buffer,
short-circuit repeated full-line searches, use static line-head search
patterns, and validate unterminated final records without building a
Value tree. Last-key-wins, legacy payload types, non-token timestamps and
JSON validation (invalid UTF-8, Unicode escapes, numeric overflow, nesting
depth) are unchanged. The manual replay harness accepts CODEX_REPLAY_ROOT
and also covers archived_sessions.
2026-11-12 05:08:36 -08:00
zhjyz2 cf341a8aeb fix(claude): treat CLAUDE_CODE_SUBAGENT_MODEL_FORCE as a provider-exclusive env field (#9455)
Route mode builds the Claude live contract from key fields plus provider-exclusive env fields. FORCE was registered as a key field, so it never made it into the contract and was cleared whenever the route was attached. Reclassify it as provider-exclusive: written with the provider, removed on switch-away only while the value still matches what the previous provider wrote, and kept when the user sets it globally.

Fixes #9451
2026-11-12 16:08:39 +08:00
Owlbay d0da1349f9 feat(workbuddy): add WorkBuddy support with official account switching (#8757) 2026-11-12 15:50:52 +08:00
jinyule 479e632a69 fix(tray): stop setting the tray tooltip on macOS (#9446) 2026-11-12 15:42:29 +08:00
Jason d300a120bf docs(readme): move AICodeMirror ahead of PackyCode in the sponsor table 2026-11-11 23:06:02 -08:00
Jason 3a0b86a266 docs(release): add v4.0.30 release notes v4.0.30 2026-11-12 09:12:45 +08:00
Jason 609e791427 chore(release): v4.0.30 2026-11-12 09:12:45 +08:00
Jason 08ec82aabc fix(proxy): strip every OpenAI-only Codex field for third-party Responses upstreams
Since third-party routes are written as the built-in openai provider (905c91485), Codex takes its is_openai() branch and sends fields only the ChatGPT backend accepts. Strict gateways reject the whole request, e.g. LiteLLM and a DeepSeek relay answer 400 for input[*].internal_chat_message_metadata_passthrough (#9042). The earlier fix only removed the include marker.

Mirror the !is_openai branch of codex-rs build_responses_request for native Responses requests to non-official upstreams: the output.encrypted_content include marker, stream_options.reasoning_summary_delivery, configuration_update items, per-item internal_chat_message_metadata_passthrough, encrypted_content on the item types Codex clears (reasoning and compaction keep theirs), and function_call encrypted_function_args. Also drop top-level access_programs, which Codex only sends with a ChatGPT login. ChatGPT managed accounts are now exempt as well as the official card. Requests without these fields stay byte-identical.

Verified with codex-cli 0.167.0 through the proxy against a strict upstream: two turns including a resume succeed; with the gate disabled the same 400 comes back.
2026-11-12 08:52:43 +08:00
Jason 23c57e8d89 fix(copilot): derive maxPromptTokens from the context window and output limit
Copilot limits input by maxPromptTokens (default 128000) and only uses maxContextWindowTokens as a cap, so cards that set just the window still showed 128K. When a model has a window and a max output but no maxPromptTokens, write window minus output. Values the user set are kept, and the derived value is dropped when reading back so it keeps following the card.
2026-11-12 08:52:43 +08:00
Jason 4a1369f26a refactor(copilot): fold the official login card into the added group
The official card is still launch-only, but it no longer gets its own section. It now sits first in the added group and counts toward its total, matching the other additive apps. Drop the unused copilot.section locale keys in all seven languages.
2026-11-12 08:52:43 +08:00
Allen Xu 2abcaa6ee0 fix: show account identity for Codex OAuth provider cards (#9300)
Co-authored-by: Jason <farion1231@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 23:42:58 +08:00
wyr-zal d4647fbbf5 fix(skills): move local metadata refresh off the list query (#9316)
- Keep get_installed_skills read-only: return the DB snapshot via run_db_task without scanning SSOT directories
- Add refresh_local_skill_metadata as a separate async command on the blocking pool; scan hashes outside the global skill write lock and re-check installed_at, directory, and previous content_hash before writing back
- Trigger the refresh from a separate frontend query with staleTime Infinity; invalidate the installed list only when metadata changed
- Add backend tests for repo-skill exclusion and concurrent updates, plus hook tests for refresh and invalidation behavior

Refs #7848
2026-11-11 23:36:54 +08:00