Files
108226bfe3 feat: combine localization and status-bar formatting (#40456)
* feat(appearance): let app chrome follow the terminal theme

Add an "App Chrome Appearance" setting (Default / Match Terminal) next to
Left Sidebar Appearance. In match-terminal mode the terminal theme's
background/foreground are written as document-root CSS variables
(--bg-titlebar, --background/--card/--popover/..., both sidebar token
families), so the tab strip, status bar, side panels, full-page views and
popovers all follow the terminal instead of the app theme. Left-sidebar
modes still win because they scope their own variables below the root.

The terminal color pair and token derivation move into
terminal-surface-colors.ts and are shared with the sidebar resolver.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(status-bar): configurable usage format template

Add Settings → Appearance → Status Bar → "Usage format": a template that
replaces the built-in per-provider usage text when non-empty. Placeholders
cover {provider}, {plan}, the 5h/7d/fable/30d windows as percentages
(following Used/Remaining), {x.reset} countdowns, {x.resetAt} clock times
and Gemini {buckets}; "[...]" groups drop out when a placeholder inside is
empty so one template works across providers with different windows.
Whitespace is rendered as authored (whitespace-pre).

Persisted as PersistedUIState.statusBarUsageFormat with a byProvider
override map reserved for later; the RPC UI-update schema gains the
optional field.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore(appearance): document touched functions; surface usage format in search

Add one-line JSDoc to every function this branch adds or edits so the
review docstring gate passes. Include the usage-format entry in the
Status Bar section's search match so searching "template" or
"placeholder" no longer hides the parent row, and mention popovers in
the App Chrome Appearance descriptions since the setting styles them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(appearance): let file editors follow the terminal theme in match-terminal mode

With App Chrome Appearance = Match Terminal, the tab strip, status bar and
side panels took the terminal palette but every file pane kept the stock app
theme: Monaco (code, plain text, diffs, notebooks, markdown source) was
hard-wired to `vs`/`vs-dark`, and the markdown preview / rich editor painted
the fixed `--editor-surface` with GitHub-colored hljs tokens.

- `terminal-editor-palette.ts` derives an editor palette from the active
  terminal theme (background/foreground/cursor/selection + syntax roles mapped
  onto the ANSI slots) and builds a Monaco theme (`orca-terminal`) from it;
  light/dark is rated by the terminal background, so a light terminal theme
  under a dark OS setting still gets light styling.
- match-terminal chrome variables now include `--editor-surface` and
  `--syntax-*`; the hljs stylesheets read those ahead of their defaults.
- `useEditorSurfaceAppearance` / `useMonacoEditorTheme` replace the inline
  `isDark ? 'vs-dark' : 'vs'` computations; the diff-section chain passes the
  Monaco theme name instead of a dark flag.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbWbChctXeMvaR2zdbFY99
(cherry picked from commit dc85fadee0a2664adbf55a49dd3c97c9b10fc111)

* fix(status-bar): honor the usage template in compact usage mode

ProviderSegment only rendered a user template on the verbose branch, so
switching usage mode to compact silently fell back to the built-in
tightest-window label. A non-empty template now replaces the built-in
text in both modes; the mini bar stays verbose-only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbWbChctXeMvaR2zdbFY99

* docs(appearance): document remaining functions touched by the diff

Adds one-line JSDoc to the editor surfaces, diff viewers, palette helpers
and UI-slice entry points this branch modifies so the diff's docstring
coverage clears the pre-merge threshold.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbWbChctXeMvaR2zdbFY99

* fix(editor): keep Monaco theme registration and preview clock out of render

The upgraded oxlint React rules flag reassigning a module variable during
render and calling Date.now() inside useMemo. Move the terminal Monaco
theme's signature cache into ensureTerminalMonacoTheme() and pin the
usage-format preview clock with a lazy useState initializer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VbWbChctXeMvaR2zdbFY99

* localization: complete Brazilian Portuguese catalogs

* fix(i18n): localize remaining hard-coded UI copy and complete Simplified Chinese coverage

Route the English literals and shared English labels that ignored the UI
language through the existing catalog: host labels, plugin cards and consent,
CLI and SSH errors, the checks pill, browser profile labels, shortcut groups,
app and context menus, and the macOS computer-use permission window. Shared
labels are translated where they render, so src/shared stays English for
mobile, CLI and older paired hosts.

- en.json gains 314 keys bootstrapped from inline fallbacks; four duplicate
  "Unassigned" keys collapse into translateUnassignedLabel()
- zh gains 337 entries and refreshes existing ones; the other nine locales get
  the newly extracted keys
- joinSentences ends a CJK sentence that has no final stop with 。 before the
  next one
- the desktop caller passes the computer-use helper its locale; orcad and the
  CLI stay Electron-free
- three files the copy pushed past max-lines each shed a focused module

* test: expect labeled roles in the editable context menu

The edit menu now passes explicit Cut, Copy and Select All labels so the roles render in the UI language; the upstream template assertion still expected bare roles.

* fix(i18n): key translated memos on the UI language without bare void reads

Upstream's React Compiler ratchet rejects `void language;`, which the compiler drops, and treats a react-hooks lint suppression as a bailout. The two host-label hooks now pass the language through readUiLanguageMemoInput so it stays a real memo input. ContextualTourOverlay drops its language key: getContextualTour is a static lookup, and step copy is localized at render.

* fix(i18n): translate editor theme settings

* Fix reactive localization and catalog extraction

* Fix combined localization validation

* Localize nested import failures and refine catalogs

* Handle older nested import responses

* Fix localized merge prompts and quota windows

* Address localization and runtime review feedback

* Keep host search and configuration examples usable

* Preserve configured names in add-project host selector

* Preserve host label origins across views

* Use localized fallback for missing local host

* Preserve custom names and refresh localized host labels

* Refresh task host labels without repeating searches

* Preserve Portuguese mobile tab translations

* Address localization review feedback

* fix(status-bar): import window visibility interval from its new path (#40951)

---------

Co-authored-by: lisi <lisi.see@bytedance.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: marlico77 <marlonssoficial@gmail.com>
Co-authored-by: x-Ai <5061489+x-Ai@users.noreply.github.com>
Co-authored-by: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com>
2026-11-10 18:21:19 -08:00

117 lines
5.0 KiB
Swift

import Foundation
public struct PermissionWindowCopy: Equatable, Sendable {
public let windowTitle: String
public let checkingTitle: String
public let readyTitle: String
public let enableTitle: String
public let checkingSubtitle: String
public let readySubtitle: String
public let permissionSubtitle: String
public let accessibilityTitle: String
public let accessibilityDetail: String
public let screenshotsTitle: String
public let screenshotsDetail: String
public let screenRecordingDescription: String
public let allowButton: String
public let doneButton: String
public let dragWindowTitle: String
public let dragAccessibilityInstruction: String
public let dragScreenshotsInstruction: String
public let closeButtonDescription: String
public init(localeIdentifier: String?) {
let normalized = (localeIdentifier ?? "")
.trimmingCharacters(in: .whitespacesAndNewlines)
.lowercased()
.replacingOccurrences(of: "_", with: "-")
if normalized == "zh" || normalized.hasPrefix("zh-cn") || normalized.hasPrefix("zh-hans") {
self = Self.chinese
} else {
self = Self.english
}
}
private static let english = PermissionWindowCopy(
windowTitle: "Enable Orca Computer Use",
checkingTitle: "Checking Computer Use",
readyTitle: "Computer Use is Ready",
enableTitle: "Enable Orca Computer Use",
checkingSubtitle: "Checking Accessibility and Screenshots.",
readySubtitle: "Orca can use local apps when you ask.",
permissionSubtitle: "Grant permissions so Orca can use apps when you ask.",
accessibilityTitle: "Accessibility",
accessibilityDetail: "Read and control app interfaces",
screenshotsTitle: "Screenshots",
screenshotsDetail: "Capture windows for visual state",
screenRecordingDescription: "Screen Recording",
allowButton: "Allow",
doneButton: "Done",
dragWindowTitle: "Drag Orca Computer Use",
dragAccessibilityInstruction: "Drag Orca Computer Use into the list above to allow Accessibility.",
dragScreenshotsInstruction: "Drag Orca Computer Use into the list above to allow Screenshots.",
closeButtonDescription: "Close"
)
private static let chinese = PermissionWindowCopy(
windowTitle: "启用 Orca 计算机使用功能",
checkingTitle: "正在检查计算机使用权限",
readyTitle: "计算机使用功能已就绪",
enableTitle: "启用 Orca 计算机使用功能",
checkingSubtitle: "正在检查辅助功能和屏幕截图权限。",
readySubtitle: "当你提出要求时,Orca 可以使用本地应用。",
permissionSubtitle: "授予权限,以便 Orca 在你提出要求时使用应用。",
accessibilityTitle: "辅助功能",
accessibilityDetail: "读取并控制应用界面",
screenshotsTitle: "屏幕截图",
screenshotsDetail: "捕获窗口以识别视觉状态",
screenRecordingDescription: "屏幕录制",
allowButton: "允许",
doneButton: "完成",
dragWindowTitle: "拖入 Orca Computer Use",
dragAccessibilityInstruction: "将 Orca Computer Use 拖入上方列表以允许辅助功能。",
dragScreenshotsInstruction: "将 Orca Computer Use 拖入上方列表以允许屏幕截图。",
closeButtonDescription: "关闭"
)
private init(
windowTitle: String,
checkingTitle: String,
readyTitle: String,
enableTitle: String,
checkingSubtitle: String,
readySubtitle: String,
permissionSubtitle: String,
accessibilityTitle: String,
accessibilityDetail: String,
screenshotsTitle: String,
screenshotsDetail: String,
screenRecordingDescription: String,
allowButton: String,
doneButton: String,
dragWindowTitle: String,
dragAccessibilityInstruction: String,
dragScreenshotsInstruction: String,
closeButtonDescription: String
) {
self.windowTitle = windowTitle
self.checkingTitle = checkingTitle
self.readyTitle = readyTitle
self.enableTitle = enableTitle
self.checkingSubtitle = checkingSubtitle
self.readySubtitle = readySubtitle
self.permissionSubtitle = permissionSubtitle
self.accessibilityTitle = accessibilityTitle
self.accessibilityDetail = accessibilityDetail
self.screenshotsTitle = screenshotsTitle
self.screenshotsDetail = screenshotsDetail
self.screenRecordingDescription = screenRecordingDescription
self.allowButton = allowButton
self.doneButton = doneButton
self.dragWindowTitle = dragWindowTitle
self.dragAccessibilityInstruction = dragAccessibilityInstruction
self.dragScreenshotsInstruction = dragScreenshotsInstruction
self.closeButtonDescription = closeButtonDescription
}
}