refactor(sidebar-right): take the auto-fullscreen rule from the seats
The fullscreen command needs to know whether the frame is narrow enough that an expanded panel is fullscreen automatically. Reading it from a new ctx.layout.viewportWidth widened the layout plugin's public face for this one consumer. The seats already receive the frame width as owner props and compute the rule they render with, so each seat now reports that verdict through its inject face, as it reports its docking kit's room. The command reads the latest report only when the user runs it, after the commit that rendered the width has settled. - Revert ctx.layout.viewportWidth and the test fakes that provided it. - SidebarRightInjected gains reportAutoFullscreen.
This commit is contained in:
1 parent
ebb6b03378
commit
4ccf48c4ef
22 files changed
+72
-69
No files matched your search
+2
-2
@@ -21,8 +21,8 @@
|
||||
en: 774c3bf80a48ffbe
|
||||
zh: c513245789aa8efd
|
||||
/agent-note-right-sidebar-tab-types-and-navigation/decision/navigation-ctx-sidebarright:
|
||||
en: c70040a8041e3d06
|
||||
zh: a6958514a35733c4
|
||||
en: c52363f57001b7ac
|
||||
zh: bbcbdbc038cbf316
|
||||
/agent-note-right-sidebar-tab-types-and-navigation/decision/addresses:
|
||||
en: eeb1e7e7478a2f2c
|
||||
zh: bddbc5bc78245f63
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ interface SidebarRightTabParamsMap {} // key: kind — a page type declar
|
||||
|
||||
`openResource` accepts the union of every declared resource shape and `openTab<K>` the shape declared for `K`; a body narrows `navigation.params` by the protocol or kind it knows it serves. Parameters belong to the resource type rather than to the viewer because a line number is a fact about a file location, not about the text preview, and any type that claims `file` addresses receives the same shape. Values must be JSON-serializable, and a record must be rebuildable from address and parameters alone, because undo, redo, reload, and HMR rebuild tabs after the opener is gone.
|
||||
|
||||
Beside the two opens, the face carries `close(tabId)`, `active()`, `isExpanded()`, `toggleExpanded()`, and four operational methods — `focus(tabId)`, `split(paneId?)` (returning the new pane, or `undefined` when the pane budget or the width rule forbids the split, recording nothing), `float(tabId, rect?)`, and `dock(paneId)` — each recording one history entry and a no-op on a missing target or one already in the requested state. There is no layout snapshot, no subscription, and no lookup by address: the face grants control over the layout, not a view of it. The plugin names the Session on screen — the selected Session while the Conversation fills the main column — from the Session selection and the main panel, before React renders either change, and publishes it as `mounted`; a command on the public face acts on that Session through its adopted store and throws when no Session is on screen or its store has not been minted. The seat reports only the room its docking kit measured. A tab's own actions reach their session's own store instead: the slot runtime mints one store per session, the plugin adopts each as it is minted, and the controller routes by session id, so an action fired after the user switched sessions still lands, and does nothing for a session whose store was never minted.
|
||||
Beside the two opens, the face carries `close(tabId)`, `active()`, `isExpanded()`, `toggleExpanded()`, and four operational methods — `focus(tabId)`, `split(paneId?)` (returning the new pane, or `undefined` when the pane budget or the width rule forbids the split, recording nothing), `float(tabId, rect?)`, and `dock(paneId)` — each recording one history entry and a no-op on a missing target or one already in the requested state. There is no layout snapshot, no subscription, and no lookup by address: the face grants control over the layout, not a view of it. The plugin names the Session on screen — the selected Session while the Conversation fills the main column — from the Session selection and the main panel, before React renders either change, and publishes it as `mounted`; a command on the public face acts on that Session through its adopted store and throws when no Session is on screen or its store has not been minted. The seat reports only what it renders with: the room its docking kit measured and whether its frame width presents the panel fullscreen automatically. A tab's own actions reach their session's own store instead: the slot runtime mints one store per session, the plugin adopts each as it is minted, and the controller routes by session id, so an action fired after the user switched sessions still lands, and does nothing for a session whose store was never minted.
|
||||
|
||||
### Addresses
|
||||
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ interface SidebarRightTabParamsMap {} // key: kind — a page type declar
|
||||
|
||||
`openResource` 接受所有已声明资源形状的联合,`openTab<K>` 接受为 `K` 声明的形状;正文按自己所服务的协议或 kind 收窄 `navigation.params`。参数属于资源类型而非查看器,因为行号是关于文件位置的事实,不是关于文本预览的,任何认领 `file` 地址的类型收到同一形状。值必须可 JSON 序列化,一条记录必须只凭地址与参数就能重建,因为撤销、重做、刷新与 HMR 都在开启方已不在时重建 tab。
|
||||
|
||||
除两种打开外,该面还有 `close(tabId)`、`active()`、`isExpanded()`、`toggleExpanded()`,以及四个操作型方法——`focus(tabId)`、`split(paneId?)`(返回新格,预算或宽度规则不允许分栏时返回 `undefined` 且不记账)、`float(tabId, rect?)` 与 `dock(paneId)`——每个记一条历史,目标不存在或已在目标态时为 no-op。没有布局快照、没有订阅、没有按地址查找:该面给的是对布局的控制权,不是布局的视图。插件依据会话选择与主面板确定屏上会话——Conversation 占据主栏时的选中会话——并在 React 渲染这两者的变化之前将其发布为 `mounted`;公开面上的命令经该会话被收养的 store 作用于它,没有会话在屏上或其 store 尚未铸出时抛错。座位只上报其停靠套件测得的空间。tab 自己的动作则到达其会话自己的 store:slot 运行时每个会话铸一个 store,插件在铸出时逐个收养,控制器按会话 id 路由,因此用户切换会话之后触发的动作照样落地,而 store 从未铸出的会话什么也不做。
|
||||
除两种打开外,该面还有 `close(tabId)`、`active()`、`isExpanded()`、`toggleExpanded()`,以及四个操作型方法——`focus(tabId)`、`split(paneId?)`(返回新格,预算或宽度规则不允许分栏时返回 `undefined` 且不记账)、`float(tabId, rect?)` 与 `dock(paneId)`——每个记一条历史,目标不存在或已在目标态时为 no-op。没有布局快照、没有订阅、没有按地址查找:该面给的是对布局的控制权,不是布局的视图。插件依据会话选择与主面板确定屏上会话——Conversation 占据主栏时的选中会话——并在 React 渲染这两者的变化之前将其发布为 `mounted`;公开面上的命令经该会话被收养的 store 作用于它,没有会话在屏上或其 store 尚未铸出时抛错。座位只上报它渲染时依据的事实:停靠套件测得的空间,以及框架宽度是否让面板自动全屏。tab 自己的动作则到达其会话自己的 store:slot 运行时每个会话铸一个 store,插件在铸出时逐个收养,控制器按会话 id 路由,因此用户切换会话之后触发的动作照样落地,而 store 从未铸出的会话什么也不做。
|
||||
|
||||
### 地址
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
en: 1e1d3361dac7d8b0
|
||||
zh: b6b3d210d65738f0
|
||||
/deepseek-ai-dsh-client-ui-layout/understand-the-implementation:
|
||||
en: d3a95bd98997ff42
|
||||
zh: cad20230a114a1ec
|
||||
en: 8af800fa55786c71
|
||||
zh: 7421c12eb3585c21
|
||||
/deepseek-ai-dsh-client-ui-layout/further-exploration:
|
||||
en: b6c728b6ed70f2a7
|
||||
zh: 8ee2003b98695323
|
||||
|
||||
@@ -51,7 +51,7 @@ The presenter consumes resolved theme snapshots and projects them onto the docum
|
||||
|
||||
`selectPanel(id)` checks the live `main` registry before changing selection; an absent key throws and leaves the current panel intact. `beginNavigation()` returns an abort signal for an asynchronous UI navigation. A later call, a valid panel selection (including repeated selection), or layout disposal aborts that signal without cancelling underlying Session creation. Consumers check the signal before committing navigation or moving drafts.
|
||||
|
||||
One registration declares five child slots and binds `ctx.layout` methods `selectPanel`, `toggleSidebar`, `openRightbar(track, fullscreen)`, and `closeRightbar`. One root store separates `panelInfo` selection from `layoutInfo` measurements, width preferences, and presentation reports. `ctx.layout.panelInfo` and the standard `usePanelInfo` hook share the same selection source; `ctx.layout.viewportWidth` publishes the frame's measured width from the same store, the value the `rightbar` owner receives as `viewportWidth`. AppFrame subscribes to the stable layout object. The `rightbar` owner supplies actual `width`, `viewportWidth`, and normal-presentation eligibility `canShow`; insufficient room causes a deterministic close, never automatic reopening on widening. Fullscreen hides the width handle without releasing a track the occupant retains. AppFrame keeps the column containers mounted. The right column's root controller renders `rightbar.session` through `SessionProvider` only while the Conversation is selected; its unmount report releases the track. The independent title component uses the selected Session title only while the Conversation is visible, with the build-configured product title or localized `common.brand.localBuild` as its fallback; locale revisions update that fallback. The theme presenter is a second effect: pure DOM writes from resolved snapshots — initial state through the getter once, then event-driven only, with no React path. It applies palette, font-size, and token variables before measuring the rendered background as the single color authority. Fullscreen presentation suppresses grid and handle transitions; its occupant reports the new columns only after covering the frame. Fullscreen exit keeps transitions suppressed while the frame installs its destination geometry: close removes the right track, and restore retains it. Subsequent normal geometry actions restore ordinary transitions.
|
||||
One registration declares five child slots and binds `ctx.layout` methods `selectPanel`, `toggleSidebar`, `openRightbar(track, fullscreen)`, and `closeRightbar`. One root store separates `panelInfo` selection from `layoutInfo` measurements, width preferences, and presentation reports. `ctx.layout.panelInfo` and the standard `usePanelInfo` hook share the same selection source; AppFrame subscribes to the stable layout object. The `rightbar` owner supplies actual `width`, `viewportWidth`, and normal-presentation eligibility `canShow`; insufficient room causes a deterministic close, never automatic reopening on widening. Fullscreen hides the width handle without releasing a track the occupant retains. AppFrame keeps the column containers mounted. The right column's root controller renders `rightbar.session` through `SessionProvider` only while the Conversation is selected; its unmount report releases the track. The independent title component uses the selected Session title only while the Conversation is visible, with the build-configured product title or localized `common.brand.localBuild` as its fallback; locale revisions update that fallback. The theme presenter is a second effect: pure DOM writes from resolved snapshots — initial state through the getter once, then event-driven only, with no React path. It applies palette, font-size, and token variables before measuring the rendered background as the single color authority. Fullscreen presentation suppresses grid and handle transitions; its occupant reports the new columns only after covering the frame. Fullscreen exit keeps transitions suppressed while the frame installs its destination geometry: close removes the right track, and restore retains it. Subsequent normal geometry actions restore ordinary transitions.
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ Windows Electron 的 `data-windows-titlebar` 标记在所有列上方预留顶
|
||||
|
||||
`selectPanel(id)` 在改变选中态前检查实时 `main` 注册表;缺失的 key 会抛错并保留当前面板。`beginNavigation()` 为异步 UI 导航返回 abort signal。后续调用、有效面板选择(包括重复选择)或布局释放会中止该 signal,但不取消底层会话创建。消费方在提交导航或搬移草稿前检查 signal。
|
||||
|
||||
一次注册声明五个子 slot,并绑定 `ctx.layout` 的 `selectPanel`、`toggleSidebar`、`openRightbar(track, fullscreen)` 与 `closeRightbar`。同一个 root 存储把 `panelInfo` 选中态与 `layoutInfo` 测量、宽度偏好、呈现报告分开。`ctx.layout.panelInfo` 与标准 `usePanelInfo` hook 共用同一个选中态来源;`ctx.layout.viewportWidth` 从同一存储发布框架测得的宽度,即 `rightbar` owner 收到的 `viewportWidth`。AppFrame 订阅引用稳定的布局对象。`rightbar` owner 提供实际 `width`、`viewportWidth`,以及表示能否以普通模式呈现的 `canShow`;占用方在空间不足时执行确定性的收起,变宽不自行重新展开。全屏隐藏宽度手柄,但不自行释放占用方要求保留的轨道。AppFrame 保持各列容器挂载。右栏的 root 控制器仅在选中会话界面时,经 `SessionProvider` 渲染 `rightbar.session`;内容卸载时的报告释放轨道。独立的标题组件仅在会话界面可见时使用所选会话标题,以构建配置的产品标题或本地化 `common.brand.localBuild` 为回退值;语言变化会更新该回退值。主题呈现器是第二个 effect:从解析后的快照做纯 DOM 写入——初始状态经 getter 读取一次,此后仅事件驱动,不经过 React。它先应用调色板、字号与 token 变量,再把渲染出的背景测量为唯一的颜色依据。全屏呈现禁用网格和手柄过渡;占用方完全覆盖框架后才报告新的列布局。退出全屏时,框架先保持无过渡并安装目标布局:关闭移除右轨道,恢复保留右轨道。后续普通几何操作恢复正常过渡。
|
||||
一次注册声明五个子 slot,并绑定 `ctx.layout` 的 `selectPanel`、`toggleSidebar`、`openRightbar(track, fullscreen)` 与 `closeRightbar`。同一个 root 存储把 `panelInfo` 选中态与 `layoutInfo` 测量、宽度偏好、呈现报告分开。`ctx.layout.panelInfo` 与标准 `usePanelInfo` hook 共用同一个选中态来源;AppFrame 订阅引用稳定的布局对象。`rightbar` owner 提供实际 `width`、`viewportWidth`,以及表示能否以普通模式呈现的 `canShow`;占用方在空间不足时执行确定性的收起,变宽不自行重新展开。全屏隐藏宽度手柄,但不自行释放占用方要求保留的轨道。AppFrame 保持各列容器挂载。右栏的 root 控制器仅在选中会话界面时,经 `SessionProvider` 渲染 `rightbar.session`;内容卸载时的报告释放轨道。独立的标题组件仅在会话界面可见时使用所选会话标题,以构建配置的产品标题或本地化 `common.brand.localBuild` 为回退值;语言变化会更新该回退值。主题呈现器是第二个 effect:从解析后的快照做纯 DOM 写入——初始状态经 getter 读取一次,此后仅事件驱动,不经过 React。它先应用调色板、字号与 token 变量,再把渲染出的背景测量为唯一的颜色依据。全屏呈现禁用网格和手柄过渡;占用方完全覆盖框架后才报告新的列布局。退出全屏时,框架先保持无过渡并安装目标布局:关闭移除右轨道,恢复保留右轨道。后续普通几何操作恢复正常过渡。
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -164,12 +164,8 @@ export function apply(ctx: ClientContext): void {
|
||||
getSnapshot: () => instance.getSnapshot().panelInfo,
|
||||
subscribe: listener => instance.subscribe(listener),
|
||||
}
|
||||
const viewportWidth: HostObservable<number> = {
|
||||
getSnapshot: () => instance.getSnapshot().layoutInfo.viewportWidth,
|
||||
subscribe: listener => instance.subscribe(listener),
|
||||
}
|
||||
const layout = new LayoutController(instance.actions, id =>
|
||||
ctx.slots.entries('main').some(entry => entry.options.key === id), panelInfo, viewportWidth)
|
||||
ctx.slots.entries('main').some(entry => entry.options.key === id), panelInfo)
|
||||
const disposePanelInfo = ctx.slots.provideRoot({ hooks: { panelInfo: layout.panelInfo } })
|
||||
const disposeService = ctx.reflect.provide('layout', layout)
|
||||
const disposeRegistration = ctx.slots.register({
|
||||
|
||||
@@ -28,8 +28,6 @@ export type PanelActions = BoundActions<ReturnType<typeof createLayoutStore>>
|
||||
export interface ILayout {
|
||||
/** Selected central panel from the same root store used by `usePanelInfo`. */
|
||||
readonly panelInfo: HostObservable<PanelInfo>
|
||||
/** The frame's measured width in CSS pixels, from the same root store; the `rightbar` owner receives it as `viewportWidth`. */
|
||||
readonly viewportWidth: HostObservable<number>
|
||||
/**
|
||||
* Select a global central panel without changing the current Session.
|
||||
* @param panelId - registered main key, or null to show the Conversation.
|
||||
@@ -63,13 +61,11 @@ export class LayoutController implements ILayout {
|
||||
* @param panels - actions of the instance shared with the root entry.
|
||||
* @param hasMainPanel - checks the live main-slot registry for a panel id.
|
||||
* @param panelInfo - root store's shared central-panel selection source.
|
||||
* @param viewportWidth - root store's measured frame width source.
|
||||
*/
|
||||
constructor(
|
||||
private readonly panels: PanelActions,
|
||||
private readonly hasMainPanel: (id: MainPanelId) => boolean,
|
||||
readonly panelInfo: HostObservable<PanelInfo>,
|
||||
readonly viewportWidth: HostObservable<number>,
|
||||
) {}
|
||||
|
||||
/** Select a global panel or return to the Conversation. */
|
||||
|
||||
@@ -95,24 +95,6 @@ describe('ui-layout client apply', () => {
|
||||
expect(slots.spec('shell.leading')).toEqual({ kind: 'single', scope: 'root' })
|
||||
})
|
||||
|
||||
it('publishes the frame\'s measured viewport width from the root store', async () => {
|
||||
const { ctx, slots } = await bench()
|
||||
const fiber = ctx.plugin({ inject: [...inject], apply })
|
||||
await fiber.await()
|
||||
const instance = (slots.entries('root')[0]!.store as ReturnType<typeof createLayoutStore>).create()
|
||||
const layout = ctx.get('layout') as LayoutController
|
||||
const seen: number[] = []
|
||||
const unsubscribe = layout.viewportWidth.subscribe(() => { seen.push(layout.viewportWidth.getSnapshot()) })
|
||||
try {
|
||||
instance.actions.setViewportWidth(700)
|
||||
expect(layout.viewportWidth.getSnapshot()).toBe(700)
|
||||
expect(seen).toContain(700)
|
||||
} finally {
|
||||
unsubscribe()
|
||||
await fiber.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
it('shares a pre-created instance between service actions, root rendering, and panelInfo', async () => {
|
||||
const { ctx, slots, rendererHost } = await bench()
|
||||
const fiber = ctx.plugin({ inject: [...inject], apply })
|
||||
|
||||
@@ -19,7 +19,7 @@ function fakePanels(): PanelActions {
|
||||
describe('LayoutController', () => {
|
||||
it('forwards right column transitions to the constructor-supplied actions', () => {
|
||||
const panels = fakePanels()
|
||||
const service = new LayoutController(panels, () => true, createSnapshotStore({ activePanelId: null }), createSnapshotStore(1440))
|
||||
const service = new LayoutController(panels, () => true, createSnapshotStore({ activePanelId: null }))
|
||||
|
||||
service.openRightbar(true, false)
|
||||
service.openRightbar(true, true)
|
||||
@@ -36,7 +36,7 @@ describe('LayoutController', () => {
|
||||
|
||||
it('can toggle the sidebar immediately after construction', () => {
|
||||
const panels = fakePanels()
|
||||
const service = new LayoutController(panels, () => true, createSnapshotStore({ activePanelId: null }), createSnapshotStore(1440))
|
||||
const service = new LayoutController(panels, () => true, createSnapshotStore({ activePanelId: null }))
|
||||
|
||||
service.toggleSidebar()
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('LayoutController', () => {
|
||||
|
||||
it('forwards panel selection and returning to the Conversation without changing geometry', () => {
|
||||
const panels = fakePanels()
|
||||
const service = new LayoutController(panels, () => true, createSnapshotStore({ activePanelId: null }), createSnapshotStore(1440))
|
||||
const service = new LayoutController(panels, () => true, createSnapshotStore({ activePanelId: null }))
|
||||
const panelId = 'panel-a' as MainPanelId
|
||||
service.selectPanel(panelId)
|
||||
service.selectPanel(panelId)
|
||||
@@ -62,8 +62,8 @@ describe('LayoutController', () => {
|
||||
it('keeps separately constructed controllers bound to their own instances', () => {
|
||||
const first = fakePanels()
|
||||
const second = fakePanels()
|
||||
const firstService = new LayoutController(first, () => true, createSnapshotStore({ activePanelId: null }), createSnapshotStore(1440))
|
||||
const secondService = new LayoutController(second, () => true, createSnapshotStore({ activePanelId: null }), createSnapshotStore(1440))
|
||||
const firstService = new LayoutController(first, () => true, createSnapshotStore({ activePanelId: null }))
|
||||
const secondService = new LayoutController(second, () => true, createSnapshotStore({ activePanelId: null }))
|
||||
firstService.toggleSidebar()
|
||||
expect(first.toggleSidebar).toHaveBeenCalledTimes(1)
|
||||
expect(second.toggleSidebar).not.toHaveBeenCalled()
|
||||
@@ -75,8 +75,7 @@ describe('LayoutController', () => {
|
||||
it('rejects an absent main entry without changing selection or cancelling pending navigation', () => {
|
||||
const panels = fakePanels()
|
||||
const present = new Set(['panel-a'])
|
||||
const service = new LayoutController(
|
||||
panels, id => present.has(id), createSnapshotStore({ activePanelId: null }), createSnapshotStore(1440))
|
||||
const service = new LayoutController(panels, id => present.has(id), createSnapshotStore({ activePanelId: null }))
|
||||
service.selectPanel('panel-a' as MainPanelId)
|
||||
const navigation = service.beginNavigation()
|
||||
present.delete('panel-a')
|
||||
@@ -88,7 +87,7 @@ describe('LayoutController', () => {
|
||||
})
|
||||
|
||||
it('supersedes asynchronous navigation on another request, any valid selection, and disposal', () => {
|
||||
const service = new LayoutController(fakePanels(), () => true, createSnapshotStore({ activePanelId: null }), createSnapshotStore(1440))
|
||||
const service = new LayoutController(fakePanels(), () => true, createSnapshotStore({ activePanelId: null }))
|
||||
const first = service.beginNavigation()
|
||||
const second = service.beginNavigation()
|
||||
expect(first.aborted).toBe(true)
|
||||
|
||||
@@ -57,9 +57,6 @@ async function bench() {
|
||||
const layout = new LayoutController(layoutStore.actions, id => id === 'plugins', {
|
||||
getSnapshot: () => layoutStore.getSnapshot().panelInfo,
|
||||
subscribe: listener => layoutStore.subscribe(listener),
|
||||
}, {
|
||||
getSnapshot: () => layoutStore.getSnapshot().layoutInfo.viewportWidth,
|
||||
subscribe: listener => layoutStore.subscribe(listener),
|
||||
})
|
||||
ctx.provide('layout', layout)
|
||||
ctx.provide('sessions', { list })
|
||||
|
||||
@@ -40,7 +40,7 @@ async function boot() {
|
||||
const rt = await SlotTestRuntime.create()
|
||||
runtime = rt
|
||||
rt.ctx.provide('configForms', { developerTools: { enabled: createSnapshotStore(true) } } as never)
|
||||
rt.ctx.provide('layout', { openRightbar: vi.fn(), closeRightbar: vi.fn(), panelInfo: rt.panelInfo, viewportWidth: createSnapshotStore(1440) } as never)
|
||||
rt.ctx.provide('layout', { openRightbar: vi.fn(), closeRightbar: vi.fn(), panelInfo: rt.panelInfo } as never)
|
||||
rt.ctx.provide('shortcuts', { register: () => () => {}, catalog: { getSnapshot: () => SHORTCUT_CATALOG, subscribe: () => () => {} } } as never)
|
||||
const locale = new LocaleRuntime(rt.ctx)
|
||||
rt.ctx.provide('locale', locale)
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
en: ef2af36136c4a919
|
||||
zh: 48d992e2c923a130
|
||||
/deepseek-ai-dsh-client-ui-sidebar-right/ctx-sidebarright:
|
||||
en: 1b4b0a47625d91c1
|
||||
zh: 7878c3dcaa4c2811
|
||||
en: 4519c4633d160c2a
|
||||
zh: e4019a62532f885a
|
||||
/deepseek-ai-dsh-client-ui-sidebar-right/the-tab-domain:
|
||||
en: 717b86e05b44ebdd
|
||||
zh: 0f4f694d0ea1d7f8
|
||||
|
||||
@@ -94,7 +94,7 @@ Two more seats extend what is already there: `sidebar.right.tab.guide` (chain) r
|
||||
|
||||
`preferNewPane: true` first asks the target docked pane to split under the normal two-pane and room rules, then falls back to that pane when no split is available. `replaceTab` takes precedence and disables this preference.
|
||||
|
||||
`close(tabId)` closes a tab; `active()` reads the active tab. `isExpanded()` and `toggleExpanded()` read and drive the column's expansion; `toggleFullscreen(target)` applies the panel control’s display-mode action to a captured dock pane. Layout operations, for callers that arrange the column programmatically, each recorded like the gesture it stands in for: `focus(tabId)` focuses a tab and its pane; `split(paneId?)` splits a docked pane (the active one by default) under the same pane budget and room rule as the strip's control and returns the new pane's id, or `undefined` — recording nothing — when it cannot; `float(tabId, rect?)` takes a docked tab out into a panel; `dock(paneId)` returns a floating panel to the active docked pane. A tab or pane that does not exist, or already is where the call would put it, is left alone. The face exposes operations only: no layout snapshot, no operation log, no lookup by address. `_undo()` / `_redo()` step the on-screen surface's history; they are `@internal` — the sequence has no user-facing control, and these exist for tests. Commands act on the on-screen Session through its adopted store; with no Session on screen, or before the runtime mints its store, they throw rather than write into a surface nobody draws. `mounted` is the observable of the Session on screen: the selected Session while the Conversation fills the main column, `undefined` while a global panel replaces it or no Session is selected. The plugin derives it from the Session selection and `ctx.layout.panelInfo`, and it changes before React renders the change that causes it, so a component rendered in that commit reads the arriving Session and may act on it from its effects: the frame renders that Session's seat in the same pass, which mints its store. Seats never publish it; each reports only the room its docking kit measured, which `split` and `preferNewPane` apply to that Session's panes, and unmeasured panes have room. The plan review's automatic open reads `mounted` through a bound hook.
|
||||
`close(tabId)` closes a tab; `active()` reads the active tab. `isExpanded()` and `toggleExpanded()` read and drive the column's expansion; `toggleFullscreen(target)` applies the panel control’s display-mode action to a captured dock pane. Layout operations, for callers that arrange the column programmatically, each recorded like the gesture it stands in for: `focus(tabId)` focuses a tab and its pane; `split(paneId?)` splits a docked pane (the active one by default) under the same pane budget and room rule as the strip's control and returns the new pane's id, or `undefined` — recording nothing — when it cannot; `float(tabId, rect?)` takes a docked tab out into a panel; `dock(paneId)` returns a floating panel to the active docked pane. A tab or pane that does not exist, or already is where the call would put it, is left alone. The face exposes operations only: no layout snapshot, no operation log, no lookup by address. `_undo()` / `_redo()` step the on-screen surface's history; they are `@internal` — the sequence has no user-facing control, and these exist for tests. Commands act on the on-screen Session through its adopted store; with no Session on screen, or before the runtime mints its store, they throw rather than write into a surface nobody draws. `mounted` is the observable of the Session on screen: the selected Session while the Conversation fills the main column, `undefined` while a global panel replaces it or no Session is selected. The plugin derives it from the Session selection and `ctx.layout.panelInfo`, and it changes before React renders the change that causes it, so a component rendered in that commit reads the arriving Session and may act on it from its effects: the frame renders that Session's seat in the same pass, which mints its store. Seats never publish it; each reports only what it renders with: the room its docking kit measured, which `split` and `preferNewPane` apply to that Session's panes (unmeasured panes have room), and whether its frame width presents the panel fullscreen automatically, which the fullscreen command applies. The plan review's automatic open reads `mounted` through a bound hook.
|
||||
|
||||
`focusedTarget(element?)` resolves the current DOM pane and tab, including an embedding iframe; outside focus returns no page. `commandTarget(element?)` additionally allows an outside open to use the on-screen Session's active dock pane. Captures include the occurrence and navigation revision; `isTargetCurrent(target)` rejects changed Sessions, moved or reopened tabs, and intervening navigation. Focus and pointer activation remain separate from persisted layout selection.
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ tab 类型分两阶段注册,随包发布的引导类型走的正是别的包
|
||||
|
||||
`preferNewPane: true` 会先按普通的两格上限与空间规则尝试分割目标停靠格,无法分栏时回退到该格。`replaceTab` 优先并会禁用这项偏好。
|
||||
|
||||
`close(tabId)` 关闭一个 tab;`active()` 读取活动 tab。`isExpanded()` 与 `toggleExpanded()` 读取并驱动该列的展开;`toggleFullscreen(target)` 对捕获的停靠分栏执行面板控件的显示模式操作。布局操作供以编程方式安排该列的调用方使用,每个都像它替代的手势一样被记录:`focus(tabId)` 聚焦一个 tab 及其格;`split(paneId?)` 在与 tab 条控件相同的格预算与空间规则下分栏一个停靠格(默认活跃格),返回新格的 id,做不到时返回 `undefined`——且不记录任何东西;`float(tabId, rect?)` 把停靠 tab 浮出为浮窗;`dock(paneId)` 把浮窗放回活跃停靠格。不存在的 tab 或格、或已处于调用目标状态的,都原样不动。该接口只暴露操作:没有布局快照、没有操作日志、没有按地址查找。`_undo()` / `_redo()` 步进屏幕上停靠面的历史;它们是 `@internal`——序列没有面向用户的控件,这两个只为测试存在。命令通过屏幕上会话已采用的 store 作用于该会话;没有会话在屏幕上、或运行时尚未创建它的 store 时,命令 throw,而不是写进一个没人绘制的面里。`mounted` 是「屏幕上的会话」的可观察值:Conversation 占据主栏时为选中的会话,全局面板替代它或没有选中会话时为 `undefined`。插件从会话选择与 `ctx.layout.panelInfo` 推导它,它在 React 渲染引起变化的那次更新之前就已改变,因此同一次提交里渲染的组件读到的是到来的会话,并可以在自己的 effect 里对它行动:框架在同一轮渲染里渲染该会话的席位,席位随之创建它的 store。席位从不发布它;每个席位只上报停靠套件测得的空间,`split` 与 `preferNewPane` 把它用于该会话的分栏,未测量的分栏视为有空间。计划审阅的自动打开通过绑定的 hook 读取 `mounted`。
|
||||
`close(tabId)` 关闭一个 tab;`active()` 读取活动 tab。`isExpanded()` 与 `toggleExpanded()` 读取并驱动该列的展开;`toggleFullscreen(target)` 对捕获的停靠分栏执行面板控件的显示模式操作。布局操作供以编程方式安排该列的调用方使用,每个都像它替代的手势一样被记录:`focus(tabId)` 聚焦一个 tab 及其格;`split(paneId?)` 在与 tab 条控件相同的格预算与空间规则下分栏一个停靠格(默认活跃格),返回新格的 id,做不到时返回 `undefined`——且不记录任何东西;`float(tabId, rect?)` 把停靠 tab 浮出为浮窗;`dock(paneId)` 把浮窗放回活跃停靠格。不存在的 tab 或格、或已处于调用目标状态的,都原样不动。该接口只暴露操作:没有布局快照、没有操作日志、没有按地址查找。`_undo()` / `_redo()` 步进屏幕上停靠面的历史;它们是 `@internal`——序列没有面向用户的控件,这两个只为测试存在。命令通过屏幕上会话已采用的 store 作用于该会话;没有会话在屏幕上、或运行时尚未创建它的 store 时,命令 throw,而不是写进一个没人绘制的面里。`mounted` 是「屏幕上的会话」的可观察值:Conversation 占据主栏时为选中的会话,全局面板替代它或没有选中会话时为 `undefined`。插件从会话选择与 `ctx.layout.panelInfo` 推导它,它在 React 渲染引起变化的那次更新之前就已改变,因此同一次提交里渲染的组件读到的是到来的会话,并可以在自己的 effect 里对它行动:框架在同一轮渲染里渲染该会话的席位,席位随之创建它的 store。席位从不发布它;每个席位只上报它渲染时依据的事实:停靠套件测得的空间,`split` 与 `preferNewPane` 把它用于该会话的分栏(未测量的分栏视为有空间);以及框架宽度是否让面板自动全屏,全屏命令据此执行。计划审阅的自动打开通过绑定的 hook 读取 `mounted`。
|
||||
|
||||
`focusedTarget(element?)` 解析当前 DOM 分栏和标签页,也接受嵌入 iframe;焦点位于外部时不返回页面。`commandTarget(element?)` 另外允许外部打开动作使用屏幕上会话的活动停靠分栏。捕获值包含 occurrence 和导航版本;`isTargetCurrent(target)` 拒绝会话变更、已移动或重新打开的标签页,以及期间发生的导航。焦点和指针激活独立于持久化的布局选择。
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import type {} from './contract/slots.ts'
|
||||
import { GuideBody, type GuideInjected } from './tabs/guide/GuideBody.tsx'
|
||||
import { GuideTitle } from './tabs/guide/GuideTitle.tsx'
|
||||
import { ExpandButton } from './shell/ExpandButton.tsx'
|
||||
import { AUTO_FULLSCREEN_BELOW, RightbarSeat, type SidebarRightInjected } from './shell/SidebarRight.tsx'
|
||||
import { RightbarSeat, type SidebarRightInjected } from './shell/SidebarRight.tsx'
|
||||
import { closeWithPaneFocus, openWithPaneFocus } from './shell/close-focus.ts'
|
||||
import { RightbarRoot, type RightbarRootInjected } from './shell/RightbarRoot.tsx'
|
||||
import { SidebarSessionViews } from './session-views.ts'
|
||||
@@ -117,11 +117,14 @@ export function apply(ctx: ClientContext): void {
|
||||
return () => { unsubscribe(); views.dispose() }
|
||||
}, 'ui-sidebar-right: retained Session views')
|
||||
const layout: ILayout = ctx.layout
|
||||
// The automatic fullscreen rule as the seats last rendered it: the frame
|
||||
// hands them its width as owner props, and every seat reports the same rule.
|
||||
let autoFullscreen = false
|
||||
const { controller, adopt, forget, show, measure } = createSidebarRightController(
|
||||
tabs,
|
||||
(address, signal) => { ctx.resources.pin(address, signal) },
|
||||
{
|
||||
autoFullscreen: () => layout.viewportWidth.getSnapshot() < AUTO_FULLSCREEN_BELOW,
|
||||
autoFullscreen: () => autoFullscreen,
|
||||
openWithFocus: (sessionId, open) => { openWithPaneFocus(document, sessionId, open) },
|
||||
closeWithFocus: (sessionId, paneId, close) => { closeWithPaneFocus(document, sessionId, paneId, close) },
|
||||
},
|
||||
@@ -187,6 +190,7 @@ export function apply(ctx: ClientContext): void {
|
||||
if (shown) layout.openRightbar(track, fullscreen)
|
||||
else layout.closeRightbar()
|
||||
},
|
||||
reportAutoFullscreen: (value) => { autoFullscreen = value },
|
||||
splitPane: (paneId) => { controller.split(paneId) },
|
||||
toggleFullscreen: () => { const target = controller.commandTarget(); if (target !== undefined) controller.toggleFullscreen(target) },
|
||||
openTab: (kind, options) => { controller.openTab(kind, options) },
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
* command with no Session on screen, or with one whose store the runtime has not
|
||||
* minted, has nothing to act on and fails loudly rather than writing into a
|
||||
* surface nobody is drawing. The seats never publish which Session they draw:
|
||||
* a seat reports only the room rule its docking kit measured for its panes.
|
||||
* they report only what they render with, the room their docking kit measured
|
||||
* and the automatic fullscreen rule of their frame width.
|
||||
*
|
||||
* A tab's own actions (`tabActions`) aim at the session the tab is in, not at
|
||||
* the on-screen one: they run through that session's adopted store, so a callback
|
||||
@@ -30,7 +31,7 @@
|
||||
* domain. Placement is the caller's option, never a type's property.
|
||||
*
|
||||
* The registration adopts Session stores, names the on-screen Session, and
|
||||
* forwards each seat's room readings; callers use the service's navigation methods.
|
||||
* forwards the seats' reports; callers use the service's navigation methods.
|
||||
*/
|
||||
import { sidebarTargetFromElement, type SidebarRightTarget } from './focus.ts'
|
||||
import { randomUUID } from '@deepseek-ai/dsh-util-crypto'
|
||||
@@ -82,7 +83,7 @@ interface SidebarRightSessions {
|
||||
export interface SidebarRightHost {
|
||||
/**
|
||||
* Whether the viewport is narrow enough that an expanded panel is presented fullscreen.
|
||||
* @returns the rule's verdict for the current frame width.
|
||||
* @returns the rule's verdict for the frame width the seats last rendered at.
|
||||
*/
|
||||
readonly autoFullscreen: () => boolean
|
||||
/**
|
||||
|
||||
@@ -84,6 +84,14 @@ export interface SidebarRightInjected {
|
||||
* @param canSplitPane - whether two working halves of a docked pane would fit; unmeasured panes fit.
|
||||
*/
|
||||
readonly measureRoom: (canSplitPane: (paneId: PaneId) => boolean) => void
|
||||
/**
|
||||
* Record whether the frame width this seat renders at presents an expanded panel fullscreen automatically.
|
||||
*
|
||||
* The fullscreen command reads the latest report: while it holds, the command
|
||||
* closes the panel instead of switching its recorded mode.
|
||||
* @param autoFullscreen - whether the frame is narrower than the automatic fullscreen width.
|
||||
*/
|
||||
readonly reportAutoFullscreen: (autoFullscreen: boolean) => void
|
||||
/**
|
||||
* The navigation face's `openTab`, for the strip's add control: a new tab is
|
||||
* the guide opened by kind, through the same path as every other open.
|
||||
@@ -336,24 +344,22 @@ function SidebarPanel(panel: PanelProps & { width: number; panelRef: RefObject<H
|
||||
)
|
||||
}
|
||||
|
||||
/** Frame widths below this present an expanded panel fullscreen, whatever its recorded mode. */
|
||||
export const AUTO_FULLSCREEN_BELOW = 768
|
||||
|
||||
/**
|
||||
* The right column's occupant: stable tab containers, docked or floating.
|
||||
* It is also where the frame learns the panel's presentation, because this is
|
||||
* the seat that knows it. `ctx.sidebarRight` names the on-screen Session
|
||||
* itself; this seat reports only the room its kit measured.
|
||||
* itself; this seat reports only what it renders with: the room its kit
|
||||
* measured and the automatic fullscreen rule of its frame width.
|
||||
*/
|
||||
export function RightbarSeat({
|
||||
sessionId, width, viewportWidth, canShow, useStore, actions, t, renderSlot, syncPresentation, measureRoom, openTab, closeTab,
|
||||
useTabTypes, useTabNavigation, occurrence, retainTab, active, useShortcuts, splitPane, toggleFullscreen,
|
||||
sessionId, width, viewportWidth, canShow, useStore, actions, t, renderSlot, syncPresentation, measureRoom, reportAutoFullscreen,
|
||||
openTab, closeTab, useTabTypes, useTabNavigation, occurrence, retainTab, active, useShortcuts, splitPane, toggleFullscreen,
|
||||
}: RightbarSeatProps): ReactNode {
|
||||
// One store instance per session, so this map holds this session's surface.
|
||||
const shortcuts = useShortcuts(entries => entries)
|
||||
const surface = useStore(state => state.bySession[sessionId])
|
||||
const shown = active && surface !== undefined && surface.layout.expanded
|
||||
const autoFullscreen = viewportWidth < AUTO_FULLSCREEN_BELOW
|
||||
const autoFullscreen = viewportWidth < 768
|
||||
const fullscreen = autoFullscreen || surface?.layout.mode === 'fullscreen'
|
||||
const panelRef = useRef<HTMLDivElement | null>(null)
|
||||
// A reading never re-renders anything: the service applies it when it splits.
|
||||
@@ -370,6 +376,9 @@ export function RightbarSeat({
|
||||
if (shown && !fullscreen && !canShow) actions.setExpanded(sessionId, false)
|
||||
}, [actions, sessionId, shown, fullscreen, canShow])
|
||||
|
||||
// Read only when the fullscreen command runs, after this commit has settled.
|
||||
useLayoutEffect(() => { reportAutoFullscreen(autoFullscreen) }, [reportAutoFullscreen, autoFullscreen])
|
||||
|
||||
// The open/close slide needs no pulse of its own: the shell's window drag
|
||||
// watcher (ui-web) measures the marked rows every frame the surface moves and
|
||||
// sets the recall mark itself (electron#32341).
|
||||
|
||||
@@ -66,7 +66,6 @@ async function boot(shortcuts: Partial<Shortcuts> = {}) {
|
||||
const layout = {
|
||||
openRightbar: vi.fn(), closeRightbar: vi.fn(),
|
||||
panelInfo: createSnapshotStore<{ activePanelId: string | null }>({ activePanelId: null }),
|
||||
viewportWidth: createSnapshotStore(1440),
|
||||
}
|
||||
const current = createSnapshotStore<{ key: SessionId | undefined }>({ key: undefined })
|
||||
const resources = { pin: vi.fn<(address: string, signal: AbortSignal) => void>() }
|
||||
@@ -206,7 +205,14 @@ describe('ui-sidebar-right apply', () => {
|
||||
injected.measureRoom(() => true)
|
||||
injected.splitPane(surface.layout.activePaneId)
|
||||
expect(panes()).toHaveLength(2)
|
||||
// The fullscreen command follows the automatic fullscreen rule the seats report.
|
||||
const layoutOf = () => instance.getSnapshot().bySession[SESSION]?.layout
|
||||
injected.toggleFullscreen()
|
||||
expect(layoutOf()?.mode).toBe('fullscreen')
|
||||
injected.reportAutoFullscreen(true)
|
||||
injected.toggleFullscreen()
|
||||
expect(layoutOf()?.expanded).toBe(false)
|
||||
expect(layoutOf()?.mode).toBe('push')
|
||||
// A global panel takes the Conversation's place: no Session is on screen.
|
||||
layout.panelInfo.set({ activePanelId: 'plugins' })
|
||||
expect(() => { ctx.sidebarRight.toggleExpanded() }).toThrow('no session surface is mounted')
|
||||
|
||||
@@ -71,9 +71,7 @@ function transition(property = 'transform') {
|
||||
async function mountSeat(viewportWidth = 1440, canShow = true, entryCount = 0, opener = false, keepMounted = false) {
|
||||
const runtime = await SlotTestRuntime.create()
|
||||
runtimes.push(runtime)
|
||||
const frame = {
|
||||
openRightbar: vi.fn(), closeRightbar: vi.fn(), panelInfo: runtime.panelInfo, viewportWidth: createSnapshotStore(viewportWidth),
|
||||
}
|
||||
const frame = { openRightbar: vi.fn(), closeRightbar: vi.fn(), panelInfo: runtime.panelInfo }
|
||||
const pin = vi.fn<(address: string, signal: AbortSignal) => void>()
|
||||
runtime.ctx.provide('layout', frame as never)
|
||||
runtime.ctx.provide('resources', { pin } as never)
|
||||
@@ -512,6 +510,22 @@ describe('RightbarSeat presentation', () => {
|
||||
expect(h.layout().expanded).toBe(false)
|
||||
})
|
||||
|
||||
it('applies the automatic fullscreen rule of the width it renders at to the fullscreen command', async () => {
|
||||
const h = await mountSeat()
|
||||
h.open()
|
||||
// Narrowed below the automatic fullscreen width, the command closes the panel.
|
||||
h.view.update({ width: 420, viewportWidth: 700, canShow: false })
|
||||
fireEvent.click(element(h.view.container, '[data-sidebar-right-mode]'))
|
||||
expect(h.layout().expanded).toBe(false)
|
||||
expect(h.layout().mode).toBe('push')
|
||||
// Widened again, the command switches the recorded mode.
|
||||
h.view.update({ width: 420, viewportWidth: 1440, canShow: true })
|
||||
act(() => { h.controller.toggleExpanded() })
|
||||
fireEvent.click(element(h.view.container, '[data-sidebar-right-mode]'))
|
||||
expect(h.layout().expanded).toBe(true)
|
||||
expect(h.layout().mode).toBe('fullscreen')
|
||||
})
|
||||
|
||||
it('preserves manual fullscreen through narrow and wide viewport changes', async () => {
|
||||
const h = await mountSeat()
|
||||
h.open()
|
||||
|
||||
@@ -39,7 +39,6 @@ async function bench(collapsed = false) {
|
||||
locale.setLocale('en')
|
||||
const layout = {
|
||||
panelInfo: runtime.panelInfo,
|
||||
viewportWidth: createSnapshotStore(1440),
|
||||
beginNavigation: vi.fn(() => new AbortController().signal),
|
||||
toggleSidebar: vi.fn(),
|
||||
selectPanel: vi.fn((activePanelId: MainPanelId | null) => { runtime.panelInfo.set({ activePanelId }) }),
|
||||
|
||||
@@ -279,7 +279,7 @@ function bench(options: BenchOptions = {}) {
|
||||
selectPanel: vi.fn(), retainMainPanels: vi.fn(),
|
||||
setSidebar: vi.fn(), toggleSidebar: vi.fn(), setViewportWidth: vi.fn(),
|
||||
setRightbar: vi.fn(), openRightbar: vi.fn(), closeRightbar: vi.fn(),
|
||||
}, () => true, createSnapshotStore({ activePanelId: null }), createSnapshotStore(1440))
|
||||
}, () => true, createSnapshotStore({ activePanelId: null }))
|
||||
const selectPanel = vi.spyOn(layout, 'selectPanel')
|
||||
ctx.provide('layout', layout)
|
||||
ctx.effect(() => () => { layout.dispose() })
|
||||
|
||||
Reference in new issue
Block a user