dsh-workspace-browser 0.4.13 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/client.js +1335 -1090
- package/package.json +40 -40
- package/scripts/build.mjs +42 -37
- package/src/browser.css +472 -439
- package/src/client.js +1330 -1087
- package/src/edit.svg +9 -0
- package/src/large-icons.svg +6 -6
- package/src/list-view.svg +6 -6
- package/src/menu-folder.svg +7 -7
- package/src/session-inactive.svg +3 -0
package/lib/client.js
CHANGED
|
@@ -6,12 +6,14 @@ window.__ModuleLoader__.load({
|
|
|
6
6
|
const react = require('react');
|
|
7
7
|
const { createPortal, flushSync } = require('react-dom');
|
|
8
8
|
const ui = require('@deepseek-ai/dsh-client-ui-primitives');
|
|
9
|
-
const css = "[data-dwb-grid] > :not(.dwb-mount) { display: none; }\n.dwb-mount[hidden] { display: none; }\n.dwb-toolbar-mount[hidden], .dwb-address-mount[hidden] { display: none; }\n\n@property --dwb-reveal-size {\n syntax: '<length>';\n inherits: true;\n initial-value: 0px;\n}\n\n[data-dwb-layout] {\n --dwb-edge-end: 9px;\n --dwb-content-start: 14px;\n --dwb-list-item-padding: 8px;\n --dwb-nav-width: 95px;\n --dwb-tile-start: calc(var(--dwb-content-start) - var(--dwb-list-item-padding));\n --dwb-heading-opacity: 1;\n --dwb-heading-visibility: visible;\n --dwb-heading-hide-delay: 0ms;\n --dwb-reveal-height: 40px;\n --dwb-reveal-delay: 0ms;\n --dwb-reveal-size: 0px;\n --dwb-control-opacity: 0;\n --dwb-control-visibility: hidden;\n --dwb-fade-duration: 42.5ms;\n --dwb-visibility-delay: 42.5ms;\n container-type: inline-size;\n min-block-size: 0;\n position: relative;\n transition: --dwb-reveal-size 95ms ease var(--dwb-reveal-delay);\n}\n\n[data-dwb-layout]:is([data-dwb-reveal-held], [data-dwb-reveal-hover], :has(> .dwb-toolbar-mount .dwb-nav-buttons :focus-visible, > [data-dwb-header] :focus-visible, > .dwb-address-mount :focus-visible)) {\n --dwb-reveal-delay: 50ms;\n --dwb-reveal-size: var(--dwb-reveal-height);\n --dwb-heading-opacity: 0;\n --dwb-heading-visibility: hidden;\n --dwb-heading-hide-delay: 117.5ms;\n --dwb-control-opacity: 1;\n --dwb-control-visibility: visible;\n --dwb-fade-duration: 67.5ms;\n --dwb-visibility-delay: var(--dwb-reveal-delay);\n}\n\n[data-slot='sidebar.workspaces'] [data-dwb-layout] > [data-dwb-grid] {\n margin-inline: 0;\n padding-inline: 0;\n flex: 1 1 0;\n min-block-size: 0;\n display: block;\n overflow: hidden;\n overflow-y: auto;\n overscroll-behavior-y: contain;\n}\n\n.dwb-heading[hidden], [data-dwb-replaced-heading] { display: none; }\n.dwb-heading {\n display: flex;\n align-items: center;\n gap: 4px;\n max-width: calc(100cqi - var(--dsh-sidebar-row-padding, 12px) - 104px);\n min-width: 0;\n flex: none;\n white-space: nowrap;\n line-height: 20px;\n height: 22px;\n position: absolute;\n top: 21px;\n inset-inline-start: var(--dwb-content-start);\n z-index: 3;\n pointer-events: none;\n}\n\n.dwb-heading:has(> .dwb-notifications) {\n /* Center the 22px dot in the same 23px slot as the back arrow. */\n inset-inline-start: calc(var(--dwb-tile-start) + 0.5px);\n}\n\n.dwb-heading-name {\n overflow: hidden;\n text-overflow: ellipsis;\n translate: 0 var(--dwb-reveal-size);\n opacity: var(--dwb-heading-opacity);\n visibility: var(--dwb-heading-visibility);\n transition: opacity 67.5ms ease var(--dwb-reveal-delay), visibility 0s linear var(--dwb-heading-hide-delay);\n}\n\n[data-dwb-header]:has(button[aria-expanded='true']) .dwb-heading-name { display: none; }\n\n[data-slot='sidebar.workspaces'] [data-dwb-layout] > .dwb-toolbar-mount + [data-dwb-header] {\n margin-block-start: 0;\n}\n\n[data-slot='sidebar.workspaces'] [data-dwb-layout] > [data-dwb-header]:has(button[aria-expanded='true']) {\n padding-inline-start: calc(var(--dwb-tile-start) + var(--dwb-nav-width));\n}\n\n[data-slot='sidebar.workspaces'] [data-dwb-layout] > [data-dwb-header]:not(:has(button[aria-expanded='true'])) {\n margin-inline-end: 0;\n /* The native header reserves one 4px gap after its tool group. */\n padding-inline-end: calc(var(--dwb-edge-end) - 4px);\n}\n\n.dwb-menu-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }\n.dwb-menu-label svg { flex: none; }\n\n/* In this grouping mode, only the new grouping row carries a check. */\n[data-dwb-selected] .dwb-native-group > svg:last-child { visibility: hidden; }\n\n.dwb-browser {\n min-width: 0;\n padding: 0 0 10px;\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n}\n\n.dwb-toolbar-mount { flex: none; }\n.dwb-reveal-zone {\n min-height: 2px;\n padding-block-end: 2px;\n}\n\n.dwb-address-mount {\n flex: none;\n block-size: var(--dwb-reveal-size);\n}\n\n.dwb-reveal-control {\n visibility: var(--dwb-control-visibility);\n opacity: var(--dwb-control-opacity);\n transition: opacity var(--dwb-fade-duration) ease var(--dwb-reveal-delay),\n visibility 0s linear var(--dwb-visibility-delay);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dwb-reveal-control, .dwb-heading-name, [data-dwb-layout] { transition: none; }\n}\n\n.dwb-divider {\n position: relative;\n width: 100cqi;\n height: 12px;\n touch-action: none;\n}\n\n.dwb-divider[role='separator'] { cursor: row-resize; }\n\n.dwb-divider::before {\n content: '';\n position: absolute;\n inset: 50% 0 auto;\n transform: translateY(-50%);\n pointer-events: none;\n border-top: 0.5px solid var(--dsw-alias-border-l3);\n}\n\n[data-dwb-resized-navigation] {\n height: var(--dwb-navigation-height);\n min-height: 0;\n overflow-y: auto;\n scrollbar-width: thin;\n flex-shrink: 0;\n}\n\n[data-dwb-resized-navigation] > * { flex-shrink: 0; }\n\n.dwb-nav-buttons {\n position: absolute;\n top: 19px;\n inset-inline-start: var(--dwb-tile-start);\n z-index: 2;\n display: flex;\n gap: 1px;\n}\n\n.dwb-nav-buttons .dwb-nav-button {\n width: 23px;\n height: 26px;\n padding: 0;\n justify-content: center;\n}\n\n.dwb-nav-buttons .dwb-nav-button:disabled { cursor: default; }\n\n.dwb-path {\n position: absolute;\n top: calc(59px - var(--dwb-reveal-height));\n translate: 0 var(--dwb-reveal-size);\n inset-inline-start: var(--dwb-tile-start);\n width: calc(100cqi - var(--dwb-tile-start) - var(--dwb-edge-end));\n z-index: 2;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: 2px;\n min-width: 0;\n height: 30px;\n padding: 0 5px;\n overflow-x: auto;\n scrollbar-width: none;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n}\n\n.dwb-crumb {\n display: inline-flex;\n flex: none;\n align-items: center;\n gap: 2px;\n white-space: nowrap;\n}\n\n.dwb-crumb button { min-height: 24px; height: 24px; padding-inline: 4px; font-size: 12px; }\n.dwb-current { padding: 0 4px; }\n.dwb-indicator { flex: none; color: var(--dsw-alias-label-tertiary); }\n\n.dwb-list {\n box-sizing: border-box;\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 76px), 1fr));\n gap: 4px 5px;\n list-style: none;\n width: calc(100cqi - var(--dwb-edge-end));\n margin: 8px 0 0;\n padding-inline: var(--dwb-tile-start) 0;\n}\n\n.dwb-list[data-dwb-display='icons'] { align-items: start; }\n.dwb-list > li { min-width: 0; position: relative; }\n.dwb-list > li[data-dwb-drop]::after {\n content: '';\n pointer-events: none;\n position: absolute;\n z-index: 1;\n border-radius: 2px;\n background: var(--dsw-alias-state-business-primary, #3975ea);\n}\n.dwb-list[data-dwb-display='icons'] > li[data-dwb-drop]::after { inset-block: 0; width: 2px; }\n.dwb-list[data-dwb-display='icons'] > li[data-dwb-drop='before']::after { inset-inline-start: -2px; }\n.dwb-list[data-dwb-display='icons'] > li[data-dwb-drop='after']::after { inset-inline-end: -2px; }\n.dwb-list[data-dwb-display='list'] > li[data-dwb-drop]::after { inset-inline: 0; height: 2px; }\n.dwb-list[data-dwb-display='list'] > li[data-dwb-drop='before']::after { inset-block-start: 0; }\n.dwb-list[data-dwb-display='list'] > li[data-dwb-drop='after']::after { inset-block-end: 0; }\n\n.dwb-list .dwb-tile {\n position: relative;\n width: 100%;\n height: auto;\n padding: 9px 4px 5px;\n flex-direction: column;\n justify-content: flex-start;\n gap: 5px;\n border-radius: var(--dsw-radius-md);\n font-size: 12px;\n font-weight: 400;\n line-height: 15px;\n color: var(--dsw-alias-label-primary);\n user-select: none;\n}\n\n.dwb-list .dwb-tile {\n --dwb-tile-fill: transparent;\n background: var(--dwb-tile-fill);\n}\n\n.dwb-list .dwb-tile[data-dwb-guide] { --dwb-tile-fill: #F1F3F5; }\n:where([data-ds-dark-theme]) .dwb-list .dwb-tile[data-dwb-guide] { --dwb-tile-fill: var(--dsw-alias-bg-layer-2); }\n\n@media (hover: hover) {\n .dwb-list .dwb-tile:hover { --dwb-tile-fill: var(--dsw-alias-interactive-bg-hover); }\n}\n\n.dwb-list .dwb-tile[aria-pressed='true'] { --dwb-tile-fill: var(--dsw-alias-interactive-bg-hover); }\n\n.dwb-list .dwb-tile[aria-current] {\n --dwb-tile-fill: var(--dsw-alias-interactive-bg-active);\n}\n\n.dwb-list .dwb-tile:is(:hover, :active):not(:disabled) { background: var(--dwb-tile-fill); }\n\n.dwb-tile-icon {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--dsw-alias-label-secondary);\n}\n\n.dwb-tile[aria-current] .dwb-tile-icon { color: var(--dsw-alias-state-business-primary, var(--dsw-alias-label-primary)); }\n.dwb-tile-icon img { display: block; object-fit: contain; }\n.dwb-session-icon {\n display: block;\n background: #C3C3C3;\n mask: center / contain no-repeat;\n}\n.dwb-tile[aria-current] .dwb-session-icon { background: #61666B; }\n:where([data-ds-dark-theme]) .dwb-session-icon { background: rgba(255, 255, 255, 0.45); }\n:where([data-ds-dark-theme]) .dwb-tile[aria-current] .dwb-session-icon { background: rgba(255, 255, 255, 0.85); }\n\n.dwb-label {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n width: 100%;\n overflow: hidden;\n overflow-wrap: anywhere;\n white-space: normal;\n text-align: center;\n}\n\n.dwb-status { margin: 10px 8px; color: var(--dsw-alias-label-secondary); }\n\n.dwb-menu-icon { display: block; object-fit: contain; }\n\n.dwb-list[data-dwb-display='list'] { grid-template-columns: minmax(0, 1fr); gap: 0; }\n\n.dwb-list[data-dwb-display='list'] .dwb-tile {\n height: 32px;\n padding: 0 var(--dwb-list-item-padding);\n flex-direction: row;\n align-items: center;\n gap: 8px;\n font-size: 14px;\n}\n\n.dwb-list[data-dwb-display='list'] .dwb-tile-icon { flex: none; }\n.dwb-list[data-dwb-display='list'] .dwb-label {\n display: block;\n text-align: start;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n\n.dwb-notifications { display: inline-flex; align-items: center; flex: none; gap: 2px; }\n.dwb-notification { display: inline-flex; }\n.dwb-notification[data-dwb-notification='done'] {\n --dsw-alias-state-done-primary: #48AD00;\n --dsw-alias-state-success-primary: #48AD00;\n}\n.dwb-notification:is([data-dwb-notification='error'], [data-dwb-notification='warning']) {\n animation: dwb-notification-pulse 1.2s ease-in-out infinite;\n}\n\n.dwb-tile-status, .dwb-status-marks {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n flex-wrap: wrap;\n gap: 2px 4px;\n color: var(--dsw-alias-label-secondary);\n}\n.dwb-tile-status:empty { display: none; }\n.dwb-running {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n min-block-size: 16px;\n padding-inline: 4px;\n border-radius: 4px;\n background: #D1E4C2;\n color: #3D9300;\n font-size: 11px;\n font-weight: 700;\n line-height: 14px;\n white-space: nowrap;\n}\n:where([data-ds-dark-theme]) .dwb-running {\n background: rgba(61, 147, 0, 0.24);\n color: #7ED04B;\n}\n.dwb-running[data-dwb-running-count] {\n box-sizing: border-box;\n aspect-ratio: 1;\n block-size: 16px;\n min-inline-size: 16px;\n}\n.dwb-row-mark { display: inline-flex; flex: none; }\n.dwb-tile-status .dwb-notifications { flex-direction: row-reverse; flex-wrap: wrap; justify-content: flex-start; max-inline-size: 100%; }\n\n.dwb-list[data-dwb-display='icons'] .dwb-tile-status {\n --dwb-corner-inset: 3px;\n position: absolute;\n inset: var(--dwb-corner-inset) var(--dwb-corner-inset) auto;\n justify-content: flex-start;\n flex-wrap: nowrap;\n pointer-events: none;\n z-index: 1;\n}\n.dwb-list[data-dwb-display='icons'] .dwb-running {\n border-radius: max(0px, calc(var(--dsw-radius-md) - var(--dwb-corner-inset)));\n}\n.dwb-list[data-dwb-display='icons'] .dwb-tile-status > .dwb-notifications {\n flex: 0 1 auto;\n min-inline-size: 0;\n justify-content: flex-end;\n order: -1;\n max-block-size: 24px;\n overflow: hidden;\n}\n.dwb-tile[data-dwb-kind='folder'] .dwb-tile-status,\n.dwb-tile[data-dwb-kind='folder'] .dwb-notifications {\n gap: 4px;\n}\n.dwb-tile[data-dwb-kind='folder'] .dwb-notification,\n.dwb-list[data-dwb-display='icons'] .dwb-tile .dwb-notification {\n /* StateDot paints the middle 60% of its 22px box. Space the visible circles. */\n position: relative;\n flex: none;\n inline-size: 13.2px;\n block-size: 22px;\n}\n.dwb-tile[data-dwb-kind='folder'] .dwb-notification > [data-state],\n.dwb-list[data-dwb-display='icons'] .dwb-tile .dwb-notification > [data-state] {\n position: absolute;\n left: calc(50% - 11px);\n}\n.dwb-list[data-dwb-display='icons'] .dwb-tile-status:has(> .dwb-notifications) {\n inset-inline-start: calc(var(--dsw-radius-md) - 6.6px);\n inset-block-start: calc(var(--dsw-radius-md) - 11px);\n}\n.dwb-list[data-dwb-display='icons'] .dwb-status-marks {\n flex: none;\n margin-inline-start: auto;\n max-inline-size: 50%;\n max-block-size: 24px;\n overflow: hidden;\n}\n.dwb-list[data-dwb-display='list'] .dwb-tile-status {\n flex: none;\n max-inline-size: 60%;\n max-block-size: 100%;\n overflow-y: auto;\n scrollbar-width: none;\n}\n\n@keyframes dwb-notification-pulse { 50% { opacity: 0.35; } }\n@media (prefers-reduced-motion: reduce) { .dwb-notification[data-dwb-notification] { animation: none; } }\n\n[data-dwb-mouse-gesture-tracking] :is(iframe, webview, object, embed) { pointer-events: none !important; }\r\n[data-dwb-mouse-gesture-dragging] .dwb-mouse-gesture { pointer-events: auto; cursor: default; }\r\n.dwb-mouse-gesture {\r\n position: fixed; inset: 0; z-index: 2147483647;\r\n display: grid; place-items: center; pointer-events: none; user-select: none;\r\n}\r\n.dwb-mouse-gesture > * { pointer-events: none; }\r\n.dwb-mouse-gesture-trail {\r\n position: absolute; inset: 0; width: 100%; height: 100%;\r\n fill: none; stroke: #3262E9; stroke-width: 6px; stroke-linecap: round; stroke-linejoin: round;\r\n}\r\n.dwb-mouse-gesture[data-stable-click] .dwb-mouse-gesture-trail { visibility: hidden; }\r\n.dwb-mouse-gesture[data-finished] .dwb-mouse-gesture-trail {\r\n animation: dwb-mouse-gesture-trail-fade 220ms ease-out forwards;\r\n}\r\n@keyframes dwb-mouse-gesture-trail-fade { to { opacity: 0; } }\r\n.dwb-mouse-gesture-badge {\r\n position: absolute; left: var(--dwb-gesture-badge-x); top: var(--dwb-gesture-badge-y);\r\n transform: translate(-50%, -50%);\r\n display: none; flex-direction: column; align-items: center; justify-content: center;\r\n width: 112px; height: 112px; gap: 8px; border-radius: 20px;\r\n background: rgb(0 0 0 / 74%); color: white; font-size: 14px; font-weight: 600; line-height: 1.25;\r\n}\r\n.dwb-mouse-gesture[data-action] .dwb-mouse-gesture-badge { display: flex; }\r\n.dwb-mouse-gesture-badge svg {\r\n width: 46px; height: 46px; fill: none; stroke: currentColor; stroke-width: 2;\r\n stroke-linecap: round; stroke-linejoin: round;\r\n}\r\n.dwb-mouse-gesture[data-action=\"left\"] .dwb-mouse-gesture-badge svg { transform: rotate(180deg); }\r\n.dwb-mouse-gesture[data-action=\"up\"] .dwb-mouse-gesture-badge svg { transform: rotate(-90deg); }\n";
|
|
9
|
+
const css = "[data-dwb-grid] > :not(.dwb-mount) { display: none; }\r\n.dwb-mount[hidden] { display: none; }\r\n.dwb-toolbar-mount[hidden], .dwb-address-mount[hidden] { display: none; }\r\n\r\n@property --dwb-reveal-size {\r\n syntax: '<length>';\r\n inherits: true;\r\n initial-value: 0px;\r\n}\r\n\r\n[data-dwb-layout] {\r\n --dwb-edge-end: 9px;\r\n --dwb-content-start: 14px;\r\n --dwb-list-item-padding: 8px;\r\n --dwb-nav-width: 95px;\r\n --dwb-tile-start: calc(var(--dwb-content-start) - var(--dwb-list-item-padding));\r\n --dwb-heading-opacity: 1;\r\n --dwb-heading-visibility: visible;\r\n --dwb-heading-hide-delay: 0ms;\r\n --dwb-reveal-height: 40px;\r\n --dwb-reveal-delay: 0ms;\r\n --dwb-reveal-size: 0px;\r\n --dwb-control-opacity: 0;\r\n --dwb-control-visibility: hidden;\r\n --dwb-fade-duration: 42.5ms;\r\n --dwb-visibility-delay: 42.5ms;\r\n container-type: inline-size;\r\n min-block-size: 0;\r\n position: relative;\r\n transition: --dwb-reveal-size 95ms ease var(--dwb-reveal-delay);\r\n}\r\n\r\n[data-dwb-layout]:is([data-dwb-reveal-held], [data-dwb-reveal-hover], :has(> .dwb-toolbar-mount .dwb-nav-buttons :focus-visible, > [data-dwb-header] :focus-visible, > .dwb-address-mount :focus-visible)) {\r\n --dwb-reveal-delay: 50ms;\r\n --dwb-reveal-size: var(--dwb-reveal-height);\r\n --dwb-heading-opacity: 0;\r\n --dwb-heading-visibility: hidden;\r\n --dwb-heading-hide-delay: 117.5ms;\r\n --dwb-control-opacity: 1;\r\n --dwb-control-visibility: visible;\r\n --dwb-fade-duration: 67.5ms;\r\n --dwb-visibility-delay: var(--dwb-reveal-delay);\r\n}\r\n\r\n/* DSH's shared scrollport normally sizes its workspace row to its content.\r\n Give the browser's own scroll area the remaining height in folder mode. */\r\n[data-sidebar-scrollport]:has([data-dwb-grid]) {\r\n grid-template-rows: 8px max-content 2px minmax(0, 1fr);\r\n overflow: hidden;\r\n}\r\n\r\n[data-sidebar-scrollport] [data-dwb-layout]:has(> [data-dwb-grid]) {\r\n flex: 1 1 0;\r\n}\r\n\r\n[data-slot='sidebar.workspaces'] [data-dwb-layout] > [data-dwb-grid] {\r\n margin-inline: 0;\r\n padding-inline: 0;\r\n flex: 1 1 0;\r\n min-block-size: 0;\r\n display: block;\r\n overflow: hidden;\r\n overflow-y: auto;\r\n overscroll-behavior-y: contain;\r\n}\r\n\r\n.dwb-heading[hidden], [data-dwb-replaced-heading] { display: none; }\r\n.dwb-heading {\r\n display: flex;\r\n align-items: center;\r\n gap: 4px;\r\n max-width: calc(100cqi - var(--dsh-sidebar-row-padding, 12px) - 104px);\r\n min-width: 0;\r\n flex: none;\r\n white-space: nowrap;\r\n line-height: 20px;\r\n height: 22px;\r\n position: absolute;\r\n top: 21px;\r\n inset-inline-start: var(--dwb-content-start);\r\n z-index: 3;\r\n pointer-events: none;\r\n}\r\n\r\n.dwb-heading:has(> .dwb-notifications) {\r\n /* Center the 22px dot in the same 23px slot as the back arrow. */\r\n inset-inline-start: calc(var(--dwb-tile-start) + 0.5px);\r\n}\r\n\r\n.dwb-heading-name {\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n translate: 0 var(--dwb-reveal-size);\r\n opacity: var(--dwb-heading-opacity);\r\n visibility: var(--dwb-heading-visibility);\r\n transition: opacity 67.5ms ease var(--dwb-reveal-delay), visibility 0s linear var(--dwb-heading-hide-delay);\r\n}\r\n\r\n[data-dwb-header]:has(button[aria-expanded='true']) .dwb-heading-name { display: none; }\r\n\r\n[data-slot='sidebar.workspaces'] [data-dwb-layout] > .dwb-toolbar-mount + [data-dwb-header] {\r\n margin-block-start: 0;\r\n}\r\n\r\n[data-slot='sidebar.workspaces'] [data-dwb-layout] > [data-dwb-header]:has(button[aria-expanded='true']) {\r\n padding-inline-start: calc(var(--dwb-tile-start) + var(--dwb-nav-width));\r\n}\r\n\r\n[data-slot='sidebar.workspaces'] [data-dwb-layout] > [data-dwb-header]:not(:has(button[aria-expanded='true'])) {\r\n margin-inline-end: 0;\r\n /* The native header reserves one 4px gap after its tool group. */\r\n padding-inline-end: calc(var(--dwb-edge-end) - 4px);\r\n}\r\n\r\n.dwb-menu-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }\r\n.dwb-menu-label svg { flex: none; }\r\n\r\n/* In this grouping mode, only the new grouping row carries a check. */\r\n[data-dwb-selected] .dwb-native-group > svg:last-child { visibility: hidden; }\r\n\r\n.dwb-browser {\r\n min-width: 0;\r\n padding: 0 0 10px;\r\n color: var(--dsw-alias-label-primary);\r\n font-size: 13px;\r\n}\r\n\r\n.dwb-toolbar-mount { flex: none; }\r\n.dwb-reveal-zone {\r\n min-height: 2px;\r\n padding-block-end: 2px;\r\n}\r\n\r\n.dwb-address-mount {\r\n flex: none;\r\n block-size: var(--dwb-reveal-size);\r\n}\r\n\r\n.dwb-reveal-control {\r\n visibility: var(--dwb-control-visibility);\r\n opacity: var(--dwb-control-opacity);\r\n transition: opacity var(--dwb-fade-duration) ease var(--dwb-reveal-delay),\r\n visibility 0s linear var(--dwb-visibility-delay);\r\n}\r\n\r\n@media (prefers-reduced-motion: reduce) {\r\n .dwb-reveal-control, .dwb-heading-name, [data-dwb-layout] { transition: none; }\r\n}\r\n\r\n.dwb-divider {\r\n position: relative;\r\n width: 100cqi;\r\n height: 12px;\r\n touch-action: none;\r\n}\r\n\r\n.dwb-divider[role='separator'] { cursor: row-resize; }\r\n\r\n.dwb-divider::before {\r\n content: '';\r\n position: absolute;\r\n inset: 50% 0 auto;\r\n transform: translateY(-50%);\r\n pointer-events: none;\r\n border-top: 0.5px solid var(--dsw-alias-border-l3);\r\n}\r\n\r\n[data-dwb-resized-navigation] {\r\n height: var(--dwb-navigation-height);\r\n min-height: 0;\r\n overflow-y: auto;\r\n scrollbar-width: thin;\r\n flex-shrink: 0;\r\n}\r\n\r\n[data-dwb-resized-navigation] > * { flex-shrink: 0; }\r\n\r\n.dwb-nav-buttons {\r\n position: absolute;\r\n top: 19px;\r\n inset-inline-start: var(--dwb-tile-start);\r\n z-index: 2;\r\n display: flex;\r\n gap: 1px;\r\n}\r\n\r\n.dwb-nav-buttons .dwb-nav-button {\r\n width: 23px;\r\n height: 26px;\r\n padding: 0;\r\n justify-content: center;\r\n}\r\n\r\n.dwb-nav-buttons .dwb-nav-button:disabled { cursor: default; }\r\n\r\n.dwb-path {\r\n position: absolute;\r\n top: calc(59px - var(--dwb-reveal-height));\r\n translate: 0 var(--dwb-reveal-size);\r\n inset-inline-start: var(--dwb-tile-start);\r\n width: calc(100cqi - var(--dwb-tile-start) - var(--dwb-edge-end));\r\n z-index: 2;\r\n box-sizing: border-box;\r\n display: flex;\r\n align-items: center;\r\n gap: 2px;\r\n min-width: 0;\r\n height: 30px;\r\n padding: 0 5px;\r\n overflow-x: auto;\r\n scrollbar-width: none;\r\n border: 0.5px solid var(--dsw-alias-border-l3);\r\n border-radius: var(--dsw-radius-md);\r\n background: var(--dsw-alias-bg-layer-1);\r\n}\r\n\r\n.dwb-crumb {\r\n display: inline-flex;\r\n flex: none;\r\n align-items: center;\r\n gap: 2px;\r\n white-space: nowrap;\r\n}\r\n\r\n.dwb-crumb button { min-height: 24px; height: 24px; padding-inline: 4px; font-size: 12px; }\r\n.dwb-current { padding: 0 4px; }\r\n.dwb-indicator { flex: none; color: var(--dsw-alias-label-tertiary); }\r\n\r\n.dwb-list {\r\n box-sizing: border-box;\r\n display: grid;\r\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 76px), 1fr));\r\n gap: 4px 5px;\r\n list-style: none;\r\n width: calc(100cqi - var(--dwb-edge-end));\r\n margin: 8px 0 0;\r\n padding-inline: var(--dwb-tile-start) 0;\r\n}\r\n\r\n.dwb-list[data-dwb-display='icons'] { align-items: start; }\r\n.dwb-list > li { min-width: 0; position: relative; }\r\n.dwb-list > li[data-dwb-drop]::after {\r\n content: '';\r\n pointer-events: none;\r\n position: absolute;\r\n z-index: 1;\r\n border-radius: 2px;\r\n background: var(--dsw-alias-state-business-primary, #3975ea);\r\n}\r\n.dwb-list[data-dwb-display='icons'] > li[data-dwb-drop]::after { inset-block: 0; width: 2px; }\r\n.dwb-list[data-dwb-display='icons'] > li[data-dwb-drop='before']::after { inset-inline-start: -2px; }\r\n.dwb-list[data-dwb-display='icons'] > li[data-dwb-drop='after']::after { inset-inline-end: -2px; }\r\n.dwb-list[data-dwb-display='list'] > li[data-dwb-drop]::after { inset-inline: 0; height: 2px; }\r\n.dwb-list[data-dwb-display='list'] > li[data-dwb-drop='before']::after { inset-block-start: 0; }\r\n.dwb-list[data-dwb-display='list'] > li[data-dwb-drop='after']::after { inset-block-end: 0; }\r\n.dwb-list[data-dwb-lifted='true'] .dwb-tile { cursor: grabbing; }\r\n\r\n.dwb-list .dwb-tile {\r\n position: relative;\r\n width: 100%;\r\n height: auto;\r\n padding: 9px 4px 5px;\r\n flex-direction: column;\r\n justify-content: flex-start;\r\n gap: 5px;\r\n border-radius: var(--dsw-radius-md);\r\n font-size: 12px;\r\n font-weight: 400;\r\n line-height: 15px;\r\n color: var(--dsw-alias-label-primary);\r\n user-select: none;\r\n}\r\n\r\n.dwb-list .dwb-tile {\r\n --dwb-tile-fill: transparent;\r\n background: var(--dwb-tile-fill);\r\n}\r\n\r\n.dwb-list .dwb-tile[data-dwb-guide] { --dwb-tile-fill: #F1F3F5; }\r\n:where([data-ds-dark-theme]) .dwb-list .dwb-tile[data-dwb-guide] { --dwb-tile-fill: var(--dsw-alias-bg-layer-2); }\r\n\r\n@media (hover: hover) {\r\n .dwb-list .dwb-tile:hover { --dwb-tile-fill: var(--dsw-alias-interactive-bg-hover); }\r\n}\r\n\r\n.dwb-list .dwb-tile[aria-pressed='true'] { --dwb-tile-fill: var(--dsw-alias-interactive-bg-hover); }\r\n\r\n.dwb-list .dwb-tile[aria-current] {\r\n --dwb-tile-fill: var(--dsw-alias-interactive-bg-active);\r\n}\r\n\r\n.dwb-list .dwb-tile:is(:hover, :active):not(:disabled) { background: var(--dwb-tile-fill); }\r\n\r\n.dwb-tile-icon {\r\n position: relative;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n\r\n.dwb-tile[aria-current] .dwb-tile-icon { color: var(--dsw-alias-state-business-primary, var(--dsw-alias-label-primary)); }\r\n.dwb-tile-icon img { display: block; object-fit: contain; }\r\n.dwb-session-icon {\r\n display: block;\r\n background: #C3C3C3;\r\n mask: center / contain no-repeat;\r\n}\r\n.dwb-tile[aria-current] .dwb-session-icon { background: #61666B; }\r\n:where([data-ds-dark-theme]) .dwb-session-icon { background: rgba(255, 255, 255, 0.45); }\r\n:where([data-ds-dark-theme]) .dwb-tile[aria-current] .dwb-session-icon { background: rgba(255, 255, 255, 0.85); }\r\n\r\n.dwb-label {\r\n display: -webkit-box;\r\n -webkit-box-orient: vertical;\r\n -webkit-line-clamp: 2;\r\n width: 100%;\r\n overflow: hidden;\r\n overflow-wrap: anywhere;\r\n white-space: normal;\r\n text-align: center;\r\n}\r\n\r\n.dwb-status { margin: 10px 8px; color: var(--dsw-alias-label-secondary); }\r\n\r\n.dwb-menu-icon { display: block; object-fit: contain; }\r\n\r\n.dwb-list[data-dwb-display='list'] { grid-template-columns: minmax(0, 1fr); gap: 0; }\r\n\r\n.dwb-list[data-dwb-display='list'] .dwb-tile {\r\n height: 32px;\r\n padding: 0 var(--dwb-list-item-padding);\r\n flex-direction: row;\r\n align-items: center;\r\n gap: 8px;\r\n font-size: 14px;\r\n}\r\n\r\n.dwb-list[data-dwb-display='list'] .dwb-tile-icon { flex: none; }\r\n.dwb-list[data-dwb-display='list'] .dwb-label {\r\n display: block;\r\n text-align: start;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n}\r\n\r\n.dwb-notifications { display: inline-flex; align-items: center; flex: none; gap: 2px; }\r\n.dwb-notification { display: inline-flex; }\r\n.dwb-notification[data-dwb-notification='done'] {\r\n --dsw-alias-state-done-primary: #48AD00;\r\n --dsw-alias-state-success-primary: #48AD00;\r\n}\r\n.dwb-notification:is([data-dwb-notification='error'], [data-dwb-notification='warning']) {\r\n animation: dwb-notification-pulse 1.2s ease-in-out infinite;\r\n}\r\n\r\n.dwb-tile-status, .dwb-status-marks {\r\n display: flex;\r\n align-items: center;\r\n justify-content: flex-end;\r\n flex-wrap: wrap;\r\n gap: 2px 4px;\r\n color: var(--dsw-alias-label-secondary);\r\n}\r\n.dwb-tile-status:empty { display: none; }\r\n.dwb-running {\r\n display: inline-flex;\r\n flex: none;\r\n align-items: center;\r\n justify-content: center;\r\n min-block-size: 16px;\r\n padding-inline: 4px;\r\n border-radius: 4px;\r\n background: #D1E4C2;\r\n color: #3D9300;\r\n font-size: 11px;\r\n font-weight: 700;\r\n line-height: 14px;\r\n white-space: nowrap;\r\n}\r\n:where([data-ds-dark-theme]) .dwb-running {\r\n background: rgba(61, 147, 0, 0.24);\r\n color: #7ED04B;\r\n}\r\n.dwb-running[data-dwb-running-count] {\r\n box-sizing: border-box;\r\n aspect-ratio: 1;\r\n block-size: 16px;\r\n min-inline-size: 16px;\r\n}\r\n.dwb-row-mark { display: inline-flex; flex: none; }\r\n.dwb-tile-status .dwb-notifications { flex-direction: row-reverse; flex-wrap: wrap; justify-content: flex-start; max-inline-size: 100%; }\r\n\r\n.dwb-list[data-dwb-display='icons'] .dwb-tile-status {\r\n --dwb-corner-inset: 3px;\r\n position: absolute;\r\n inset: var(--dwb-corner-inset) var(--dwb-corner-inset) auto;\r\n justify-content: flex-start;\r\n flex-wrap: nowrap;\r\n pointer-events: none;\r\n z-index: 1;\r\n}\r\n.dwb-list[data-dwb-display='icons'] .dwb-running {\r\n border-radius: max(0px, calc(var(--dsw-radius-md) - var(--dwb-corner-inset)));\r\n}\r\n.dwb-list[data-dwb-display='icons'] .dwb-tile-status > .dwb-notifications {\r\n flex: 0 1 auto;\r\n min-inline-size: 0;\r\n justify-content: flex-end;\r\n order: -1;\r\n max-block-size: 24px;\r\n overflow: hidden;\r\n}\r\n.dwb-tile[data-dwb-kind='folder'] .dwb-tile-status,\r\n.dwb-tile[data-dwb-kind='folder'] .dwb-notifications {\r\n gap: 4px;\r\n}\r\n.dwb-tile[data-dwb-kind='folder'] .dwb-notification,\r\n.dwb-list[data-dwb-display='icons'] .dwb-tile .dwb-notification {\r\n /* StateDot paints the middle 60% of its 22px box. Space the visible circles. */\r\n position: relative;\r\n flex: none;\r\n inline-size: 13.2px;\r\n block-size: 22px;\r\n}\r\n.dwb-tile[data-dwb-kind='folder'] .dwb-notification > [data-state],\r\n.dwb-list[data-dwb-display='icons'] .dwb-tile .dwb-notification > [data-state] {\r\n position: absolute;\r\n left: calc(50% - 11px);\r\n}\r\n.dwb-list[data-dwb-display='icons'] .dwb-tile-status:has(> .dwb-notifications) {\r\n inset-inline-start: calc(var(--dsw-radius-md) - 6.6px);\r\n inset-block-start: calc(var(--dsw-radius-md) - 11px);\r\n}\r\n.dwb-list[data-dwb-display='icons'] .dwb-status-marks {\r\n flex: none;\r\n margin-inline-start: auto;\r\n max-inline-size: 50%;\r\n max-block-size: 24px;\r\n overflow: hidden;\r\n}\r\n.dwb-list[data-dwb-display='list'] .dwb-tile-status {\r\n flex: none;\r\n max-inline-size: 60%;\r\n max-block-size: 100%;\r\n overflow-y: auto;\r\n scrollbar-width: none;\r\n}\r\n\r\n@keyframes dwb-notification-pulse { 50% { opacity: 0.35; } }\r\n@media (prefers-reduced-motion: reduce) { .dwb-notification[data-dwb-notification] { animation: none; } }\r\n\r\n.dwb-settings {\r\n width: min(400px, calc(100vw - 48px));\r\n box-sizing: border-box;\r\n padding: 24px;\r\n border: 1px solid var(--dsw-alias-border-l3);\r\n border-radius: var(--dsw-radius-md, 12px);\r\n color: var(--dsw-alias-label-primary);\r\n background: var(--dsw-alias-bg-layer-1);\r\n font: inherit;\r\n}\r\n.dwb-settings::backdrop { background: rgb(0 0 0 / 25%); }\r\n.dwb-settings h2 { margin: 0 0 24px; font-size: 18px; }\r\n.dwb-settings fieldset { border: 0; padding: 0; margin: 0 0 24px; }\r\n.dwb-settings legend { padding: 0; margin-bottom: 12px; }\r\n.dwb-settings label { display: inline-flex; align-items: center; gap: 6px; margin-inline-end: 24px; }\r\n\r\n.dwb-group-row { display: flex; align-items: center; gap: 2px; }\r\n.dwb-group-row > :first-child { flex: 1; min-width: 0; }\r\n.dwb-group-row .dwb-group-settings { flex: none; width: 28px; height: 28px; padding: 0; justify-content: center; }\r\n.dwb-group-settings img { display: block; }\r\n\n[data-dwb-mouse-gesture-tracking] :is(iframe, webview, object, embed) { pointer-events: none !important; }\r\n[data-dwb-mouse-gesture-dragging] .dwb-mouse-gesture { pointer-events: auto; cursor: default; }\r\n.dwb-mouse-gesture {\r\n position: fixed; inset: 0; z-index: 2147483647;\r\n display: grid; place-items: center; pointer-events: none; user-select: none;\r\n}\r\n.dwb-mouse-gesture > * { pointer-events: none; }\r\n.dwb-mouse-gesture-trail {\r\n position: absolute; inset: 0; width: 100%; height: 100%;\r\n fill: none; stroke: #3262E9; stroke-width: 6px; stroke-linecap: round; stroke-linejoin: round;\r\n}\r\n.dwb-mouse-gesture[data-stable-click] .dwb-mouse-gesture-trail { visibility: hidden; }\r\n.dwb-mouse-gesture[data-finished] .dwb-mouse-gesture-trail {\r\n animation: dwb-mouse-gesture-trail-fade 220ms ease-out forwards;\r\n}\r\n@keyframes dwb-mouse-gesture-trail-fade { to { opacity: 0; } }\r\n.dwb-mouse-gesture-badge {\r\n position: absolute; left: var(--dwb-gesture-badge-x); top: var(--dwb-gesture-badge-y);\r\n transform: translate(-50%, -50%);\r\n display: none; flex-direction: column; align-items: center; justify-content: center;\r\n width: 112px; height: 112px; gap: 8px; border-radius: 20px;\r\n background: rgb(0 0 0 / 74%); color: white; font-size: 14px; font-weight: 600; line-height: 1.25;\r\n}\r\n.dwb-mouse-gesture[data-action] .dwb-mouse-gesture-badge { display: flex; }\r\n.dwb-mouse-gesture-badge svg {\r\n width: 46px; height: 46px; fill: none; stroke: currentColor; stroke-width: 2;\r\n stroke-linecap: round; stroke-linejoin: round;\r\n}\r\n.dwb-mouse-gesture[data-action=\"left\"] .dwb-mouse-gesture-badge svg { transform: rotate(180deg); }\r\n.dwb-mouse-gesture[data-action=\"up\"] .dwb-mouse-gesture-badge svg { transform: rotate(-90deg); }\n";
|
|
10
10
|
const folderIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDUiIGhlaWdodD0iNDEiIHZpZXdCb3g9IjAgMCA0NSA0MSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgNS41QzAgMi41IDEuNSAwIDUuNSAwSDEzQzE1LjUgMCAxNyAxIDE4LjUgMi41TDIxLjUgNS41QzIyLjUgNi41IDI0IDcgMjUuNSA3SDQwLjVDNDMgNyA0NSA5IDQ1IDExVjM3QzQ1IDM5IDQzLjUgNDEgNDEgNDFINUMyLjUgNDEgMCAzOSAwIDM2LjVWNS41WiIgZmlsbD0iI0MzQzNDMyIvPgo8cmVjdCB4PSIzLjUiIHk9IjEwLjUiIHdpZHRoPSIzOCIgaGVpZ2h0PSI0IiByeD0iMS41IiBmaWxsPSIjRjlGQUZCIi8+Cjwvc3ZnPgo=";
|
|
11
11
|
const sessionIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDQiIGhlaWdodD0iNDIiIHZpZXdCb3g9IjAgMCA0NCA0MiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQuMTA3MjYgMzAuNTIzM0MyLjQ0NzA3IDI3LjcwNjkgMS41MDA0OSAyNC40NTg2IDEuNTAwNDkgMjFDMS41MDA0OSAxMC4yMzA0IDEwLjY3ODcgMS41IDIyLjAwMDUgMS41QzMzLjMyMjMgMS41IDQyLjUwMDUgMTAuMjMwNCA0Mi41MDA1IDIxQzQyLjUwMDUgMzEuNzY5NiAzMy4zMjIzIDQwLjUgMjIuMDAwNSA0MC41QzE4LjU1ODEgNDAuNSAxNS41Nzg1IDM5Ljc2NzIgMTMuNDE5MSAzOC42ODZDMTEuMjU5NyAzNy42MDQ5IDcuMjcwNjkgMzcuNzc5MSA1LjMxNDQ0IDM4LjY4NkMzLjAyNjA3IDM5Ljc0NyAyLjEzNjE1IDQwLjE5NzcgMS41MDA0OSA0MC41IiBzdHJva2Utd2lkdGg9IjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlPSIjQzNDM0MzIi8+CjxjaXJjbGUgY3g9IjEzLjAwMDUiIGN5PSIyMSIgcj0iMi41IiBmaWxsPSIjQzNDM0MzIi8+CjxjaXJjbGUgY3g9IjIyLjAwMDUiIGN5PSIyMSIgcj0iMi41IiBmaWxsPSIjQzNDM0MzIi8+CjxjaXJjbGUgY3g9IjMxLjAwMDUiIGN5PSIyMSIgcj0iMi41IiBmaWxsPSIjQzNDM0MzIi8+Cjwvc3ZnPgo=";
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const inactiveSessionIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDQiIGhlaWdodD0iNDIiIHZpZXdCb3g9IjAgMCA0NCA0MiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQuMTA3MjYgMzAuNTIzM0MyLjQ0NzA3IDI3LjcwNjkgMS41MDA0OSAyNC40NTg2IDEuNTAwNDkgMjFDMS41MDA0OSAxMC4yMzA0IDEwLjY3ODcgMS41IDIyLjAwMDUgMS41QzMzLjMyMjMgMS41IDQyLjUwMDUgMTAuMjMwNCA0Mi41MDA1IDIxQzQyLjUwMDUgMzEuNzY5NiAzMy4zMjIzIDQwLjUgMjIuMDAwNSA0MC41QzE4LjU1ODEgNDAuNSAxNS41Nzg1IDM5Ljc2NzIgMTMuNDE5MSAzOC42ODZDMTEuMjU5NyAzNy42MDQ5IDcuMjcwNjkgMzcuNzc5MSA1LjMxNDQ0IDM4LjY4NkMzLjAyNjA3IDM5Ljc0NyAyLjEzNjE1IDQwLjE5NzcgMS41MDA0OSA0MC41IiBzdHJva2Utd2lkdGg9IjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlPSIjQzNDM0MzIi8+Cjwvc3ZnPgo=";
|
|
13
|
+
const largeIconsMenuIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTUiIGhlaWdodD0iNTUiIHZpZXdCb3g9IjAgMCA1NSA1NSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxyZWN0IHg9IjEwLjUiIHk9IjEwLjUiIHdpZHRoPSIxNSIgaGVpZ2h0PSIxNSIgcng9IjQuNSIgc3Ryb2tlLXdpZHRoPSIzIiBzdHJva2U9IiM2MTY2NkIiLz4NCjxyZWN0IHg9IjEwLjUiIHk9IjMwLjUiIHdpZHRoPSIxNSIgaGVpZ2h0PSIxNSIgcng9IjQuNSIgc3Ryb2tlLXdpZHRoPSIzIiBzdHJva2U9IiM2MTY2NkIiLz4NCjxyZWN0IHg9IjMwLjUiIHk9IjEwLjUiIHdpZHRoPSIxNSIgaGVpZ2h0PSIxNSIgcng9IjQuNSIgc3Ryb2tlLXdpZHRoPSIzIiBzdHJva2U9IiM2MTY2NkIiLz4NCjxyZWN0IHg9IjMwLjUiIHk9IjMwLjUiIHdpZHRoPSIxNSIgaGVpZ2h0PSIxNSIgcng9IjQuNSIgc3Ryb2tlLXdpZHRoPSIzIiBzdHJva2U9IiM2MTY2NkIiLz4NCjwvc3ZnPg0K";
|
|
14
|
+
const menuFolderIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTUiIGhlaWdodD0iNTUiIHZpZXdCb3g9IjAgMCA1NSA1NSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxtYXNrIGlkPSJzdHJva2UwXzk4XzMwNCIgZmlsbD0id2hpdGUiPg0KPHBhdGggZD0iTTUgMTIuNUM1IDkuNSA2LjUgNyAxMC41IDdIMThDMjAuNSA3IDIyIDggMjMuNSA5LjVMMjYuNSAxMi41QzI3LjUgMTMuNSAyOSAxNCAzMC41IDE0SDQ1LjVDNDggMTQgNTAgMTYgNTAgMThWNDRDNTAgNDYgNDguNSA0OCA0NiA0OEgxMEM3LjUgNDggNSA0NiA1IDQzLjVWMTIuNVoiLz4NCjwvbWFzaz4NCjxwYXRoIGQ9Ik0xMC41IDdDNi41IDcgNSA5LjUgNSAxMi41VjQzLjVDNSA0NiA3LjUgNDggMTAgNDhINDZDNDguNSA0OCA1MCA0NiA1MCA0NFYxOEM1MCAxNiA0OCAxNCA0NS41IDE0SDMwLjVDMjkgMTQgMjcuNSAxMy41IDI2LjUgMTIuNUwyMy41IDkuNUMyMiA4IDIwLjUgNyAxOCA3SDEwLjVaIiBzdHJva2Utd2lkdGg9IjYiIHN0cm9rZT0iIzYxNjY2QiIgbWFzaz0idXJsKCNzdHJva2UwXzk4XzMwNCkiLz4NCjxyZWN0IHg9IjExIiB5PSIyMCIgd2lkdGg9IjMzIiBoZWlnaHQ9IjIyIiByeD0iMS41IiBmaWxsPSIjQzNDM0MzIi8+DQo8L3N2Zz4NCg==";
|
|
15
|
+
const listMenuIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTUiIGhlaWdodD0iNTUiIHZpZXdCb3g9IjAgMCA1NSA1NSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxsaW5lIHgxPSI4LjUiIHkxPSIxNS41IiB4Mj0iNDcuNSIgeTI9IjE1LjUiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2U9IiM2MTY2NkIiLz4NCjxsaW5lIHgxPSI4LjUiIHkxPSIyNC41IiB4Mj0iNDcuNSIgeTI9IjI0LjUiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2U9IiM2MTY2NkIiLz4NCjxsaW5lIHgxPSI4LjUiIHkxPSIzMy41IiB4Mj0iNDcuNSIgeTI9IjMzLjUiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2U9IiM2MTY2NkIiLz4NCjxsaW5lIHgxPSI4LjUiIHkxPSI0Mi41IiB4Mj0iNDcuNSIgeTI9IjQyLjUiIHN0cm9rZS13aWR0aD0iMyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2U9IiM2MTY2NkIiLz4NCjwvc3ZnPg0K";
|
|
16
|
+
const editMenuIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDEiIGhlaWdodD0iNDEiIHZpZXdCb3g9IjAgMCA0MSA0MSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTI3LjgzMzQgMjkuMTA0NUw5LjUwMDA0IDI5LjEwNDUiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlPSIjMjcwNzAwIi8+CjxwYXRoIGQ9Ik0zMC4xMjUgMzEuODU1QzMwLjQ4NjEgMzEuODU1IDMwLjg0MzcgMzEuNzgzOCAzMS4xNzc0IDMxLjY0NTZDMzEuNTExIDMxLjUwNzQgMzEuODE0MiAzMS4zMDQ5IDMyLjA2OTUgMzEuMDQ5NUMzMi4zMjQ5IDMwLjc5NDIgMzIuNTI3NSAzMC40OTEgMzIuNjY1NyAzMC4xNTc0QzMyLjgwMzkgMjkuODIzNyAzMi44NzUgMjkuNDY2MSAzMi44NzUgMjkuMTA1QzMyLjg3NSAyOC43NDM4IDMyLjgwMzkgMjguMzg2MiAzMi42NjU3IDI4LjA1MjZDMzIuNTI3NSAyNy43MTkgMzIuMzI0OSAyNy40MTU4IDMyLjA2OTUgMjcuMTYwNEMzMS44MTQyIDI2LjkwNTEgMzEuNTExIDI2LjcwMjUgMzEuMTc3NCAyNi41NjQzQzMwLjg0MzcgMjYuNDI2MSAzMC40ODYxIDI2LjM1NSAzMC4xMjUgMjYuMzU1QzI5Ljc2MzkgMjYuMzU1IDI5LjQwNjMgMjYuNDI2MSAyOS4wNzI2IDI2LjU2NDNDMjguNzM5IDI2LjcwMjUgMjguNDM1OCAyNi45MDUxIDI4LjE4MDUgMjcuMTYwNEMyNy45MjUxIDI3LjQxNTggMjcuNzIyNSAyNy43MTkgMjcuNTg0MyAyOC4wNTI2QzI3LjQ0NjEgMjguMzg2MiAyNy4zNzUgMjguNzQzOCAyNy4zNzUgMjkuMTA1QzI3LjM3NSAyOS40NjYxIDI3LjQ0NjEgMjkuODIzNyAyNy41ODQzIDMwLjE1NzRDMjcuNzIyNSAzMC40OTEgMjcuOTI1MSAzMC43OTQyIDI4LjE4MDUgMzEuMDQ5NUMyOC40MzU4IDMxLjMwNDkgMjguNzM5IDMxLjUwNzQgMjkuMDcyNiAzMS42NDU2QzI5LjQwNjMgMzEuNzgzOCAyOS43NjM5IDMxLjg1NSAzMC4xMjUgMzEuODU1TDMwLjEyNSAzMS44NTVaIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZT0iIzI3MDcwMCIvPgo8cGF0aCBkPSJNMzIuODc1IDIwLjVMMjMuMjUgMjAuNSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2U9IiMyNzA3MDAiLz4KPHBhdGggZD0iTTE5LjEyNSAyMC41TDkuNSAyMC41IiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZT0iIzI3MDcwMCIvPgo8cGF0aCBkPSJNMjEuNDE2NiAyMy4yNUMyMS43Nzc4IDIzLjI1IDIyLjEzNTQgMjMuMTc4OSAyMi40NjkgMjMuMDQwN0MyMi44MDI3IDIyLjkwMjUgMjMuMTA1OCAyMi42OTk5IDIzLjM2MTIgMjIuNDQ0NUMyMy42MTY1IDIyLjE4OTIgMjMuODE5MSAyMS44ODYgMjMuOTU3MyAyMS41NTI0QzI0LjA5NTUgMjEuMjE4NyAyNC4xNjY2IDIwLjg2MTEgMjQuMTY2NiAyMC41QzI0LjE2NjYgMjAuMTM4OSAyNC4wOTU1IDE5Ljc4MTMgMjMuOTU3MyAxOS40NDc2QzIzLjgxOTEgMTkuMTE0IDIzLjYxNjUgMTguODEwOCAyMy4zNjEyIDE4LjU1NTVDMjMuMTA1OCAxOC4zMDAxIDIyLjgwMjcgMTguMDk3NSAyMi40NjkgMTcuOTU5M0MyMi4xMzU0IDE3LjgyMTEgMjEuNzc3OCAxNy43NSAyMS40MTY2IDE3Ljc1QzIxLjA1NTUgMTcuNzUgMjAuNjk3OSAxNy44MjExIDIwLjM2NDIgMTcuOTU5M0MyMC4wMzA2IDE4LjA5NzUgMTkuNzI3NCAxOC4zMDAxIDE5LjQ3MjEgMTguNTU1NUMxOS4yMTY3IDE4LjgxMDggMTkuMDE0MiAxOS4xMTQgMTguODc2IDE5LjQ0NzZDMTguNzM3OCAxOS43ODEzIDE4LjY2NjYgMjAuMTM4OSAxOC42NjY2IDIwLjVDMTguNjY2NiAyMC44NjExIDE4LjczNzggMjEuMjE4NyAxOC44NzYgMjEuNTUyNEMxOS4wMTQyIDIxLjg4NiAxOS4yMTY3IDIyLjE4OTIgMTkuNDcyMSAyMi40NDQ1QzE5LjcyNzQgMjIuNjk5OSAyMC4wMzA2IDIyLjkwMjUgMjAuMzY0MiAyMy4wNDA3QzIwLjY5NzkgMjMuMTc4OSAyMS4wNTU1IDIzLjI1IDIxLjQxNjYgMjMuMjVMMjEuNDE2NiAyMy4yNVoiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlPSIjMjcwNzAwIi8+CjxwYXRoIGQ9Ik0zMi44NzUgMTIuMDcyOEwxNSAxMi4wNzI4IiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZT0iIzI3MDcwMCIvPgo8cGF0aCBkPSJNMTIuMjUgMTQuODIyOEMxMi42MTExIDE0LjgyMjggMTIuOTY4NyAxNC43NTE2IDEzLjMwMjQgMTQuNjEzNEMxMy42MzYgMTQuNDc1MiAxMy45MzkyIDE0LjI3MjcgMTQuMTk0NSAxNC4wMTczQzE0LjQ0OTkgMTMuNzYxOSAxNC42NTI1IDEzLjQ1ODggMTQuNzkwNyAxMy4xMjUxQzE0LjkyODkgMTIuNzkxNSAxNSAxMi40MzM5IDE1IDEyLjA3MjhDMTUgMTEuNzExNiAxNC45Mjg5IDExLjM1NCAxNC43OTA3IDExLjAyMDRDMTQuNjUyNSAxMC42ODY3IDE0LjQ0OTkgMTAuMzgzNiAxNC4xOTQ1IDEwLjEyODJDMTMuOTM5MiA5Ljg3Mjg1IDEzLjYzNiA5LjY3MDI5IDEzLjMwMjQgOS41MzIwOUMxMi45Njg3IDkuMzkzODggMTIuNjExMSA5LjMyMjc1IDEyLjI1IDkuMzIyNzVDMTEuODg4OSA5LjMyMjc1IDExLjUzMTMgOS4zOTM4OCAxMS4xOTc2IDkuNTMyMDlDMTAuODY0IDkuNjcwMjkgMTAuNTYwOCA5Ljg3Mjg1IDEwLjMwNTUgMTAuMTI4MkMxMC4wNTAxIDEwLjM4MzYgOS44NDc1MyAxMC42ODY3IDkuNzA5MzMgMTEuMDIwNEM5LjU3MTEzIDExLjM1NCA5LjUgMTEuNzExNiA5LjUgMTIuMDcyOEM5LjUgMTIuNDMzOSA5LjU3MTEzIDEyLjc5MTUgOS43MDkzMyAxMy4xMjUxQzkuODQ3NTMgMTMuNDU4OCAxMC4wNTAxIDEzLjc2MTkgMTAuMzA1NSAxNC4wMTczQzEwLjU2MDggMTQuMjcyNyAxMC44NjQgMTQuNDc1MiAxMS4xOTc2IDE0LjYxMzRDMTEuNTMxMyAxNC43NTE2IDExLjg4ODkgMTQuODIyOCAxMi4yNSAxNC44MjI4TDEyLjI1IDE0LjgyMjhaIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZT0iIzI3MDcwMCIvPgo8L3N2Zz4K";
|
|
15
17
|
const dragDistance = 2;
|
|
16
18
|
const sampleDistance = 2;
|
|
17
19
|
const minimumStraightness = 0.75;
|
|
@@ -286,1092 +288,1335 @@ window.__ModuleLoader__.load({
|
|
|
286
288
|
};
|
|
287
289
|
}
|
|
288
290
|
|
|
289
|
-
const { createElement: h, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } = react;
|
|
290
|
-
const {
|
|
291
|
-
Button, MenuItemButton, StateDot, IconCheckOutlineRegular, IconChevronLeftOutlineRegular, IconChevronRightOutlineRegular,
|
|
292
|
-
IconChevronUpOutlineRegular, IconFolderOpenRegular,
|
|
293
|
-
IconPinFillRegular, IconArchiveOutlineRegular, IconClockOutlineRegular,
|
|
294
|
-
} = ui;
|
|
295
|
-
|
|
296
|
-
const inject = ['slots', 'locale', 'workspaces', 'sessions', 'uiSession', 'uiWorkspace', 'layout', 'remote', 'remote.schedule'];
|
|
297
|
-
const ungrouped = '';
|
|
298
|
-
const defaultOptions = {};
|
|
299
|
-
const emptyView = { getSnapshot: () => defaultOptions, subscribe: () => () => {} };
|
|
300
|
-
const preferenceKey = `${id}.sidebar`;
|
|
301
|
-
const unreadKey = preferenceKey + '.unread';
|
|
302
|
-
const
|
|
303
|
-
const emptySchedule = { records: [] };
|
|
304
|
-
function scheduleSourceFor(ctx) {
|
|
305
|
-
let snapshot = emptySchedule;
|
|
306
|
-
let revision = 0;
|
|
307
|
-
return {
|
|
308
|
-
getSnapshot: () => snapshot,
|
|
309
|
-
subscribe(listener) {
|
|
310
|
-
async function refresh() {
|
|
311
|
-
const request = ++revision;
|
|
312
|
-
try {
|
|
313
|
-
const result = await ctx.remote.schedule.catalog();
|
|
314
|
-
if (request !== revision || !result.ok) return;
|
|
315
|
-
snapshot = { records: result.value };
|
|
316
|
-
listener();
|
|
317
|
-
} catch {
|
|
318
|
-
// A later catalog change or reconnect retries the read.
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
const stopChanged = ctx.remote.$on('schedule/changed', refresh);
|
|
322
|
-
const stopReset = ctx.on('connection/reset', refresh);
|
|
323
|
-
refresh();
|
|
324
|
-
return () => {
|
|
325
|
-
revision++;
|
|
326
|
-
stopChanged();
|
|
327
|
-
stopReset();
|
|
328
|
-
};
|
|
329
|
-
},
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
const folderKey = key => 'folder:' + key;
|
|
333
|
-
const sessionKey = key => 'session:' + key;
|
|
334
|
-
const pageKey = folder => folder === null ? 'home' : folderKey(folder);
|
|
335
|
-
|
|
336
|
-
// The native new-session button carries no stable attribute, so it is recognised
|
|
337
|
-
// by its own new-chat glyph or by a shortcut, minus the sidebar toggles and
|
|
338
|
-
// everything inside the workspaces region (add workspace also has a shortcut).
|
|
339
|
-
function isNewSessionButton(button) {
|
|
340
|
-
if (!button || button.disabled) return false;
|
|
341
|
-
if (button.closest('[data-sidebar-toggle], [data-sidebar-opener], [data-slot="sidebar.workspaces"]')) return false;
|
|
342
|
-
return Boolean(button.querySelector('[data-icon^="dsw-icon-new-chat"]')) || button.hasAttribute('aria-keyshortcuts');
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function getNewSessionButton(event) {
|
|
346
|
-
const button = event.target instanceof Element ? event.target.closest('button') : null;
|
|
347
|
-
return isNewSessionButton(button) && button.closest('[data-slot="sidebar"]') ? button : null;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const dictionaries = {
|
|
351
|
-
zh: {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
const
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
let
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (!
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
'aria-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
return
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
const
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
(
|
|
967
|
-
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
const
|
|
975
|
-
const
|
|
976
|
-
const
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
const
|
|
982
|
-
const
|
|
983
|
-
const
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
const
|
|
1035
|
-
if (
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
if (event.
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
};
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
const
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
291
|
+
const { createElement: h, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } = react;
|
|
292
|
+
const {
|
|
293
|
+
Button, MenuItemButton, StateDot, IconCheckOutlineRegular, IconChevronLeftOutlineRegular, IconChevronRightOutlineRegular,
|
|
294
|
+
IconChevronUpOutlineRegular, IconFolderOpenRegular,
|
|
295
|
+
IconPinFillRegular, IconArchiveOutlineRegular, IconClockOutlineRegular,
|
|
296
|
+
} = ui;
|
|
297
|
+
|
|
298
|
+
const inject = ['slots', 'locale', 'workspaces', 'sessions', 'uiSession', 'uiWorkspace', 'layout', 'remote', 'remote.schedule'];
|
|
299
|
+
const ungrouped = '';
|
|
300
|
+
const defaultOptions = {};
|
|
301
|
+
const emptyView = { getSnapshot: () => defaultOptions, subscribe: () => () => {} };
|
|
302
|
+
const preferenceKey = `${id}.sidebar`;
|
|
303
|
+
const unreadKey = preferenceKey + '.unread';
|
|
304
|
+
const emptyPlacements = {};
|
|
305
|
+
const emptySchedule = { records: [] };
|
|
306
|
+
function scheduleSourceFor(ctx) {
|
|
307
|
+
let snapshot = emptySchedule;
|
|
308
|
+
let revision = 0;
|
|
309
|
+
return {
|
|
310
|
+
getSnapshot: () => snapshot,
|
|
311
|
+
subscribe(listener) {
|
|
312
|
+
async function refresh() {
|
|
313
|
+
const request = ++revision;
|
|
314
|
+
try {
|
|
315
|
+
const result = await ctx.remote.schedule.catalog();
|
|
316
|
+
if (request !== revision || !result.ok) return;
|
|
317
|
+
snapshot = { records: result.value };
|
|
318
|
+
listener();
|
|
319
|
+
} catch {
|
|
320
|
+
// A later catalog change or reconnect retries the read.
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const stopChanged = ctx.remote.$on('schedule/changed', refresh);
|
|
324
|
+
const stopReset = ctx.on('connection/reset', refresh);
|
|
325
|
+
refresh();
|
|
326
|
+
return () => {
|
|
327
|
+
revision++;
|
|
328
|
+
stopChanged();
|
|
329
|
+
stopReset();
|
|
330
|
+
};
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
const folderKey = key => 'folder:' + key;
|
|
335
|
+
const sessionKey = key => 'session:' + key;
|
|
336
|
+
const pageKey = folder => folder === null ? 'home' : folderKey(folder);
|
|
337
|
+
|
|
338
|
+
// The native new-session button carries no stable attribute, so it is recognised
|
|
339
|
+
// by its own new-chat glyph or by a shortcut, minus the sidebar toggles and
|
|
340
|
+
// everything inside the workspaces region (add workspace also has a shortcut).
|
|
341
|
+
function isNewSessionButton(button) {
|
|
342
|
+
if (!button || button.disabled) return false;
|
|
343
|
+
if (button.closest('[data-sidebar-toggle], [data-sidebar-opener], [data-slot="sidebar.workspaces"]')) return false;
|
|
344
|
+
return Boolean(button.querySelector('[data-icon^="dsw-icon-new-chat"]')) || button.hasAttribute('aria-keyshortcuts');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function getNewSessionButton(event) {
|
|
348
|
+
const button = event.target instanceof Element ? event.target.closest('button') : null;
|
|
349
|
+
return isNewSessionButton(button) && button.closest('[data-slot="sidebar"]') ? button : null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const dictionaries = {
|
|
353
|
+
zh: {
|
|
354
|
+
settings: '文件夹浏览设置', sessionOpen: '打开会话', folderOpen: '打开文件夹', singleClick: '单击', doubleClick: '双击', closeSettings: '完成',
|
|
355
|
+
panel: '文件夹浏览', home: '主页', path: '工作区路径', back: '后退', forward: '前进', up: '上一级',
|
|
356
|
+
ungrouped: '未分组会话', locate: '回到当前会话', createError: '暂时无法新建会话。',
|
|
357
|
+
loading: '正在加载…', loadError: '暂时无法读取工作区。', openError: '暂时无法打开此会话。',
|
|
358
|
+
emptyHome: '还没有工作区。', emptyFolder: '此工作区没有子工作区或会话。', noArchives: '没有已归档会话。',
|
|
359
|
+
archived: '已归档会话', scheduled: '有定时任务', running: '运行中', oneRunningSession: '1 个会话运行中', runningSessions: '{n} 个会话运行中',
|
|
360
|
+
gestureUp: '返回上一级', gestureInvalid: '无效手势',
|
|
361
|
+
display: '视图选项', icons: '大图标', list: '列表', resize: '调整工作区分隔位置',
|
|
362
|
+
},
|
|
363
|
+
en: {
|
|
364
|
+
settings: 'Folder browser settings', sessionOpen: 'Open sessions', folderOpen: 'Open folders', singleClick: 'Single click', doubleClick: 'Double click', closeSettings: 'Done',
|
|
365
|
+
panel: 'Browse folders', home: 'Home', path: 'Workspace path', back: 'Back', forward: 'Forward', up: 'Up one level',
|
|
366
|
+
ungrouped: 'Ungrouped sessions', locate: 'Go to current session', createError: 'Could not start a new session.',
|
|
367
|
+
loading: 'Loading…', loadError: 'Could not load workspaces.', openError: 'Could not open this session.',
|
|
368
|
+
emptyHome: 'No workspaces yet.', emptyFolder: 'No child workspaces or sessions in this workspace.',
|
|
369
|
+
noArchives: 'No archived sessions.', archived: 'Archived session', scheduled: 'Has scheduled tasks', running: 'Running',
|
|
370
|
+
runningSessions: '{n} sessions running', oneRunningSession: '1 session running',
|
|
371
|
+
gestureUp: 'Up one level', gestureInvalid: 'Invalid gesture',
|
|
372
|
+
display: 'View options', icons: 'Large icons', list: 'List', resize: 'Resize workspace area',
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
function workspacePath(path) {
|
|
377
|
+
const windows = /^[A-Za-z]:[/\\]/.test(path) || path.startsWith('\\\\');
|
|
378
|
+
const normalized = (windows ? path.replaceAll('\\', '/') : path).replace(/\/+$/, '');
|
|
379
|
+
return { normalized, folded: windows ? normalized.toLowerCase() : undefined };
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function workspaceTree(items) {
|
|
383
|
+
const byId = new Map(items.map(item => [item.workspaceId, item]));
|
|
384
|
+
const paths = new Map(items.map(item => [item.path, item.workspaceId]));
|
|
385
|
+
const folders = [...paths].map(([path, id]) => ({ ...workspacePath(path), id }));
|
|
386
|
+
const parents = new Map();
|
|
387
|
+
const children = new Map();
|
|
388
|
+
for (const item of items) {
|
|
389
|
+
const child = workspacePath(item.path);
|
|
390
|
+
let parent = null;
|
|
391
|
+
let length = -1;
|
|
392
|
+
let exactParent = false;
|
|
393
|
+
for (const folder of folders) {
|
|
394
|
+
if (folder.normalized.length >= child.normalized.length || folder.normalized.length < length) continue;
|
|
395
|
+
const exact = child.normalized.startsWith(`${folder.normalized}/`);
|
|
396
|
+
const folded = folder.folded !== undefined && child.folded?.startsWith(`${folder.folded}/`);
|
|
397
|
+
if ((!exact && !folded) || (folder.normalized.length === length && (exactParent || !exact))) continue;
|
|
398
|
+
parent = folder.id;
|
|
399
|
+
length = folder.normalized.length;
|
|
400
|
+
exactParent = exact;
|
|
401
|
+
}
|
|
402
|
+
parents.set(item.workspaceId, parent);
|
|
403
|
+
if (!children.has(parent)) children.set(parent, []);
|
|
404
|
+
children.get(parent).push(item);
|
|
405
|
+
}
|
|
406
|
+
return { byId, parents, children };
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/* The order that is on screen right now, per account: the native store freezes exactly this into manual mode. */
|
|
410
|
+
function displayedOrders(workspaceState, sessions, options) {
|
|
411
|
+
const { byId, ids } = sessions;
|
|
412
|
+
const archived = new Set(workspaceState.archivedSessionIds);
|
|
413
|
+
const pinned = new Set(workspaceState.pinnedSessionIds);
|
|
414
|
+
const assigned = new Set(workspaceState.items.flatMap(workspace => workspace.sessionIds));
|
|
415
|
+
const rank = session => session.blank ? 0 : pinned.has(session.id) && !archived.has(session.id) ? 1 : 2;
|
|
416
|
+
const order = (members, account) => {
|
|
417
|
+
const manual = options.orderBy === 'manual';
|
|
418
|
+
const stored = new Map((manual ? options.sessionOrderByAccount?.[account] ?? [] : []).map((id, index) => [id, index]));
|
|
419
|
+
return members.map(id => byId[id]).filter(session => session && session.origin !== 'subagent').sort((a, b) => rank(a) - rank(b)
|
|
420
|
+
|| (stored.get(a.id) ?? Infinity) - (stored.get(b.id) ?? Infinity)
|
|
421
|
+
|| (manual ? Number(archived.has(a.id)) - Number(archived.has(b.id)) : 0)
|
|
422
|
+
|| b.updatedAt - a.updatedAt || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)).map(session => session.id);
|
|
423
|
+
};
|
|
424
|
+
return Object.fromEntries([
|
|
425
|
+
...workspaceState.items.map(workspace => [workspace.workspaceId, order(workspace.sessionIds, workspace.workspaceId)]),
|
|
426
|
+
[ungrouped, order(ids.filter(id => !assigned.has(id)), ungrouped)],
|
|
427
|
+
['__flat_session_order__', order(ids, '__flat_session_order__')],
|
|
428
|
+
]);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function sessionRows(workspaceState, sessions, options) {
|
|
432
|
+
const { byId, ids } = sessions;
|
|
433
|
+
const archived = new Set(workspaceState.archivedSessionIds);
|
|
434
|
+
const pinned = new Set(workspaceState.pinnedSessionIds);
|
|
435
|
+
const assigned = new Set(workspaceState.items.flatMap(workspace => workspace.sessionIds));
|
|
436
|
+
const filter = options.archivedFilter ?? 'default';
|
|
437
|
+
const visible = session => session && session.origin !== 'subagent' && (!session.blank || session.retainedBy?.mainView > 0)
|
|
438
|
+
&& (filter === 'show' || (filter === 'only') === archived.has(session.id));
|
|
439
|
+
const sorted = (members, account) => {
|
|
440
|
+
const manual = options.orderBy === 'manual';
|
|
441
|
+
const order = new Map((manual ? options.sessionOrderByAccount?.[account] ?? [] : []).map((id, index) => [id, index]));
|
|
442
|
+
const rank = session => session.blank ? 0 : pinned.has(session.id) && !archived.has(session.id) ? 1 : 2;
|
|
443
|
+
return members.map(id => byId[id]).filter(visible).sort((a, b) => rank(a) - rank(b)
|
|
444
|
+
|| (order.get(a.id) ?? Infinity) - (order.get(b.id) ?? Infinity)
|
|
445
|
+
|| (manual ? Number(archived.has(a.id)) - Number(archived.has(b.id)) : 0)
|
|
446
|
+
|| b.updatedAt - a.updatedAt || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
447
|
+
};
|
|
448
|
+
const byWorkspace = new Map(workspaceState.items.map(workspace => [workspace.workspaceId, sorted(workspace.sessionIds, workspace.workspaceId)]));
|
|
449
|
+
byWorkspace.set(ungrouped, sorted(ids.filter(id => !assigned.has(id)), ungrouped));
|
|
450
|
+
return { byWorkspace, pinned, archived };
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/* Mirrors the native tree: one pinned section at a time, and the blank session stays where the sort puts it. */
|
|
454
|
+
function sessionDragOrder(order, rows, drag, over, isPinned) {
|
|
455
|
+
const source = rows.find(row => row.id === drag.id);
|
|
456
|
+
const target = rows.find(row => row.id === over.id);
|
|
457
|
+
if (!source || !target || source.blank) return undefined;
|
|
458
|
+
if (isPinned(source.id) !== drag.pinned || isPinned(target.id) !== drag.pinned) return undefined;
|
|
459
|
+
if (source.id === target.id || !order.includes(source.id)) return undefined;
|
|
460
|
+
const section = rows.filter(row => isPinned(row.id) === drag.pinned);
|
|
461
|
+
const sourceIndex = section.findIndex(row => row.id === source.id);
|
|
462
|
+
const targetIndex = section.filter(row => row.id !== source.id).findIndex(row => row.id === target.id);
|
|
463
|
+
if (targetIndex + (over.side === 'after' ? 1 : 0) === sourceIndex) return undefined;
|
|
464
|
+
const next = order.filter(id => id !== source.id);
|
|
465
|
+
const index = next.indexOf(target.id);
|
|
466
|
+
if (index === -1) return undefined;
|
|
467
|
+
next.splice(index + (over.side === 'after' ? 1 : 0), 0, source.id);
|
|
468
|
+
return next;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const statusDetails = {
|
|
472
|
+
approval: { state: 'error', label: 'status.waitingApproval', priority: 3 },
|
|
473
|
+
question: { state: 'warning', label: 'status.waitingAnswer', priority: 2 },
|
|
474
|
+
'plan-review': { state: 'warning', label: 'status.planReview', priority: 2 },
|
|
475
|
+
completed: { state: 'done', label: 'status.completed', priority: 1 },
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
function completionSource(ctx) {
|
|
479
|
+
const list = ctx.sessions.list;
|
|
480
|
+
const status = ctx.uiSession.sessionStatus;
|
|
481
|
+
const panel = ctx.layout.panelInfo;
|
|
482
|
+
const listeners = new Set();
|
|
483
|
+
const persistedIds = value => Array.isArray(value) ? value.filter(id => typeof id === 'string') : [];
|
|
484
|
+
let unread = new Set();
|
|
485
|
+
let awaitingInteraction = new Set();
|
|
486
|
+
try {
|
|
487
|
+
const saved = JSON.parse(localStorage.getItem(unreadKey));
|
|
488
|
+
unread = new Set(persistedIds(Array.isArray(saved) ? saved : saved?.unread));
|
|
489
|
+
awaitingInteraction = new Set(persistedIds(saved?.awaitingInteraction).filter(id => unread.has(id)));
|
|
490
|
+
} catch { /* Storage may be unavailable. */ }
|
|
491
|
+
|
|
492
|
+
let previous = new Map();
|
|
493
|
+
let previousTaskbarStatus = status.getSnapshot();
|
|
494
|
+
const pendingWhileAway = new Map();
|
|
495
|
+
const completedWhileAway = new Set();
|
|
496
|
+
const taskbar = window.dshDesktop?.taskbar;
|
|
497
|
+
let taskbarColor;
|
|
498
|
+
let readTimer;
|
|
499
|
+
let readTarget;
|
|
500
|
+
const hasAttention = () => document.visibilityState !== 'hidden' && document.hasFocus();
|
|
501
|
+
|
|
502
|
+
function save(next, protectedIds = awaitingInteraction) {
|
|
503
|
+
const changed = next.size !== unread.size || [...next].some(id => !unread.has(id));
|
|
504
|
+
const protectionChanged = protectedIds.size !== awaitingInteraction.size
|
|
505
|
+
|| [...protectedIds].some(id => !awaitingInteraction.has(id));
|
|
506
|
+
if (!changed && !protectionChanged) return;
|
|
507
|
+
if (changed) unread = next;
|
|
508
|
+
awaitingInteraction = protectedIds;
|
|
509
|
+
try {
|
|
510
|
+
localStorage.setItem(unreadKey, JSON.stringify({ unread: [...unread], awaitingInteraction: [...awaitingInteraction] }));
|
|
511
|
+
} catch { /* Keep the in-memory state. */ }
|
|
512
|
+
if (changed) for (const listener of listeners) listener();
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function updateTaskbar(sessions, statuses, focused) {
|
|
516
|
+
if (!taskbar?.setReminder) return;
|
|
517
|
+
if (focused) {
|
|
518
|
+
pendingWhileAway.clear();
|
|
519
|
+
completedWhileAway.clear();
|
|
520
|
+
}
|
|
521
|
+
const archived = new Set(ctx.workspaces.list.getSnapshot().archivedSessionIds);
|
|
522
|
+
let priority = 0;
|
|
523
|
+
if (!focused) for (const [id, state] of statuses) {
|
|
524
|
+
const session = sessions.byId[id];
|
|
525
|
+
if (!session || session.blank || session.origin === 'subagent' || archived.has(id)) {
|
|
526
|
+
pendingWhileAway.delete(id);
|
|
527
|
+
completedWhileAway.delete(id);
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
const before = previousTaskbarStatus.get(id);
|
|
531
|
+
const pending = state.pendingInteraction;
|
|
532
|
+
const previousPending = before?.pendingInteraction;
|
|
533
|
+
const pendingPriority = statusDetails[pending?.kind]?.priority ?? 0;
|
|
534
|
+
if (!pendingPriority) pendingWhileAway.delete(id);
|
|
535
|
+
else if (pending.kind !== previousPending?.kind || pending.key !== previousPending?.key) {
|
|
536
|
+
pendingWhileAway.set(id, pendingPriority);
|
|
537
|
+
}
|
|
538
|
+
if (state.running) completedWhileAway.delete(id);
|
|
539
|
+
else if (before?.running === true || (state.completionUnread && !before?.completionUnread)) completedWhileAway.add(id);
|
|
540
|
+
priority = Math.max(priority, pendingWhileAway.get(id) ?? 0, completedWhileAway.has(id) ? 1 : 0);
|
|
541
|
+
}
|
|
542
|
+
previousTaskbarStatus = statuses;
|
|
543
|
+
const color = ['normal', 'green', 'yellow', 'red'][priority];
|
|
544
|
+
if (color === taskbarColor) return;
|
|
545
|
+
taskbarColor = color;
|
|
546
|
+
taskbar.setReminder(color);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function sync() {
|
|
550
|
+
const sessions = list.getSnapshot();
|
|
551
|
+
const statuses = status.getSnapshot();
|
|
552
|
+
const focused = hasAttention();
|
|
553
|
+
const conversationVisible = panel.getSnapshot().activePanelId === null;
|
|
554
|
+
const next = new Set(unread);
|
|
555
|
+
const protectedIds = new Set(awaitingInteraction);
|
|
556
|
+
for (const [id, state] of statuses) {
|
|
557
|
+
const before = previous.get(id);
|
|
558
|
+
const session = sessions.byId[id];
|
|
559
|
+
if (!session) continue;
|
|
560
|
+
if (!focused && before?.running === true && state.running === false) {
|
|
561
|
+
next.add(id);
|
|
562
|
+
if (session.retainedBy?.mainView > 0) protectedIds.add(id);
|
|
563
|
+
} else if (state.completionUnread && !before?.completionUnread) {
|
|
564
|
+
next.add(id);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
previous = statuses;
|
|
568
|
+
for (const id of next) {
|
|
569
|
+
const session = sessions.byId[id];
|
|
570
|
+
const removed = !session && sessions.phase === 'ready';
|
|
571
|
+
if (!removed) continue;
|
|
572
|
+
next.delete(id);
|
|
573
|
+
protectedIds.delete(id);
|
|
574
|
+
}
|
|
575
|
+
save(next, protectedIds);
|
|
576
|
+
updateTaskbar(sessions, statuses, focused);
|
|
577
|
+
const current = focused && conversationVisible
|
|
578
|
+
? Object.values(sessions.byId).find(session => session.retainedBy?.mainView > 0 && next.has(session.id))?.id
|
|
579
|
+
: undefined;
|
|
580
|
+
if (current !== readTarget) {
|
|
581
|
+
clearTimeout(readTimer);
|
|
582
|
+
readTarget = current;
|
|
583
|
+
if (current) readTimer = setTimeout(() => {
|
|
584
|
+
readTimer = undefined;
|
|
585
|
+
if (hasAttention() && panel.getSnapshot().activePanelId === null
|
|
586
|
+
&& list.getSnapshot().byId[current]?.retainedBy?.mainView > 0) clearCurrent();
|
|
587
|
+
readTarget = undefined;
|
|
588
|
+
}, 3000);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function acknowledgeCurrent(event) {
|
|
593
|
+
if (!event.isTrusted || !hasAttention() || panel.getSnapshot().activePanelId !== null) return;
|
|
594
|
+
if (!(event.target instanceof Element) || !event.target.closest('[data-slot="main"]')) return;
|
|
595
|
+
clearCurrent();
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function clearCurrent() {
|
|
599
|
+
const active = Object.values(list.getSnapshot().byId).find(session => session.retainedBy?.mainView > 0);
|
|
600
|
+
if (!active || !unread.has(active.id)) return;
|
|
601
|
+
const next = new Set(unread);
|
|
602
|
+
const protectedIds = new Set(awaitingInteraction);
|
|
603
|
+
next.delete(active.id);
|
|
604
|
+
protectedIds.delete(active.id);
|
|
605
|
+
save(next, protectedIds);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
ctx.effect(() => {
|
|
609
|
+
const stops = [status.subscribe(sync), list.subscribe(sync), panel.subscribe(sync), ctx.workspaces.list.subscribe(sync)];
|
|
610
|
+
window.addEventListener('focus', sync);
|
|
611
|
+
window.addEventListener('blur', sync);
|
|
612
|
+
document.addEventListener('visibilitychange', sync);
|
|
613
|
+
document.addEventListener('pointerdown', acknowledgeCurrent, true);
|
|
614
|
+
document.addEventListener('drop', acknowledgeCurrent, true);
|
|
615
|
+
document.addEventListener('wheel', acknowledgeCurrent, { capture: true, passive: true });
|
|
616
|
+
document.addEventListener('scroll', acknowledgeCurrent, true);
|
|
617
|
+
sync();
|
|
618
|
+
return () => {
|
|
619
|
+
clearTimeout(readTimer);
|
|
620
|
+
readTarget = undefined;
|
|
621
|
+
stops.forEach(stop => stop());
|
|
622
|
+
taskbar?.setReminder?.('normal');
|
|
623
|
+
window.removeEventListener('focus', sync);
|
|
624
|
+
window.removeEventListener('blur', sync);
|
|
625
|
+
document.removeEventListener('visibilitychange', sync);
|
|
626
|
+
document.removeEventListener('pointerdown', acknowledgeCurrent, true);
|
|
627
|
+
document.removeEventListener('drop', acknowledgeCurrent, true);
|
|
628
|
+
document.removeEventListener('wheel', acknowledgeCurrent, true);
|
|
629
|
+
document.removeEventListener('scroll', acknowledgeCurrent, true);
|
|
630
|
+
};
|
|
631
|
+
});
|
|
632
|
+
return {
|
|
633
|
+
getSnapshot: () => unread,
|
|
634
|
+
subscribe(listener) {
|
|
635
|
+
listeners.add(listener);
|
|
636
|
+
return () => listeners.delete(listener);
|
|
637
|
+
},
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
function workspaceNotifications(workspaces, sessions, statuses, parents, archived, unread) {
|
|
642
|
+
const owners = new Map();
|
|
643
|
+
for (const workspace of workspaces) {
|
|
644
|
+
for (const sessionId of workspace.sessionIds) owners.set(sessionId, workspace.workspaceId);
|
|
645
|
+
}
|
|
646
|
+
const bySession = new Map();
|
|
647
|
+
const byFolder = new Map();
|
|
648
|
+
const runningBySession = new Map();
|
|
649
|
+
const runningByFolder = new Map();
|
|
650
|
+
for (const id of sessions.ids) {
|
|
651
|
+
const session = sessions.byId[id];
|
|
652
|
+
if (!session || session.blank || session.origin === 'subagent' || archived.has(id)) continue;
|
|
653
|
+
const running = (statuses.get(id)?.running ?? session.running) === true;
|
|
654
|
+
const subagents = sessions.projectionsBySession?.[id]?.values?.subagentCatalog?.filter(child =>
|
|
655
|
+
(statuses.get(child.id)?.running ?? sessions.byId[child.id]?.running) === true).length ?? 0;
|
|
656
|
+
if (running || subagents > 0) runningBySession.set(id, { running, subagents });
|
|
657
|
+
if (!running) continue;
|
|
658
|
+
for (let folder = owners.get(id) ?? ungrouped; folder !== null; folder = parents.get(folder) ?? null) {
|
|
659
|
+
runningByFolder.set(folder, (runningByFolder.get(folder) ?? 0) + 1);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
const all = [];
|
|
663
|
+
for (const sessionId of sessions.ids) {
|
|
664
|
+
const session = sessions.byId[sessionId];
|
|
665
|
+
if (!session || session.blank || session.origin === 'subagent' || archived.has(sessionId)) continue;
|
|
666
|
+
const detail = statusDetails[statuses.get(sessionId)?.pendingInteraction?.kind]
|
|
667
|
+
?? (unread.has(sessionId) && !runningBySession.has(sessionId) ? statusDetails.completed : undefined);
|
|
668
|
+
if (!detail) continue;
|
|
669
|
+
const notification = { ...detail, sessionId };
|
|
670
|
+
bySession.set(sessionId, notification);
|
|
671
|
+
all.push(notification);
|
|
672
|
+
for (let folder = owners.get(sessionId) ?? ungrouped; folder !== null; folder = parents.get(folder) ?? null) {
|
|
673
|
+
if (!byFolder.has(folder)) byFolder.set(folder, []);
|
|
674
|
+
byFolder.get(folder).push(notification);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
for (const notifications of byFolder.values()) notifications.sort((a, b) => b.priority - a.priority);
|
|
678
|
+
return { bySession, byFolder, all, runningBySession, runningByFolder };
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function NotificationDots({ entries, translate, size }) {
|
|
682
|
+
return h('span', { className: 'dwb-notifications' }, entries.map(entry => {
|
|
683
|
+
const label = translate(entry.label);
|
|
684
|
+
return h('span', { key: entry.sessionId, role: 'img', 'aria-label': label, title: label,
|
|
685
|
+
className: 'dwb-notification', 'data-dwb-notification': entry.state }, h(StateDot, { state: entry.state, size }));
|
|
686
|
+
}));
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
function readPreference() {
|
|
690
|
+
try { return JSON.parse(localStorage.getItem(preferenceKey)) ?? {}; }
|
|
691
|
+
catch { return {}; }
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function savePreference(value) {
|
|
695
|
+
try { localStorage.setItem(preferenceKey, JSON.stringify(value)); }
|
|
696
|
+
catch { /* The view can still be used without storage. */ }
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function usePageFade() {
|
|
700
|
+
const running = useRef(new Map());
|
|
701
|
+
useEffect(() => () => {
|
|
702
|
+
for (const animation of running.current.values()) animation.cancel();
|
|
703
|
+
running.current.clear();
|
|
704
|
+
}, []);
|
|
705
|
+
|
|
706
|
+
const [fade] = useState(() => async (element, update) => {
|
|
707
|
+
if (!element?.isConnected || matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
708
|
+
update();
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
const animations = running.current;
|
|
712
|
+
const opacity = getComputedStyle(element).opacity;
|
|
713
|
+
animations.get(element)?.cancel();
|
|
714
|
+
const outgoing = element.animate([{ opacity }, { opacity: 0 }], { duration: 42.5, easing: 'ease-out', fill: 'forwards' });
|
|
715
|
+
animations.set(element, outgoing);
|
|
716
|
+
try {
|
|
717
|
+
await outgoing.finished;
|
|
718
|
+
if (animations.get(element) !== outgoing || !element.isConnected) return;
|
|
719
|
+
flushSync(update);
|
|
720
|
+
const incoming = element.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 67.5, easing: 'ease-in-out' });
|
|
721
|
+
outgoing.cancel();
|
|
722
|
+
animations.set(element, incoming);
|
|
723
|
+
await incoming.finished;
|
|
724
|
+
if (animations.get(element) === incoming) animations.delete(element);
|
|
725
|
+
} catch (error) {
|
|
726
|
+
if (error.name !== 'AbortError') console.warn(`${id}: page transition failed`, error);
|
|
727
|
+
} finally {
|
|
728
|
+
if (animations.get(element) === outgoing) {
|
|
729
|
+
outgoing.cancel();
|
|
730
|
+
animations.delete(element);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
return fade;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// Slot wrappers use `display: contents` and own no box, so climb past them
|
|
738
|
+
// before reading a container's geometry.
|
|
739
|
+
function containerOf(node) {
|
|
740
|
+
let current = node ?? null;
|
|
741
|
+
while (current && current !== document.body && getComputedStyle(current).display === 'contents') {
|
|
742
|
+
current = current.parentElement;
|
|
743
|
+
}
|
|
744
|
+
return current && current !== document.body ? current : null;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// The host has no grouping-item slot. Walk down from the one stable anchor
|
|
748
|
+
// (`[data-slot="sidebar.workspaces"]`) and read the browser's own boxes by
|
|
749
|
+
// position: our mounts are known by class, the header is the first native child
|
|
750
|
+
// of the region and the list is the last one.
|
|
751
|
+
function useSidebarMounts(nativeText) {
|
|
752
|
+
const [mounts, setMounts] = useState({});
|
|
753
|
+
useLayoutEffect(() => {
|
|
754
|
+
const grid = document.createElement('div');
|
|
755
|
+
grid.className = 'dwb-mount';
|
|
756
|
+
grid.hidden = true;
|
|
757
|
+
const toolbar = document.createElement('div');
|
|
758
|
+
toolbar.className = 'dwb-toolbar-mount';
|
|
759
|
+
toolbar.hidden = true;
|
|
760
|
+
const address = document.createElement('div');
|
|
761
|
+
address.className = 'dwb-address-mount';
|
|
762
|
+
address.hidden = true;
|
|
763
|
+
const heading = document.createElement('span');
|
|
764
|
+
heading.className = 'dwb-heading';
|
|
765
|
+
heading.hidden = true;
|
|
766
|
+
const menuMount = document.createElement('div');
|
|
767
|
+
menuMount.className = 'dwb-menu-mount';
|
|
768
|
+
let active;
|
|
769
|
+
let workspace;
|
|
770
|
+
let frame = 0;
|
|
771
|
+
|
|
772
|
+
function sync() {
|
|
773
|
+
workspace = document.querySelector('[data-slot="sidebar.workspaces"]');
|
|
774
|
+
const region = containerOf(workspace?.firstElementChild);
|
|
775
|
+
const area = containerOf(region?.parentElement);
|
|
776
|
+
const scrollport = containerOf(area?.parentElement);
|
|
777
|
+
const panel = scrollport?.matches('[data-sidebar-scrollport]')
|
|
778
|
+
? scrollport.closest('[class*="_sidebarCol"]') ?? scrollport
|
|
779
|
+
: scrollport;
|
|
780
|
+
const natives = region
|
|
781
|
+
? [...region.children].filter(child => ![...child.classList].some(name => name.startsWith('dwb-')))
|
|
782
|
+
: [];
|
|
783
|
+
const header = natives.length > 1 ? natives[0] : null;
|
|
784
|
+
const list = natives.length > 1 ? natives[natives.length - 1] : null;
|
|
785
|
+
const trigger = [...header?.querySelectorAll('button[aria-label]') ?? []]
|
|
786
|
+
.find(button => button.getAttribute('aria-label') === nativeText('viewOptions.label'));
|
|
787
|
+
const searchButton = header?.querySelector('button[aria-expanded]') ?? null;
|
|
788
|
+
const searchInput = header?.querySelector('input[type="text"], input[type="search"]') ?? null;
|
|
789
|
+
// The native title sits immediately before the search control.
|
|
790
|
+
const title = searchButton?.parentElement?.parentElement?.previousElementSibling ?? null;
|
|
791
|
+
const nativeHeading = title?.matches('span:not(.dwb-heading)') ? title : null;
|
|
792
|
+
// The popup is recognised by the grouping rows it is the only menu to list
|
|
793
|
+
// (the same localized strings the trigger is found by), so the body-level
|
|
794
|
+
// workspace context menu -- a menu too, with other rows -- never adopts us.
|
|
795
|
+
const groupLabels = ['groupBy.workspace', 'groupBy.workspaceTree', 'groupBy.flat'].map(key => {
|
|
796
|
+
try {
|
|
797
|
+
return nativeText(key);
|
|
798
|
+
} catch {
|
|
799
|
+
return null;
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
let menu = active?.menu?.isConnected ? active.menu : null;
|
|
803
|
+
if (!menu) {
|
|
804
|
+
const menus = [...document.body.querySelectorAll(':scope > [role="menu"]:not([data-context-menu])')];
|
|
805
|
+
menu = menus.reverse().find(node => [...node.querySelectorAll('button[role="menuitem"]')]
|
|
806
|
+
.some(row => !menuMount.contains(row) && groupLabels.includes(row.textContent?.trim()))) ?? null;
|
|
807
|
+
}
|
|
808
|
+
// Our own separator lives inside the mount, so skip it and take the first
|
|
809
|
+
// native one: every grouping row precedes it and nothing else does.
|
|
810
|
+
const menuSeparator = menu
|
|
811
|
+
? [...menu.querySelectorAll('[role="separator"]')].find(node => !menuMount.contains(node)) ?? null
|
|
812
|
+
: null;
|
|
813
|
+
const groupRows = menu && menuSeparator
|
|
814
|
+
? [...menu.querySelectorAll('button[role="menuitem"]')].filter(row => !menuMount.contains(row)
|
|
815
|
+
&& Boolean(menuSeparator.compareDocumentPosition(row) & Node.DOCUMENT_POSITION_PRECEDING))
|
|
816
|
+
: [];
|
|
817
|
+
const lastGroup = groupRows.length > 0 ? groupRows[groupRows.length - 1].parentElement : null;
|
|
818
|
+
const menuBody = groupRows.length > 0 ? groupRows[0].parentElement?.parentElement ?? null : null;
|
|
819
|
+
const label = menuSeparator?.nextElementSibling ?? null;
|
|
820
|
+
const menuLabel = label?.getAttribute('role') === 'presentation' ? label : null;
|
|
821
|
+
|
|
822
|
+
if (trigger && header && list) {
|
|
823
|
+
if (toolbar.nextElementSibling !== header) header.before(toolbar);
|
|
824
|
+
if (header.nextElementSibling !== address) header.after(address);
|
|
825
|
+
if (grid.parentElement !== list) list.prepend(grid);
|
|
826
|
+
} else {
|
|
827
|
+
toolbar.remove();
|
|
828
|
+
address.remove();
|
|
829
|
+
grid.remove();
|
|
830
|
+
}
|
|
831
|
+
if (nativeHeading) {
|
|
832
|
+
if (heading.nextElementSibling !== nativeHeading) nativeHeading.before(heading);
|
|
833
|
+
} else heading.remove();
|
|
834
|
+
if (lastGroup) {
|
|
835
|
+
groupRows.forEach(row => row.classList.add('dwb-native-group'));
|
|
836
|
+
if (lastGroup.nextElementSibling !== menuMount) lastGroup.after(menuMount);
|
|
837
|
+
} else menuMount.remove();
|
|
838
|
+
const searchOpen = searchButton?.getAttribute('aria-expanded') === 'true';
|
|
839
|
+
const searching = Boolean(searchOpen && searchInput?.value.trim());
|
|
840
|
+
const next = { grid, list, toolbar, address, header, heading, nativeHeading, trigger, menu, menuMount, menuSeparator, menuLabel, groupRows, searching, searchOpen, region, area, panel, menuBody };
|
|
841
|
+
const changed = active?.menu !== menu || active?.list !== list || active?.header !== header
|
|
842
|
+
|| active?.nativeHeading !== nativeHeading || active?.trigger !== trigger || active?.searching !== searching
|
|
843
|
+
|| active?.searchOpen !== searchOpen || active?.region !== region || active?.area !== area
|
|
844
|
+
|| active?.panel !== panel || active?.menuBody !== menuBody;
|
|
845
|
+
active = next;
|
|
846
|
+
if (changed) setMounts(next);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
function schedule() {
|
|
850
|
+
if (frame) return;
|
|
851
|
+
frame = requestAnimationFrame(() => { frame = 0; sync(); });
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
const observer = new MutationObserver(records => {
|
|
855
|
+
if (!workspace?.isConnected || records.some(record =>
|
|
856
|
+
workspace.contains(record.target) || active?.menu?.contains(record.target)
|
|
857
|
+
|| (record.target === document.body && [...record.addedNodes, ...record.removedNodes]
|
|
858
|
+
.some(node => node instanceof Element && node.matches('[role="menu"]'))))) schedule();
|
|
859
|
+
});
|
|
860
|
+
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['aria-expanded', 'aria-label'] });
|
|
861
|
+
document.addEventListener('input', schedule);
|
|
862
|
+
sync();
|
|
863
|
+
return () => {
|
|
864
|
+
observer.disconnect();
|
|
865
|
+
cancelAnimationFrame(frame);
|
|
866
|
+
document.removeEventListener('input', schedule);
|
|
867
|
+
grid.remove();
|
|
868
|
+
toolbar.remove();
|
|
869
|
+
address.remove();
|
|
870
|
+
heading.remove();
|
|
871
|
+
menuMount.remove();
|
|
872
|
+
};
|
|
873
|
+
}, [nativeText]);
|
|
874
|
+
return mounts;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
function NavButton({ icon, label, disabled, onClick }) {
|
|
878
|
+
return h(Button, {
|
|
879
|
+
size: 'sm', className: 'dwb-nav-button', icon: icon && h(icon, { size: 16, 'aria-hidden': true }),
|
|
880
|
+
title: label, 'aria-label': label, disabled, onClick,
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function LocateIcon({ size }) {
|
|
885
|
+
return h('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', 'aria-hidden': true,
|
|
886
|
+
stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round' },
|
|
887
|
+
h('circle', { cx: 12, cy: 12, r: 7 }),
|
|
888
|
+
h('path', { d: 'M12 2v4m0 12v4M2 12h4m12 0h4' }),
|
|
889
|
+
h('circle', { cx: 12, cy: 12, r: 1.5, fill: 'currentColor', stroke: 'none' }));
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
function SidebarDivider({ label, toolbar, area, ratio, saveRatio }) {
|
|
893
|
+
const drag = useRef(null);
|
|
894
|
+
// The region area owns the navigation list right above it.
|
|
895
|
+
const navigation = area?.previousElementSibling ?? null;
|
|
896
|
+
const upper = navigation?.matches('nav') ? navigation : null;
|
|
897
|
+
|
|
898
|
+
function maximum() {
|
|
899
|
+
const viewport = upper.parentElement;
|
|
900
|
+
return Math.max(0, viewport.getBoundingClientRect().bottom - upper.getBoundingClientRect().top - 138);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
useLayoutEffect(() => {
|
|
904
|
+
if (!upper || !Number.isFinite(ratio)) return;
|
|
905
|
+
const resize = () => upper.style.setProperty('--dwb-navigation-height', `${Math.round(ratio * maximum())}px`);
|
|
906
|
+
upper.setAttribute('data-dwb-resized-navigation', '');
|
|
907
|
+
const observer = new ResizeObserver(resize);
|
|
908
|
+
observer.observe(upper.parentElement);
|
|
909
|
+
resize();
|
|
910
|
+
return () => {
|
|
911
|
+
observer.disconnect();
|
|
912
|
+
upper.removeAttribute('data-dwb-resized-navigation');
|
|
913
|
+
upper.style.removeProperty('--dwb-navigation-height');
|
|
914
|
+
};
|
|
915
|
+
}, [upper, ratio]);
|
|
916
|
+
|
|
917
|
+
function resize(height) {
|
|
918
|
+
const available = maximum();
|
|
919
|
+
if (available > 0) saveRatio(Math.max(0, Math.min(1, height / available)));
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
return h('div', {
|
|
923
|
+
className: 'dwb-divider',
|
|
924
|
+
...(upper && {
|
|
925
|
+
role: 'separator', 'aria-label': label, 'aria-orientation': 'horizontal', tabIndex: 0,
|
|
926
|
+
'aria-valuenow': Math.round((ratio ?? Math.min(1, upper.offsetHeight / Math.max(1, maximum()))) * 100),
|
|
927
|
+
onPointerDown: event => {
|
|
928
|
+
if (event.button !== 0) return;
|
|
929
|
+
event.preventDefault();
|
|
930
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
931
|
+
drag.current = { y: event.clientY, height: upper.offsetHeight };
|
|
932
|
+
},
|
|
933
|
+
onPointerMove: event => {
|
|
934
|
+
if (!drag.current || !event.currentTarget.hasPointerCapture(event.pointerId)) return;
|
|
935
|
+
const distance = event.clientY - drag.current.y;
|
|
936
|
+
if (distance !== 0) resize(drag.current.height + distance);
|
|
937
|
+
},
|
|
938
|
+
onLostPointerCapture: () => { drag.current = null; },
|
|
939
|
+
onDoubleClick: () => saveRatio(null),
|
|
940
|
+
onKeyDown: event => {
|
|
941
|
+
if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') return;
|
|
942
|
+
event.preventDefault();
|
|
943
|
+
resize(upper.offsetHeight + (event.key === 'ArrowUp' ? -16 : 16));
|
|
944
|
+
},
|
|
945
|
+
}),
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
function FolderIcon({ size }) {
|
|
950
|
+
return h('img', { src: folderIcon, alt: '', width: size, height: size, draggable: false });
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
function SessionIcon({ size, active }) {
|
|
954
|
+
return h('span', { className: 'dwb-session-icon', style: { width: size, height: size, maskImage: `url("${active ? sessionIcon : inactiveSessionIcon}")` } });
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
function Browser({ sessionClick = 'single', folderClick = 'single', t, nativeText, workspaceSource, sessionSource, view, startFolder, rememberFolder, openSession, insertBefore, toolbar, address, heading, area, panel, display, split, saveSplit, animatePage, useContextMenu, useSessionStatus, startSession, placements, savePlacement, panelSource, scheduleSource, unreadSource }) {
|
|
958
|
+
const { getTriggerProps } = useContextMenu();
|
|
959
|
+
const workspaceState = useSyncExternalStore(workspaceSource.subscribe, workspaceSource.getSnapshot);
|
|
960
|
+
const sessions = useSyncExternalStore(sessionSource.subscribe, sessionSource.getSnapshot);
|
|
961
|
+
const statuses = useSessionStatus(snapshot => snapshot);
|
|
962
|
+
const unread = useSyncExternalStore(unreadSource.subscribe, unreadSource.getSnapshot);
|
|
963
|
+
const { activePanelId } = useSyncExternalStore(panelSource.subscribe, panelSource.getSnapshot);
|
|
964
|
+
const sessionVisible = activePanelId === null;
|
|
965
|
+
const catalog = useSyncExternalStore(scheduleSource.subscribe, scheduleSource.getSnapshot);
|
|
966
|
+
const scheduledSessions = useMemo(() => {
|
|
967
|
+
const ids = new Set();
|
|
968
|
+
for (const task of catalog.records) {
|
|
969
|
+
if (task.status !== 'active') continue;
|
|
970
|
+
for (const id of task.involvedSessionIds) ids.add(id);
|
|
971
|
+
const target = task.target.kind === 'new' ? task.lastDelivery?.targetSessionId : task.target.sessionId;
|
|
972
|
+
if (target) ids.add(target);
|
|
973
|
+
}
|
|
974
|
+
return ids;
|
|
975
|
+
}, [catalog.records]);
|
|
976
|
+
const options = useSyncExternalStore(view.subscribe, view.getSnapshot);
|
|
977
|
+
const { byId, parents, children } = useMemo(() => workspaceTree(workspaceState.items), [workspaceState.items]);
|
|
978
|
+
const { byWorkspace, pinned, archived } = useMemo(() => sessionRows(workspaceState, sessions, options), [workspaceState, sessions, options]);
|
|
979
|
+
const notifications = useMemo(() => workspaceNotifications(workspaceState.items, sessions, statuses, parents, archived, unread),
|
|
980
|
+
[workspaceState.items, sessions, statuses, parents, archived, unread]);
|
|
981
|
+
const [history, setHistory] = useState(() => startFolder === null
|
|
982
|
+
? { entries: [null], index: 0 } : { entries: [null, startFolder], index: 1 });
|
|
983
|
+
const [openError, setOpenError] = useState(null);
|
|
984
|
+
const [selectedFolder, setSelectedFolder] = useState(null);
|
|
985
|
+
const locate = useRef(null);
|
|
986
|
+
const dragged = useRef(null);
|
|
987
|
+
const [dropTarget, setDropTarget] = useState(null);
|
|
988
|
+
const [lifted, setLifted] = useState(false);
|
|
989
|
+
const crumbsRef = useRef(null);
|
|
990
|
+
// 抓手光标只在真正开始拖动之后出现:按下后移动超过 6px 才算拖动,单纯点击不变。
|
|
991
|
+
const liftThreshold = 6;
|
|
992
|
+
useEffect(() => {
|
|
993
|
+
if (!lifted) return undefined;
|
|
994
|
+
const clear = () => setLifted(false);
|
|
995
|
+
// 松手、拖拽结束、拖到别处丢掉时都要落回普通光标,避免拖拽事件被浏览器吞掉后卡在抓手。
|
|
996
|
+
const types = ['pointerup', 'mouseup', 'pointercancel', 'dragend', 'drop', 'blur'];
|
|
997
|
+
for (const type of types) window.addEventListener(type, clear, true);
|
|
998
|
+
return () => {
|
|
999
|
+
for (const type of types) window.removeEventListener(type, clear, true);
|
|
1000
|
+
};
|
|
1001
|
+
}, [lifted]);
|
|
1002
|
+
function draggedSide(event) {
|
|
1003
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
1004
|
+
return display === 'list'
|
|
1005
|
+
? (event.clientY < rect.top + rect.height / 2 ? 'before' : 'after')
|
|
1006
|
+
: (event.clientX < rect.left + rect.width / 2 ? 'before' : 'after');
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
function dragPayload(key) {
|
|
1010
|
+
if (key.startsWith('session:')) {
|
|
1011
|
+
const session = entries.get(key);
|
|
1012
|
+
if (!session || session.blank) return null;
|
|
1013
|
+
const owner = workspaceState.items.find(item => item.sessionIds.includes(session.id));
|
|
1014
|
+
return { key, kind: 'session', id: session.id, accountKey: owner?.workspaceId ?? ungrouped,
|
|
1015
|
+
pinned: pinned.has(session.id) && !archived.has(session.id) };
|
|
1016
|
+
}
|
|
1017
|
+
const item = entries.get(key);
|
|
1018
|
+
return item ? { key, kind: 'folder', id: item.workspaceId, parent: folder } : null;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/* A drop only counts where the native tree would also take it: same account, same pinned section. */
|
|
1022
|
+
function accepts(drag, target) {
|
|
1023
|
+
if (!drag || drag.key === target.key || drag.kind !== target.kind) return false;
|
|
1024
|
+
if (drag.kind === 'session') return drag.accountKey === target.accountKey && drag.pinned === target.pinned;
|
|
1025
|
+
return drag.parent === target.parent;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
function dropSession(drag, target, side) {
|
|
1029
|
+
const snapshot = view.getSnapshot();
|
|
1030
|
+
const actions = view.actions ?? {};
|
|
1031
|
+
if (snapshot.orderBy !== 'manual' || !accepts(drag, target)) return;
|
|
1032
|
+
if (typeof actions.setSessionOrder !== 'function') return;
|
|
1033
|
+
const orders = displayedOrders(workspaceState, sessions, snapshot);
|
|
1034
|
+
const rows = byWorkspace.get(drag.accountKey) ?? [];
|
|
1035
|
+
const isPinned = id => pinned.has(id) && !archived.has(id);
|
|
1036
|
+
const next = sessionDragOrder(orders[drag.accountKey] ?? [], rows, drag, { id: target.id, side }, isPinned);
|
|
1037
|
+
if (!next) return;
|
|
1038
|
+
actions.setSessionOrder(drag.accountKey, next, orders);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
function dropFolder(drag, target, side) {
|
|
1042
|
+
if (typeof insertBefore !== 'function' || !accepts(drag, target)) return;
|
|
1043
|
+
const ids = (children.get(folder) ?? []).map(item => item.workspaceId);
|
|
1044
|
+
if (!ids.includes(drag.id) || !ids.includes(target.id)) return;
|
|
1045
|
+
const rest = ids.filter(id => id !== drag.id);
|
|
1046
|
+
const index = rest.indexOf(target.id) + (side === 'after' ? 1 : 0);
|
|
1047
|
+
rest.splice(index, 0, drag.id);
|
|
1048
|
+
if (rest.join() === ids.join()) return;
|
|
1049
|
+
try {
|
|
1050
|
+
Promise.resolve(insertBefore(drag.id, rest[index + 1])).catch(() => {});
|
|
1051
|
+
} catch { /* Older hosts hide the Workspace writer. */ }
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
function dragProps(key) {
|
|
1055
|
+
if (options.orderBy !== 'manual' || key === folderKey(ungrouped)) return {};
|
|
1056
|
+
const payload = dragPayload(key);
|
|
1057
|
+
if (!payload) return {};
|
|
1058
|
+
return {
|
|
1059
|
+
draggable: true,
|
|
1060
|
+
'data-dwb-drop': dropTarget?.key === key ? dropTarget.side : undefined,
|
|
1061
|
+
onPointerDown: event => {
|
|
1062
|
+
if (event.button !== 0) return;
|
|
1063
|
+
const startX = event.clientX;
|
|
1064
|
+
const startY = event.clientY;
|
|
1065
|
+
const finish = () => {
|
|
1066
|
+
window.removeEventListener('pointermove', move);
|
|
1067
|
+
window.removeEventListener('pointerup', release);
|
|
1068
|
+
window.removeEventListener('pointercancel', release);
|
|
1069
|
+
};
|
|
1070
|
+
function move(moveEvent) {
|
|
1071
|
+
if (Math.hypot(moveEvent.clientX - startX, moveEvent.clientY - startY) < liftThreshold) return;
|
|
1072
|
+
setLifted(true);
|
|
1073
|
+
finish();
|
|
1074
|
+
}
|
|
1075
|
+
function release() {
|
|
1076
|
+
if (!dragged.current) setLifted(false);
|
|
1077
|
+
finish();
|
|
1078
|
+
}
|
|
1079
|
+
window.addEventListener('pointermove', move);
|
|
1080
|
+
window.addEventListener('pointerup', release);
|
|
1081
|
+
window.addEventListener('pointercancel', release);
|
|
1082
|
+
},
|
|
1083
|
+
onDragStart: event => {
|
|
1084
|
+
dragged.current = payload;
|
|
1085
|
+
setLifted(true);
|
|
1086
|
+
if (!event.dataTransfer) return;
|
|
1087
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
1088
|
+
event.dataTransfer.setData('text/plain', key);
|
|
1089
|
+
},
|
|
1090
|
+
onDragOver: event => {
|
|
1091
|
+
if (!accepts(dragged.current, payload)) return;
|
|
1092
|
+
event.preventDefault();
|
|
1093
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = 'move';
|
|
1094
|
+
const side = draggedSide(event);
|
|
1095
|
+
setDropTarget(current => (current?.key === key && current.side === side ? current : { key, side }));
|
|
1096
|
+
},
|
|
1097
|
+
onDragLeave: event => {
|
|
1098
|
+
if (event.currentTarget.contains(event.relatedTarget)) return;
|
|
1099
|
+
setDropTarget(current => (current?.key === key ? null : current));
|
|
1100
|
+
},
|
|
1101
|
+
onDrop: event => {
|
|
1102
|
+
const drag = dragged.current;
|
|
1103
|
+
dragged.current = null;
|
|
1104
|
+
setDropTarget(null);
|
|
1105
|
+
setLifted(false);
|
|
1106
|
+
if (!accepts(drag, payload)) return;
|
|
1107
|
+
event.preventDefault();
|
|
1108
|
+
const side = draggedSide(event);
|
|
1109
|
+
if (drag.kind === 'session') dropSession(drag, payload, side);
|
|
1110
|
+
else dropFolder(drag, payload, side);
|
|
1111
|
+
},
|
|
1112
|
+
onDragEnd: () => {
|
|
1113
|
+
dragged.current = null;
|
|
1114
|
+
setDropTarget(null);
|
|
1115
|
+
setLifted(false);
|
|
1116
|
+
},
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
useEffect(() => {
|
|
1121
|
+
const path = crumbsRef.current;
|
|
1122
|
+
function scrollPath(event) {
|
|
1123
|
+
if (event.ctrlKey || event.metaKey || event.deltaX !== 0 || event.deltaY === 0 || path.scrollWidth <= path.clientWidth) return;
|
|
1124
|
+
const scale = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? path.clientWidth : 1;
|
|
1125
|
+
event.preventDefault();
|
|
1126
|
+
event.stopPropagation();
|
|
1127
|
+
path.scrollLeft += event.deltaY * scale;
|
|
1128
|
+
}
|
|
1129
|
+
path.addEventListener('wheel', scrollPath, { passive: false });
|
|
1130
|
+
return () => path.removeEventListener('wheel', scrollPath);
|
|
1131
|
+
}, [address]);
|
|
1132
|
+
const browserRef = useRef(null);
|
|
1133
|
+
useEffect(() => {
|
|
1134
|
+
if (selectedFolder === null) return;
|
|
1135
|
+
function clearSelection(event) {
|
|
1136
|
+
if (event.button !== 0 || (event.type === 'click' && event.detail > 0)) return;
|
|
1137
|
+
if (getNewSessionButton(event)) return;
|
|
1138
|
+
const selectedTile = browserRef.current?.querySelector('.dwb-tile[data-dwb-kind="folder"][aria-pressed="true"]');
|
|
1139
|
+
if (!event.composedPath().includes(selectedTile)) setSelectedFolder(null);
|
|
1140
|
+
}
|
|
1141
|
+
window.addEventListener('pointerdown', clearSelection, true);
|
|
1142
|
+
window.addEventListener('click', clearSelection, true);
|
|
1143
|
+
return () => {
|
|
1144
|
+
window.removeEventListener('pointerdown', clearSelection, true);
|
|
1145
|
+
window.removeEventListener('click', clearSelection, true);
|
|
1146
|
+
};
|
|
1147
|
+
}, [selectedFolder]);
|
|
1148
|
+
|
|
1149
|
+
const exists = key => key === null || key === ungrouped || byId.has(key);
|
|
1150
|
+
const current = history.entries[history.index];
|
|
1151
|
+
const folder = exists(current) ? current : null;
|
|
1152
|
+
const parent = parents.get(folder) ?? null;
|
|
1153
|
+
const activeSession = Object.values(sessions.byId).find(session => session.retainedBy?.mainView > 0);
|
|
1154
|
+
const activeOwner = activeSession && workspaceState.items.find(item => item.sessionIds.includes(activeSession.id));
|
|
1155
|
+
let guideFolder;
|
|
1156
|
+
if (activeSession) {
|
|
1157
|
+
for (let child = activeOwner?.workspaceId ?? ungrouped; child !== null && child !== folder; child = parents.get(child) ?? null) {
|
|
1158
|
+
if ((parents.get(child) ?? null) !== folder) continue;
|
|
1159
|
+
guideFolder = child;
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
const onlyArchived = options.archivedFilter === 'only';
|
|
1164
|
+
const foldersWithArchives = useMemo(() => {
|
|
1165
|
+
const visible = new Set();
|
|
1166
|
+
if (onlyArchived) for (const [key, rows] of byWorkspace) {
|
|
1167
|
+
if (rows.length === 0) continue;
|
|
1168
|
+
for (let item = key; item !== null && !visible.has(item); item = parents.get(item) ?? null) visible.add(item);
|
|
1169
|
+
}
|
|
1170
|
+
return visible;
|
|
1171
|
+
}, [byWorkspace, onlyArchived, parents]);
|
|
1172
|
+
const folders = (children.get(folder) ?? []).filter(item => !onlyArchived || foldersWithArchives.has(item.workspaceId));
|
|
1173
|
+
const placement = placements?.[pageKey(folder)];
|
|
1174
|
+
const rows = byWorkspace.get(folder) ?? [];
|
|
1175
|
+
const rowIds = new Set(rows.map(row => row.id));
|
|
1176
|
+
const shortcuts = (placement?.shortcuts ?? []).map(id => sessions.byId[id]).filter(session => session
|
|
1177
|
+
&& !rowIds.has(session.id) && (!session.blank || session.retainedBy?.mainView > 0)
|
|
1178
|
+
&& (options.archivedFilter === 'show' || onlyArchived === archived.has(session.id)));
|
|
1179
|
+
const inside = new Set(notifications.byFolder.get(folder)?.map(entry => entry.sessionId));
|
|
1180
|
+
for (const session of shortcuts) inside.add(session.id);
|
|
1181
|
+
const outside = folder === null ? undefined : notifications.all.reduce((highest, entry) =>
|
|
1182
|
+
!inside.has(entry.sessionId) && entry.priority > (highest?.priority ?? 0) ? entry : highest, undefined);
|
|
1183
|
+
const workspaceLabel = workspace => workspace.title === 'default-workspace' ? nativeText('workspace.defaultName') : workspace.title;
|
|
1184
|
+
const crumbs = [{ key: null, label: t('home') }];
|
|
1185
|
+
if (folder === ungrouped) {
|
|
1186
|
+
crumbs.push({ key: ungrouped, label: t('ungrouped') });
|
|
1187
|
+
} else if (folder !== null) {
|
|
1188
|
+
const trail = [];
|
|
1189
|
+
for (let key = folder; key !== null; key = parents.get(key) ?? null) {
|
|
1190
|
+
const workspace = byId.get(key);
|
|
1191
|
+
trail.push({ key, label: workspaceLabel(workspace), path: workspace.path });
|
|
1192
|
+
}
|
|
1193
|
+
crumbs.push(...trail.reverse());
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
function visit(key) {
|
|
1197
|
+
if (key === folder) return;
|
|
1198
|
+
animatePage(() => {
|
|
1199
|
+
setOpenError(null);
|
|
1200
|
+
setSelectedFolder(null);
|
|
1201
|
+
rememberFolder(key);
|
|
1202
|
+
setHistory(previous => ({
|
|
1203
|
+
entries: [...previous.entries.slice(0, previous.index + 1), key], index: previous.index + 1,
|
|
1204
|
+
}));
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
function historyTarget(direction) {
|
|
1209
|
+
let index = history.index + direction;
|
|
1210
|
+
while (index >= 0 && index < history.entries.length) {
|
|
1211
|
+
if (exists(history.entries[index])) return index;
|
|
1212
|
+
index += direction;
|
|
1213
|
+
}
|
|
1214
|
+
return undefined;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
function go(index) {
|
|
1218
|
+
animatePage(() => {
|
|
1219
|
+
setOpenError(null);
|
|
1220
|
+
setSelectedFolder(null);
|
|
1221
|
+
rememberFolder(history.entries[index]);
|
|
1222
|
+
setHistory(previous => ({ ...previous, index }));
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
const back = historyTarget(-1);
|
|
1227
|
+
const forward = historyTarget(1);
|
|
1228
|
+
const gestureAction = useRef(null);
|
|
1229
|
+
useLayoutEffect(() => {
|
|
1230
|
+
gestureAction.current = direction => {
|
|
1231
|
+
if (direction === 'up') { visit(parent); return; }
|
|
1232
|
+
const index = direction === 'left' ? back : forward;
|
|
1233
|
+
if (index !== undefined) go(index);
|
|
1234
|
+
};
|
|
1235
|
+
});
|
|
1236
|
+
useEffect(() => installMouseGestures(
|
|
1237
|
+
() => direction => gestureAction.current?.(direction),
|
|
1238
|
+
() => {
|
|
1239
|
+
const bounds = panel?.getBoundingClientRect();
|
|
1240
|
+
if (bounds?.width >= 112 && bounds.height >= 112) return bounds;
|
|
1241
|
+
},
|
|
1242
|
+
target => Boolean(panel?.contains(target)) && !panel.closest('[inert]') && !toolbar.hidden,
|
|
1243
|
+
direction => t({ left: 'back', right: 'forward', up: 'gestureUp', invalid: 'gestureInvalid' }[direction]),
|
|
1244
|
+
), [toolbar, panel, t]);
|
|
1245
|
+
const hasUngrouped = folder === null && byWorkspace.get(ungrouped).length > 0;
|
|
1246
|
+
const loading = workspaceState.state !== 'error' && (workspaceState.phase !== 'ready' || sessions.phase !== 'ready');
|
|
1247
|
+
const entries = new Map([
|
|
1248
|
+
...folders.map(item => [folderKey(item.workspaceId), item]),
|
|
1249
|
+
...(hasUngrouped ? [[folderKey(ungrouped), null]] : []),
|
|
1250
|
+
...[...rows, ...shortcuts].map(session => [sessionKey(session.id), session]),
|
|
1251
|
+
]);
|
|
1252
|
+
const keys = [...entries.keys()];
|
|
1253
|
+
const activeKey = activeSession && sessionKey(activeSession.id);
|
|
1254
|
+
const hasActiveTile = entries.has(activeKey);
|
|
1255
|
+
const empty = keys.length === 0;
|
|
1256
|
+
|
|
1257
|
+
useLayoutEffect(() => {
|
|
1258
|
+
function createSession(event) {
|
|
1259
|
+
if (event.defaultPrevented || toolbar.hidden || !getNewSessionButton(event)) return;
|
|
1260
|
+
const selected = entries.get(selectedFolder);
|
|
1261
|
+
const inWorkspace = byId.has(folder);
|
|
1262
|
+
const workspaceId = inWorkspace ? folder : selected?.workspaceId ?? activeOwner?.workspaceId;
|
|
1263
|
+
if (!workspaceState.items.length) return;
|
|
1264
|
+
event.preventDefault();
|
|
1265
|
+
event.stopPropagation();
|
|
1266
|
+
setSelectedFolder(null);
|
|
1267
|
+
setOpenError(null);
|
|
1268
|
+
startSession(workspaceId, sessionId => {
|
|
1269
|
+
if (inWorkspace) return;
|
|
1270
|
+
savePlacement(folder, (saved = {}) => {
|
|
1271
|
+
const shortcuts = saved.shortcuts ?? [];
|
|
1272
|
+
return { shortcuts: shortcuts.includes(sessionId) ? shortcuts : [...shortcuts, sessionId] };
|
|
1273
|
+
});
|
|
1274
|
+
}).catch(() => setOpenError('create'));
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
document.addEventListener('click', createSession, true);
|
|
1278
|
+
return () => document.removeEventListener('click', createSession, true);
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
function locateCurrentSession() {
|
|
1282
|
+
locate.current = activeSession.id;
|
|
1283
|
+
if (!hasActiveTile && folder !== (activeOwner?.workspaceId ?? ungrouped) && !onlyArchived) {
|
|
1284
|
+
visit(activeOwner?.workspaceId ?? ungrouped);
|
|
1285
|
+
} else {
|
|
1286
|
+
revealCurrentSession();
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
function revealCurrentSession() {
|
|
1291
|
+
if (locate.current === null) return;
|
|
1292
|
+
const item = browserRef.current.querySelector('[data-dwb-session-id="' + CSS.escape(locate.current) + '"] > button');
|
|
1293
|
+
if (!item) { locate.current = null; return; }
|
|
1294
|
+
locate.current = null;
|
|
1295
|
+
item.focus({ preventScroll: true });
|
|
1296
|
+
item.scrollIntoView({ block: 'nearest' });
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
useLayoutEffect(() => {
|
|
1300
|
+
const crumbsElement = crumbsRef.current;
|
|
1301
|
+
crumbsElement.scrollLeft = crumbsElement.scrollWidth;
|
|
1302
|
+
const list = browserRef.current.closest('[data-dwb-grid]');
|
|
1303
|
+
if (list) list.scrollTop = 0;
|
|
1304
|
+
revealCurrentSession();
|
|
1305
|
+
}, [folder, display]);
|
|
1306
|
+
|
|
1307
|
+
function tile({ key, label, title = label, icon, kind, activate, active, guided, pinned, archived, scheduled, menuTarget, dots, sessionId, runningText, runningCount, subagents }) {
|
|
1308
|
+
const subagentLabel = subagents ? nativeText(subagents === 1 ? 'status.subagentsRunning.one' : 'status.subagentsRunning.other', { n: subagents }) : undefined;
|
|
1309
|
+
const countBadge = display === 'icons' && runningCount > 0;
|
|
1310
|
+
const description = [runningText, subagentLabel, scheduled && t('scheduled'), ...(dots ?? []).map(entry => nativeText(entry.label))].filter(Boolean).join(', ');
|
|
1311
|
+
return h('li', { key, 'data-dwb-session-id': sessionId, ...dragProps(key) }, h(Button, {
|
|
1312
|
+
className: 'dwb-tile', title, 'data-dwb-kind': kind,
|
|
1313
|
+
'aria-label': label,
|
|
1314
|
+
'aria-description': description || undefined,
|
|
1315
|
+
'aria-current': active ? 'true' : undefined,
|
|
1316
|
+
'data-dwb-guide': guided ? '' : undefined,
|
|
1317
|
+
'aria-pressed': kind === 'folder' ? selectedFolder === key : undefined,
|
|
1318
|
+
...getTriggerProps(menuTarget),
|
|
1319
|
+
onClick: event => {
|
|
1320
|
+
const double = (kind === 'session' ? sessionClick : folderClick) === 'double';
|
|
1321
|
+
if (event.detail === 0 || (!double && event.detail === 1)) activate();
|
|
1322
|
+
else if (kind === 'folder') setSelectedFolder(key);
|
|
1323
|
+
},
|
|
1324
|
+
onDoubleClick: (kind === 'session' ? sessionClick : folderClick) === 'double' ? activate : undefined,
|
|
1325
|
+
}, h('span', { className: 'dwb-tile-icon', 'aria-hidden': true }, h(icon, { size: display === 'list' ? 16 : 30, active })),
|
|
1326
|
+
h('span', { className: 'dwb-label' }, label),
|
|
1327
|
+
h('span', { className: 'dwb-tile-status' },
|
|
1328
|
+
runningText && h('span', {
|
|
1329
|
+
className: 'dwb-running', 'data-dwb-running-count': countBadge ? '' : undefined, 'aria-hidden': true,
|
|
1330
|
+
}, countBadge ? runningCount : runningText),
|
|
1331
|
+
dots?.length > 0 && h(NotificationDots, { entries: dots, translate: nativeText, size: 22 }),
|
|
1332
|
+
(subagentLabel || scheduled || pinned || archived) && h('span', { className: 'dwb-status-marks' },
|
|
1333
|
+
subagentLabel && h('span', { className: 'dwb-row-mark', role: 'img', 'aria-label': subagentLabel, title: subagentLabel },
|
|
1334
|
+
h(StateDot, { state: 'ongoing' })),
|
|
1335
|
+
scheduled && h(IconClockOutlineRegular, { className: 'dwb-row-mark', size: 14, 'aria-label': t('scheduled'), role: 'img' }),
|
|
1336
|
+
pinned && h(IconPinFillRegular, { className: 'dwb-row-mark', size: 13, 'aria-label': nativeText('menu.unpin'), role: 'img' }),
|
|
1337
|
+
archived && h(IconArchiveOutlineRegular, { className: 'dwb-row-mark', size: 13, 'aria-label': t('archived'), role: 'img' })))));
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
function folderTile(key, label, path) {
|
|
1341
|
+
const menuTarget = key === ungrouped ? undefined : { kind: 'workspace', value: { workspaceId: key, path, displayTitle: label } };
|
|
1342
|
+
const count = notifications.runningByFolder.get(key);
|
|
1343
|
+
const runningText = count ? t(count === 1 ? 'oneRunningSession' : 'runningSessions', { n: count }) : undefined;
|
|
1344
|
+
return tile({ key: folderKey(key), label, title: path ?? label, icon: FolderIcon, kind: 'folder',
|
|
1345
|
+
activate: () => visit(key), guided: sessionVisible && key === guideFolder, menuTarget, runningText, runningCount: count, dots: notifications.byFolder.get(key) });
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
return h('section', { className: 'dwb-browser', 'aria-label': t('panel'), ref: browserRef },
|
|
1349
|
+
createPortal(h(react.Fragment, null, outside && h(NotificationDots, { entries: [outside], translate: nativeText, size: 22 }),
|
|
1350
|
+
h('span', { className: 'dwb-heading-name' }, folder === null ? nativeText('section.workspaces') : crumbs.at(-1).label)), heading),
|
|
1351
|
+
createPortal(h('div', { className: 'dwb-toolbar' },
|
|
1352
|
+
h(SidebarDivider, { label: t('resize'), toolbar, area, ratio: split, saveRatio: saveSplit }),
|
|
1353
|
+
h('div', { className: 'dwb-reveal-zone' }),
|
|
1354
|
+
h('div', { className: 'dwb-nav-buttons dwb-reveal-control' },
|
|
1355
|
+
h(NavButton, { icon: outside ? undefined : IconChevronLeftOutlineRegular, label: t('back'), disabled: back === undefined, onClick: () => go(back) }),
|
|
1356
|
+
h(NavButton, { icon: IconChevronRightOutlineRegular, label: t('forward'), disabled: forward === undefined, onClick: () => go(forward) }),
|
|
1357
|
+
h(NavButton, { icon: IconChevronUpOutlineRegular, label: t('up'), disabled: folder === null, onClick: () => visit(parent) }),
|
|
1358
|
+
h(NavButton, { icon: LocateIcon, label: t('locate'), disabled: !activeSession || (onlyArchived && !hasActiveTile),
|
|
1359
|
+
onClick: locateCurrentSession }))), toolbar),
|
|
1360
|
+
createPortal(h('nav', { className: 'dwb-path dwb-reveal-control', 'aria-label': t('path'), ref: crumbsRef },
|
|
1361
|
+
h(IconFolderOpenRegular, { size: 16, className: 'dwb-indicator', 'aria-hidden': true }),
|
|
1362
|
+
crumbs.map(({ key, label, path }, index) => h('span', { className: 'dwb-crumb', key: key === ungrouped ? 'ungrouped' : key ?? 'home' },
|
|
1363
|
+
index > 0 && h(IconChevronRightOutlineRegular, { size: 12, className: 'dwb-indicator', 'aria-hidden': true }),
|
|
1364
|
+
index === crumbs.length - 1
|
|
1365
|
+
? h('span', { className: 'dwb-current', title: path, 'aria-current': 'location' }, label)
|
|
1366
|
+
: h(Button, { size: 'sm', title: path, onClick: () => visit(key) }, label)))), address),
|
|
1367
|
+
h('div', { 'aria-busy': loading },
|
|
1368
|
+
workspaceState.state === 'error' && h('p', { className: 'dwb-status', role: 'status' }, t('loadError')),
|
|
1369
|
+
openError && h('p', { className: 'dwb-status', role: 'alert' }, openError === 'archived'
|
|
1370
|
+
? nativeText('toast.archivedNotOpenable') : t(openError === 'create' ? 'createError' : 'openError')),
|
|
1371
|
+
empty && workspaceState.state !== 'error' && h('p', { className: 'dwb-status', role: 'status' },
|
|
1372
|
+
t(loading ? 'loading' : onlyArchived ? 'noArchives' : folder === null ? 'emptyHome' : 'emptyFolder')),
|
|
1373
|
+
!empty && h('ul', { className: 'dwb-list', 'data-dwb-display': display, 'data-dwb-lifted': lifted ? 'true' : undefined },
|
|
1374
|
+
keys.map(key => {
|
|
1375
|
+
const item = entries.get(key);
|
|
1376
|
+
if (item === null) return folderTile(ungrouped, t('ungrouped'));
|
|
1377
|
+
if (key.startsWith('folder:')) return folderTile(item.workspaceId, workspaceLabel(item), item.path);
|
|
1378
|
+
const session = item;
|
|
1379
|
+
const label = session.blank ? nativeText('session.new') : session.title?.trim() || nativeText('session.untitled');
|
|
1380
|
+
const isArchived = archived.has(session.id);
|
|
1381
|
+
const activity = notifications.runningBySession.get(session.id);
|
|
1382
|
+
const active = sessionVisible && activeKey === key;
|
|
1383
|
+
return tile({ key, sessionId: session.id, label, title: isArchived ? `${label} · ${t('archived')}` : label,
|
|
1384
|
+
icon: SessionIcon, kind: 'session',
|
|
1385
|
+
pinned: !isArchived && pinned.has(session.id), archived: isArchived, scheduled: !isArchived && !session.blank && scheduledSessions.has(session.id), active,
|
|
1386
|
+
runningText: activity?.running ? t('running') : undefined, subagents: activity?.subagents,
|
|
1387
|
+
dots: notifications.bySession.has(session.id) ? [notifications.bySession.get(session.id)] : undefined,
|
|
1388
|
+
menuTarget: session.blank ? undefined : { kind: 'session', value: { sessionId: session.id, displayTitle: label } },
|
|
1389
|
+
activate: () => {
|
|
1390
|
+
setOpenError(isArchived ? 'archived' : null);
|
|
1391
|
+
if (!isArchived && !active) openSession(session.id, () => setOpenError('open'));
|
|
1392
|
+
},
|
|
1393
|
+
});
|
|
1394
|
+
}))));
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
function BrowserSettings({ t, preference, setPreference, onClose }) {
|
|
1398
|
+
const dialog = useRef(null);
|
|
1399
|
+
useEffect(() => { dialog.current.showModal(); }, []);
|
|
1400
|
+
return h('dialog', { ref: dialog, className: 'dwb-settings', 'aria-label': t('settings'),
|
|
1401
|
+
onClose, onClick: event => {
|
|
1402
|
+
if (event.target !== dialog.current) return;
|
|
1403
|
+
const box = dialog.current.getBoundingClientRect();
|
|
1404
|
+
if (event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom) onClose();
|
|
1405
|
+
} },
|
|
1406
|
+
h('h2', null, t('settings')),
|
|
1407
|
+
...[['sessionClick', 'sessionOpen'], ['folderClick', 'folderOpen']].map(([key, label]) =>
|
|
1408
|
+
h('fieldset', { key }, h('legend', null, t(label)),
|
|
1409
|
+
...['single', 'double'].map(value => h('label', { key: value },
|
|
1410
|
+
h('input', { type: 'radio', name: key, value, checked: (preference[key] ?? 'single') === value,
|
|
1411
|
+
onChange: () => setPreference(previous => ({ ...previous, [key]: value })) }),
|
|
1412
|
+
t(value === 'single' ? 'singleClick' : 'doubleClick'))))),
|
|
1413
|
+
h(Button, { onClick: onClose }, t('closeSettings')));
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
function SidebarExtension({ t, nativeText, workspaceSource, sessionSource, nativeEntry, openSession, startSession, insertBefore, useContextMenu, useSessionStatus, panelSource, scheduleSource, unreadSource }) {
|
|
1417
|
+
const [preference, setPreference] = useState(readPreference);
|
|
1418
|
+
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
1419
|
+
const enabled = preference.enabled === true;
|
|
1420
|
+
const fade = usePageFade();
|
|
1421
|
+
const [actions] = useState(() => ({
|
|
1422
|
+
setEnabled: (enabled, list) => {
|
|
1423
|
+
const update = () => setPreference(previous => ({ ...previous, enabled }));
|
|
1424
|
+
if (list?.hasAttribute('data-dwb-grid') === enabled) return;
|
|
1425
|
+
fade(list, update);
|
|
1426
|
+
},
|
|
1427
|
+
rememberFolder: folder => setPreference(previous => ({ ...previous, folder })),
|
|
1428
|
+
setDisplay: display => setPreference(previous => ({ ...previous, display })),
|
|
1429
|
+
saveSplit: split => setPreference(previous => ({ ...previous, split })),
|
|
1430
|
+
savePlacement: (folder, update) => setPreference(previous => {
|
|
1431
|
+
const placements = previous.placements ?? emptyPlacements;
|
|
1432
|
+
const key = pageKey(folder);
|
|
1433
|
+
return { ...previous, placements: { ...placements, [key]: update(placements[key]) } };
|
|
1434
|
+
}),
|
|
1435
|
+
}));
|
|
1436
|
+
const { grid, list, toolbar, address, header, heading, nativeHeading, trigger, menu, menuMount, menuSeparator, menuLabel, searching, searchOpen, region, area, panel } = useSidebarMounts(nativeText);
|
|
1437
|
+
const display = preference.display === 'list' ? 'list' : 'icons';
|
|
1438
|
+
const entry = useSyncExternalStore(nativeEntry.subscribe, nativeEntry.getSnapshot);
|
|
1439
|
+
const view = useMemo(() => entry?.store?.create() ?? emptyView, [entry]);
|
|
1440
|
+
const animatePage = update => fade(list, update);
|
|
1441
|
+
|
|
1442
|
+
function openConversation(sessionId, onError) {
|
|
1443
|
+
const main = document.querySelector('[data-slot="main"]');
|
|
1444
|
+
fade(main?.parentElement, () => {
|
|
1445
|
+
try { openSession(sessionId); } catch { onError(); }
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
useEffect(() => { savePreference(preference); }, [preference]);
|
|
1450
|
+
useLayoutEffect(() => {
|
|
1451
|
+
if (!grid || !list || !header || !region) return;
|
|
1452
|
+
const show = enabled && Boolean(trigger);
|
|
1453
|
+
grid.hidden = !show || searching;
|
|
1454
|
+
toolbar.hidden = !show;
|
|
1455
|
+
address.hidden = !show;
|
|
1456
|
+
heading.hidden = !show;
|
|
1457
|
+
nativeHeading?.toggleAttribute('data-dwb-replaced-heading', show);
|
|
1458
|
+
region.toggleAttribute('data-dwb-layout', show);
|
|
1459
|
+
header.toggleAttribute('data-dwb-header', show);
|
|
1460
|
+
list.toggleAttribute('data-dwb-grid', show && !searching);
|
|
1461
|
+
return () => {
|
|
1462
|
+
region.removeAttribute('data-dwb-layout');
|
|
1463
|
+
header.removeAttribute('data-dwb-header');
|
|
1464
|
+
list.removeAttribute('data-dwb-grid');
|
|
1465
|
+
grid.hidden = true;
|
|
1466
|
+
toolbar.hidden = true;
|
|
1467
|
+
address.hidden = true;
|
|
1468
|
+
heading.hidden = true;
|
|
1469
|
+
nativeHeading?.removeAttribute('data-dwb-replaced-heading');
|
|
1470
|
+
};
|
|
1471
|
+
}, [grid, list, toolbar, address, header, heading, nativeHeading, enabled, trigger, searching, region]);
|
|
1472
|
+
useLayoutEffect(() => {
|
|
1473
|
+
region?.toggleAttribute('data-dwb-reveal-held', enabled && Boolean(searchOpen || menu));
|
|
1474
|
+
return () => region?.removeAttribute('data-dwb-reveal-held');
|
|
1475
|
+
}, [region, enabled, searchOpen, menu]);
|
|
1476
|
+
useLayoutEffect(() => {
|
|
1477
|
+
if (!enabled || !trigger || !header || !toolbar || !address || !region) return;
|
|
1478
|
+
const sidebar = panel ?? region;
|
|
1479
|
+
const divider = toolbar.querySelector('.dwb-divider');
|
|
1480
|
+
if (!divider) return;
|
|
1481
|
+
const clear = () => region.removeAttribute('data-dwb-reveal-hover');
|
|
1482
|
+
function update(event) {
|
|
1483
|
+
if (event.pointerType === 'touch') return;
|
|
1484
|
+
const { clientX: x, clientY: y } = event;
|
|
1485
|
+
const { left, right } = sidebar.getBoundingClientRect();
|
|
1486
|
+
const top = divider.getBoundingClientRect().bottom;
|
|
1487
|
+
const bottom = address.getBoundingClientRect().bottom;
|
|
1488
|
+
region.toggleAttribute('data-dwb-reveal-hover', x >= left && x < right && y >= top && y < bottom);
|
|
1489
|
+
}
|
|
1490
|
+
window.addEventListener('pointermove', update);
|
|
1491
|
+
sidebar.addEventListener('pointerleave', clear);
|
|
1492
|
+
window.addEventListener('blur', clear);
|
|
1493
|
+
return () => {
|
|
1494
|
+
window.removeEventListener('pointermove', update);
|
|
1495
|
+
sidebar.removeEventListener('pointerleave', clear);
|
|
1496
|
+
window.removeEventListener('blur', clear);
|
|
1497
|
+
clear();
|
|
1498
|
+
};
|
|
1499
|
+
}, [enabled, trigger, header, toolbar, address, region, panel]);
|
|
1500
|
+
useLayoutEffect(() => {
|
|
1501
|
+
if (!menu) return;
|
|
1502
|
+
menu.toggleAttribute('data-dwb-selected', enabled);
|
|
1503
|
+
return () => menu.removeAttribute('data-dwb-selected');
|
|
1504
|
+
}, [menu, enabled]);
|
|
1505
|
+
|
|
1506
|
+
useLayoutEffect(() => {
|
|
1507
|
+
if (!menu || !trigger || !view.actions) return;
|
|
1508
|
+
const { setGroupBy, setOrderBy, setArchivedFilter } = view.actions;
|
|
1509
|
+
const select = new Map([
|
|
1510
|
+
[nativeText('groupBy.workspace'), () => { actions.setEnabled(false, list); setGroupBy('workspace'); }],
|
|
1511
|
+
[nativeText('groupBy.workspaceTree'), () => { actions.setEnabled(false, list); setGroupBy('workspace-tree'); }],
|
|
1512
|
+
[nativeText('groupBy.flat'), () => { actions.setEnabled(false, list); setGroupBy('flat'); }],
|
|
1513
|
+
[nativeText('orderBy.manual'), () => setOrderBy('manual', displayedOrders(
|
|
1514
|
+
workspaceSource.getSnapshot(), sessionSource.getSnapshot(), view.getSnapshot()))],
|
|
1515
|
+
[nativeText('orderBy.updated'), () => setOrderBy('updated', {})],
|
|
1516
|
+
[nativeText('viewOptions.hideArchived'), () => setArchivedFilter('default')],
|
|
1517
|
+
[nativeText('viewOptions.showArchived'), () => setArchivedFilter('show')],
|
|
1518
|
+
[nativeText('viewOptions.onlyArchived'), () => setArchivedFilter('only')],
|
|
1519
|
+
]);
|
|
1520
|
+
function selectNative(event) {
|
|
1521
|
+
const button = event.target instanceof Element && event.target.closest('button[role="menuitem"]');
|
|
1522
|
+
if (!button || menuMount.contains(button)) return;
|
|
1523
|
+
const apply = select.get(button.textContent.trim());
|
|
1524
|
+
if (!apply) return;
|
|
1525
|
+
event.preventDefault();
|
|
1526
|
+
event.stopPropagation();
|
|
1527
|
+
apply();
|
|
1528
|
+
}
|
|
1529
|
+
let closing = false;
|
|
1530
|
+
function dismissOutside(event) {
|
|
1531
|
+
if (closing || menu.contains(event.target) || trigger.contains(event.target)) return;
|
|
1532
|
+
closing = true;
|
|
1533
|
+
trigger.click();
|
|
1534
|
+
}
|
|
1535
|
+
menu.addEventListener('click', selectNative, true);
|
|
1536
|
+
document.addEventListener('wheel', dismissOutside, { capture: true, passive: true });
|
|
1537
|
+
document.addEventListener('contextmenu', dismissOutside, true);
|
|
1538
|
+
return () => {
|
|
1539
|
+
menu.removeEventListener('click', selectNative, true);
|
|
1540
|
+
document.removeEventListener('wheel', dismissOutside, true);
|
|
1541
|
+
document.removeEventListener('contextmenu', dismissOutside, true);
|
|
1542
|
+
};
|
|
1543
|
+
}, [menu, trigger, menuMount, view, actions, list, nativeText, workspaceSource, sessionSource]);
|
|
1544
|
+
|
|
1545
|
+
function menuItem(label, src, current, select) {
|
|
1546
|
+
const icon = h('img', { className: 'dwb-menu-icon', src, alt: '', width: 16, height: 16, draggable: false });
|
|
1547
|
+
return h(MenuItemButton, { current, icon, onSelect: select },
|
|
1548
|
+
h('span', { className: 'dwb-menu-label' }, t(label), current && h(IconCheckOutlineRegular, { size: 14, 'aria-hidden': true })));
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
return h(react.Fragment, null,
|
|
1552
|
+
menu && createPortal(h(react.Fragment, null,
|
|
1553
|
+
h('div', { className: 'dwb-group-row' },
|
|
1554
|
+
menuItem('panel', menuFolderIcon, enabled, () => actions.setEnabled(true, list)),
|
|
1555
|
+
enabled && h(Button, {
|
|
1556
|
+
className: 'dwb-group-settings', size: 'sm', role: 'menuitem',
|
|
1557
|
+
title: t('settings'), 'aria-label': t('settings'),
|
|
1558
|
+
onClick: () => { trigger.click(); setSettingsOpen(true); },
|
|
1559
|
+
}, h('img', { src: editMenuIcon, width: 20, height: 20, alt: '', draggable: false }))),
|
|
1560
|
+
enabled && h(react.Fragment, null,
|
|
1561
|
+
h('div', { role: 'separator', className: menuSeparator?.className }),
|
|
1562
|
+
h('div', { role: 'presentation', className: menuLabel?.className }, t('display')),
|
|
1563
|
+
menuItem('icons', largeIconsMenuIcon, display === 'icons', () => {
|
|
1564
|
+
if (display !== 'icons') animatePage(() => actions.setDisplay('icons'));
|
|
1565
|
+
}),
|
|
1566
|
+
menuItem('list', listMenuIcon, display === 'list', () => {
|
|
1567
|
+
if (display !== 'list') animatePage(() => actions.setDisplay('list'));
|
|
1568
|
+
}),
|
|
1569
|
+
)), menuMount),
|
|
1570
|
+
settingsOpen && createPortal(h(BrowserSettings, { t, preference, setPreference, onClose: () => setSettingsOpen(false) }), document.body),
|
|
1571
|
+
enabled && grid && createPortal(h(Browser, {
|
|
1572
|
+
sessionClick: preference.sessionClick, folderClick: preference.folderClick,
|
|
1573
|
+
t, nativeText, workspaceSource, sessionSource, view, openSession: openConversation, insertBefore, toolbar, address, heading, area, panel, display, animatePage, useContextMenu, useSessionStatus,
|
|
1574
|
+
split: !trigger ? null : preference.split, saveSplit: actions.saveSplit,
|
|
1575
|
+
startSession, placements: preference.placements, savePlacement: actions.savePlacement, panelSource, scheduleSource, unreadSource,
|
|
1576
|
+
startFolder: typeof preference.folder === 'string' ? preference.folder : null, rememberFolder: actions.rememberFolder,
|
|
1577
|
+
}), grid));
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
function apply(ctx) {
|
|
1581
|
+
const nativeText = ctx.locale.bind('workspace');
|
|
1582
|
+
const slots = ctx.slots;
|
|
1583
|
+
ctx.effect(() => ctx.locale.register(id, dictionaries));
|
|
1584
|
+
ctx.effect(() => {
|
|
1585
|
+
const style = document.createElement('style');
|
|
1586
|
+
style.textContent = css;
|
|
1587
|
+
document.head.append(style);
|
|
1588
|
+
return () => style.remove();
|
|
1589
|
+
});
|
|
1590
|
+
const workspaces = ctx.workspaces.list;
|
|
1591
|
+
const sessions = ctx.sessions.list;
|
|
1592
|
+
const navigation = ctx.uiWorkspace;
|
|
1593
|
+
const panel = ctx.layout.panelInfo;
|
|
1594
|
+
const panelSource = { subscribe: listener => panel.subscribe(listener), getSnapshot: () => panel.getSnapshot() };
|
|
1595
|
+
const workspaceSource = { subscribe: listener => workspaces.subscribe(listener), getSnapshot: () => workspaces.getSnapshot() };
|
|
1596
|
+
const sessionSource = { subscribe: listener => sessions.subscribe(listener), getSnapshot: () => sessions.getSnapshot() };
|
|
1597
|
+
const nativeEntry = {
|
|
1598
|
+
subscribe: listener => slots.subscribe('sidebar.workspaces', listener),
|
|
1599
|
+
getSnapshot: () => slots.entries('sidebar.workspaces').find(entry => entry.locale === 'workspace' && entry.store),
|
|
1600
|
+
};
|
|
1601
|
+
const scheduleSource = scheduleSourceFor(ctx);
|
|
1602
|
+
const unreadSource = completionSource(ctx);
|
|
1603
|
+
slots.inject('shell.overlay', () => slots.register({
|
|
1604
|
+
name: 'shell.overlay', id, locale: id,
|
|
1605
|
+
inject: () => ({
|
|
1606
|
+
nativeText, workspaceSource, sessionSource, nativeEntry, panelSource, scheduleSource, unreadSource,
|
|
1607
|
+
insertBefore: (workspaceId, beforeWorkspaceId) => ctx.workspaces.insertBefore(workspaceId, beforeWorkspaceId),
|
|
1608
|
+
openSession: sessionId => navigation.openSession(sessionId),
|
|
1609
|
+
startSession: (workspaceId, onCreated) => {
|
|
1610
|
+
const snapshot = sessions.getSnapshot();
|
|
1611
|
+
const target = workspaceId ?? workspaces.getSnapshot().items.reduce((recent, item) => {
|
|
1612
|
+
const latest = item.sessionIds.reduce((time, id) => Math.max(time, snapshot.byId[id]?.updatedAt ?? -Infinity), -Infinity);
|
|
1613
|
+
const activity = latest === -Infinity ? Date.parse(item.createdAt) : latest;
|
|
1614
|
+
return !recent || activity > recent.activity ? { workspaceId: item.workspaceId, activity } : recent;
|
|
1615
|
+
}, undefined)?.workspaceId;
|
|
1616
|
+
return target === undefined ? Promise.resolve() : navigation.openWorkspace(target, onCreated);
|
|
1617
|
+
},
|
|
1618
|
+
}),
|
|
1619
|
+
}, SidebarExtension));
|
|
1375
1620
|
}
|
|
1376
1621
|
return { apply, inject };
|
|
1377
1622
|
},
|