Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export default {
await message.hover();
await message.getByRole('button', { name: await ui.t('chat.messageActionBar.moreActions'), exact: true }).click();
await page.getByRole('menuitem', { name: await ui.t('chat.shareImage.entry'), exact: true }).click();
const bar = page.getByRole('checkbox', { name: await ui.t('chat.shareImage.selectAll'), exact: true }).locator('..');
// The select-all box sits in a label inside the bar; measure the bar itself.
const bar = page.getByRole('checkbox', { name: await ui.t('chat.shareImage.selectAll'), exact: true }).locator('xpath=ancestor::div[1]');
const during = await bounds(bar);
await ui.capture('sharing');
assert.deepEqual(during, before, 'image sharing stays aligned with the composer');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function EntryControl({ entry, sessionId, clientId, active, appearance }: { entr
</button>;
if (action.kind === 'status') return <span className={header ? 'max-w-48 shrink-0 truncate text-12 text-[var(--text-secondary)]' : 'text-12 text-[var(--text-secondary)]'} title={controlTitle}>{title}</span>;
if (action.kind === 'select') return <Select label={title} value={state?.value ?? value} options={action.options ?? []}
disabled={pending || state?.disabled} onValueChange={next => void run(next)} className="h-7 max-w-48 text-12" />;
disabled={pending || state?.disabled} onValueChange={next => void run(next)} size="inline" className="max-w-48 text-12" />;
if (action.presentation === 'popover' && action.view) return <Popover open={open && active} onOpenChange={setOpen}>
<PopoverTrigger asChild><Button variant="secondary" tone="quiet" size="sm" disabled={state?.disabled}
className={header ? 'max-w-48' : undefined} title={controlTitle}>{label}</Button></PopoverTrigger>
Expand Down Expand Up @@ -390,7 +390,7 @@ function PluginUiBodyChoice({ children, entries, sessionId, clientId, context }:
const entry = entries.find(entry => `${entry.instanceId}:${entry.contribution.id}` === selected);
return <>
<div className="mb-1 flex min-w-0 items-center gap-1">
<Select label={t('pluginUi.display')} value={entry ? selected : 'original'} className="h-7 max-w-56 text-12"
<Select label={t('pluginUi.display')} value={entry ? selected : 'original'} size="inline" className="max-w-56 text-12"
options={[{ value: 'original', label: t('pluginUi.original') }, ...entries.map(entry => ({
value: `${entry.instanceId}:${entry.contribution.id}`, label: `${entry.contribution.title} · ${entry.ghost.manifest.name}`,
}))]} onValueChange={setSelected} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
* 只订阅自己那一条的选中态(useIsMessageSelected):勾选是高频动作,细粒度订阅让
* 一次点击只重渲染这一个按钮,而不是整条消息流(见 shareSelectionStore 文件头)。
*
* 圆形不违反§5 三档圆角 —— 它是 pill 档(9999px)。自带 `data-share-exclude`,
* 用共享 Checkbox(DESIGN.md §4,B-10),外包一层 20px 点击区。自带 `data-share-exclude`,
* 光栅化时会被清洗掉,不会出现在产物图片里。
*/

import { Check } from 'lucide-react';
import { useTranslation } from 'react-i18next';

import { cn } from '@/lib/utils';
import { Checkbox } from '@/components/ui/checkbox';
import { SHARE_EXCLUDE_ATTR } from '@/lib/shareConversationImage';
import { shareSelectionStore, useIsMessageSelected } from './shareSelectionStore';

Expand All @@ -23,31 +22,18 @@ export function ShareMessageCheckbox({ clientId }: { clientId: string }) {
const selected = useIsMessageSelected(clientId);

return (
<button
type="button"
role="checkbox"
aria-checked={selected}
aria-label={t('chat.shareImage.checkboxLabel')}
// 落在 MessageStream 让出的 40px 缩进里(左 8px / 右 12px,20px 点击区居中偏左);
// top 微调让框心对齐消息首行的视觉中线。点击区只拦截冒泡,勾选由原生 input 处理。
<label
{...{ [SHARE_EXCLUDE_ATTR]: '' }}
onClick={(e) => {
e.stopPropagation();
shareSelectionStore.toggle(clientId);
}}
className={cn(
// 落在 MessageStream 让出的 40px 缩进里(左 8px / 右 12px,20px 框居中偏左);
// top 微调让圆心对齐消息首行的视觉中线。
'absolute -left-8 top-[2px] z-raised flex h-5 w-5 shrink-0 items-center justify-center',
'rounded-full transition-colors cursor-pointer',
'focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)] outline-none',
selected
? 'bg-[var(--accent-cta-bg-pure)] text-[var(--accent-pure-cta-fg)]'
: cn(
'border border-[var(--border-default)] bg-transparent',
'hover:border-[var(--text-secondary)]',
),
)}
onClick={(e) => e.stopPropagation()}
className="absolute -left-8 top-[2px] z-raised flex size-5 shrink-0 cursor-pointer items-center justify-center"
>
{selected ? <Check size={12} strokeWidth={2.5} aria-hidden /> : null}
</button>
<Checkbox
checked={selected}
aria-label={t('chat.shareImage.checkboxLabel')}
onChange={() => shareSelectionStore.toggle(clientId)}
/>
</label>
);
}
34 changes: 11 additions & 23 deletions apps/desktop/src/renderer/components/chat/ShareSelectionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
useState,
type CSSProperties,
} from 'react';
import { Check } from 'lucide-react';
import { useTranslation } from 'react-i18next';

import { blobToDataUrl } from '@/lib/annotationBurnIn';
Expand All @@ -41,6 +40,7 @@ import { cn } from '@/lib/utils';
import { useBrandLogo } from '@/hooks/useBrandLogo';
import shareCharacterSrc from '@/assets/cindy-share-character.jpg';
import { shareSelectionStore, useShareSelectionCount } from './shareSelectionStore';
import { Checkbox } from '@/components/ui/checkbox';

const log = createLogger('ShareSelectionBar');

Expand Down Expand Up @@ -193,6 +193,7 @@ export function ShareSelectionBar({
}, [busy, toggleAll]);

const disabled = count === 0 || busy !== null;
const selectAllDisabled = busy !== null || shareableMessageIds.length === 0;

return (
<div
Expand All @@ -208,32 +209,19 @@ export function ShareSelectionBar({
>
{/* 部分勾选不等于全选:按钮仍显示未选中,点击后临时补齐全部;只有当前
可选项全部勾上时才显示选中态,再次点击恢复全选前的用户选择。 */}
<button
type="button"
role="checkbox"
aria-checked={allSelected}
aria-label={t('chat.shareImage.selectAll')}
onClick={toggleAll}
disabled={busy !== null || shareableMessageIds.length === 0}
<label
className={cn(
'inline-flex h-8 shrink-0 items-center gap-2 rounded-full border px-3 text-13 font-medium transition-colors',
'outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
'border-[var(--border-default)] bg-[var(--surface-chip)] text-[var(--text-primary)]',
'hover:bg-[var(--surface-hover)] disabled:cursor-default disabled:opacity-50',
'inline-flex h-8 shrink-0 items-center gap-2 text-13 font-medium text-[var(--text-primary)]',
selectAllDisabled ? 'opacity-60' : 'cursor-pointer',
)}
>
<span
className={cn(
'flex h-4 w-4 items-center justify-center rounded-full border transition-colors',
allSelected
? 'border-[var(--accent-cta-bg-pure)] bg-[var(--accent-cta-bg-pure)] text-[var(--accent-pure-cta-fg)]'
: 'border-[var(--text-tertiary)] bg-transparent',
)}
>
{allSelected ? <Check size={11} strokeWidth={2.5} aria-hidden /> : null}
</span>
<Checkbox
checked={allSelected}
onChange={toggleAll}
disabled={selectAllDisabled}
/>
<span>{t('chat.shareImage.selectAll')}</span>
</button>
</label>

<div className="min-w-0 flex-1">
<div className="text-14 font-medium leading-tight text-[var(--text-primary)]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function useDeleteMessage({
description: t('chat.messageActionBar.deleteConfirmDescription'),
confirmText: t('chat.messageActionBar.deleteConfirm'),
cancelText: t('chat.messageActionBar.deleteCancel'),
confirmVariant: 'destructive',
});
if (!ok) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
type CindyMakeContributionError,
type CindyMakeContributionView,
} from '../../../shared/cindyMakeContribution';
import { Checkbox } from '@/components/ui/checkbox';

const key = 'cindyMake.contribution';

Expand Down Expand Up @@ -355,12 +356,11 @@ export function CindyMakeContributionDialog({
{draft.touchesUi && <li>{t(`${key}.dialog.uiNote`)}</li>}
</ul>
<label className="flex min-h-8 cursor-pointer items-start gap-2 text-13 text-[var(--text-primary)]">
<input
type="checkbox"
<Checkbox
checked={signed}
disabled={submitting}
onChange={(event) => setSigned(event.target.checked)}
className="mt-0.5 size-4 shrink-0 accent-[var(--confirm-btn-primary-bg)]"
className="mt-0.5"
/>
<span>{t(`${key}.dialog.dco`, { name: name.trim(), email: email.trim() })}</span>
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
contributionActionKey,
useCindyMakeContributions,
} from './CindyMakeContribution';
import { Checkbox } from '@/components/ui/checkbox';

type Filter = 'all' | 'pending' | 'integrated' | 'ended';
/** Historical facts and allowed actions come from Main; an old button cannot authorize a write. */
Expand Down Expand Up @@ -603,7 +604,8 @@ export function CindyMakeHistoryPanel({
setCheckedIds([]);
}}
disabled={!!pending}
className="h-8 w-[168px]"
size="compact"
width="sm"
/>
<Input
size="sm"
Expand Down Expand Up @@ -652,16 +654,12 @@ export function CindyMakeHistoryPanel({
{selecting && (
<div className="flex flex-wrap items-center gap-3 text-12 text-[var(--text-secondary)]">
<label className="flex min-h-8 cursor-pointer items-center gap-2">
<input
type="checkbox"
<Checkbox
checked={allChecked}
disabled={!!pending || !selectable.length}
ref={(node) => {
if (node)
node.indeterminate =
!allChecked && selectable.some((item) => checkedIds.includes(item.runId));
}}
className="size-4 accent-[var(--confirm-btn-primary-bg)]"
indeterminate={
!allChecked && selectable.some((item) => checkedIds.includes(item.runId))
}
onChange={() =>
setCheckedIds((previous) =>
allChecked
Expand Down Expand Up @@ -767,14 +765,12 @@ export function CindyMakeHistoryPanel({
<li key={item.runId} className="flex items-center gap-1">
{selecting && (
<label className="flex min-h-8 min-w-8 shrink-0 cursor-pointer items-center justify-center">
<input
type="checkbox"
<Checkbox
checked={checked.some((entry) => entry.runId === item.runId)}
disabled={!!pending || !item.canSelectForBuild}
aria-label={t('cindyMake.history.batch.selectItem', {
title: formatCindyMakeTitle(item.title, item.runId),
})}
className="size-4 accent-[var(--confirm-btn-primary-bg)]"
onChange={(event) =>
setCheckedIds((previous) =>
event.target.checked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
*
* 三个安全上限改用下拉(各含「不限」=null),默认收起。值类型 number | null。
* 预设见下方常量;若当前值不在预设里(历史自定义值),会作为额外一项保留显示。
* 颜色全走主题 token(规则 16):trigger 用 settings-input,下拉面板用 model-dropdown。
* 下拉用共享 Select(紧凑 32px、220px),颜色随共享组件;120px 窄档放不下「不限」的译文。
*/

import { SelectParts as Select } from '@/components/ui/select';
import { Check, ChevronDown, ChevronRight } from 'lucide-react';
import { Select } from '@/components/ui/select';
import { ChevronDown, ChevronRight } from 'lucide-react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -38,28 +38,15 @@ function formatTokens(n: number): string {
return String(n);
}

function LimitItem({ value, label }: { value: string; label: string }): React.ReactElement {
return (
<Select.Item
value={value}
className="flex cursor-pointer items-center justify-between gap-3 rounded-lg px-2.5 py-1.5 text-12 outline-none"
style={{ color: 'var(--model-item-text)' }}
>
<Select.ItemText>{label}</Select.ItemText>
<Select.ItemIndicator>
<Check size={13} className="shrink-0" />
</Select.ItemIndicator>
</Select.Item>
);
}

function LimitSelect({
label,
value,
onChange,
presets,
format,
noLimitLabel,
}: {
label: string;
value: number | null;
onChange: (v: number | null) => void;
presets: number[];
Expand All @@ -69,42 +56,19 @@ function LimitSelect({
// 当前值不在预设里(历史自定义)→ 作为额外一项前置,避免编辑时丢值。
const nums = value != null && !presets.includes(value) ? [value, ...presets] : presets;
const current = value == null ? UNLIMITED : String(value);
// 共享 Select(DESIGN.md §4 Desktop settings controls):紧凑 32px、220px。
return (
<Select.Root value={current} onValueChange={(s) => onChange(s === UNLIMITED ? null : Number(s))}>
<Select.Trigger
className="flex h-8 w-[140px] items-center justify-between gap-1 rounded-full border px-3 text-12 outline-none"
style={{
backgroundColor: 'var(--settings-input-bg)',
borderColor: 'var(--settings-input-border)',
color: 'var(--settings-input-text)',
}}
>
<Select.Value />
<Select.Icon>
<ChevronDown size={13} className="opacity-60" />
</Select.Icon>
</Select.Trigger>
<Select.Portal>
<Select.Content
position="popper"
sideOffset={4}
className="z-modal-nested overflow-hidden rounded-xl border p-1.5"
style={{
// 宽度严格跟随 trigger(radix popper 暴露的变量),避免 popup 按内容宽度自适应。
width: 'var(--radix-select-trigger-width)',
backgroundColor: 'var(--model-dropdown-bg)',
borderColor: 'var(--model-dropdown-border)',
}}
>
<Select.Viewport>
{nums.map((n) => (
<LimitItem key={n} value={String(n)} label={format(n)} />
))}
<LimitItem value={UNLIMITED} label={noLimitLabel} />
</Select.Viewport>
</Select.Content>
</Select.Portal>
</Select.Root>
<Select
label={label}
value={current}
size="compact"
width="sm"
options={[
...nums.map((n) => ({ value: String(n), label: format(n) })),
{ value: UNLIMITED, label: noLimitLabel },
]}
onValueChange={(s) => onChange(s === UNLIMITED ? null : Number(s))}
/>
);
}

Expand Down Expand Up @@ -149,6 +113,7 @@ export function GoalAdvancedLimits({
</div>
<Row label={t('goal.editGoal.maxTurns')}>
<LimitSelect
label={t('goal.editGoal.maxTurns')}
value={value.maxTurns}
onChange={(v) => onChange({ ...value, maxTurns: v })}
presets={MAX_TURNS_PRESETS}
Expand All @@ -158,6 +123,7 @@ export function GoalAdvancedLimits({
</Row>
<Row label={t('goal.editGoal.budgetTokens')}>
<LimitSelect
label={t('goal.editGoal.budgetTokens')}
value={value.budgetTokens}
onChange={(v) => onChange({ ...value, budgetTokens: v })}
presets={BUDGET_PRESETS}
Expand All @@ -167,6 +133,7 @@ export function GoalAdvancedLimits({
</Row>
<Row label={t('goal.editGoal.noProgressLimit')}>
<LimitSelect
label={t('goal.editGoal.noProgressLimit')}
value={value.noProgressLimit}
onChange={(v) => onChange({ ...value, noProgressLimit: v })}
presets={NO_PROGRESS_PRESETS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Button } from '@/components/ui/button';
import { useAuth } from '@/contexts/AuthContext';
import type { DesktopAccountDeletionChallenge } from '@/lib/authService';
import { cn } from '@/lib/utils';
import { Checkbox } from '@/components/ui/checkbox';

/**
* Server-gated personal-account deletion entry and OTP confirmation dialog.
Expand Down Expand Up @@ -182,12 +183,12 @@ export function AccountDeletionSection() {
)}
/>
<label className="flex cursor-pointer items-start gap-2 text-13 leading-5 text-[var(--confirm-desc)]">
<input
type="checkbox"
<Checkbox
data-settings-search-action="Acknowledges the account deletion consequences inside the deletion dialog"
checked={acknowledged}
disabled={busy}
onChange={(event) => setAcknowledged(event.target.checked)}
className="mt-1 size-3.5 shrink-0 cursor-pointer accent-[hsl(var(--destructive))]"
className="mt-0.5"
/>
<span>{t('accountDeletion.acknowledgement')}</span>
</label>
Expand Down
Loading
Loading