feat(sidebar): polish loading, floating windows and clue provenance

This commit is contained in:
Menghuan1918 committed 2026-11-24 16:43:27 +08:00
1 parent 3313b8779f
commit 39ccabcefb
40 files changed
+337 -101

No files matched your search

+2 -2
View File
@@ -51,7 +51,7 @@ import type { ClueSelectionActionTarget } from './clues/selection-actions.tsx'
import { clearRetargetedPath, closePathTabs, consumeRetargetedPath, pathTabKey, retargetPathTabs } from './tree-mutations.ts'
import type { EditorToolbarControls, EditorToolbarState, FileViewerDescriptor, TabActionDescriptor } from './service.ts'
import { firstLeaf, insertLeafAt, leafWithTab, mintTabId, type SidebarStore, type SidebarTab } from './state.ts'
import { Tabs } from './ui/index.ts'
import { LoadingIndicator, Tabs } from './ui/index.ts'
import css from './sidebar.module.css'
/**
@@ -945,7 +945,7 @@ export function EditorHost(props: {
<div className={css.editorMain}>
{actionError !== null && <div className={css.editorError}>{actionError}</div>}
{showEmpty && <div className={css.editorPlaceholder}>{t('editorEmptyHint')}</div>}
{!showEmpty && load.status === 'loading' && <div className={css.editorPlaceholder}>{t('loading')}</div>}
{!showEmpty && load.status === 'loading' && <LoadingIndicator centered />}
{!showEmpty && load.status === 'error' && (
<div className={css.editorError} role="alert">
<div>{load.fileNotFound ? t('editorFileNotFound', { path }) : load.message}</div>
+2 -2
View File
@@ -4,7 +4,7 @@
* scrolling body, an optional footer and three resize strips.
*
* Tokens only (`--dsw-alias-*` / `--dsw-font-*`): the frame wears the same
* 1px `border-l2` edge, 6px corners and a flat token surface.
* 2px `border-l4` edge, 6px corners and a flat token surface.
*/
.window {
position: fixed;
@@ -14,7 +14,7 @@
min-width: 0;
min-height: 0;
background: var(--dsw-alias-bg-layer-1);
border: 1px solid var(--dsw-alias-border-l2);
border: 2px solid var(--dsw-alias-border-l4);
border-radius: 6px;
box-shadow: none;
overflow: hidden;
+1 -1
View File
@@ -34,7 +34,7 @@
* streamed log is the visible drag lag of #315).
*
* Skin contract: tokens only (`--dsw-alias-*` / `--dsw-font-*`), the floating
* layer uses the same flat 1px border and 6px corners as the shared controls.
* layer uses a stronger 2px edge and 6px corners to separate it from the page.
*/
import {
Fragment, isValidElement, useCallback, useEffect, useMemo, useRef, useState,
+2 -1
View File
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from 'react'
import clsx from 'clsx'
import { downloadUrl, mediaUrl, type SessionScope } from './api.ts'
import { t } from './locales.ts'
import { LoadingIndicator } from './ui/LoadingIndicator.tsx'
import css from './sidebar.module.css'
export function PdfView(props: { scope: SessionScope; path: string; title: string }) {
@@ -91,7 +92,7 @@ export function PdfView(props: { scope: SessionScope; path: string; title: strin
</a>
</div>
<div className={css.editorPdfStage}>
{load.status === 'loading' && <div className={css.editorPlaceholder}>{t('loading')}</div>}
{load.status === 'loading' && <LoadingIndicator centered />}
{load.status === 'error' && <div className={css.editorError}>{load.message}</div>}
{load.status === 'ready' && (
<iframe
+9 -12
View File
@@ -1724,7 +1724,7 @@ export function SideCardSection(props: SideCardSectionInjected & Partial<PropsRu
rowKey: string
error?: string
onToggle: (next: boolean) => void
/** A feature with related settings shows a separate secondary action. */
/** An absent handler leaves the aligned settings action disabled. */
onOpenSettings?: () => void
}) => {
const hasSettingsAction = props.onOpenSettings !== undefined
@@ -1748,13 +1748,12 @@ export function SideCardSection(props: SideCardSectionInjected & Partial<PropsRu
onChange={props.onToggle}
/>
</div>
{hasSettingsAction && (
<IconButton
icon={<IconSettingsOutlineRegular size={14} />}
label={`${props.title} ${t('settingsPopup')}`}
onClick={() => { props.onOpenSettings?.() }}
/>
)}
<IconButton
icon={<IconSettingsOutlineRegular size={14} />}
label={`${props.title} ${t('settingsPopup')}`}
disabled={!hasSettingsAction}
onClick={() => { props.onOpenSettings?.() }}
/>
{props.error !== undefined && (
<p className={css.cardError} role="alert" data-settings-error={props.rowKey}>
{props.error}
@@ -1785,9 +1784,7 @@ export function SideCardSection(props: SideCardSectionInjected & Partial<PropsRu
rowKey: `tab:${tab.id}`,
error: writeErrors[`tab:${tab.id}`],
onToggle: (next) => { onToggleTab(tab.id, next) },
// The settings gear only while the feature is enabled: its
// related settings are dormant while the feature is off.
onOpenSettings: prefs.tabsEnabled[tab.id] !== false && hasSettings(tab)
onOpenSettings: hasSettings(tab)
? () => { setSettingsFor(tab) }
: undefined,
})}
@@ -1828,7 +1825,7 @@ export function SideCardSection(props: SideCardSectionInjected & Partial<PropsRu
rowKey: `viewer:${viewer.id}`,
error: writeErrors[`viewer:${viewer.id}`],
onToggle: (next) => { onToggleViewer(viewer.id, next) },
onOpenSettings: prefs.viewersEnabled[viewer.id] !== false && hasSettings(viewer)
onOpenSettings: hasSettings(viewer)
? () => { setSettingsFor(viewer) }
: undefined,
})}
+3 -1
View File
@@ -34,4 +34,6 @@
color: var(--dsw-alias-label-primary);
}
/* Clues uses its own token-layered collection artwork (clues/artwork.tsx). */
.clues {
color: var(--dsw-alias-state-business-primary, var(--dsw-alias-brand-primary));
}
+21 -18
View File
@@ -6,19 +6,13 @@
* tab strip, the native right Sidebar's guide capsules and its tab chips — all
* read the same colorful glyph from `descriptor.icon`.
*
* The color always arrives from a theme token, never from the plugin: the
* ordinary glyph is a VSCodicon drawn in `currentColor`, and the wrapper class
* supplies that color. Clues instead uses token-colored layered artwork, as do
* the collection rows inside its workbench. A skin keeps control (guide §12);
* `tests/theme.spec.ts` checks these modules for color literals.
*
* `files` is the one exception in kind rather than in color: it renders DSH's
* own folder artwork (`FileTypeIcon`), matching the file rows this tab shows.
* Each glyph draws in `currentColor`; its wrapper supplies a skin-owned
* token. File preview and Clues use distinct outline silhouettes so their
* meaning remains clear at dense tab-strip sizes. Collection rows retain
* their separate layered artwork. `tests/theme.spec.ts` guards the palette.
*/
import type { ReactNode } from 'react'
import { FileTypeIcon } from '@deepseek-ai/dsh-client-ui-primitives'
import styles from './tab-icons.module.css'
import { CluePackArtwork } from '../clues/artwork.tsx'
import {
VscCommentDiscussion,
VscGitCommit,
@@ -26,7 +20,7 @@ import {
VscTerminal,
} from 'react-icons/vsc'
/** The styled wrapper classes; typed so a renamed rule fails the build. */
const css = styles as Record<'files' | 'changes' | 'tasks' | 'sidechat' | 'terminal', string>
const css = styles as Record<'files' | 'clues' | 'changes' | 'tasks' | 'sidechat' | 'terminal', string>
/** One tab type's glyph, sized by the caller's surface (14px in a strip). */
export type TabIcon = (size: number) => ReactNode
@@ -36,11 +30,14 @@ function themed(className: string, glyph: ReactNode): ReactNode {
return <span className={className}>{glyph}</span>
}
/** The Files tab: the host's folder artwork, like the rows it opens. */
export const filesTabIcon: TabIcon = (size) => (
<span className={css.files}>
<FileTypeIcon kind="folder" size={size} />
</span>
/** File preview: a folded document with a clear reading aperture. */
export const filesTabIcon: TabIcon = (size) => themed(css.files,
<svg width={size} height={size} viewBox="0 0 20 20" fill="none" aria-hidden="true" focusable="false">
<path d="M4 2h7l4 4v4M15 16v1a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1Z" stroke="currentColor" strokeWidth="1.5" strokeLinejoin="round" />
<path d="M11 2v4h4M6 6h2M6 9h4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
<path d="M8 13.5s2-3 5-3 5 3 5 3-2 3-5 3-5-3-5-3Z" stroke="currentColor" strokeWidth="1.5" />
<circle cx="13" cy="13.5" r="1.4" fill="currentColor" />
</svg>,
)
/** Changes / diff: the commit glyph, green like the diff affordances. */
@@ -67,5 +64,11 @@ export const sidechatTabIcon: TabIcon = (size) =>
export const terminalTabIcon: TabIcon = (size) =>
themed(css.terminal, <VscTerminal size={Math.max(10, Math.round(size * 0.85))} />)
/** Clues — the same layered collection artwork used by its directory rows. */
export const cluesTabIcon: TabIcon = (size) => <CluePackArtwork size={size} />
/** Clues: collected cards with a bookmark, distinct from the file viewer. */
export const cluesTabIcon: TabIcon = (size) => themed(css.clues,
<svg width={size} height={size} viewBox="0 0 20 20" fill="none" aria-hidden="true" focusable="false">
<path d="M3 13H2.5A1.5 1.5 0 0 1 1 11.5v-8A1.5 1.5 0 0 1 2.5 2h10A1.5 1.5 0 0 1 14 3.5V4" stroke="currentColor" strokeWidth="1.5" />
<rect x="5" y="6" width="13" height="12" rx="2" stroke="currentColor" strokeWidth="1.5" />
<path d="M12 6v6l2-1.5 2 1.5V6M8 14h3M8 16h5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
</svg>,
)
+19
View File
@@ -33,6 +33,7 @@ import type { ClueSourceDescriptor } from '../../clues/types.ts'
import { t } from '../locales.ts'
import {
insertDraftReference,
insertReferenceOrText,
type ComposerReference,
type ComposerSpan,
} from '../conversation-draft.ts'
@@ -201,6 +202,24 @@ export function insertClueReference(ctx: Context, sessionId: string, request: Cl
}
}
/** Insert a selected excerpt with its stable provenance in one model-facing payload. */
export function insertClueSelectionReference(ctx: Context, sessionId: string, request: {
readonly clueId: string
readonly selection: string
readonly label?: string
}): boolean {
if (sessionId === '' || request.selection.trim() === '') return false
let token: string
try { token = serializeClueToken('clue', request.clueId) } catch { return false }
// The built-in reference codec sends this payload verbatim; the clue codec
// sends only the source token and would discard the selected excerpt.
return insertReferenceOrText(ctx, sessionId, {
label: request.label ?? request.selection.trim().split('\n')[0]!.slice(0, 80),
text: token + '\n\n' + request.selection,
clipboardText: token,
})
}
/**
* Insert a whole pack's reference (no ensure: the pack id is already stable).
* @returns whether the chip landed.
+21 -7
View File
@@ -109,7 +109,8 @@ export function startClueSelectionAction(request: ClueSelectionActionRequest): P
}
/** One insert decision: the parent appends the payload to its composer draft. */
interface ClueSelectionInsertInput {
export interface ClueSelectionInsertInput {
readonly clueId?: string
/** Present when the wrapper/bridge knows the owning clue target. */
readonly workspaceId?: string
readonly sessionId?: string
@@ -123,7 +124,7 @@ interface ClueSelectionInsertInput {
}
/** The parent-installed insert callback; `false` may mean "refused". */
export type ClueSelectionInsertHandler = (input: ClueSelectionInsertInput) => boolean | void
export type ClueSelectionInsertHandler = (input: ClueSelectionInsertInput) => boolean | void | Promise<boolean | void>
/**
* The page-wide bridge. It survives a component tree with no
@@ -184,7 +185,7 @@ export function useClueSelectionActionTarget(scope?: ClueSelectionActionScope):
const local = useContext(TargetContext)
const bridge = useSyncExternalStore(subscribeClueSelectionActionContext, getClueSelectionActionContext, getClueSelectionActionContext)
if (local !== undefined) {
return bridge?.onInsert === undefined ? local : { ...local, onInsert: bridge.onInsert }
return local.onInsert !== undefined || bridge?.onInsert === undefined ? local : { ...local, onInsert: bridge.onInsert }
}
if (bridge?.workspaceId === undefined || bridge.resource === undefined) return undefined
// A module-level target is only safe for the surface it named. A caller
@@ -336,8 +337,19 @@ export function SelectionActionMenu(props: SelectionActionMenuProps): ReactNode
// A parent may refuse the insert (e.g. the composer moved); keep the
// menu and the captured selection available for an explicit retry.
const reference = props.reference ?? { label: selection.trim().split('\n')[0]!.slice(0, 80), text: insert }
const accepted = onInsert?.({ workspaceId, sessionId, resource, selection, insert, reference })
if (accepted !== false) onClose?.()
busyRef.current = true
setBusy(action)
setFailure(null)
try {
const accepted = await onInsert?.({ workspaceId, sessionId, resource, selection, insert, reference })
if (accepted === false) setFailure({ message: t('clueInsertFailed') })
else onClose?.()
} catch (error) {
setFailure({ message: error instanceof Error ? error.message : t('clueInsertFailed') })
} finally {
busyRef.current = false
setBusy(null)
}
return
}
// Freeze synchronously as well as visually: two clicks in one render must not mint two intents.
@@ -455,6 +467,7 @@ export function SelectionActionMenu(props: SelectionActionMenuProps): ReactNode
/** Props of the wrapper surface. */
interface ResourceSelectionActionsProps {
readonly onInsert?: ClueSelectionInsertHandler
readonly workspaceId: string
readonly sessionId: string
readonly resource: ClueClientResourceInput
@@ -472,12 +485,13 @@ export function ResourceSelectionActions(props: ResourceSelectionActionsProps):
const { workspaceId, sessionId, resource, children, comment } = props
const wrapperRef = useRef<HTMLDivElement>(null)
const bridge = useClueSelectionActionContext()
const onInsert = props.onInsert ?? bridge?.onInsert
const target: ClueSelectionActionTarget = {
workspaceId,
sessionId,
resource,
...(comment === undefined ? {} : { comment }),
...(bridge?.onInsert === undefined ? {} : { onInsert: bridge.onInsert }),
...(onInsert === undefined ? {} : { onInsert }),
}
const popup = useSelectionPopup({
onCommit: () => undefined,
@@ -546,7 +560,7 @@ export function ResourceSelectionActions(props: ResourceSelectionActionsProps):
...(comment === undefined ? {} : { comment }),
left: popup.popup.left,
top: popup.popup.top,
...(bridge?.onInsert === undefined ? {} : { onInsert: bridge.onInsert }),
...(onInsert === undefined ? {} : { onInsert }),
onClose: () => { popup.hide() },
containerRef: popup.popupRef,
}),
+1 -1
View File
@@ -367,7 +367,7 @@ export function CluesTab({ ctx, store, scope, visible }: CluesTabProps): ReactNo
{visible && helpOpen && <ClueHelpOverlay onClose={closeHelp} />}
{!resolved && (
<LoadingIndicator className={css.state} />
<LoadingIndicator centered />
)}
{resolved && workspaceId === undefined && (
<EmptyState tone="page" title={t('clueTabNoWorkspace')}
+1 -1
View File
@@ -1261,7 +1261,7 @@ export function ClueBrowser(props: ClueBrowserProps): ReactNode {
}} />
)}
{state.kind === 'idle' && <EmptyState title={t('clueBrowserSearchNeeded')} />}
{state.kind === 'loading' && <LoadingIndicator className={css.stateLine} />}
{state.kind === 'loading' && <LoadingIndicator centered />}
{state.kind === 'needs-scope' && (
<EmptyState title={state.reason === 'search' ? t('clueBrowserSearchScopeNeeded') : t('clueScopeNoDefault')}
actions={<ActionButton size="sm" onClick={() => { setScopeOpen(true) }}>{t('clueBrowserScopeEdit')}</ActionButton>} />
@@ -353,6 +353,8 @@
overscroll-behavior: contain;
scrollbar-width: thin;
}
.resultArea[data-clue-browser-state='loading'] { display: flex; flex-direction: column; }
.resultArea[data-clue-browser-state='loading'] > .listContainer { flex: 1; min-height: 0; }
.resultArea:focus-visible {
outline: 2px solid var(--dsw-alias-brand-primary);
outline-offset: -2px;
@@ -494,6 +496,7 @@
.packRegion > [data-workbench-section] {
max-height: 100%;
}
.packScroll:has(> [data-loading-indicator][data-centered]) { display: flex; flex-direction: column; }
.packScroll {
flex: 1;
min-height: 0;
+2 -2
View File
@@ -44,7 +44,7 @@ import { cluesApi, invalidateClueRequests, peekClueRequest } from '../api.ts'
import { openShareWindow } from '../windows/share.tsx'
import {
ActionButton, ConfirmDialog, EmptyState, ErrorBlock, IconButton, ListRow, LoadingIndicator, Menu,
Notice, SearchField, StatusLine, TextInput,
Notice, SearchField, TextInput,
} from '../../ui/index.ts'
import { useScrollLoad } from '../../ui/use-scroll-load.ts'
import { useListNavigation } from '../../ui/use-list-navigation.ts'
@@ -454,7 +454,7 @@ export function CluePacksSection(props: CluePacksSectionProps): ReactNode {
)}
<div ref={scrollRef} className={css.packScroll} data-clue-pack-scroll>
{phase === 'loading' && <StatusLine plain text={<LoadingIndicator inline />} />}
{phase === 'loading' && <LoadingIndicator centered />}
{error !== null && (
<ErrorBlock
message={error}
+1 -1
View File
@@ -22,7 +22,7 @@ export interface ResourceDiscussionProps {
readonly pathImages?: MarkdownPathImages
readonly showAvatars?: boolean
/** Captured resource ownership; only each comment's body enters this surface. */
readonly selectionTarget?: Pick<ClueSelectionActionTarget, 'workspaceId' | 'sessionId' | 'resource'>
readonly selectionTarget?: Pick<ClueSelectionActionTarget, 'workspaceId' | 'sessionId' | 'resource' | 'onInsert'>
onLoad(cursor?: string, parentId?: string): void
onCreate(body: string, replyToId: string | undefined, requestId: string): Promise<void>
}
+19 -5
View File
@@ -79,7 +79,7 @@ import {
} from '../resource-summary.tsx'
import { ClueError } from '../../../clues/error.ts'
import { ResourceDiscussion } from './comments.tsx'
import { ResourceSelectionActions, type ClueSelectionActionTarget } from '../selection-actions.tsx'
import { getClueSelectionActionContext, ResourceSelectionActions, type ClueSelectionActionTarget, type ClueSelectionInsertInput } from '../selection-actions.tsx'
import { BUILTIN_SOURCE_IDS } from '../../../clues/types.ts'
import css from './detail.module.css'
@@ -269,7 +269,7 @@ function readOnlyReasonCopy(reason: string | undefined): string {
/** The loading body. */
function DetailStatus(props: { readonly text: string }): ReactNode {
return createElement('div', { className: css.status }, createElement(LoadingIndicator, { label: props.text }))
return createElement(LoadingIndicator, { centered: true, label: props.text })
}
/** One explicit failure that could not even produce a preview. */
@@ -608,7 +608,7 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
// active composer/session later when the reader selects its retained body.
const selectionTarget: ClueSelectionActionTarget | undefined = options.sessionId === undefined || options.sessionId === ''
? undefined
: { workspaceId, sessionId: options.sessionId, resource }
: { workspaceId, sessionId: options.sessionId, resource, onInsert: insertSelection }
// Optional methods keep existing third-party API fakes body-only.
const discussionApi = face.api as typeof face.api & {
commentsList?(workspaceId: string, input: ClueClientResourceInput & { cursor?: string; parentId?: string }, signal?: AbortSignal): Promise<ClueDiscussionPage>
@@ -771,11 +771,9 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
}
function pendingContent(): ReactNode {
const header = headerNode()
return createElement(
'div',
{ className: css.view, 'data-clue-detail-view': 'pending' },
header ?? null,
createElement(DetailStatus, { text: t('loading') }),
)
}
@@ -1577,6 +1575,22 @@ function createDetailController(options: ClueDetailWindowOptions): DetailControl
if (commentsCapabilities?.read === true) void loadComments()
}
/** A quote carries the stable source token as well as the exact selected text. */
async function insertSelection(input: ClueSelectionInsertInput): Promise<boolean> {
const insert = getClueSelectionActionContext()?.onInsert
if (insert === undefined || referenceBusy || (target.clueId === undefined && state.read === null)) return false
referenceBusy = true
render()
try {
const clueId = target.clueId ?? (await face.api.ensure(workspaceId, ensureInput())).clue.id
if (disposed) return false
return (await insert({ ...input, clueId })) !== false
} finally {
referenceBusy = false
render()
}
}
/** Insert one reference; first persistence carries subtitle/info snapshots. */
async function insertReference(): Promise<void> {
// A candidate with no authoritative read must not persist the opening
+3
View File
@@ -10,6 +10,7 @@
*/
import { createElement } from 'react'
import type { SidebarStore } from '../../state.ts'
import type { NativeGuideCatalog } from '../../native/guide-catalog.ts'
import type { BetterSidebarService } from '../../service.ts'
import type { BetterSidebarWindowsClientFace, WindowHandle } from '../../windows/types.ts'
@@ -27,6 +28,7 @@ interface OpenClueSettingsWindowOptions {
readonly store: SidebarStore
readonly service: BetterSidebarService
readonly group?: ClueSettingsGroup
readonly guideCatalog?: NativeGuideCatalog
}
/**
@@ -47,6 +49,7 @@ export function openClueSettingsWindow(options: OpenClueSettingsWindowOptions):
store: options.store,
service: options.service,
initialGroup: group,
guideCatalog: options.guideCatalog,
}),
})
}
+4 -2
View File
@@ -48,7 +48,7 @@ import { registerGithubSourceClient } from './clues/sources/github/index.tsx'
import { registerFeishuSourceClient } from './clues/sources/feishu/index.tsx'
import { appDateTime } from './clues/sources/feishu/time.ts'
import { installClueInputTriggers } from './clues/mentions.ts'
import { insertClueReferenceSpan, setClueNoticeSink } from './clues/insert.ts'
import { insertClueReferenceSpan, insertClueSelectionReference, setClueNoticeSink } from './clues/insert.ts'
import { clueMentionsCopy, feishuClientLabels } from './clues/locale-copy.ts'
import { notifyClue } from './clues/notify.ts'
import { resolveWorkspaceIdForSession } from './clues/workspace-id.ts'
@@ -263,7 +263,9 @@ export function apply(ctx: Context): void {
invalidate: invalidateClueAgentSave,
})
setClueSelectionActionContext({ onInsert: input => {
const inserted = input.sessionId !== undefined && insertReferenceOrText(ctx, input.sessionId, input.reference ?? { label: input.selection.slice(0, 80), text: input.insert })
const inserted = input.sessionId !== undefined && (input.clueId === undefined
? insertReferenceOrText(ctx, input.sessionId, input.reference ?? { label: input.selection.slice(0, 80), text: input.insert })
: insertClueSelectionReference(ctx, input.sessionId, { clueId: input.clueId, selection: input.selection, label: input.reference?.label }))
if (!inserted) notifyClue(t('clueInsertFailed'))
return inserted
} })
+13 -3
View File
@@ -53,6 +53,8 @@ export interface NativeGuideProps {
onBrowsePlugins?: () => void
/** Host "create your plugin" action, when the workspace can start a session. */
onCreatePlugin?: () => void
/** Open the same Sidebar settings used elsewhere in the plugin. */
onOpenSettings?: () => void
}
/** The grid's inputs, extracted for direct rendering in tests. */
@@ -71,6 +73,8 @@ export interface GuideGridProps {
onBrowsePlugins?: () => void
/** Host "Create your plugin" action, when the workspace can start a session. */
onCreatePlugin?: () => void
/** Open the same Sidebar settings used elsewhere in the plugin. */
onOpenSettings?: () => void
shellMenu?: GuideShellMenu | undefined
}
@@ -204,7 +208,7 @@ function GuideCard(props: {
export function GuideGrid(props: GuideGridProps) {
const {
entries, prefs, width, onOpen, onSaveOrder, onToggleHidden, onSaveRows,
onBrowsePlugins, onCreatePlugin, shellMenu,
onBrowsePlugins, onCreatePlugin, onOpenSettings, shellMenu,
} = props
const inventory = props.inventory ?? entries
const [orderOpen, setOrderOpen] = useState(false)
@@ -262,7 +266,8 @@ export function GuideGrid(props: GuideGridProps) {
...(layout.overflow.length === 0 ? [] : [{ type: 'separator' as const, id: 'overflow-separator' }]),
...hostActions,
...(hostActions.length === 0 ? [] : [{ type: 'separator' as const, id: 'actions-separator' }]),
{ id: 'order', label: t('guideOrder'), icon: menuIcon(<IconSettingsOutlineRegular size={14} />) },
{ id: 'order', label: t('guideOrder'), icon: menuIcon(<IconEllipsisOutlineRegular size={14} />) },
...(onOpenSettings === undefined ? [] : [{ id: 'settings', label: t('clueSettingsWindowTitle'), icon: menuIcon(<IconSettingsOutlineRegular size={14} />) }]),
]
/** The grid body; the More anchor is a card-sized Menu trigger. */
@@ -285,6 +290,10 @@ export function GuideGrid(props: GuideGridProps) {
onCreatePlugin?.()
return
}
if (id === 'settings') {
onOpenSettings?.()
return
}
if (id === 'order') {
setOrderOpen(true)
return
@@ -365,7 +374,7 @@ function useGuideWidth(ref: { current: HTMLDivElement | null }): number {
/** The chain component registered into the host's guide slot. */
export function NativeGuide(props: NativeGuideProps) {
const { catalog, store, service, shellMenu, onBrowsePlugins, onCreatePlugin, useTabInfo } = props
const { catalog, store, service, shellMenu, onBrowsePlugins, onCreatePlugin, onOpenSettings, useTabInfo } = props
const entries = useSyncExternalStore(catalog.subscribe, catalog.getSnapshot, catalog.getSnapshot)
const [descriptors, setDescriptors] = useState(() => service.getTabs())
useEffect(() => service.subscribe(() => setDescriptors(service.getTabs())), [service])
@@ -414,6 +423,7 @@ export function NativeGuide(props: NativeGuideProps) {
onSaveRows={(next) => { saveGuideRows(store, next) }}
onBrowsePlugins={onBrowsePlugins}
onCreatePlugin={onCreatePlugin}
onOpenSettings={onOpenSettings}
shellMenu={shellMenu}
/>
</div>
+2
View File
@@ -36,6 +36,7 @@ import type { SidebarStore } from '../state.ts'
import { webTerminals } from '../terminal-client.ts'
import type { NativeGuideCatalog } from './guide-catalog.ts'
import { NativeGuide } from './guide.tsx'
import { openClueSettingsWindow } from '../clues/windows/settings.tsx'
import { EDITOR_KIND, FILES_KIND, nativeId } from './guide-ids.ts'
import { mountedSessionId } from './surface.ts'
import {
@@ -391,6 +392,7 @@ export function registerNativeSurface(deps: NativeSurfaceDeps): () => void {
catalog,
store,
service,
onOpenSettings: () => { openClueSettingsWindow({ windows: service.windows, store, service, guideCatalog: catalog, group: 'general' }) },
...(shellMenu === undefined ? {} : { shellMenu }),
...(onBrowsePlugins === undefined ? {} : { onBrowsePlugins }),
...(onCreatePlugin === undefined ? {} : { onCreatePlugin }),
+11 -5
View File
@@ -1,24 +1,30 @@
/** Shared loading feedback. CSS motion stops with hidden pages and reduced motion. */
import type { AriaRole, ReactNode } from 'react'
import clsx from 'clsx'
import { IconLoadingOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
import { t } from '../locales.ts'
import css from './loading-indicator.module.css'
export interface LoadingIndicatorProps {
label?: ReactNode
inline?: boolean
/** Fill the available content area instead of occupying a status line. */
centered?: boolean
size?: number
className?: string
role?: AriaRole
}
export function LoadingIndicator({ label, inline = false, size = 14, className, role = 'status' }: LoadingIndicatorProps): ReactNode {
export function LoadingIndicator({ label, inline = false, centered = false, size = centered ? 24 : 14, className, role = 'status' }: LoadingIndicatorProps): ReactNode {
const text = label === undefined ? t('loading') : label
return <span className={clsx(css.root, inline && css.inline, className)}
return <span className={clsx(css.root, inline && css.inline, centered && css.centered, className)}
role={role} aria-live={role === 'presentation' || role === 'none' ? undefined : 'polite'} aria-label={text === '' ? t('loading') : undefined}
data-loading-indicator data-kind="loading">
<span className={css.glyph} aria-hidden="true"><IconLoadingOutlineRegular size={size} /></span>
data-loading-indicator data-kind="loading" data-centered={centered || undefined}>
<span className={css.glyph} aria-hidden="true">
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" focusable="false">
<circle className={css.track} cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="2" />
<path d="M12 3a9 9 0 0 1 9 9" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
</svg>
</span>
{text === '' || text === null ? null : <span className={css.label}>{text}</span>}
</span>
}
+1 -1
View File
@@ -140,7 +140,7 @@ export function Notice(props: {
}): ReactNode {
const tone = props.tone ?? 'well'
if (props.kind === 'loading') {
return <LoadingIndicator label={props.children} inline={tone === 'inline'} role={props.role}
return <LoadingIndicator label={props.children} inline={tone === 'inline'} centered={tone === 'page'} role={props.role}
className={clsx(css.notice, tone === 'page' ? css.noticePage : tone === 'inline' ? css.noticeInline : css.noticeWell,
css.noticeHint, props.className)} />
}
@@ -1,12 +1,24 @@
.root {
display: flex;
align-items: center;
justify-content: center;
gap: var(--ds-sidebar-space-2);
min-width: 0;
color: var(--dsw-alias-label-tertiary);
font: var(--dsw-font-xxs-12);
}
.inline { display: inline-flex; }
.centered {
flex: 1;
align-self: stretch;
flex-direction: column;
justify-content: center;
min-height: 96px;
padding: 24px;
box-sizing: border-box;
text-align: center;
}
.track { opacity: 0.18; }
.glyph {
display: inline-flex;
flex: none;
+4 -1
View File
@@ -48,6 +48,7 @@ interface RetainedSurfaceProps {
readonly surface: WindowView['surface']
readonly destination: HTMLElement | undefined
readonly children: ReactNode
readonly onPlaced: () => void
}
/**
@@ -98,6 +99,7 @@ class RetainedSurface extends Component<RetainedSurfaceProps> {
node.scrollLeft = position.left
}
if (active?.isConnected && document.activeElement !== active) active.focus({ preventScroll: true })
this.props.onPlaced()
}
componentDidMount(): void { this.place(null) }
@@ -124,10 +126,11 @@ function WindowFrame(props: {
const changeBox = useCallback((box: WindowView['box']): void => { host.setBox(id, box) }, [host, id])
const changeMaximized = useCallback((maximized: boolean): void => { host.setMaximized(id, maximized) }, [host, id])
const back = useCallback((): void => { host.popPage(id) }, [host, id])
const placed = useCallback((): void => { host.completeSurfaceMove(id) }, [host, id])
return (
<RetainedSurface target={target} id={id} surface={view.surface}
destination={view.surface === 'floating' ? document.body : view.sidebarTarget}>
destination={view.surface === 'floating' ? document.body : view.sidebarTarget} onPlaced={placed}>
<FloatingWindow
title={view.title}
portalTarget={target}
+1 -1
View File
@@ -259,7 +259,7 @@ export function ClueFormatHost(props: ClueFormatHostProps): ReactNode {
>
<div className={css.formatContent}>
{editLoading === true
? <div className={css.documentStatus} data-window-edit-loading><LoadingIndicator label={t('clueResourceEditLoading')} /></div>
? <div className={css.documentStatus} data-window-edit-loading><LoadingIndicator centered label={t('clueResourceEditLoading')} /></div>
: body(false)}
</div>
</section>}
+11
View File
@@ -13,6 +13,7 @@
* never a second window, never a replaced draft;
* - `update` only changes the fields it names: a streamed refresh cannot move
* or resize a window the reader placed;
* - floating first moves the retained DOM, then removes the native tab;
* - a close runs `onBeforeClose` first (async allowed); false/rejection keeps
* the window and its content alive;
* - the close/unmount path releases the layer subscription, so no listener
@@ -61,6 +62,7 @@ interface WindowRecord {
readonly id: string
readonly sessionId: string | undefined
surface: 'floating' | 'sidebar'
pendingSidebarClose: boolean
sidebarTarget: HTMLElement | undefined
/** The window's own (base) title; a pushed page may override it while on top. */
title: string
@@ -330,6 +332,8 @@ export function createWindowHost(options: WindowHostOptions = {}): WindowHostCon
return false
}
}
if (record.surface === 'sidebar' && surface === 'floating') record.pendingSidebarClose = true
if (surface === 'sidebar') record.pendingSidebarClose = false
record.surface = surface
notify()
if (surface === 'floating') raiseWindowLayer(layerKey(record.id))
@@ -405,6 +409,7 @@ export function createWindowHost(options: WindowHostOptions = {}): WindowHostCon
sessionId: options.sessionId ?? optionsSessionId(),
surface: 'floating',
sidebarTarget: undefined,
pendingSidebarClose: false,
title: options.title,
base: {
content: options.content,
@@ -509,6 +514,12 @@ export function createWindowHost(options: WindowHostOptions = {}): WindowHostCon
const record = currentRecord(id)
return record !== undefined && setSurface(record, surface)
},
completeSurfaceMove(id): void {
const record = currentRecord(id)
if (record === undefined || record.surface !== 'floating' || !record.pendingSidebarClose) return
record.pendingSidebarClose = false
if (record.sessionId !== undefined) sidebar?.close(record.id, record.sessionId)
},
setSidebarTarget(id, sessionId, target): void {
const record = currentRecord(id)
if (record === undefined || record.sessionId !== sessionId || record.sidebarTarget === target) return
+1 -10
View File
@@ -8,7 +8,6 @@ import { useLayoutEffect, useRef, useSyncExternalStore, type ReactNode } from 'r
import type { Context } from '../../context-types.ts'
import type { NativeTabInfo } from '../native/tab-adapter.tsx'
import type { WindowHostController } from './types.ts'
import { ActionButton } from '../ui/index.ts'
import { t } from '../locales.ts'
import design from '../ui/design.module.css'
import css from './windows.module.css'
@@ -67,15 +66,7 @@ function NativeWindowBody({ host, sessionId, useTabInfo }: NativeWindowProps): R
if (view?.sidebarTarget === destination) host.setSidebarTarget(id, sessionId, undefined)
}
}, [host, sessionId, id])
const snapshot = useSyncExternalStore(host.subscribe, host.getSnapshot, host.getSnapshot)
const view = snapshot.windows.find(window => window.id === id && window.sessionId === sessionId)
return <div ref={target} className={`${design.surface} ${css.nativeDestination}`} data-window-sidebar-destination>
{view?.surface !== 'sidebar' && <div className={css.documentStatus}>
<p>{t('windowFloatingHint')}</p>
{view !== undefined && <ActionButton variant="outline" size="sm"
onClick={() => { host.setSurface(view.id, 'sidebar') }}>{t('windowDock')}</ActionButton>}
</div>}
</div>
return <div ref={target} className={`${design.surface} ${css.nativeDestination}`} data-window-sidebar-destination />
}
function NativeWindowTitle({ host, sessionId, useTabInfo }: NativeWindowProps): ReactNode {
+3 -1
View File
@@ -222,7 +222,7 @@ export interface WindowHandle {
close(): Promise<void>
/** Move this instance to its original session's native sidebar; false when unavailable. */
dock?(): boolean
/** Return this same instance to its floating frame (optional for external window faces). */
/** Float this same instance and close its native tab after moving the content. */
float?(): void
readonly navigation: WindowNavigation
}
@@ -306,6 +306,8 @@ export interface WindowHostController extends BetterSidebarWindowsClientFace {
attachSidebar(sidebar: WindowSidebarAdapter): () => void
/** @internal Move a live window without replacing its content. */
setSurface(id: string, surface: 'floating' | 'sidebar'): boolean
/** @internal Release the old tab after the retained DOM has moved to the floating frame. */
completeSurfaceMove(id: string): void
/** @internal Attach/detach the native body's DOM destination. */
setSidebarTarget(id: string, sessionId: string, target: HTMLElement | undefined): void
/** @internal Native close path, sharing the same draft guard. */