refactor(shell): retire the plugin's own right panel and free windows
DSH 0.1.5 owns the right column (its native Sidebar hosts every tab type this plugin registers), so the plugin's own right panel, its width drag / new-session seed prefs, and the free-window feature are gone. The bottom workbench is the only plugin-owned surface left, and its expand/collapse control is registered into DSH's session-header utilities list slot (the header's corner seat belongs to the native sidebar's own control). - state: one `bottomSplits` tree; `makeDefaultState()` takes no arguments; `toggleBottomPanel` / `openTabInBottomPane` are the only landing reducers; `setBottomHeight` and `sanitizeState` share the `CONVERSATION_MIN` cap (a persisted tall height no longer snaps on the first drag). - service: every landing in the workbench (creation or focus) expands it; `SIDEBAR_FEATURES` drops `'floatWindows'`; the open/close/activate tab pools cover the single tree. - shell: `Sidebar.tsx` renders only the bottom workbench; the toggle lives in `sidebar/bottom-toggle.tsx`; layout-push pushes height only (no width, no `--dsh-sidebar-width`). - prefs: `openByDefault` / `defaultWidthPercent` / `changesDiffFloat` removed from the schema, defaults, client parser, settings page, and all 20 dictionaries; the retired keys in stored documents are ignored. - tests: free-window specs deleted, panel/float assertions dropped, remaining suites adapted (124 files / 1287 tests); the mount lane asserts the header toggle and sweeps the native sidebar's guide page. - docs: README / README_EN / guide §0,§11 / AGENTS test map.
This commit is contained in:
1 parent
91de0e2932
commit
223b2545d9
77 files changed
+1029
-4727
No files matched your search
+28
-85
@@ -22,11 +22,10 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import type { Context } from '../context-types.ts'
|
||||
import {
|
||||
activateTab as activateTabReducer, allLeaves, closeTab as closeTabReducer, closeFloatByTab, floatWithTab,
|
||||
leafWithTab, openTabInActivePane, openTabInBottomPane, patchTab, raiseFloat, tabOpenIn, togglePanel, treeOf,
|
||||
activateTab as activateTabReducer, allLeaves, closeTab as closeTabReducer,
|
||||
leafWithTab, openTabInBottomPane, patchTab, tabOpenIn,
|
||||
type SidebarSnapshot, type SidebarState, type SidebarStore, type SidebarTab, type TabType,
|
||||
} from './state.ts'
|
||||
import { isNarrowWidth } from './breakpoints.ts'
|
||||
import { extOf } from './paths.ts'
|
||||
import type { SessionScope } from './api.ts'
|
||||
import type { SidebarPrefs } from '../prefs-shared.ts'
|
||||
@@ -430,12 +429,10 @@ export interface BetterSidebarService {
|
||||
* without switching the UI's active session; when absent the open lands
|
||||
* in the currently active session (the pre-0.12 behavior).
|
||||
*
|
||||
* A CONTENT open (a `path` or `url` seed) must land in sight: when the
|
||||
* panel hosting the landing pane is collapsed, it is expanded
|
||||
* automatically (the right panel by default, the bottom panel when the
|
||||
* active pane lives there; on narrow viewports the merged drawer opens).
|
||||
* Type-only opens (the + menu, agent-terminal auto-tabs) never expand —
|
||||
* the panel behavior is their caller's business.
|
||||
* Every open lands in the bottom workbench and expands it (the workbench
|
||||
* is the plugin's only own surface; the right column is DSH's native
|
||||
* Sidebar). An open carrying a `path` or `url` goes through the native
|
||||
* surface instead, which never touches this state.
|
||||
*
|
||||
* Note: `available` gates the + menu's disabled state only — it does NOT
|
||||
* refuse `openTab` (only the settings disable switch does).
|
||||
@@ -536,9 +533,10 @@ export const SIDEBAR_SERVICE_VERSION = '0.19.0-alpha.0'
|
||||
* - 'pluginSettings': SidebarSettingsDeclaration.pluginToggles/render
|
||||
* - 'urlTarget' (v0.13.0): TabDescriptor.urlTarget (external-link claims)
|
||||
* - 'settingSelect': SidebarSettingToggle type 'select' (options/multi)
|
||||
* - 'floatWindows' (v0.16.0): tabs float as free windows — openTab's dedupe/
|
||||
* id focus targets RAISE the floating window (never duplicate the tab or
|
||||
* expand panels), closeTab on a floating tab closes it with its window.
|
||||
*
|
||||
* v0.19.0 REMOVED 'floatWindows': the free-window feature is gone (DSH 0.1.5
|
||||
* owns the right column, so the plugin keeps only its bottom workbench).
|
||||
* Consumers must not gate on it any more.
|
||||
*/
|
||||
export const SIDEBAR_FEATURES = [
|
||||
'badge',
|
||||
@@ -551,7 +549,6 @@ export const SIDEBAR_FEATURES = [
|
||||
'pluginSettings',
|
||||
'urlTarget',
|
||||
'settingSelect',
|
||||
'floatWindows',
|
||||
] as const
|
||||
|
||||
/** Run one plugin callback; a throw is logged and never breaks the caller. */
|
||||
@@ -733,7 +730,7 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe
|
||||
// A bottom-targeted open lands in the bottom workbench's own pane; the
|
||||
// right tree it would otherwise follow is no longer rendered (DSH's
|
||||
// native sidebar owns the right column).
|
||||
const land = seed.target === 'bottom' ? openTabInBottomPane : openTabInActivePane
|
||||
const land = openTabInBottomPane
|
||||
const reducer = (state: SidebarState): SidebarState => {
|
||||
// Let the descriptor mint the tab (terminal's nextTerminal bump, etc.).
|
||||
let tab: SidebarTab
|
||||
@@ -766,8 +763,7 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe
|
||||
// tab that never closes.
|
||||
const dedupeKey = descriptor.dedupeKey ?? (descriptor.single === true ? () => descriptor.id : undefined)
|
||||
const key = dedupeKey?.(tab)
|
||||
const inputTabs = allLeaves(state.splits).concat(allLeaves(state.bottomSplits)).flatMap(leaf => leaf.tabs)
|
||||
.concat(state.floats.map(f => f.tab))
|
||||
const inputTabs = allLeaves(state.bottomSplits).flatMap(leaf => leaf.tabs)
|
||||
const existedByKey = key !== undefined
|
||||
&& inputTabs.some(candidate => candidate.type === tab.type && dedupeKey!(candidate) === key)
|
||||
const existedById = tabOpenIn(state, tab.id)
|
||||
@@ -787,57 +783,23 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe
|
||||
if (isCreation) {
|
||||
// Resolve the ACTUAL landed tab — the url patch mints a new object,
|
||||
// so the callback must see the tab that was really inserted.
|
||||
const landedTabs = allLeaves(landed.splits).concat(allLeaves(landed.bottomSplits)).flatMap(leaf => leaf.tabs)
|
||||
const landedTabs = allLeaves(landed.bottomSplits).flatMap(leaf => leaf.tabs)
|
||||
created = landedTabs.find(candidate => candidate.id === tab.id) ?? tab
|
||||
} else {
|
||||
// A focus happened: resolve the tab that is actually active now and
|
||||
// report THAT to onActivate (never the caller's un-inserted seed).
|
||||
// The pool covers free windows too — a floating instance focuses by
|
||||
// raising, and the callback must see the real (patched) tab.
|
||||
const candidates = allLeaves(landed.splits).concat(allLeaves(landed.bottomSplits)).flatMap(leaf => leaf.tabs)
|
||||
.concat(landed.floats.map(f => f.tab))
|
||||
const candidates = allLeaves(landed.bottomSplits).flatMap(leaf => leaf.tabs)
|
||||
activated = key !== undefined
|
||||
? candidates.find(candidate => candidate.type === tab.type && dedupeKey!(candidate) === key)
|
||||
: candidates.find(candidate => candidate.id === tab.id)
|
||||
activated ??= tab
|
||||
}
|
||||
// A CONTENT open that focuses an existing FLOATING tab is already in
|
||||
// sight (free windows render regardless of panel state): expanding a
|
||||
// panel for it would point the user at a pane the content is not in.
|
||||
if (
|
||||
!isCreation
|
||||
&& floatWithTab(landed, activated?.id ?? tab.id) !== undefined
|
||||
) {
|
||||
return landed
|
||||
}
|
||||
// A CONTENT open (file / browser) must land in sight: when the panel
|
||||
// hosting the landing pane is collapsed, expand it. On narrow
|
||||
// viewports the two workbenches merge into one drawer, so the drawer
|
||||
// (panelOpen) is the only lever; on wide viewports the landing pane's
|
||||
// own panel opens — the bottom panel when the active pane lives in the
|
||||
// bottom tree, else the right panel. Type-only opens (+ menu,
|
||||
// agent-terminal auto-tabs) never expand (the panel behavior is their
|
||||
// caller's business). The check runs on the post-dedupe state, so a
|
||||
// content open that merely FOCUSES an existing tab expands the panel
|
||||
// too — the open must never land out of sight. Opens targeted at an
|
||||
// INACTIVE session never expand (nothing is in sight for the user).
|
||||
if (
|
||||
!targetsInactiveSession
|
||||
&& typeof window !== 'undefined'
|
||||
&& (seed.path !== undefined || seed.url !== undefined)
|
||||
) {
|
||||
if (isNarrowWidth(window.innerWidth)) {
|
||||
if (!landed.panelOpen) return togglePanel(landed)
|
||||
} else {
|
||||
const hostKey = treeOf(landed, landed.activePane ?? '')
|
||||
if (hostKey === 'bottomSplits') {
|
||||
if (!landed.bottomOpen) return { ...landed, bottomOpen: true }
|
||||
} else if (!landed.panelOpen) {
|
||||
return togglePanel(landed)
|
||||
}
|
||||
}
|
||||
}
|
||||
return landed
|
||||
// Every open that lands in the workbench is visible: a creation
|
||||
// expands it (openTabInBottomPane) and so does a FOCUS (the dedupe/id
|
||||
// reducers only activate the tab). An open targeted at an INACTIVE
|
||||
// session expands THAT session's workbench — it is waiting for the
|
||||
// user when they switch to it.
|
||||
return landed.bottomOpen ? landed : { ...landed, bottomOpen: true }
|
||||
}
|
||||
// A scope targeting ANOTHER session lands the open there without
|
||||
// switching the UI; a scope naming the active session (or no scope)
|
||||
@@ -871,14 +833,8 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe
|
||||
// Unknown tab ids are a strict no-op: no state churn, no notify, no
|
||||
// pointless localStorage rewrite (mirrors updateTab's short-circuit).
|
||||
if (!tabOpenIn(state, tabId)) return state
|
||||
// A floating tab closes WITH its window — the float is the tab's pane.
|
||||
const float = floatWithTab(state, tabId)
|
||||
if (float !== undefined) {
|
||||
closed = float.tab
|
||||
return closeFloatByTab(state, tabId)
|
||||
}
|
||||
const paneId = findPaneIdOf(state, tabId)
|
||||
const leaf = leafWithTab(state[treeOf(state, paneId)], tabId)
|
||||
const leaf = leafWithTab(state.bottomSplits, tabId)
|
||||
closed = leaf?.tabs.find(tab => tab.id === tabId)
|
||||
return closeTabReducer(state, paneId, tabId)
|
||||
})
|
||||
@@ -915,14 +871,8 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe
|
||||
store.reduce((state) => {
|
||||
// Unknown tab ids are a strict no-op (no state churn / notify).
|
||||
if (!tabOpenIn(state, tabId)) return state
|
||||
// A floating tab "activates" by raising its window — no pane switch.
|
||||
const float = floatWithTab(state, tabId)
|
||||
if (float !== undefined) {
|
||||
activated = float.tab
|
||||
return raiseFloat(state, float.id)
|
||||
}
|
||||
const paneId = findPaneIdOf(state, tabId)
|
||||
const leaf = leafWithTab(state[treeOf(state, paneId)], tabId)
|
||||
const leaf = leafWithTab(state.bottomSplits, tabId)
|
||||
activated = leaf?.tabs.find(tab => tab.id === tabId)
|
||||
return activateTabReducer(state, paneId, tabId)
|
||||
})
|
||||
@@ -968,37 +918,30 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe
|
||||
|
||||
/**
|
||||
* Apply dedup: if a tab whose `dedupeKey` matches an existing tab of the
|
||||
* same type exists, focus it; otherwise land the tab through
|
||||
* `openTabInActivePane` (the id safety net + active-pane landing are that
|
||||
* reducer's job — not re-implemented here).
|
||||
* same type exists, focus it; otherwise land the tab through `land` (the id
|
||||
* safety net + landing are that reducer's job — not re-implemented here).
|
||||
* `single: true` resolves to the id-key sugar when no explicit key is given.
|
||||
*/
|
||||
function applyDedupe(
|
||||
state: SidebarState,
|
||||
tab: SidebarTab,
|
||||
descriptor: TabDescriptor,
|
||||
land: (state: SidebarState, tab: SidebarTab) => SidebarState = openTabInActivePane,
|
||||
land: (state: SidebarState, tab: SidebarTab) => SidebarState = openTabInBottomPane,
|
||||
): SidebarState {
|
||||
const dedupeKey = descriptor.dedupeKey ?? (descriptor.single === true ? () => descriptor.id : undefined)
|
||||
const key = dedupeKey?.(tab)
|
||||
if (key !== undefined) {
|
||||
// The scan covers BOTH trees: opening a single-instance tab from the
|
||||
// bottom panel focuses an existing instance wherever it lives.
|
||||
for (const leaf of allLeaves(state.splits).concat(allLeaves(state.bottomSplits))) {
|
||||
for (const leaf of allLeaves(state.bottomSplits)) {
|
||||
const existing = leaf.tabs.find(t => t.type === tab.type && dedupeKey!(t) === key)
|
||||
if (existing !== undefined) return activateTabReducer(state, leaf.id, existing.id)
|
||||
}
|
||||
// A floating instance focuses by raising its window (no duplicate tab,
|
||||
// no panel expansion — the window is the tab's pane).
|
||||
const floated = state.floats.find(f => f.tab.type === tab.type && dedupeKey!(f.tab) === key)
|
||||
if (floated !== undefined) return raiseFloat(state, floated.id)
|
||||
}
|
||||
return land(state, tab)
|
||||
}
|
||||
|
||||
/** Find which pane hosts a tab id ('' if none). Either tree is searched. */
|
||||
/** Find which pane hosts a tab id ('' if none). */
|
||||
function findPaneIdOf(state: SidebarState, tabId: string): string {
|
||||
for (const leaf of allLeaves(state.splits).concat(allLeaves(state.bottomSplits))) {
|
||||
for (const leaf of allLeaves(state.bottomSplits)) {
|
||||
if (leaf.tabs.some(t => t.id === tabId)) return leaf.id
|
||||
}
|
||||
return state.activePane ?? ''
|
||||
|
||||
Reference in new issue
Block a user