Skip to content

Agent Zero AI framework

Add universal right canvas shell

Alessandroc9f1bd21ca2d
diff --git a/tests/test_webui_extension_surfaces.py b/tests/test_webui_extension_surfaces.py
index 2d6880ced..b0ca89f46 100644
--- a/tests/test_webui_extension_surfaces.py
+++ b/tests/test_webui_extension_surfaces.py
@@ -52,6 +52,14 @@ SURFACE_SCENARIOS: list[tuple[str, str]] = [
("plugins-list-dropdown-end", "webui/components/plugins/list/plugin-list.html"),
("modal-shell-start", "webui/js/modals.js"),
("modal-shell-end", "webui/js/modals.js"),
+ ("right-canvas-shell-start", "webui/components/canvas/right-canvas.html"),
+ ("right-canvas-tabs-start", "webui/components/canvas/right-canvas.html"),
+ ("right-canvas-tabs-end", "webui/components/canvas/right-canvas.html"),
+ ("right-canvas-toolbar-start", "webui/components/canvas/right-canvas.html"),
+ ("right-canvas-toolbar-end", "webui/components/canvas/right-canvas.html"),
+ ("right-canvas-panels", "webui/components/canvas/right-canvas.html"),
+ ("right-canvas-empty-state", "webui/components/canvas/right-canvas.html"),
+ ("right-canvas-shell-end", "webui/components/canvas/right-canvas.html"),
]
diff --git a/webui/components/canvas/right-canvas-store.js b/webui/components/canvas/right-canvas-store.js
new file mode 100644
index 000000000..19b820fb5
--- /dev/null
+++ b/webui/components/canvas/right-canvas-store.js
@@ -0,0 +1,283 @@
+import { createStore } from "/js/AlpineStore.js";
+import { callJsExtensions } from "/js/extensions.js";
+
+const STORAGE_KEY = "a0.rightCanvas";
+const DEFAULT_WIDTH = 720;
+const MIN_WIDTH = 420;
+const MAX_WIDTH = 900;
+const DESKTOP_BREAKPOINT = 1200;
+const MOBILE_BREAKPOINT = 768;
+
+function clamp(value, min, max) {
+ return Math.min(Math.max(value, min), max);
+}
+
+function viewportWidth() {
+ return Math.max(document.documentElement.clientWidth || 0, globalThis.innerWidth || 0);
+}
+
+const model = {
+ surfaces: [],
+ activeSurfaceId: "",
+ isOpen: false,
+ width: DEFAULT_WIDTH,
+ isOverlayMode: false,
+ isMobileMode: false,
+ _initialized: false,
+ _registering: false,
+ _rootElement: null,
+ _resizeCleanup: null,
+ _lastPayloadBySurface: {},
+
+ async init(element = null) {
+ if (element) this._rootElement = element;
+ if (this._initialized) {
+ this.applyLayoutState();
+ return;
+ }
+
+ this._initialized = true;
+ this.restore();
+ this.updateLayoutMode();
+ this.applyLayoutState();
+ globalThis.addEventListener("resize", () => {
+ this.updateLayoutMode();
+ this.setWidth(this.width, { persist: false });
+ this.applyLayoutState();
+ });
+
+ if (!this._registering) {
+ this._registering = true;
+ await callJsExtensions("right_canvas_register_surfaces", this);
+ this._registering = false;
+ this.ensureActiveSurface();
+ if (this.isOpen && this.activeSurfaceId) {
+ globalThis.requestAnimationFrame?.(() => {
+ void this.open(this.activeSurfaceId, this._lastPayloadBySurface[this.activeSurfaceId] || {});
+ });
+ }
+ }
+ },
+
+ registerSurface(surface) {
+ if (!surface?.id) return;
+ const normalized = {
+ title: surface.id,
+ icon: "web_asset",
+ order: 100,
+ canOpen: () => true,
+ open: () => {},
+ close: () => {},
+ modalPath: "",
+ ...surface,
+ };
+
+ const index = this.surfaces.findIndex((item) => item.id === normalized.id);
+ if (index >= 0) {
+ this.surfaces.splice(index, 1, normalized);
+ } else {
+ this.surfaces.push(normalized);
+ }
+ this.surfaces.sort((a, b) => (a.order ?? 100) - (b.order ?? 100));
+ this.ensureActiveSurface();
+ },
+
+ ensureActiveSurface() {
+ if (!this.surfaces.length) {
+ this.activeSurfaceId = "";
+ return;
+ }
+ if (!this.surfaces.some((surface) => surface.id === this.activeSurfaceId)) {
+ this.activeSurfaceId = this.surfaces[0].id;
+ }
+ },
+
+ async open(surfaceId = "", payload = {}) {
+ const targetId = surfaceId || this.activeSurfaceId || this.surfaces[0]?.id || "";
+ const surface = this.getSurface(targetId);
+ if (!surface) return false;
+ if (typeof surface.canOpen === "function" && surface.canOpen(payload) === false) {
+ return false;
+ }
+
+ this.activeSurfaceId = targetId;
+ this.isOpen = true;
+ this._lastPayloadBySurface[targetId] = payload || {};
+ this.persist();
+ this.applyLayoutState();
+
+ try {
+ await surface.open?.(payload || {});
+ } catch (error) {
+ console.error(`Canvas surface ${targetId} failed to open`, error);
+ }
+ return true;
+ },
+
+ async close() {
+ const surface = this.currentSurface();
+ this.isOpen = false;
+ this.persist();
+ this.applyLayoutState();
+ try {
+ await surface?.close?.(this._lastPayloadBySurface[this.activeSurfaceId] || {});
+ } catch (error) {
+ console.error(`Canvas surface ${this.activeSurfaceId} failed to close`, error);
+ }
+ },
+
+ async dockSurface(surfaceId, payload = {}) {
+ const surface = this.getSurface(surfaceId);
+ if (!surface) return false;
+ const modalPath = payload.modalPath || surface.modalPath || "";
+ if (modalPath && globalThis.isModalOpen?.(modalPath)) {
+ await globalThis.closeModal?.(modalPath);
+ }
+ return await this.open(surfaceId, { ...payload, source: "modal" });
+ },
+
+ async undockSurface(surfaceId = "", payload = {}) {
+ const targetId = surfaceId || this.activeSurfaceId;
+ const surface = this.getSurface(targetId);
+ const modalPath = payload.modalPath || surface?.modalPath || "";
+ if (!surface || !modalPath) return false;
+ if (this.activeSurfaceId === targetId) {
+ this.isOpen = false;
+ this.persist();
+ this.applyLayoutState();
+ try {
+ await surface.close?.(this._lastPayloadBySurface[targetId] || {});
+ } catch (error) {
+ console.error(`Canvas surface ${targetId} failed to close while undocking`, error);
+ }
+ }
+ const modalPromise = globalThis.ensureModalOpen?.(modalPath);
+ if (modalPromise?.catch) {
+ modalPromise.catch((error) => console.error(`Canvas surface ${targetId} failed to undock`, error));
+ }
+ return true;
+ },
+
+ async undockActiveSurface() {
+ return await this.undockSurface(this.activeSurfaceId);
+ },
+
+ currentSurfaceCanUndock() {
+ return Boolean(this.currentSurface()?.modalPath);
+ },
+
+ async toggle(surfaceId = "", payload = {}) {
+ const targetId = surfaceId || this.activeSurfaceId || this.surfaces[0]?.id || "";
+ if (this.isOpen && targetId === this.activeSurfaceId) {
+ await this.close();
+ return false;
+ }
+ return await this.open(targetId, payload);
+ },
+
+ setWidth(px, options = {}) {
+ const { persist = true } = options;
+ const max = this.maxWidth();
+ const next = clamp(Number(px) || DEFAULT_WIDTH, MIN_WIDTH, max);
+ this.width = next;
+ this.applyLayoutState();
+ if (persist) this.persist();
+ },
+
+ maxWidth() {
+ return Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Math.floor(viewportWidth() * 0.58)));
+ },
+
+ defaultWidth() {
+ return Math.min(DEFAULT_WIDTH, Math.floor(viewportWidth() * 0.45));
+ },
+
+ startResize(event) {
+ if (this.isOverlayMode || this.isMobileMode || !this.isOpen) return;
+ if (event.button !== 0) return;
+ event.preventDefault();
+
+ const onPointerMove = (moveEvent) => {
+ const nextWidth = viewportWidth() - moveEvent.clientX;
+ this.setWidth(nextWidth);
+ };
+ const onPointerUp = () => {
+ globalThis.removeEventListener("pointermove", onPointerMove);
+ globalThis.removeEventListener("pointerup", onPointerUp);
+ document.body.classList.remove("right-canvas-resizing");
+ this.persist();
+ };
+
+ document.body.classList.add("right-canvas-resizing");
+ globalThis.addEventListener("pointermove", onPointerMove);
+ globalThis.addEventListener("pointerup", onPointerUp);
+ },
+
+ persist() {
+ try {
+ localStorage.setItem(
+ STORAGE_KEY,
+ JSON.stringify({
+ isOpen: this.isOpen,
+ activeSurfaceId: this.activeSurfaceId,
+ width: this.width,
+ }),
+ );
+ } catch (error) {
+ console.warn("Could not persist right canvas state", error);
+ }
+ },
+
+ restore() {
+ this.width = this.defaultWidth();
+ try {
+ const saved = JSON.parse(localStorage.getItem(STORAGE_KEY) || "{}");
+ this.isOpen = Boolean(saved.isOpen);
+ this.activeSurfaceId = String(saved.activeSurfaceId || "");
+ if (saved.width) this.width = Number(saved.width);
+ } catch (error) {
+ console.warn("Could not restore right canvas state", error);
+ }
+ this.setWidth(this.width, { persist: false });
+ },
+
+ updateLayoutMode() {
+ const width = viewportWidth();
+ this.isOverlayMode = width < DESKTOP_BREAKPOINT;
+ this.isMobileMode = width <= MOBILE_BREAKPOINT;
+ },
+
+ applyLayoutState() {
+ this.updateLayoutMode();
+ document.documentElement.style.setProperty("--right-canvas-width", `${this.width}px`);
+ document.body.classList.toggle("right-canvas-open", this.isOpen);
+ document.body.classList.toggle("right-canvas-overlay-mode", this.isOverlayMode);
+ document.body.classList.toggle("right-canvas-mobile-mode", this.isMobileMode);
+ },
+
+ widthStyle() {
+ if (this.isMobileMode) return "";
+ if (this.isOverlayMode) {
+ return `width: min(${this.width}px, calc(100vw - 44px));`;
+ }
+ return `width: ${this.isOpen ? this.width : 52}px;`;
+ },
+
+ getSurface(id) {
+ return this.surfaces.find((surface) => surface.id === id) || null;
+ },
+
+ currentSurface() {
+ return this.getSurface(this.activeSurfaceId);
+ },
+
+ isSurfaceActive(id) {
+ return this.activeSurfaceId === id;
+ },
+
+ activeTitle() {
+ return this.currentSurface()?.title || "Canvas";
+ },
+};
+
+export const store = createStore("rightCanvas", model);
diff --git a/webui/components/canvas/right-canvas.css b/webui/components/canvas/right-canvas.css
new file mode 100644
index 000000000..5bb931ba1
--- /dev/null
+++ b/webui/components/canvas/right-canvas.css
@@ -0,0 +1,306 @@
+.container > *,
+#right-panel {
+ min-width: 0;
+}
+
+#right-panel {
+ position: relative;
+}
+
+.container > x-component[path="canvas/right-canvas.html"],
+.container > x-component[path="canvas/right-canvas.html"] > div[x-data] {
+ display: flex;
+ flex: 0 0 auto;
+ height: 100%;
+ min-width: 0;
+ min-height: 0;
+}
+
+body.right-canvas-resizing {
+ cursor: col-resize;
+ user-select: none;
+}
+
+.right-canvas {
+ --right-canvas-chrome: color-mix(in srgb, var(--color-background) 94%, #000 6%);
+ --right-canvas-surface: color-mix(in srgb, var(--color-panel) 88%, var(--color-background) 12%);
+ --right-canvas-border: color-mix(in srgb, var(--color-border) 70%, transparent);
+ position: relative;
+ z-index: 1200;
+ display: flex;
+ flex: 0 0 auto;
+ height: 100%;
+ min-width: 52px;
+ max-width: min(900px, 58vw);
+ overflow: hidden;
+ border-left: 1px solid var(--right-canvas-border);
+ background: var(--right-canvas-chrome);
+ transition: width 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
+}
+
+.right-canvas.is-closed .right-canvas-shell {
+ display: none;
+}
+
+.right-canvas-rail {
+ display: flex;
+ flex: 0 0 52px;
+ flex-direction: column;
+ align-items: center;
+ gap: 7px;
+ padding: 10px 7px;
+ border-right: 1px solid var(--right-canvas-border);
+ background: color-mix(in srgb, var(--color-background) 92%, #000 8%);
+}
+
+.right-canvas-rail-button,
+.right-canvas-icon-button,
+.right-canvas-tab {
+ appearance: none;
+ border: 1px solid transparent;
+ color: var(--color-text);
+ font: inherit;
+ cursor: pointer;
+}
+
+.right-canvas-rail-button,
+.right-canvas-icon-button {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 34px;
+ height: 34px;
+ min-width: 34px;
+ min-height: 34px;
+ padding: 0;
+ border-radius: 7px;
+ background: transparent;
+ opacity: 0.76;
+ transition: background-color 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
+}
+
+.right-canvas-rail-button:hover,
+.right-canvas-icon-button:hover,
+.right-canvas-rail-button.is-active {
+ opacity: 1;
+ border-color: color-mix(in srgb, var(--color-primary) 28%, var(--right-canvas-border));
+ background: color-mix(in srgb, var(--color-background-hover) 72%, transparent);
+}
+
+.right-canvas-rail-button .material-symbols-outlined,
+.right-canvas-icon-button .material-symbols-outlined {
+ font-size: 19px;
+}
+
+.right-canvas-shell {
+ display: flex;
+ flex: 1 1 auto;
+ min-width: 0;
+ min-height: 0;
+ flex-direction: column;
+}
+
+.right-canvas-header {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ align-items: center;
+ gap: 8px;
+ min-height: 45px;
+ padding: 7px 8px 0 10px;
+ border-bottom: 1px solid var(--right-canvas-border);
+ background: color-mix(in srgb, var(--color-background) 91%, #000 9%);
+}
+
+.right-canvas-tabs {
+ display: flex;
+ align-items: end;
+ gap: 4px;
+ min-width: 0;
+ overflow-x: auto;
+ overflow-y: hidden;
+ scrollbar-width: thin;
+}
+
+.right-canvas-tabs::-webkit-scrollbar {
+ height: 4px;
+}
+
+.right-canvas-tabs::-webkit-scrollbar-track {
+ background: transparent;
+}
+
+.right-canvas-tabs::-webkit-scrollbar-thumb {
+ background: color-mix(in srgb, var(--color-border) 76%, transparent);
+ border-radius: 999px;
+}
+
+.right-canvas-tab {
+ display: inline-flex;
+ flex: 0 1 auto;
+ align-items: center;
+ gap: 7px;
+ min-width: 0;
+ height: 34px;
+ padding: 0 10px;
+ border-radius: 7px 7px 0 0;
+ background: transparent;
+ opacity: 0.7;
+ white-space: nowrap;
+ transition: border-color 0.16s ease, background-color 0.16s ease, opacity 0.16s ease;
+}
+
+.right-canvas-tab:hover,
+.right-canvas-tab.is-active {
+ opacity: 1;
+ border-color: var(--right-canvas-border);
+ background: color-mix(in srgb, var(--color-panel) 72%, transparent);
+}
+
+.right-canvas-tab .material-symbols-outlined {
+ flex: 0 0 auto;
+ font-size: 18px;
+}
+
+.right-canvas-tab-label {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ font-size: 0.84rem;
+ font-weight: 650;
+}
+
+.right-canvas-toolbar {
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ padding-bottom: 6px;
+}
+
+.right-canvas-panels {
+ position: relative;
+ display: flex;
+ flex: 1 1 auto;
+ min-width: 0;
+ min-height: 0;
+ overflow: hidden;
+ background: var(--right-canvas-surface);
+}
+
+.right-canvas-panels > x-extension {
+ display: contents;
+}
+
+.right-canvas-panels > x-extension > x-component {
+ display: contents;
+}
+
+.right-canvas-surface-panel {
+ display: flex;
+ flex: 1 1 auto;
+ width: 100%;
+ min-width: 0;
+ min-height: 0;
+ overflow: hidden;
+}
+
+.right-canvas-surface-panel > x-component,
+.right-canvas-surface-panel > x-component > div[x-data] {
+ display: flex;
+ flex: 1 1 auto;
+ width: 100%;
+ height: 100%;
+ min-width: 0;
+ min-height: 0;
+}
+
+.right-canvas-empty-state {
+ display: grid;
+ flex: 1 1 auto;
+ place-items: center;
+ align-content: center;
+ gap: 8px;
+ color: color-mix(in srgb, var(--color-text) 60%, transparent);
+}
+
+.right-canvas-empty-state .material-symbols-outlined {
+ font-size: 28px;
+}
+
+.right-canvas-resize-handle {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: -3px;
+ z-index: 3;
+ width: 7px;
+ cursor: col-resize;
+}
+
+body.right-canvas-overlay-mode .right-canvas {
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ height: 100%;
+ max-width: calc(100vw - 44px);
+ box-shadow: -16px 0 38px rgba(0, 0, 0, 0.34);
+ transform: translateX(100%);
+}
+
+body.right-canvas-overlay-mode .right-canvas.is-open {
+ transform: translateX(0);
+}
+
+body.right-canvas-overlay-mode .right-canvas.is-closed {
+ overflow: visible;
+}
+
+body.right-canvas-overlay-mode .right-canvas.is-closed .right-canvas-rail {
+ position: absolute;
+ right: 100%;
+ top: 50%;
+ height: auto;
+ max-height: 70vh;
+ transform: translateY(-50%);
+ border: 1px solid var(--right-canvas-border);
+ border-right: 0;
+ border-radius: 8px 0 0 8px;
+ box-shadow: -10px 0 30px rgba(0, 0, 0, 0.24);
+}
+
+body.right-canvas-overlay-mode .right-canvas-resize-handle {
+ display: none;
+}
+
+body.right-canvas-mobile-mode .right-canvas {
+ left: 0;
+ width: 100vw !important;
+ max-width: 100vw;
+ min-width: 100vw;
+ border-left: 0;
+}
+
+body.right-canvas-mobile-mode .right-canvas.is-closed {
+ transform: translateX(100%);
+}
+
+body.right-canvas-mobile-mode .right-canvas-rail {
+ display: none;
+}
+
+body.right-canvas-mobile-mode .right-canvas-header {
+ min-height: 48px;
+ padding: 7px 8px 0;
+}
+
+body.right-canvas-mobile-mode .right-canvas-tab {
+ min-width: 42px;
+ justify-content: center;
+ padding: 0 9px;
+}
+
+@media (max-width: 480px) {
+ .right-canvas-tab-label {
+ display: none;
+ }
+}
diff --git a/webui/components/canvas/right-canvas.html b/webui/components/canvas/right-canvas.html
new file mode 100644
index 000000000..fa8340643
--- /dev/null
+++ b/webui/components/canvas/right-canvas.html
@@ -0,0 +1,106 @@
+<html>
+<head>
+ <script type="module">
+ import { store } from "/components/canvas/right-canvas-store.js";
+ </script>
+</head>
+<body>
+ <div x-data>
+ <template x-if="$store.rightCanvas">
+ <aside
+ id="right-canvas"
+ class="right-canvas"
+ :class="{
+ 'is-open': $store.rightCanvas.isOpen,
+ 'is-closed': !$store.rightCanvas.isOpen,
+ 'is-overlay': $store.rightCanvas.isOverlayMode,
+ 'is-mobile': $store.rightCanvas.isMobileMode
+ }"
+ :style="$store.rightCanvas.widthStyle()"
+ x-init="$store.rightCanvas.init($el)"
+ x-effect="$store.rightCanvas.applyLayoutState()"
+ aria-label="Universal Canvas"
+ >
+ <div class="right-canvas-resize-handle" title="Resize canvas" @pointerdown="$store.rightCanvas.startResize($event)"></div>
+
+ <nav class="right-canvas-rail" aria-label="Canvas surfaces">
+ <template x-for="surface in $store.rightCanvas.surfaces" :key="surface.id">
+ <button
+ type="button"
+ class="right-canvas-rail-button"
+ :class="{ 'is-active': $store.rightCanvas.isSurfaceActive(surface.id) && $store.rightCanvas.isOpen }"
+ :title="surface.title"
+ :aria-label="surface.title"
+ @click="$store.rightCanvas.toggle(surface.id)"
+ >
+ <span class="material-symbols-outlined" x-text="surface.icon"></span>
+ </button>
+ </template>
+ </nav>
+
+ <section class="right-canvas-shell">
+ <x-extension id="right-canvas-shell-start"></x-extension>
+
+ <header class="right-canvas-header">
+ <div class="right-canvas-tabs" role="tablist" aria-label="Canvas tabs">
+ <x-extension id="right-canvas-tabs-start"></x-extension>
+ <template x-for="surface in $store.rightCanvas.surfaces" :key="surface.id">
+ <button
+ type="button"
+ class="right-canvas-tab"
+ role="tab"
+ :aria-selected="$store.rightCanvas.isSurfaceActive(surface.id).toString()"
+ :title="surface.title"
+ :class="{ 'is-active': $store.rightCanvas.isSurfaceActive(surface.id) }"
+ @click="$store.rightCanvas.open(surface.id)"
+ >
+ <span class="material-symbols-outlined" aria-hidden="true" x-text="surface.icon"></span>
+ <span class="right-canvas-tab-label" x-text="surface.title"></span>
+ </button>
+ </template>
+ <x-extension id="right-canvas-tabs-end"></x-extension>
+ </div>
+
+ <div class="right-canvas-toolbar" aria-label="Canvas toolbar">
+ <x-extension id="right-canvas-toolbar-start"></x-extension>
+ <button
+ type="button"
+ class="right-canvas-icon-button"
+ title="Open as window"
+ aria-label="Open as window"
+ x-show="$store.rightCanvas.currentSurfaceCanUndock()"
+ @click="$store.rightCanvas.undockActiveSurface()"
+ >
+ <span class="material-symbols-outlined">open_in_new</span>
+ </button>
+ <button
+ type="button"
+ class="right-canvas-icon-button"
+ title="Close canvas"
+ aria-label="Close canvas"
+ @click="$store.rightCanvas.close()"
+ >
+ <span class="material-symbols-outlined">close</span>
+ </button>
+ <x-extension id="right-canvas-toolbar-end"></x-extension>
+ </div>
+ </header>
+
+ <main class="right-canvas-panels">
+ <x-extension id="right-canvas-panels"></x-extension>
+ <template x-if="$store.rightCanvas.surfaces.length === 0">
+ <div class="right-canvas-empty-state">
+ <x-extension id="right-canvas-empty-state"></x-extension>
+ <span class="material-symbols-outlined">space_dashboard</span>
+ <span>Canvas</span>
+ </div>
+ </template>
+ </main>
+
+ <x-extension id="right-canvas-shell-end"></x-extension>
+ </section>
+ </aside>
+ </template>
+ </div>
+</body>
+</html>
diff --git a/webui/css/modals.css b/webui/css/modals.css
index a9b757e9f..df94a5655 100644
--- a/webui/css/modals.css
+++ b/webui/css/modals.css
@@ -78,9 +78,10 @@ some classes like modal-header are shared between the old and the new system */
/* Modal Header */
.modal-header {
display: grid;
- grid-template-columns: 40fr 0.5fr;
+ grid-template-columns: minmax(0, 1fr) auto auto;
align-items: center;
justify-content: space-between;
+ gap: 0.5rem;
padding: 0.5rem 1.5rem 0.5rem 2rem;
background-color: var(--color-background);
color: var(--color-primary);
@@ -88,6 +89,10 @@ some classes like modal-header are shared between the old and the new system */
}
.modal-header h2 {
margin: 0;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
/* Modal Subheader */
@@ -114,6 +119,34 @@ some classes like modal-header are shared between the old and the new system */
opacity: 1;
}
+.modal-dock-button {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 34px;
+ height: 34px;
+ min-width: 34px;
+ min-height: 34px;
+ padding: 0;
+ border: 1px solid transparent;
+ border-radius: 7px;
+ background: transparent;
+ color: var(--color-text);
+ cursor: pointer;
+ opacity: 0.72;
+ transition: background-color 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
+}
+
+.modal-dock-button:hover {
+ opacity: 1;
+ border-color: color-mix(in srgb, var(--color-primary) 28%, var(--color-border));
+ background: color-mix(in srgb, var(--color-background-hover) 72%, transparent);
+}
+
+.modal-dock-button .material-symbols-outlined {
+ font-size: 19px;
+}
+
/* Modal Description */
.modal-description {
padding: 0.8rem 1rem 0 1rem;
diff --git a/webui/index.css b/webui/index.css
index 1aeb95f1a..604475b20 100644
--- a/webui/index.css
+++ b/webui/index.css
@@ -137,6 +137,7 @@ html {
body {
overscroll-behavior: none;
-webkit-overscroll-behavior: none;
+ overflow-x: hidden;
}
x-extension:not(:empty) {
@@ -393,6 +394,8 @@ img {
display: -webkit-flex;
display: flex;
height: 100%;
+ min-width: 0;
+ overflow: hidden;
}
.panel {
@@ -408,9 +411,10 @@ img {
#right-panel {
display: -webkit-flex;
display: flex;
- width: 100%;
+ width: auto;
+ min-width: 0;
flex-direction: column;
- flex-grow: 1;
+ flex: 1 1 0;
-webkit-transition: margin-left var(--transition-speed) ease-in-out;
transition: margin-left var(--transition-speed) ease-in-out;
}
@@ -477,7 +481,8 @@ div#right-panel::-webkit-scrollbar-thumb:hover {
#time-date-container {
z-index: 1000;
- position: fixed;
+ position: absolute;
+ top: 0;
right: var(--spacing-md);
display: flex;
align-items: center;
@@ -1684,4 +1689,4 @@ body *::-webkit-scrollbar-thumb:active {
.light-mode *::-webkit-scrollbar-thumb:active {
background-color: #8a8a8a;
-}
\ No newline at end of file
+}
diff --git a/webui/index.html b/webui/index.html
index abb457f12..46712c2db 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -19,6 +19,7 @@
<link rel="stylesheet" href="css/notification.css">
<link rel="stylesheet" href="css/buttons.css">
<link rel="stylesheet" href="css/tables.css">
+ <link rel="stylesheet" href="components/canvas/right-canvas.css">
<!-- Flatpickr for datetime picker -->
<link rel="stylesheet" href="vendor/flatpickr/flatpickr.min.css">
@@ -139,7 +140,8 @@
<x-component path="chat/input/chat-bar.html"></x-component>
</div>
</div>
- </div>
+ <x-component path="canvas/right-canvas.html"></x-component>
+ </div>
<!-- Drag and Drop Overlay Component -->
<x-component path="chat/attachments/dragDropOverlay.html"></x-component>
diff --git a/webui/js/modals.js b/webui/js/modals.js
index a3076b2fe..fb53f9441 100644
--- a/webui/js/modals.js
+++ b/webui/js/modals.js
@@ -56,6 +56,8 @@ function modalSuppressesBackdrop(modal) {
const path = String(modal?.path || "");
return path === "/plugins/_browser/webui/main.html"
|| path === "plugins/_browser/webui/main.html"
+ || path === "/plugins/_office/webui/main.html"
+ || path === "plugins/_office/webui/main.html"
|| modal?.element?.classList?.contains("modal-floating")
|| modal?.element?.classList?.contains("modal-no-backdrop")
|| modal?.inner?.classList?.contains("modal-no-backdrop");
@@ -151,6 +153,7 @@ function createModalElement(path) {
path: path,
element: newModal,
title: newModal.querySelector(".modal-title"),
+ header: newModal.querySelector(".modal-header"),
body: newModal.querySelector(".modal-bd"),
close: close_button,
footerSlot: newModal.querySelector(".modal-footer-slot"),
@@ -162,6 +165,43 @@ function createModalElement(path) {
};
}
+function getDockMetadata(doc, modalPath) {
+ const htmlDataset = doc?.documentElement?.dataset || {};
+ const bodyDataset = doc?.body?.dataset || {};
+ const surfaceId = htmlDataset.canvasSurface || bodyDataset.canvasSurface || "";
+ if (!surfaceId) return null;
+ return {
+ surfaceId,
+ modalPath: htmlDataset.canvasModalPath || bodyDataset.canvasModalPath || modalPath,
+ title: htmlDataset.canvasDockTitle || bodyDataset.canvasDockTitle || "Open in canvas",
+ icon: htmlDataset.canvasDockIcon || bodyDataset.canvasDockIcon || "dock_to_right",
+ };
+}
+
+function configureModalDockButton(modal, doc) {
+ const metadata = getDockMetadata(doc, modal.path);
+ if (!metadata || !modal.header || modal.header.querySelector(".modal-dock-button")) {
+ return;
+ }
+
+ const button = document.createElement("button");
+ button.type = "button";
+ button.className = "modal-dock-button";
+ button.title = metadata.title;
+ button.setAttribute("aria-label", metadata.title);
+ button.innerHTML = `<span class="material-symbols-outlined" aria-hidden="true">${metadata.icon}</span>`;
+ button.addEventListener("click", async () => {
+ const canvas = globalThis.Alpine?.store?.("rightCanvas")
+ || (await import("/components/canvas/right-canvas-store.js")).store;
+ await canvas?.dockSurface?.(metadata.surfaceId, {
+ modalPath: metadata.modalPath,
+ source: "modal",
+ });
+ });
+
+ modal.close?.insertAdjacentElement("beforebegin", button);
+}
+
// Function to open modal with content from URL
export async function openModal(modalPath, beforeClose = null) {
const openCtx = { modalPath, modal: null, cancel: false };
@@ -208,6 +248,8 @@ export async function openModal(modalPath, beforeClose = null) {
if (doc.body && doc.body.classList) {
modal.body.classList.add(...doc.body.classList);
}
+ configureModalDockButton(modal, doc);
+ updateModalZIndexes();
// Some modals have a footer. Check if it exists and move it to footer slot
// Use requestAnimationFrame to let Alpine mount the component first