Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(ui): keep desktop segmented controls on one line (#5064)

Kirozengbd7a35ddead8
diff --git a/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx b/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx
index cd710c6575..75cf717c7b 100644
--- a/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx
@@ -230,7 +230,7 @@ export function AgentResourceSection() {
高度恒等于四者中最高的一段,与窗口宽度和语言都无关(固定 min-height 只是下限,
长文案照样会溢出撑高)。因为与宽度无关,提示就留在左列、不必独占整行,分段控件
才能像同卡其它行一样相对「标签 + 说明」整块垂直居中。 */}
- <div className={ROW_CLASS}>
+ <div className={cn(ROW_CLASS, 'cindy-segmented-row')}>
<div className="flex min-w-0 flex-col gap-1">
<p id="settings-search-settings-agentResource-preset" className={ROW_LABEL_CLASS} style={{ letterSpacing: '0.12px' }}>
{t('settings.agentResource.preset')}
@@ -302,7 +302,7 @@ export function AgentResourceSection() {
<div className={DIVIDER_CLASS} />
{/* 进程优先级 */}
- <div className={ROW_CLASS}>
+ <div className={cn(ROW_CLASS, 'cindy-segmented-row')}>
<div className="flex min-w-0 flex-col gap-1">
<p id="settings-search-settings-agentResource-priority" className={ROW_LABEL_CLASS} style={{ letterSpacing: '0.12px' }}>
{t('settings.agentResource.priority')}
diff --git a/apps/desktop/src/renderer/components/settings/AppearanceSection.tsx b/apps/desktop/src/renderer/components/settings/AppearanceSection.tsx
index db346e80b2..487009fdaa 100644
--- a/apps/desktop/src/renderer/components/settings/AppearanceSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/AppearanceSection.tsx
@@ -798,7 +798,7 @@ export function AppearanceSection() {
'border border-[var(--settings-theme-card-border)]',
)}
>
- <div className="flex items-center justify-between gap-3">
+ <div className="cindy-segmented-row">
<div className="flex min-w-0 flex-col gap-1">
<p id="settings-search-settings-appearance-sidebarCardMode-label"
className="text-13 font-medium text-[var(--settings-section-sublabel)]"
@@ -823,7 +823,7 @@ export function AppearanceSection() {
/>
</div>
- <div className="flex items-center justify-between gap-3">
+ <div className="cindy-segmented-row">
<div className="flex min-w-0 flex-col gap-1">
<p id="settings-search-settings-appearance-sidebarMainListMode-label"
className="text-13 font-medium text-[var(--settings-section-sublabel)]"
@@ -847,7 +847,7 @@ export function AppearanceSection() {
/>
</div>
- <div className="flex items-center justify-between gap-3">
+ <div className="cindy-segmented-row">
<div className="flex min-w-0 flex-col gap-1">
<p id="settings-search-settings-appearance-ghostPanelRestore-label"
className="text-13 font-medium text-[var(--settings-section-sublabel)]"
diff --git a/apps/desktop/src/renderer/components/settings/BrowserBackendSubsection.tsx b/apps/desktop/src/renderer/components/settings/BrowserBackendSubsection.tsx
index 07f9a39d81..70598c0b85 100644
--- a/apps/desktop/src/renderer/components/settings/BrowserBackendSubsection.tsx
+++ b/apps/desktop/src/renderer/components/settings/BrowserBackendSubsection.tsx
@@ -60,7 +60,7 @@ export function BrowserBackendSubsection({
active === 'rsb-webview' && health?.active === 'rsb-webview' ? health : null;
return (
<div className="border-t border-[var(--settings-theme-card-border)]">
- <div className="flex flex-wrap items-center justify-between gap-3 px-4 py-[14px]">
+ <div className="cindy-segmented-row px-4 py-[14px]">
<div className="flex min-w-0 flex-col gap-1">
<p className="text-12 font-medium leading-[1.4] text-[var(--settings-section-title)]">
{t('settings.computerUse.browserBackend.title')}
diff --git a/apps/desktop/src/renderer/components/settings/GitSafetySection.tsx b/apps/desktop/src/renderer/components/settings/GitSafetySection.tsx
index 4d0538cb1b..2c99e4de6d 100644
--- a/apps/desktop/src/renderer/components/settings/GitSafetySection.tsx
+++ b/apps/desktop/src/renderer/components/settings/GitSafetySection.tsx
@@ -49,7 +49,7 @@ export function GitSafetySection() {
'border border-[var(--settings-theme-card-border)]',
)}
>
- <div className="flex items-center justify-between gap-3">
+ <div className="cindy-segmented-row">
<div className="flex min-w-0 flex-col gap-1">
<p id="settings-search-settings-gitSafety-autoSnapshotTitle" className="text-13 font-medium text-[var(--settings-section-sublabel)]">
{t('settings.gitSafety.autoSnapshotTitle')}
@@ -57,6 +57,7 @@ export function GitSafetySection() {
<p className="text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">{t('settings.gitSafety.description')}</p>
</div>
+ <div className="cindy-segmented-row-actions">
<SegmentedControl
value={mode}
onValueChange={handleModeChange}
@@ -67,9 +68,9 @@ export function GitSafetySection() {
{ value: 'existing-git', label: t('settings.gitSafety.modes.existingGit') },
{ value: 'all-projects', label: t('settings.gitSafety.modes.allProjects') },
] satisfies ReadonlyArray<{ value: GitSafetyMode; label: string }>}
- fullWidth
/>
<DefaultOverrideControls isCustomized={isCustomized} disabled={saving} onReset={handleReset} />
+ </div>
</div>
</div>
</div>
diff --git a/apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx b/apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx
index 46d762e891..3a2635e121 100644
--- a/apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx
@@ -39,7 +39,7 @@ const CARD_CLASS = cn(
'bg-[var(--settings-theme-card-bg)]',
'border border-[var(--settings-theme-card-border)]',
);
-const ROW_CLASS = 'flex items-center justify-between gap-3 px-4 py-4';
+const ROW_CLASS = 'cindy-segmented-row px-4 py-4';
const ROW_LABEL_CLASS = 'text-13 font-medium text-[var(--settings-section-sublabel)]';
const ROW_HINT_CLASS = 'text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70';
const DIVIDER_CLASS = 'mx-4 h-px bg-[var(--settings-theme-card-border)]';
@@ -62,7 +62,7 @@ function LinkOpenPreferenceRow({ kind }: { kind: LinkOpenKind }) {
<p className={ROW_HINT_CLASS}>{t(`settings.linkOpen.${kind}.description`)}</p>
</div>
- <div className="flex shrink-0 items-center gap-2">
+ <div className="cindy-segmented-row-actions">
<DefaultOverrideControls isCustomized={isCustomized} onReset={onReset} />
<SegmentedControl
aria-label={t(`settings.linkOpen.${kind}.ariaLabel`)}
diff --git a/apps/desktop/src/renderer/components/settings/TelegramBehaviorSettings.tsx b/apps/desktop/src/renderer/components/settings/TelegramBehaviorSettings.tsx
index 37dd0cabe3..b7e1b4f1e1 100644
--- a/apps/desktop/src/renderer/components/settings/TelegramBehaviorSettings.tsx
+++ b/apps/desktop/src/renderer/components/settings/TelegramBehaviorSettings.tsx
@@ -678,7 +678,7 @@ export function TelegramGroupActivationSettings({
</div>
) : (
groups.map((group) => (
- <div key={group.chatId} className="flex items-center justify-between gap-3">
+ <div key={group.chatId} className="cindy-segmented-row">
<div className="min-w-0 flex-1">
<div className="truncate text-12 font-medium text-[var(--settings-section-title)]">
{group.chatName || group.chatId}
diff --git a/apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx b/apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx
index 221edbd6f8..7e4a523b28 100644
--- a/apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx
@@ -179,7 +179,7 @@ export function WindowBehaviorSection() {
{(isWindows || isLinux) && (
<div
className={cn(
- 'flex items-center justify-between gap-3 rounded-xl p-5',
+ 'cindy-segmented-row rounded-xl p-5',
'bg-[var(--settings-theme-card-bg)]',
'border border-[var(--settings-theme-card-border)]',
)}
diff --git a/apps/desktop/src/renderer/components/ui/segmented-control.css b/apps/desktop/src/renderer/components/ui/segmented-control.css
index eef31d819c..331f8af16f 100644
--- a/apps/desktop/src/renderer/components/ui/segmented-control.css
+++ b/apps/desktop/src/renderer/components/ui/segmented-control.css
@@ -1,12 +1,41 @@
+.cindy-segmented-row {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: flex-end;
+ gap: var(--space-3);
+}
+
+.cindy-segmented-row > :first-child {
+ flex: 1 1 12rem;
+ min-width: 0;
+ overflow-wrap: anywhere;
+}
+
+.cindy-segmented-row-actions {
+ display: flex;
+ align-items: center;
+ flex: 0 1 auto;
+ min-width: 0;
+ max-width: 100%;
+ gap: var(--space-2);
+}
+
+.cindy-segmented-row-actions > .cindy-segmented {
+ flex-shrink: 1;
+}
+
.cindy-segmented {
position: relative;
isolation: isolate;
display: inline-flex;
- flex-wrap: wrap;
+ flex-wrap: nowrap;
+ flex-shrink: 0;
align-items: center;
gap: 2px;
- width: fit-content;
+ width: max-content;
max-width: 100%;
+ overflow-x: auto;
min-height: var(--segmented-height);
padding: calc((var(--segmented-height) - var(--segmented-option-height)) / 2);
border-radius: var(--radius-full);
@@ -47,6 +76,7 @@
}
.cindy-segmented-option {
+ flex-shrink: 0;
height: var(--segmented-option-height);
background: transparent;
color: var(--segmented-option-fg);
diff --git a/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx b/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx
index dc69afd5ce..b3e58aa008 100644
--- a/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx
@@ -199,7 +199,7 @@ export function IssueConfirmCard({ sessionId, pending, onRespond }: IssueConfirm
)}
>
{/* Title row: heading + type toggle */}
- <div className="flex items-center justify-between gap-3">
+ <div className="cindy-segmented-row">
<p className="text-15 font-semibold leading-tight text-[var(--chat-input-text)]">
{t('issueAgent.confirm.title')}
</p>
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/pluginMotionDesign.test.ts b/apps/desktop/src/renderer/features/plugin/__tests__/pluginMotionDesign.test.ts
index 5876c25a85..39648c7f9c 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/pluginMotionDesign.test.ts
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/pluginMotionDesign.test.ts
@@ -18,7 +18,7 @@ describe('plugin motion design contracts', () => {
expect(previewCardRule).not.toContain('color-mix');
});
- it('wraps recommended filters against the actual catalog content width', () => {
+ it('keeps recommended filters on one line against the actual catalog content width', () => {
const contentQueryStart = pluginMotionCss.indexOf(
'@container plugin-management-content (max-width: 720px)',
);
@@ -32,6 +32,7 @@ describe('plugin motion design contracts', () => {
expect(contentQuery).toContain('.plugin-catalog-toolbar');
expect(contentQuery).toContain('flex-direction: column;');
expect(contentQuery).toContain('.plugin-catalog-filters');
- expect(contentQuery).toContain('flex-wrap: wrap;');
+ expect(contentQuery).toContain('width: auto;');
+ expect(contentQuery).not.toContain('flex-wrap: wrap;');
});
});
diff --git a/apps/desktop/src/renderer/features/plugin/plugin-motion.css b/apps/desktop/src/renderer/features/plugin/plugin-motion.css
index d90bb17259..85cfd4769d 100644
--- a/apps/desktop/src/renderer/features/plugin/plugin-motion.css
+++ b/apps/desktop/src/renderer/features/plugin/plugin-motion.css
@@ -129,8 +129,6 @@
}
.plugin-catalog-filters {
- flex-wrap: wrap;
- justify-content: flex-start;
width: auto;
}
}
@@ -158,8 +156,8 @@
}
.plugin-management-layout-root .plugin-management-tab {
- min-width: 0;
- flex: 1 1 0%;
+ min-width: max-content;
+ flex: 1 0 auto;
}
.plugin-management-layout-root .plugin-management-tools {
diff --git a/apps/desktop/src/renderer/features/skillhub/components/SkillCategoryFilterBar.tsx b/apps/desktop/src/renderer/features/skillhub/components/SkillCategoryFilterBar.tsx
index 825d719467..7f73ff4832 100644
--- a/apps/desktop/src/renderer/features/skillhub/components/SkillCategoryFilterBar.tsx
+++ b/apps/desktop/src/renderer/features/skillhub/components/SkillCategoryFilterBar.tsx
@@ -133,7 +133,7 @@ export function SkillCategoryFilterBar({
className="flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-x-auto overscroll-x-contain [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
>
<SegmentedControl
- className="cindy-segmented-nowrap shrink-0"
+ className="shrink-0 !max-w-none"
role="radiogroup"
aria-label={ariaLabel}
height={32}
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index 0a16e8ebf7..cb8a2393b4 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -368,12 +368,12 @@ Reference implementation: `apps/desktop/src/renderer/components/ui/confirm-dialo
- Active: Light Gray bg (`--surface-chip`); Inactive: transparent
- All pill-shaped (9999px)
-### Desktop segmented controls (v8, owner-approved 2026-09-18)
+### Desktop segmented controls (v8 appearance / v9 layout, owner-approved 2026-09-25)
- All Desktop segmented settings, form choices, filters, Agent selectors and pill navigation use `components/ui/segmented-control.tsx`. `VendorSegmentedSwitcher` only adapts Agent labels/icons. Mobile and native iOS controls are outside this decision.
- The borderless pill track uses `--segmented-track`: a black alpha overlay, Light 6% / Dark 25%, applied to its background only. It adapts to the parent surface; pure black cannot be darkened further. Do not add a compensating track border.
- The selected pill uses component-local `--segmented-selected-bg`, `--segmented-selected-border` and `--segmented-selected-shadow`. CINDY Light: #FDFDF8 / #F0F0EB; Dark: #353535 / #3B3B3B. Its narrowly scoped two-layer shadow is the owner-approved elevation exception; it does not authorize shadows on other controls. Other themes default to their elevated/border aliases and may override these roles without changing saved theme files. DTCG is the numeric source.
-- Preserve each scene's density, icons, counts, configured markers, width, wrapping and callbacks. Settings default to a 32px track / 28px option; compact Diff retains 24px / 18px visuals with a transparent minimum 24px target. Do not force all scenes to one fixed dimension.
+- Preserve each scene's density, icons, counts, configured markers, width and callbacks. Options stay on one line. Let the description wrap first; when the row cannot fit, move the whole control to the next line. At extreme widths the outer viewport scrolls horizontally while the track remains one line. Settings default to a 32px track / 28px option; compact Diff retains 24px / 18px visuals with a transparent minimum 24px target. Do not force all scenes to one fixed dimension.
- A single measured plate moves with selection over `--motion-base`; hover/press use `--motion-fast`, and press scale is .98. Reduced motion disables movement/transitions. Resize and label changes realign the plate. Unselected text uses `--segmented-option-fg`, hover fill uses `--segmented-hover-bg`, selected/hover text uses `--text-primary`; all options keep weight 500. Disabled controls preserve selection at reduced opacity and cannot activate; focus remains independently visible.
- Settings and filters use `radiogroup` / `radio` / `aria-checked`; panel navigation retains `tablist` / `tab` / `aria-selected`. Tab enters at the enabled selected option (or first enabled option); arrows wrap, skip disabled choices and respect RTL. Home/End select the first/last enabled option; Space/Enter retain native button activation. A missing preset remains unselected.
- Fixed short alternatives with one shared setting can share a track (Telegram reply modes, import dimensions, authentication mode/flow). Dynamic account/object lists, wrapping API protocols, popup actions, multi-select and ordinary document/sidebar tabs remain separate controls.