merge #1101: fix(changes) 视角切换改用公开 SegmentedControl,删除对宿主私有 CSS 哈希类名的依赖(#1098)
This commit is contained in:
commit
5178cabcec
5 files changed
+22
-44
No files matched your search
@@ -2,7 +2,7 @@
|
||||
* The unified changes tab: one tab, two lenses on "what changed?" — Git
|
||||
* (repository truth: staged/unstaged files, commit box, history) and the
|
||||
* session round (agent truth: every file the model read, wrote, or edited).
|
||||
* A 36px header carries the host conversation Tabs and the current
|
||||
* A 36px header carries the public SegmentedControl and the current
|
||||
* lens's refresh action; both lenses preview their selections in a shared
|
||||
* resizable bottom pane ({@link DiffPane}), and git targets expand into the
|
||||
* dedicated diff tab docked in the workbench's diff pane. The bottom pane is
|
||||
@@ -22,7 +22,7 @@
|
||||
* store owns its own poller).
|
||||
*/
|
||||
import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
|
||||
import { IconRefreshOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import { IconRefreshOutlineRegular, SegmentedControl } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { SidebarSessionEvent } from '../../context-types.ts'
|
||||
import type { TabComponentProps } from '../service.ts'
|
||||
import { t } from '../locales.ts'
|
||||
@@ -248,35 +248,16 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen
|
||||
return (
|
||||
<div className={css.root}>
|
||||
<div className={css.head}>
|
||||
{/* ponytail: conversation Tabs are private in DSH 0.2.0-rc.2; reuse
|
||||
their CSS classes until the host exports the component. */}
|
||||
<div className="wSkVaW_tabs" role="tablist" aria-label={t('changes')}>
|
||||
{(['git', 'session'] as const).map(value => (
|
||||
<button
|
||||
key={value}
|
||||
id={`${lensId}-${value}`}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={lens === value}
|
||||
aria-controls={`${lensId}-${value}-panel`}
|
||||
tabIndex={lens === value ? 0 : -1}
|
||||
className={`wSkVaW_tab${lens === value ? ' wSkVaW_tabActive' : ''}`}
|
||||
onClick={() => { chooseLens(value) }}
|
||||
onKeyDown={event => {
|
||||
let next: Lens
|
||||
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') next = value === 'git' ? 'session' : 'git'
|
||||
else if (event.key === 'Home') next = 'git'
|
||||
else if (event.key === 'End') next = 'session'
|
||||
else return
|
||||
event.preventDefault()
|
||||
chooseLens(next)
|
||||
event.currentTarget.parentElement?.querySelector<HTMLButtonElement>(`[id="${lensId}-${next}"]`)?.focus()
|
||||
}}
|
||||
>
|
||||
{t(value === 'git' ? 'changesGitLens' : 'changesSessionLens')}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<SegmentedControl
|
||||
id={lensId}
|
||||
value={lens === 'session' ? 'session' : 'git'}
|
||||
options={[
|
||||
{ value: 'git', label: t('changesGitLens') },
|
||||
{ value: 'session', label: t('changesSessionLens') },
|
||||
] as const}
|
||||
onChange={chooseLens}
|
||||
label={t('changes')}
|
||||
/>
|
||||
{/* The Git lens refreshes from its own Changes header (#944); only the
|
||||
session lens needs the tab-level action. */}
|
||||
{lens === 'session' && <IconButton
|
||||
|
||||
@@ -124,9 +124,8 @@ export interface PaneTab {
|
||||
* A compact tab strip — a real tablist with roving focus: the active tab is
|
||||
* the only tab stop, and Left/Right/Home/End move focus AND selection (the
|
||||
* standard automatic-activation model). Born as the bottom pane's strip
|
||||
* (details / diff); the changes tab's header reuses it for the lens switcher
|
||||
* so the page's two switchers read as one component. Rendered only when the
|
||||
* caller hosts more than one view, so a diff-only preview never grows a strip.
|
||||
* (details / diff). Rendered only when the caller hosts more than one view,
|
||||
* so a diff-only preview never grows a strip.
|
||||
*/
|
||||
export function PaneTabStrip(props: { tabs: readonly PaneTab[]; active: string; onSelect(id: string): void; className?: string; label?: string }) {
|
||||
const buttons = useRef<(HTMLButtonElement | null)[]>([])
|
||||
|
||||
@@ -15,12 +15,10 @@
|
||||
|
||||
.head { flex: none; display: flex; align-items: stretch; gap: 8px; height: 36px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--dsw-alias-border-l1); }
|
||||
.headAction { margin-left: auto; align-self: center; }
|
||||
.head :global(.wSkVaW_tabs) { gap: 24px; }
|
||||
.lensBody { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
||||
/* Retained but not on screen: `display: flex` above would otherwise win over
|
||||
the `hidden` attribute and two lenses would share the column. */
|
||||
.lensBody[hidden] { display: none; }
|
||||
.head :global(.wSkVaW_tab):focus-visible { outline: 2px solid var(--dsw-alias-interactive-bg-hover-accent); outline-offset: -2px; }
|
||||
|
||||
/* ── Git lens (the former git panel) ───────────────────────────────────── */
|
||||
|
||||
|
||||
Reference in new issue
Block a user