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。

Merge remote-tracking branch 'origin/main' into feat/desktop-wallpaper-trim

kirozeng8cfab1d3fd08
diff --cc apps/desktop/src/renderer/components/settings/WallpaperSection.tsx
index 5250c40a55,d24d750ea5..754c186c75
--- a/apps/desktop/src/renderer/components/settings/WallpaperSection.tsx
+++ b/apps/desktop/src/renderer/components/settings/WallpaperSection.tsx
@@@ -137,253 -130,265 +134,265 @@@ export function WallpaperSection()
</Button>
</div>
- <div
- className="grid grid-cols-[repeat(auto-fill,minmax(6rem,1fr))] gap-2"
- role="radiogroup"
- aria-label={t('settings.appearance.wallpaper.aria')}
- onBlur={(event) => {
- if (!event.currentTarget.contains(event.relatedTarget)) setFocusedWallpaperId(null);
- }}
- >
- {pickerIds.map((id, index) => {
- const selected = wallpaperId === id;
- const label = t('settings.appearance.wallpaper.options.' + id);
- const background =
- id === 'custom' && customWallpaperUrl && !customVideo
- ? `url("${customWallpaperUrl}")`
- : getBuiltinWallpaperPreview(id);
- return (
- <Tip key={id} text={label}>
- <button
- ref={(button) => {
- if (button) buttons.current.set(id, button);
- else buttons.current.delete(id);
- }}
- type="button"
- role="radio"
- aria-checked={selected}
- aria-label={label}
- disabled={busy}
- tabIndex={!busy && id === entryId ? 0 : -1}
- onFocus={() => setFocusedWallpaperId(id)}
- onKeyDown={(event) => {
- if (busy || event.altKey || event.ctrlKey || event.metaKey) return;
- const rtl = getComputedStyle(event.currentTarget).direction === 'rtl';
- let next: number;
- switch (event.key) {
- case 'ArrowRight':
- next = index + (rtl ? -1 : 1);
- break;
- case 'ArrowLeft':
- next = index + (rtl ? 1 : -1);
- break;
- case 'ArrowDown':
- next = index + 1;
- break;
- case 'ArrowUp':
- next = index - 1;
- break;
- case 'Home':
- next = 0;
- break;
- case 'End':
- next = pickerIds.length - 1;
- break;
- default:
- return;
- }
- event.preventDefault();
- const count = pickerIds.length;
- const target = pickerIds[(next + count) % count];
- buttons.current.get(target)?.focus();
- // An empty custom tile needs explicit activation to open the file picker.
- if (target !== wallpaperId && (target !== 'custom' || customWallpaperUrl)) {
- setWallpaper(target);
- }
- }}
- onClick={() =>
- id === 'custom' && !customWallpaperUrl ? void chooseWallpaper() : setWallpaper(id)
- }
- className={cn(
- 'flex min-w-0 flex-col gap-1 rounded-xl text-left transition-colors',
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--settings-theme-icon-active)]',
- )}
- >
- <span
- className={cn(
- 'relative aspect-video w-full overflow-hidden rounded-xl border bg-[var(--settings-input-bg)]',
- selected
- ? 'border-2 border-[var(--settings-theme-preview-border-active)]'
- : 'border-[var(--settings-theme-preview-border)]',
- )}
- style={{
- backgroundImage: background,
- backgroundPosition: 'center',
- backgroundRepeat: 'no-repeat',
- backgroundSize: 'cover',
- }}
- >
- {id === 'custom' && customVideo ? (
- <span className="absolute inset-0 flex items-center justify-center text-[var(--settings-section-sublabel)]">
- <Film size={22} aria-hidden="true" />
- </span>
- ) : null}
- {id === 'custom' && !customWallpaperUrl ? (
- <span className="absolute inset-0 flex items-center justify-center text-[var(--settings-section-sublabel)]">
- <ImagePlus size={22} aria-hidden="true" />
+ <div id="settings-search-settings-appearance-wallpaper" className={SETTINGS_CARD_CLASS}>
+ <div className="flex flex-col gap-4 px-4 py-4">
+ <div
+ className="grid grid-cols-[repeat(auto-fill,minmax(6rem,1fr))] gap-2"
+ role="radiogroup"
+ aria-label={t('settings.appearance.wallpaper.aria')}
+ onBlur={(event) => {
+ if (!event.currentTarget.contains(event.relatedTarget)) setFocusedWallpaperId(null);
+ }}
+ >
- {SELECTABLE_WALLPAPER_IDS.map((id, index) => {
++ {pickerIds.map((id, index) => {
+ const selected = wallpaperId === id;
+ const label = t('settings.appearance.wallpaper.options.' + id);
+ const background =
+ id === 'custom' && customWallpaperUrl && !customVideo
+ ? `url("${customWallpaperUrl}")`
+ : getBuiltinWallpaperPreview(id);
+ return (
+ <Tip key={id} text={label}>
+ <button
+ ref={(button) => {
+ if (button) buttons.current.set(id, button);
+ else buttons.current.delete(id);
+ }}
+ type="button"
+ role="radio"
+ aria-checked={selected}
+ aria-label={label}
+ disabled={busy}
+ tabIndex={!busy && id === entryId ? 0 : -1}
+ onFocus={() => setFocusedWallpaperId(id)}
+ onKeyDown={(event) => {
+ if (busy || event.altKey || event.ctrlKey || event.metaKey) return;
+ const rtl = getComputedStyle(event.currentTarget).direction === 'rtl';
+ let next: number;
+ switch (event.key) {
+ case 'ArrowRight':
+ next = index + (rtl ? -1 : 1);
+ break;
+ case 'ArrowLeft':
+ next = index + (rtl ? 1 : -1);
+ break;
+ case 'ArrowDown':
+ next = index + 1;
+ break;
+ case 'ArrowUp':
+ next = index - 1;
+ break;
+ case 'Home':
+ next = 0;
+ break;
+ case 'End':
- next = SELECTABLE_WALLPAPER_IDS.length - 1;
++ next = pickerIds.length - 1;
+ break;
+ default:
+ return;
+ }
+ event.preventDefault();
- const count = SELECTABLE_WALLPAPER_IDS.length;
- const target = SELECTABLE_WALLPAPER_IDS[(next + count) % count];
++ const count = pickerIds.length;
++ const target = pickerIds[(next + count) % count];
+ buttons.current.get(target)?.focus();
+ // An empty custom tile needs explicit activation to open the file picker.
+ if (target !== wallpaperId && (target !== 'custom' || customWallpaperUrl)) {
+ setWallpaper(target);
+ }
+ }}
+ onClick={() =>
+ id === 'custom' && !customWallpaperUrl
+ ? void chooseWallpaper()
+ : setWallpaper(id)
+ }
+ className={cn(
+ 'flex min-w-0 flex-col gap-1 rounded-xl text-left transition-colors',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--settings-theme-icon-active)]',
+ )}
+ >
+ <span
+ className={cn(
+ 'relative aspect-video w-full overflow-hidden rounded-xl border bg-[var(--settings-input-bg)]',
+ selected
+ ? 'border-2 border-[var(--settings-theme-preview-border-active)]'
+ : 'border-[var(--settings-theme-preview-border)]',
+ )}
+ style={{
+ backgroundImage: background,
+ backgroundPosition: 'center',
+ backgroundRepeat: 'no-repeat',
+ backgroundSize: 'cover',
+ }}
+ >
+ {id === 'custom' && customVideo ? (
+ <span className="absolute inset-0 flex items-center justify-center text-[var(--settings-section-sublabel)]">
+ <Film size={22} aria-hidden="true" />
+ </span>
+ ) : null}
+ {id === 'custom' && !customWallpaperUrl ? (
+ <span className="absolute inset-0 flex items-center justify-center text-[var(--settings-section-sublabel)]">
+ <ImagePlus size={22} aria-hidden="true" />
+ </span>
+ ) : null}
+ {id === 'none' ? (
+ <span className="absolute inset-0 flex items-center justify-center text-12 text-[var(--settings-section-sublabel)]">
+ {t('settings.appearance.wallpaper.nonePreview')}
+ </span>
+ ) : null}
</span>
- ) : null}
- {id === 'none' ? (
- <span className="absolute inset-0 flex items-center justify-center text-12 text-[var(--settings-section-sublabel)]">
- {t('settings.appearance.wallpaper.nonePreview')}
+ <span
+ className={cn(
+ 'truncate text-12 font-medium',
+ selected
+ ? 'text-[var(--settings-theme-label-active)]'
+ : 'text-[var(--settings-theme-label)]',
+ )}
+ >
+ {label}
</span>
- ) : null}
- </span>
- <span
- className={cn(
- 'truncate text-12 font-medium',
- selected
- ? 'text-[var(--settings-theme-label-active)]'
- : 'text-[var(--settings-theme-label)]',
- )}
- >
- {label}
- </span>
- </button>
- </Tip>
- );
- })}
- </div>
+ </button>
+ </Tip>
+ );
+ })}
+ </div>
- {/* Only the selected wallpaper downloads; the grid stays available while it loads. */}
- {downloading && (
- <DownloadMeter
- progress={{
- label: t('settings.appearance.wallpaper.downloading'),
- percent: downloadProgress * 100,
- }}
- />
- )}
- {retryable && (
- <div role="status" className="flex items-center justify-between gap-3">
- <p className="text-12 text-[var(--settings-section-sublabel)]">
- {t('settings.appearance.wallpaper.downloadFailed')}
- </p>
- <Button variant="secondary" type="button" disabled={busy} onClick={retryDownload}>
- <RotateCcw size={14} aria-hidden="true" />
- {t('settings.appearance.wallpaper.retryDownload')}
- </Button>
- </div>
- )}
+ {/* Only the selected wallpaper downloads; the grid stays available while it loads. */}
+ {downloading && (
+ <DownloadMeter
+ progress={{
+ label: t('settings.appearance.wallpaper.downloading'),
+ percent: downloadProgress * 100,
+ }}
+ />
+ )}
+ {retryable && (
+ <div role="status" className="flex items-center justify-between gap-3">
+ <p className="text-12 text-[var(--settings-section-sublabel)]">
+ {t('settings.appearance.wallpaper.downloadFailed')}
+ </p>
+ <Button variant="secondary" type="button" disabled={busy} onClick={retryDownload}>
+ <RotateCcw size={14} aria-hidden="true" />
+ {t('settings.appearance.wallpaper.retryDownload')}
+ </Button>
+ </div>
+ )}
- <div className="flex flex-wrap items-center gap-3">
- <Button
- variant="secondary"
- type="button"
- disabled={busy}
- onClick={() => void chooseWallpaper()}
- >
- <ImagePlus size={14} aria-hidden="true" />
- {t(
- `settings.appearance.wallpaper.${busy ? 'customBusy' : customWallpaperUrl ? 'customReplace' : 'customChoose'}`,
+ <div className="flex flex-wrap items-center gap-3">
+ <Button
+ variant="secondary"
+ type="button"
+ disabled={busy}
+ onClick={() => void chooseWallpaper()}
+ >
+ <ImagePlus size={14} aria-hidden="true" />
+ {t(
+ `settings.appearance.wallpaper.${busy ? 'customBusy' : customWallpaperUrl ? 'customReplace' : 'customChoose'}`,
+ )}
+ </Button>
+ {customWallpaperUrl && (
+ <Button
+ variant="secondary"
+ type="button"
+ disabled={busy}
+ onClick={() => void removeWallpaper()}
+ >
+ {t('settings.appearance.wallpaper.customRemove')}
+ </Button>
+ )}
+ <p className="text-12 text-[var(--settings-section-sublabel)] opacity-70">
+ {t('settings.appearance.wallpaper.customHint')}
+ </p>
+ </div>
+ {(error || (wallpaperId === 'custom' && playbackFailed)) && (
+ <ErrorNotice
+ role="alert"
+ message={error || t('settings.appearance.wallpaper.customPlaybackFailed')}
+ />
)}
- </Button>
- {customWallpaperUrl && (
- <Button
- variant="secondary"
- type="button"
- disabled={busy}
- onClick={() => void removeWallpaper()}
- >
- {t('settings.appearance.wallpaper.customRemove')}
- </Button>
- )}
- <p className="text-12 text-[var(--settings-section-sublabel)]">
- {t('settings.appearance.wallpaper.customHint')}
- </p>
- </div>
- {(error || (wallpaperId === 'custom' && playbackFailed)) && (
- <ErrorNotice role="alert" message={error || t('settings.appearance.wallpaper.customPlaybackFailed')} />
- )}
+ </div>
- <div className="h-px bg-[var(--settings-input-border)]" />
+ <div className={SETTINGS_ROW_DIVIDER_CLASS} />
- <div className="flex flex-col gap-3">
- {(isSceneWallpaper(wallpaperId) || (wallpaperId === 'custom' && customVideo)) && (
- <div className="flex items-center justify-between gap-3">
- <div>
- <p className="text-13 font-medium text-[var(--settings-section-sublabel)]">
- {t('settings.appearance.wallpaper.motionLabel')}
- </p>
- <p className="mt-1 text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">
- {t('settings.appearance.wallpaper.motionHint')}
- </p>
+ <div className="flex flex-col gap-3 px-4 py-4">
+ {(isSceneWallpaper(wallpaperId) || (wallpaperId === 'custom' && customVideo)) && (
+ <div className="flex items-center justify-between gap-3">
+ <div>
+ <p className="text-13 font-medium text-[var(--settings-section-sublabel)]">
+ {t('settings.appearance.wallpaper.motionLabel')}
+ </p>
+ <p className="mt-1 text-12 leading-[1.4] text-[var(--settings-section-sublabel)] opacity-70">
+ {t('settings.appearance.wallpaper.motionHint')}
+ </p>
+ </div>
+ <SegmentedControl
+ aria-label={t('settings.appearance.wallpaper.motionLabel')}
+ value={wallpaperMotion}
+ onValueChange={setMotion}
+ options={[
+ { value: 'static', label: t('settings.appearance.wallpaper.motionStatic') },
+ { value: 'dynamic', label: t('settings.appearance.wallpaper.motionDynamic') },
+ ]}
+ />
</div>
- <SegmentedControl
- aria-label={t('settings.appearance.wallpaper.motionLabel')}
- value={wallpaperMotion}
- onValueChange={setMotion}
- options={[
- { value: 'static', label: t('settings.appearance.wallpaper.motionStatic') },
- { value: 'dynamic', label: t('settings.appearance.wallpaper.motionDynamic') },
- ]}
+ )}
+ <div className="flex items-center gap-3">
+ <span className="shrink-0 text-12 text-[var(--settings-section-sublabel)]">
+ {t('settings.appearance.wallpaper.visibilityLabel')}
+ </span>
+ <Slider
+ min={APPEARANCE_LIMITS.wallpaperVisibility.min}
+ max={APPEARANCE_LIMITS.wallpaperVisibility.max}
+ step={APPEARANCE_LIMITS.wallpaperVisibility.step}
+ value={[visibility]}
+ onValueChange={([value]) => {
+ if (typeof value === 'number') setVisibility(value);
+ }}
+ aria-label={t('settings.appearance.wallpaper.visibilityLabel')}
+ aria-describedby="wallpaper-visibility-hint"
/>
+ <span className="w-10 shrink-0 text-right font-mono text-12 text-[var(--settings-section-sublabel)]">
+ {Math.round(visibility * 100)}%
+ </span>
</div>
- )}
- <div className="flex items-center gap-3">
- <span className="shrink-0 text-12 text-[var(--settings-section-sublabel)]">
- {t('settings.appearance.wallpaper.visibilityLabel')}
- </span>
- <Slider
- min={APPEARANCE_LIMITS.wallpaperVisibility.min}
- max={APPEARANCE_LIMITS.wallpaperVisibility.max}
- step={APPEARANCE_LIMITS.wallpaperVisibility.step}
- value={[visibility]}
- onValueChange={([value]) => {
- if (typeof value === 'number') setVisibility(value);
- }}
- aria-label={t('settings.appearance.wallpaper.visibilityLabel')}
- aria-describedby="wallpaper-visibility-hint"
- />
- <span className="w-10 shrink-0 text-right font-mono text-12 text-[var(--settings-section-sublabel)]">
- {Math.round(visibility * 100)}%
- </span>
- </div>
- <p
- id="wallpaper-visibility-hint"
- className="text-12 text-[var(--settings-section-sublabel)]"
- >
- {t('settings.appearance.wallpaper.visibilityHint')}
- </p>
- <div className="flex items-center gap-3">
- <span className="shrink-0 text-12 text-[var(--settings-section-sublabel)]">
- {t('settings.appearance.wallpaper.blurLabel')}
- </span>
- <Slider
- min={APPEARANCE_LIMITS.wallpaperBlur.min}
- max={APPEARANCE_LIMITS.wallpaperBlur.max}
- step={APPEARANCE_LIMITS.wallpaperBlur.step}
- value={[wallpaperBlur ?? 0]}
- disabled={wallpaperId === 'none'}
- onValueChange={([value]) => {
- if (typeof value === 'number') previewBlur(value);
- }}
- onValueCommit={([value]) => {
- if (typeof value === 'number') setBlur(value);
- }}
- onPointerCancel={cancelBlurPreview}
- onLostPointerCapture={cancelBlurPreview}
- aria-label={t('settings.appearance.wallpaper.blurLabel')}
- aria-describedby="wallpaper-blur-hint"
- />
- <span className="w-10 shrink-0 text-right font-mono text-12 text-[var(--settings-section-sublabel)]">
- {wallpaperBlur ?? 0}
- </span>
+ <p
+ id="wallpaper-visibility-hint"
+ className="text-12 text-[var(--settings-section-sublabel)] opacity-70"
+ >
+ {t('settings.appearance.wallpaper.visibilityHint')}
+ </p>
+ <div className="flex items-center gap-3">
+ <span className="shrink-0 text-12 text-[var(--settings-section-sublabel)]">
+ {t('settings.appearance.wallpaper.blurLabel')}
+ </span>
+ <Slider
+ min={APPEARANCE_LIMITS.wallpaperBlur.min}
+ max={APPEARANCE_LIMITS.wallpaperBlur.max}
+ step={APPEARANCE_LIMITS.wallpaperBlur.step}
+ value={[wallpaperBlur ?? 0]}
+ disabled={wallpaperId === 'none'}
+ onValueChange={([value]) => {
+ if (typeof value === 'number') previewBlur(value);
+ }}
+ onValueCommit={([value]) => {
+ if (typeof value === 'number') setBlur(value);
+ }}
+ onPointerCancel={cancelBlurPreview}
+ onLostPointerCapture={cancelBlurPreview}
+ aria-label={t('settings.appearance.wallpaper.blurLabel')}
+ aria-describedby="wallpaper-blur-hint"
+ />
+ <span className="w-10 shrink-0 text-right font-mono text-12 text-[var(--settings-section-sublabel)]">
+ {wallpaperBlur ?? 0}
+ </span>
+ </div>
+ <p
+ id="wallpaper-blur-hint"
+ className="text-12 text-[var(--settings-section-sublabel)] opacity-70"
+ >
+ {t('settings.appearance.wallpaper.blurHint')}
+ </p>
</div>
- <p id="wallpaper-blur-hint" className="text-12 text-[var(--settings-section-sublabel)]">
- {t('settings.appearance.wallpaper.blurHint')}
- </p>
</div>
- </div>
+ </section>
);
}