diff --git a/src/client/clues/settings/config.tsx b/src/client/clues/settings/config.tsx index 1870ecfb..c080ee40 100644 --- a/src/client/clues/settings/config.tsx +++ b/src/client/clues/settings/config.tsx @@ -27,7 +27,7 @@ import { encode as encodeQr } from 'uqr' import { t, type CopyKey } from '../../locales.ts' import { clueRuntimeApi, type ClueRuntimeApi } from '../runtime-api.ts' import { LoadingIndicator } from '../../ui/LoadingIndicator.tsx' -import { ActionButton, Checkbox, Notice, TextInput } from '../../ui/index.ts' +import { ActionButton, Checkbox, FactRow, Notice, TextInput } from '../../ui/index.ts' import { publishClueStatuses, publishClueTask, @@ -1205,35 +1205,19 @@ export function SourceConfigPage(props: SourceConfigPageProps) { {current?.manualPath !== undefined && {t('clueDependencyManualPath')}}
-
- {t('clueDependencyActualPath')} - - {current?.executablePath ?? missingDependencyValue(current)} - -
-
- {t('clueDependencyVersion')} - - {current?.version ?? missingDependencyValue(current)} - -
+ + {current !== undefined && ( -
- {t('clueDependencyCompat')} - - {t('clueDependencyRequirement', { - minimum: current.minimumVersion, - recommended: current.recommendedVersion, - })} - -
+ )} {current?.manualPath !== undefined && ( -
- {t('clueDependencyManualPath')} - {current.manualPath} - { void clearPath(dependencyId) }} /> -
+ { void clearPath(dependencyId) }} />} /> )}

{t('clueDependencyInstallUnavailable')}

{current.manualInstall !== undefined && ( -
- {t('clueDependencyManualInstall')} - - {current.manualInstall.instructions} - {current.manualInstall.url !== undefined && ( - <> - {' '} - - {current.manualInstall.url} - - - )} - -
+ + {current.manualInstall.instructions} + {current.manualInstall.url !== undefined && ( + <> + {' '} + + {current.manualInstall.url} + + + )} + } /> )} )} {current?.state === 'installing' && current.installation !== undefined && currentTask === undefined && ( -
- {t('clueDependencyInstall')} - - {current.installation.stage === undefined - ? t('clueStateInstalling') - : t(STAGE_COPY[current.installation.stage])} - -
+ )} {currentPlan !== undefined && (
-
- - {t('clueDependencyPlanTitle', { name: currentPlan.name, version: currentPlan.version })} - -
-
- - {t('clueDependencyPlanTarget', { path: currentPlan.targetDir })} - -
+ + {/* S2 §6.1: confirm the exact asset being installed -- platform/arch, distribution source+kind, the PATH copy that will be left untouched, and the plan's expiry. */} -
- {t('clueDependencyPlanPlatform')} - - {currentPlan.platform} / {currentPlan.arch} - -
-
- {t('clueDependencyPlanDistribution')} - - {currentPlan.distribution.source} - {' · '} - {t(DISTRIBUTION_COPY[currentPlan.distribution.kind])} - -
-
- - {t('clueDependencyPlanExpires', { - time: new Date(currentPlan.expiresAt).toLocaleString(), - })} - -
+ + +

+ {t('clueDependencyPlanExpires', { time: new Date(currentPlan.expiresAt).toLocaleString() })} +

{!currentPlan.installable && (

{t('clueDependencyInstallUnavailable')} @@ -1366,25 +1319,20 @@ export function SourceConfigPage(props: SourceConfigPageProps) { ))} -

- {t('clueDependencyPlanSystemInstall')} - - {currentPlan.systemInstall === undefined - ? t('clueDependencyPlanSystemInstallNone') - : ( - <> - {currentPlan.systemInstall.executablePath} - {currentPlan.systemInstall.version === undefined - ? '' - : ` · ${currentPlan.systemInstall.version}`} - {' · '} - {currentPlan.systemInstall.compatible - ? t('clueDependencyPlanSystemInstallCompatible') - : t('clueDependencyPlanSystemInstallIncompatible')} - - )} - -
+ + {currentPlan.systemInstall.executablePath} + {currentPlan.systemInstall.version === undefined + ? '' + : ` · ${currentPlan.systemInstall.version}`} + {' · '} + {currentPlan.systemInstall.compatible + ? t('clueDependencyPlanSystemInstallCompatible') + : t('clueDependencyPlanSystemInstallIncompatible')} + + )} />
@@ -1406,17 +1354,14 @@ export function SourceConfigPage(props: SourceConfigPageProps) { )} {currentTask !== undefined && currentTask.state !== 'running' && ( -
- {t('clueDependencyInstall')} - - {currentTask.state === 'succeeded' - ? t('tasksStateDone') - : currentTask.state === 'cancelled' - ? t('clueDependencyInstallCancelled') - : t('clueDependencyInstallFailed')} - {currentTask.error !== undefined && ` — ${currentTask.error.message}`} - -
+ + {currentTask.state === 'succeeded' + ? t('tasksStateDone') + : currentTask.state === 'cancelled' + ? t('clueDependencyInstallCancelled') + : t('clueDependencyInstallFailed')} + {currentTask.error !== undefined && ` — ${currentTask.error.message}`} + } /> )} {currentTask !== undefined && currentTask.state === 'running' && currentTask.progress !== undefined && ( @@ -1457,47 +1402,29 @@ export function SourceConfigPage(props: SourceConfigPageProps) { // The first explicit read is still in flight. "Not configured" is // a terminal verdict this page has not earned yet (the table's // `checked` rule, applied here too). -
- {t('clueConnectionAuthorization')} - {t(CLUE_SOURCE_STATUS_COPY.unchecked)} -
+ {t(CLUE_SOURCE_STATUS_COPY.unchecked)}} /> ) : connection === undefined ? ( // A failed read is NOT "this source was never configured": the // distinction is the whole point of the status surface. -
- {t('clueConnectionAuthorization')} - + {t(connectionReadFailed ? CLUE_SOURCE_STATUS_COPY['request-failed'] : CLUE_SOURCE_STATUS_COPY['not-configured'])} -
+ } /> ) : ( <> -
- {t('clueConnectionAuthorization')} - {connectionReadFailed ? ( - // A failed re-read must mark the row itself, even when a - // previous projection is still on screen — the old "Ready" - // is not the current answer. - - {t(CLUE_SOURCE_STATUS_COPY['request-failed'])} - - ) : ( - - {t(CONNECTION_AUTHORIZATION_COPY[connection.authorization])} - - )} -
+ {/* A failed re-read marks the row itself, even when a previous + projection is still on screen: the old "Ready" is not the answer. */} + {t(CLUE_SOURCE_STATUS_COPY['request-failed'])} + : {t(CONNECTION_AUTHORIZATION_COPY[connection.authorization])}} /> {connection.account !== undefined && ( -
- {t('clueConnectionAccount')} - {connection.account} -
+ )} {connection.detail !== undefined &&

{connection.detail}

} {connection.error !== undefined &&

{connection.error.message}

} @@ -1568,25 +1495,14 @@ export function SourceConfigPage(props: SourceConfigPageProps) { {connection.prompt !== undefined && (
{connection.prompt.verificationUrl !== undefined && ( -
- {t('clueConnectionUrl')} - - - {connection.prompt.verificationUrl} - - -
+ + {connection.prompt.verificationUrl} + + } /> )} {connection.prompt.userCode !== undefined && ( -
- {t('clueConnectionCode')} - {connection.prompt.userCode} -
+ )} {connection.prompt.qr !== undefined && (
@@ -1601,17 +1517,12 @@ export function SourceConfigPage(props: SourceConfigPageProps) { )} -
- {t('clueConnectionQrPayload')} - {connection.prompt.qr.uri} -
+
)} -
- {t('clueConnectionExpires', { - time: new Date(connection.prompt.expiresAt).toLocaleString(), - })} -
+

+ {t('clueConnectionExpires', { time: new Date(connection.prompt.expiresAt).toLocaleString() })} +

{connection.prompt.instructions !== undefined && (

{connection.prompt.instructions}

)} @@ -1620,13 +1531,11 @@ export function SourceConfigPage(props: SourceConfigPageProps) {
{t('clueConnectionConfiguration')} · {t('windowReadOnly')}
-
- {t('clueConnectionConfiguration')} - {connectionReadFailed ? ( - // The old projection is kept as LAST-KNOWN context, but it - // is no longer the current answer: the row itself says the - // read failed instead of presenting a stale "Ready". - + {/* The old projection stays as LAST-KNOWN context, but the row + itself says the read failed instead of presenting a stale "Ready". */} + {t(CLUE_SOURCE_STATUS_COPY['request-failed'])} @@ -1634,13 +1543,10 @@ export function SourceConfigPage(props: SourceConfigPageProps) { {t('clueConnectionLastKnown')} {configurationCopy(connection.configuration)} - + ) : ( - - {configurationCopy(connection.configuration)} - - )} -
+ {configurationCopy(connection.configuration)} + )} />
diff --git a/src/client/clues/settings/settings.module.css b/src/client/clues/settings/settings.module.css index 590fb3d7..30ba8b1e 100644 --- a/src/client/clues/settings/settings.module.css +++ b/src/client/clues/settings/settings.module.css @@ -21,31 +21,6 @@ line-height: 20px; } -.sourcesIntro { - margin: 0; - padding: 0; - font-size: 12px; - line-height: 18px; - color: var(--dsw-alias-label-tertiary); - overflow-wrap: anywhere; -} - -.error { - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: space-between; - gap: 8px; - padding: var(--ds-sidebar-space-2) var(--ds-sidebar-space-3); - border: 1px solid var(--dsw-alias-border-l2); - border-radius: var(--ds-sidebar-radius); - background: var(--dsw-alias-bg-layer-1); - font-size: 12px; - line-height: 18px; - color: var(--dsw-alias-label-secondary); - overflow-wrap: anywhere; -} - .loading { padding: var(--ds-sidebar-space-2) 0; font-size: 12px; @@ -53,14 +28,6 @@ color: var(--dsw-alias-label-tertiary); } -.empty { - padding: var(--ds-sidebar-space-3) 0; - font-size: 12px; - line-height: 18px; - color: var(--dsw-alias-label-tertiary); - overflow-wrap: anywhere; -} - /* Batch controls: a scope line plus the four explicit actions. */ .batchBar { display: flex; @@ -155,13 +122,6 @@ overflow-wrap: anywhere; } -.sourceId { - font-size: 11px; - line-height: 16px; - color: var(--dsw-alias-label-tertiary); - overflow-wrap: anywhere; -} - /* Derived state badge: neutral by default, warning tint for actionable faults. */ .status { display: inline-flex; @@ -318,15 +278,6 @@ } /* The local pack library: same row geometry, no source switch. */ -.packsRow { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: var(--ds-sidebar-space-2) var(--ds-sidebar-space-3); - min-width: 0; - padding: var(--ds-sidebar-space-3) 0; - border-top: 1px solid var(--dsw-alias-border-l1); -} .addSource { display: flex; @@ -336,15 +287,6 @@ padding-top: 4px; } -.addSourceDesc { - flex: 1 1 220px; - min-width: 0; - font-size: 11px; - line-height: 16px; - color: var(--dsw-alias-label-tertiary); - overflow-wrap: anywhere; -} - /* ── Source configuration window body (S6 window content) ───────────────── */ .config { @@ -384,29 +326,6 @@ color: var(--dsw-alias-label-tertiary); } -.configRow { - display: flex; - flex-wrap: wrap; - align-items: baseline; - gap: var(--ds-sidebar-space-1) var(--ds-sidebar-space-3); - min-width: 0; - font-size: 12px; - line-height: 18px; -} - -.configLabel { - flex: none; - min-width: 72px; - color: var(--dsw-alias-label-tertiary); -} - -.configValue { - flex: 1 1 180px; - min-width: 0; - color: var(--dsw-alias-label-primary); - overflow-wrap: anywhere; -} - .configMono { font-family: var(--ds-font-family-code, monospace); font-size: 11px; @@ -592,17 +511,12 @@ width: 100%; } - .configLabel { - min-width: 0; - } - .advancedRow { align-items: flex-start; } } .configSection + .configSection { padding-top: var(--ds-sidebar-space-2); } -.sourceId { font-family: var(--ds-font-family-code, monospace); } @media (pointer: coarse) { .smallButton, .configInput, @@ -627,7 +541,6 @@ @media (pointer: coarse) { .permissionChoice { min-height: 44px; } } @container sidebar-clue-config (max-width: 480px) { - .configLabel { min-width: 0; } .configInputRow { align-items: stretch; } .configInput { flex-basis: 100%; } .permissionGrid { grid-template-columns: 1fr; } diff --git a/src/client/clues/settings/sources.tsx b/src/client/clues/settings/sources.tsx index a1aa0985..a854eefc 100644 --- a/src/client/clues/settings/sources.tsx +++ b/src/client/clues/settings/sources.tsx @@ -24,7 +24,7 @@ import { FileTypeIcon, IconLinkOutlineRegular } from '@deepseek-ai/dsh-client-ui import { BUILTIN_SOURCE_IDS } from '../../../clues/types.ts' import { CluePackArtwork } from '../artwork.tsx' import { LoadingIndicator } from '../../ui/LoadingIndicator.tsx' -import { ActionButton, ToggleSwitch } from '../../ui/index.ts' +import { ActionButton, EmptyState, ErrorBlock, ToggleSwitch } from '../../ui/index.ts' import { t, type CopyKey } from '../../locales.ts' import { isCluePacksMentionEnabled, @@ -211,21 +211,11 @@ export function ClueSourcesPanel(props: ClueSourcesPanelProps) {
{error !== null && ( -
- {t('clueSourcesLoadFailed')} {error} - - {t('retry')} - -
+ )} {statusError !== null && ( -
- {t('clueStateRequestFailed')} {statusError} - - {t('retry')} - -
+ )} {loading && !catalogueLoaded ? ( @@ -245,7 +235,7 @@ export function ClueSourcesPanel(props: ClueSourcesPanelProps) { ) : catalogueLoaded ? ( sources.length === 0 && configuredOnly.length === 0 - ?
{t('clueSourcesEmpty')}
+ ? : (
    {sources.map(source => { diff --git a/src/client/ui/patterns.module.css b/src/client/ui/patterns.module.css index f646ce44..a30998ec 100644 --- a/src/client/ui/patterns.module.css +++ b/src/client/ui/patterns.module.css @@ -24,10 +24,12 @@ padding: 0; } +/* A long value wraps under its label instead of squeezing it. */ .factRow { display: flex; + flex-wrap: wrap; align-items: baseline; - gap: var(--ds-sidebar-space-2); + gap: var(--ds-sidebar-space-1) var(--ds-sidebar-space-3); min-width: 0; padding: 3px 0; font: var(--dsw-font-xxs-12); @@ -35,15 +37,19 @@ .factLabel { flex: none; + min-width: 72px; color: var(--dsw-alias-label-tertiary); } .factValue { + flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; color: var(--dsw-alias-label-primary); } +.factAction { flex: none; } + /* One ink rung per fact tone; a default fact stays secondary. */ .factRow[data-tone='error'] .factValue { color: var(--dsw-alias-state-error-primary); } .factRow[data-tone='warn'] .factValue { color: var(--dsw-alias-state-warn-primary); } diff --git a/src/client/ui/patterns.tsx b/src/client/ui/patterns.tsx index 3f8d7162..fafd1b41 100644 --- a/src/client/ui/patterns.tsx +++ b/src/client/ui/patterns.tsx @@ -50,11 +50,13 @@ export interface Fact { } /** Props of {@link FactRow}. */ -export interface FactRowProps { - readonly label?: string +export interface FactRowProps extends DataAttributes { + readonly label?: ReactNode readonly value: ReactNode readonly mono?: boolean readonly tone?: PatternTone + /** One trailing control that acts on this fact (clear, copy). */ + readonly action?: ReactNode readonly className?: string } @@ -66,11 +68,12 @@ export interface FactRowProps { * would fight the surrounding semantics. The label/value pair is readable in * order either way. */ -export function FactRow({ label, value, mono, tone, className }: FactRowProps): ReactNode { +export function FactRow({ label, value, mono, tone, action, className, ...dataProps }: FactRowProps): ReactNode { return ( -
    +
    {label !== undefined && {label}} {value} + {action !== undefined && {action}}
    ) } diff --git a/tests/clues-settings-layout.spec.ts b/tests/clues-settings-layout.spec.ts index f3bbccd6..cc31b6d1 100644 --- a/tests/clues-settings-layout.spec.ts +++ b/tests/clues-settings-layout.spec.ts @@ -24,6 +24,7 @@ beforeAll(() => { const SECTION_SHEET = readFileSync(resolve(process.cwd(), 'src/client/SideCardSection.module.css'), 'utf8') const KIT_SHEET = readFileSync(resolve(process.cwd(), 'src/client/ui/kit.module.css'), 'utf8') const CLUE_SHEET = readFileSync(resolve(process.cwd(), 'src/client/clues/settings/settings.module.css'), 'utf8') +const PATTERN_SHEET = readFileSync(resolve(process.cwd(), 'src/client/ui/patterns.module.css'), 'utf8') function ruleBody(sheet: string, selector: string): string | undefined { return new RegExp(`${selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*\\{([^}]*?)\\}`).exec(sheet)?.[1] @@ -53,7 +54,8 @@ describe('grouped settings layout', () => { for (const selector of ['.settingsShell', '.groupPane']) expect(ruleBody(SECTION_SHEET, selector)).toContain('min-width: 0') expect(ruleBody(CLUE_SHEET, '.sources')).toContain('container: sidebar-clue-sources / inline-size') expect(ruleBody(CLUE_SHEET, '.sourceRow')).toContain('flex-wrap: wrap') - for (const selector of ['.sourceName', '.sourceId', '.configValue']) expect(ruleBody(CLUE_SHEET, selector)).toContain('overflow-wrap: anywhere') + expect(ruleBody(CLUE_SHEET, '.sourceName')).toContain('overflow-wrap: anywhere') + expect(ruleBody(PATTERN_SHEET, '.factValue')).toContain('overflow-wrap: anywhere') const narrow = containerBlock(CLUE_SHEET, 'sidebar-clue-sources', 420) expect(narrow).toMatch(/\.sourceIdentity\s*\{[^}]*flex-basis: 100%;/) expect(narrow).toMatch(/\.sourceControls\s*\{[^}]*width: 100%;/)