Commit Graph
13 Commits
Author SHA1 Message Date
funkpopo e4873bc8aa feat(kimi): add Kimi Code support (#8687)
Add Kimi Code as the 12th managed app (additive mode): native multi-provider config in ~/.kimi-code/config.toml (honors KIMI_CODE_HOME), presets derived from the Pi catalog, MCP (stdio/HTTP/SSE), Skills with native-directory protection, global prompts, session browsing/resume, and session-log usage import. Local routing and aggregation do not apply; official OAuth stays managed by Kimi Code. Schema v21 -> v22 adds enabled_kimi columns.
2026-10-22 16:50:37 +08:00
Jason b194cc09ac feat(usage): show requests or cache hit rate in the sidebar Today label
The sidebar Today label can now show requests and cache hit rate besides
cost and tokens. Up to two items can be picked, since two already take
both lines of the sidebar row; once two are ticked the rest are greyed
out. Items are kept in menu order, and the hit rate is left out before
the first request of the day.

The setting becomes a list, sidebarTodayItems, where an empty list means
hidden. The old single-value sidebarToday key was never released, so it
is not read.
2026-10-16 19:29:24 +08:00
Jason 9d83b2e872 fix(usage): drop the ≈ mark and cap decimals on converted amounts
Converted amounts no longer start with ≈; it took room and the USD value
is still shown on hover. Since the rate is entered by hand, converted
amounts now show at most two decimals (yen keeps two fewer), instead of
the 4–6 used for USD in logs and hover text. An amount that would round
to zero is written with two significant digits rather than as 0.00.
2026-10-16 19:29:24 +08:00
Jason 8f3337d993 feat(usage): choose what the sidebar Today label shows
The usage settings tab gets a "Sidebar Today" control: cost (default),
tokens, both, or hidden. Tokens use the same real-consumption total as
the usage page card, and a zero part is left out.

The sidebar row no longer lets the trailing text squeeze the item name:
the name keeps its width and the trailing text wraps at the space. With
both values the row shows only the two numbers on two lines; the full
"Today ..." text moves to the hover tooltip and the accessible name.
2026-10-16 19:29:23 +08:00
Jason 4e20fad5dc feat(usage): show usage amounts in a chosen currency
Add a Settings tab to the usage page that replaces the Pricing tab: an
amount display section on top (currency + hand-entered exchange rate) and
the existing pricing configuration below.

- Display currencies: USD, CNY, EUR, JPY, TWD, TRY; USD stays the default.
  Rates are entered manually; untouched preset rates are not written to
  settings.json so later preset updates still reach those users.
- Costs stay stored in USD; conversion only happens at display time.
  Converted amounts carry a "≈" prefix and hovers add the USD value.
- Chart data is converted before plotting so axis ticks stay round.
- Yen drops two decimals, and usage amounts now group thousands.
- The sidebar "Today" amount drops decimals from 100 up so it no longer
  squeezes the nav label.
- Settings are device-local (`usageDisplay` in ~/.cc-switch/settings.json).
2026-10-16 19:29:23 +08:00
Jason 85ae0c7ba2 refactor(usage): route usage amounts through one money formatter
Usage amounts were formatted in several places, each gluing "$" onto the
number itself: fmtUsd in format.ts, the request detail panel, the trend
chart's axis ticks and the session reader's own formatCost. Before a
display currency can be added, every one of them has to go through a
single path.

- Replace fmtUsd with formatMoney / formatMoneyCompact / formatMoneyTick.
  They take the display currency as a required argument, so a call site
  that is not converted fails the type check instead of silently showing
  dollars.
- Add useMoneyFormat(): the usage dashboard, the sidebar "Today" label
  and the session reader all format through it. It is fixed to USD for
  now; the setting will be wired in here.
- The session reader's markdown export takes formatCost in its options,
  so copied text uses the same currency as the screen.
- Pricing (entered in USD), quota and balance footers (the provider's own
  currency) and the Codex credit conversion are deliberately untouched.

No visible change: every amount renders exactly as before.
2026-10-16 19:29:23 +08:00
alkankandJason c21106ff20 feat(i18n): add Turkish interface and tray localization (#8208)
* feat(i18n): add Turkish interface and tray localization

* fix(i18n): preserve technical literals in Turkish help

* fix(i18n): treat Turkish as a community translation

Turkish falls back to English for strings it does not have yet, so new
English strings no longer fail CI or the build until someone translates
them:

- Drop the full-catalog parity check and the Pi coverage checks for tr;
  keep the non-empty and interpolation checks for existing strings
- Build the Turkish tray texts from English and override the translated
  ones, so new tray items no longer need a Turkish entry to compile
- Show usage script errors in English for Turkish instead of Chinese
- Label the option as a community translation, next to the other
  languages, using the native name like the existing options
- Restore technical literals that were translated (config.toml, AKSK,
  env placeholders, # SOUL.md, skills.sh, my-provider) and lock them in
  the literal regression test
- Format usage dates with tr-TR
- Document in CONTRIBUTING that Turkish strings are optional, and list
  Turkish as a community translation in the READMEs

---------

Co-authored-by: Jason <farion1231@gmail.com>
2026-10-14 12:22:41 +08:00
Jason a0dd3b3936 feat(usage): show first-token time in stats and estimate it without routing
The routing service has always recorded first-token time, but the usage
page only surfaced it in a hover tip and the request detail panel.

Provider and model stats gain a First token column with the median over
successful streaming requests through the routing service. The median
keeps an occasional slow request (queueing, cold start) from pulling the
number up. The request log table gains a First token column after Speed.

Without routing, first-token time is now derived from session logs and
shown with ≈:
- Claude Code: when a reply starts with a thinking block, the block's
  write time minus thinkingDurationMs (timed from content_block_start to
  content_block_stop) gives the moment output began.
- Codex: newer rollouts record started_at_ms on item_completed; the
  earliest reasoning or agent message item of a request marks its start.
Replies that open with text or a tool call yield no estimate. A real
log replay derived 9,586 Claude Code and 10,406 recent Codex values,
with medians of 1.95s and 2.69s (routed Codex: 2.6s).

The estimate is stored in first_token_ms, so exact and estimated values
are now told apart by data_source instead of a NULL first token. The
estimated speed still divides by the whole duration, since only some
rows have a first token. Rows imported before this change are not
backfilled.
2026-10-12 23:26:43 +08:00
Jason 37c8da1b87 feat(usage): show estimated speed for requests imported from session logs
Session-log requests now show a speed marked with "≈" in the request
log, the request detail and the provider table, computed from the
duration the importers estimate from log timestamps. The estimate
includes the wait for the first token, so it is kept apart from the
exact routed speed: a provider row falls back to it only when it has no
routed data, and the help text says the figure reads low.

Requests under 200 output tokens get no estimate, because the first-token
wait dominates there: measured against long replies, 200-300 token
requests read about a quarter low and 100-200 about 40% low. A higher
bar left most Codex rows empty, since only a quarter of Codex requests
exceed 500 output tokens.

The detail panel shows "Duration (estimated)" for these rows and says
why a short reply has no estimate. Help text is updated in all four
locales.
2026-10-03 23:28:59 +08:00
Jason b999b07bec feat(ui): rebuild the global pages and finish the v7 visual pass
Pages (phase 4):
- Usage: v7 layout (filter row, four metrics with more on demand,
  switchable trend, request log / provider / model / pricing tabs, data
  sources sheet). Latency becomes output speed: output / (duration -
  first token), shown only for requests with at least 100 output tokens;
  provider totals sum output and generation time instead of averaging.
- Sessions: single-column list grouped by project or time, drilling into
  a reader with resume, find, question jump and copy actions.
- MCP and Skills share one app matrix (neutral checks, retry on failed
  writes, column bulk actions with undo); MCP add/edit moves into a
  drawer with form/JSON modes; Skills merges installed and discover and
  always shows a Pi column.
- Prompts: one page for eight apps including Hermes SOUL.md, enable and
  disable as buttons, delete with undo instead of a confirm, copy to
  other apps, import existing files; app pages show the active prompt.
- Add provider is two steps: pick a preset (always-on search including
  Chinese names and domains, categories inferred for display, sorted by
  name with no promoted entries), then fill the form. Edit pages name
  the provider and warn when it is the one in use.
- App page menu links to that app's usage.

Visual pass (phase 6):
- Secondary pages cover only the content area so the sidebar stays.
- Cmd/Ctrl+K jumps to apps, pages and settings sections.
- Legacy button variants, primary color, dialogs, toasts and sheets
  follow v7 tokens; hard-coded palette classes and 10px text across
  the remaining components are replaced with tokens.
2026-10-03 23:28:58 +08:00
Jason e88437e711 fix(usage): stop output TPS from spiking on late first-token marks
first_token_ms was stamped when the usage collector accepted its first
event, so the usage filter decided what "first token" meant. When an
upstream's opening event carried no usage key (Responses passthrough
without usage on response.created, Chat passthrough with usage only on
the final chunk), the first accepted event was the terminal one, the
generation window shrank to a few milliseconds and TPS jumped into the
thousands.

Mark the first output on every SSE data line instead, independent of the
usage filter, skipping only metadata events (response.created,
response.in_progress, ping, keepalive), the same semantic TTFT rule
Sub2API uses.

On the frontend, hide TPS when the generation window is under 100ms:
relays that buffer and flush at once, or short replies landing in one
packet, measure a transport burst rather than generation speed. This
also cleans up rows recorded before the backend fix.
2026-10-02 09:10:57 +08:00
Juexe dc0febe503 feat(usage): display output tokens per second in request log table and detail panel (#3369)
Show tokens/s next to the output token count in the request log table and the request detail panel.

The generation window prefers an explicit duration when present, otherwise latency minus first-token time for streaming requests, and falls back to full latency for non-streaming requests. Rows without a positive token count or window show nothing.

Closes #5936
2026-09-13 18:05:36 +08:00
滅üandJason 5fd3ec0d6a feat(i18n): add Traditional Chinese localization (#3093)
* Add Traditional Chinese localization

* fix: address zh-TW formatting and token units

- Format `zh-TW.json` with Prettier.
- Use Traditional Chinese `萬` and `億` units for zh-TW token summaries.
- Add usage formatting coverage for Traditional Chinese locale aliases.

---------

Co-authored-by: Jason <farion1231@gmail.com>
2026-05-27 00:05:03 +08:00