Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 菜单栏面板按审查意见修正计数缩放、减少动效与默认路由
kirozeng37856db1e220
diff --git a/apps/desktop/native/menubar/macos-menubar-helper.swift b/apps/desktop/native/menubar/macos-menubar-helper.swiftindex 7104461eba..92a746bf33 100644--- a/apps/desktop/native/menubar/macos-menubar-helper.swift+++ b/apps/desktop/native/menubar/macos-menubar-helper.swift@@ -1117,6 +1117,7 @@ struct InkPillButton: View {}private struct InkPillStyle: ButtonStyle {+ @Environment(\.accessibilityReduceMotion) private var reduceMotionlet title: Stringlet shortcut: String?let height: CGFloat@@ -1129,8 +1130,8 @@ private struct InkPillStyle: ButtonStyle {HStack(spacing: 8) {if brandMark {BrandPromptMark(replayToken: replayToken)- .offset(x: configuration.isPressed ? 4 : hovering ? 2 : 0)- .scaleEffect(x: configuration.isPressed ? 0.8 : 1, anchor: .trailing)+ .offset(x: reduceMotion ? 0 : configuration.isPressed ? 4 : hovering ? 2 : 0)+ .scaleEffect(x: !reduceMotion && configuration.isPressed ? 0.8 : 1, anchor: .trailing).animation(configuration.isPressed ? .easeOut(duration: 0.12) : .spring(response: 0.35, dampingFraction: 0.6), value: configuration.isPressed).animation(.spring(response: 0.35, dampingFraction: 0.6), value: hovering).padding(.trailing, -2)@@ -2098,9 +2099,11 @@ private struct CountUpModifier: ViewModifier, Animatable {set { progress = newValue }}+ /// The visible count is laid out in the hidden final text's frame and inherits the same+ /// line limit and scale factor, so a long value shrinks together with its placeholder.func body(content: Content) -> some View {content.overlay(alignment: .trailing) {- Text(parts.render(progress)).fixedSize().accessibilityHidden(true)+ Text(parts.render(progress)).accessibilityHidden(true)}}}@@ -2150,9 +2153,11 @@ struct CountUpParts: Equatable {/// Pressing a source squeezes it a little, then it springs back as the detail page opens.struct CellPressStyle: ButtonStyle {+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+func makeBody(configuration: Configuration) -> some View {configuration.label- .scaleEffect(configuration.isPressed ? 0.95 : 1)+ .scaleEffect(!reduceMotion && configuration.isPressed ? 0.95 : 1).animation(configuration.isPressed ? .easeOut(duration: 0.1) : .spring(response: 0.35, dampingFraction: 0.55), value: configuration.isPressed)}}diff --git a/apps/desktop/src/main/menubar/__tests__/collect.test.ts b/apps/desktop/src/main/menubar/__tests__/collect.test.tsindex 2eacabf0e1..5cc01ac471 100644--- a/apps/desktop/src/main/menubar/__tests__/collect.test.ts+++ b/apps/desktop/src/main/menubar/__tests__/collect.test.ts@@ -243,6 +243,22 @@ describe('collectMenubarInputs', () => {expect(consuming).toEqual(['cindy', 'openai']);});+ it('resolves the implicit default route of a running task to the source it draws on', async () => {+ const codexRoute = { agents: ['codex'], routing: { codex: {} }, models: { codex: [{ id: 'gpt-5.5', mode: 'chat' }] } };+ const collected = await collectMenubarInputs(+ deps({+ listProviders: async () => [+ provider({ id: 'openai', auth: { method: 'oauth', native: 'codex' }, ...codexRoute } as never),+ provider({ id: 'anthropic', agents: ['claude-code'], routing: { 'claude-code': {} }, models: {} } as never),+ ],+ activities: () => [{ sessionId: 'default-route', phase: 'running', startedAtMs: NOW - 1000 } as never],+ // No explicit provider: the session runs on Codex's native default.+ sessionRow: async () => ({ title: 'default route', model: 'gpt-5.5', agentKind: 'codex', providerId: null }),+ }),+ );+ expect(collected.sources.filter((source) => source.consuming).map((source) => source.id)).toEqual(['openai']);+ });+it('leaves every source still when nothing is running', async () => {const collected = await collectMenubarInputs(deps({diff --git a/apps/desktop/src/main/menubar/collect.ts b/apps/desktop/src/main/menubar/collect.tsindex 786025e682..65b7964b0e 100644--- a/apps/desktop/src/main/menubar/collect.ts+++ b/apps/desktop/src/main/menubar/collect.ts@@ -6,7 +6,7 @@* that fails only drops its own source; the rest of the panel still renders.*/-import type { ProviderView } from '@cindy/model-providers';+import { actualSourceIdForModel, type ProviderView } from '@cindy/model-providers';import { CINDY_MAKE_ENABLED, isCindyMakeSource } from '@cindy/maker-shared/cindy-make-feature';import { matchCodexBucketForModel } from '@cindy/maker-shared/codex-usage-buckets';import type {@@ -17,6 +17,7 @@ import { isXaiWeeklyUsageCurrent } from '@cindy/maker-shared/subscription-usage'import { isSessionActivityRunning, type SessionActivitySnapshot } from '@cindy/maker-shared/session-activity';import type { MenubarModelUsage, MenubarUsageScope, MenubarUsageScopeData } from '../../shared/menubarQuota.js';+import { dbToMakerAgentKind } from '../../shared/agentKindConversion.js';import { providerWeeklyQuotaSource } from '../../shared/providerQuotaSource.js';import { formatModelShort } from '../../shared/usageModelLabel.js';import type { CodexAccountUsagePayload, RateLimitSnapshot, RateLimitWindow } from '../usageBroadcaster.js';@@ -453,13 +454,34 @@ export function paygSource(provider: ProviderView): MenubarPaygInput | null {/*** Sources a running task on this computer is drawing on: the subscription or provider it* sends to, or the Cindy balance for Cindy-managed providers (the ones `paygSource` hides- * because they bill the balance).+ * because they bill the balance). A session without an explicit provider runs on the+ * implicit default route; it is resolved the way the running route is (`actualSourceIdForModel`),+ * so that tube ripples too.*/export function consumingSourceIds(tasks: readonly MenubarTaskInput[], providers: readonly ProviderView[]): Set<string> {const ids = new Set<string>();for (const task of tasks) {- if (!task.running || !task.providerId) continue;- const provider = providers.find((candidate) => candidate.id === task.providerId);+ if (!task.running) continue;+ const explicit = task.providerId?.trim() || null;+ let resolved: string | null = null;+ if (task.routeModel) {+ try {+ resolved = actualSourceIdForModel(+ providers as ProviderView[],+ explicit,+ task.routeModel,+ dbToMakerAgentKind(task.routeAgentKind),+ );+ } catch {+ // A provider view missing its runtime map only costs the ripple, never the whole read.+ resolved = null;+ }+ }+ // An explicit provider the catalog no longer offers this model on is still what the+ // session sends to; keep marking it.+ const sourceId = resolved ?? explicit;+ if (!sourceId) continue;+ const provider = providers.find((candidate) => candidate.id === sourceId);if (!provider) continue;const managed = provider.auth.method === 'managed' || provider.access?.kind === 'managed' || provider.id === 'xd';ids.add(managed ? MENUBAR_BALANCE_SOURCE_ID : provider.id);@@ -622,6 +644,8 @@ async function collectTasks(startedAtMs: running ? (activity?.startedAtMs ?? null) : null,lastActiveAtMs: activity?.lastActivityAtMs ?? info?.lastActiveAt ?? deps.nowMs,providerId: row?.providerId ?? null,+ routeModel: model || null,+ routeAgentKind: row?.agentKind ?? null,};}),);diff --git a/apps/desktop/src/main/menubar/service.ts b/apps/desktop/src/main/menubar/service.tsindex bc80ba03c7..eefcacaf81 100644--- a/apps/desktop/src/main/menubar/service.ts+++ b/apps/desktop/src/main/menubar/service.ts@@ -46,6 +46,7 @@ import { getResolvedMainLocale, mainStringKeysUnder, rawMainString } from '../i1import { getSessionRowSnapshot } from '../localDb/ipc/sessions.js';import { createLogger } from '../logger.js';import { getDesktopProviderService } from '../maker-host/createDesktopProviderService.js';+import { getSessionProvider, hasSessionProvider } from '../maker-host/session-provider-store.js';import { inspectAppDefaultModel } from '../maker-ipc/appDefaultModelControl.js';import { applyNewMakerDraftRoute } from '../maker-ipc/register.js';import {@@ -344,7 +345,8 @@ export class MenubarService {model: row.model ?? null,agentKind: row.agentKind ?? null,source: row.source ?? null,- providerId: row.providerId ?? null,+ // The in-memory route is newer than the row (a provider switched this turn).+ providerId: hasSessionProvider(sessionId) ? getSessionProvider(sessionId) : (row.providerId ?? null),}: null;},diff --git a/apps/desktop/src/main/menubar/snapshot.ts b/apps/desktop/src/main/menubar/snapshot.tsindex 1be5989133..7bd887c55f 100644--- a/apps/desktop/src/main/menubar/snapshot.ts+++ b/apps/desktop/src/main/menubar/snapshot.ts@@ -144,8 +144,11 @@ export interface MenubarTaskInput {running: boolean;startedAtMs: number | null;lastActiveAtMs: number;- /** Provider the session sends to; only used to mark the source it is drawing on. */+ /** Provider the session sends to (null = the implicit default route); only used to mark+ * the source it is drawing on, together with the raw model and agent kind below. */providerId?: string | null;+ routeModel?: string | null;+ routeAgentKind?: string | null;}export interface MenubarUsageDeviceInput {