Agent Zero AI framework
Add Office file tabs and session closing
Alessandro67bfd3e35093
diff --git a/plugins/_office/api/office_session.py b/plugins/_office/api/office_session.pyindex 8a15f68ca..b7f96b823 100644--- a/plugins/_office/api/office_session.py+++ b/plugins/_office/api/office_session.py@@ -24,6 +24,14 @@ class OfficeSession(ApiHandler):return {"ok": True, **collabora_status.read_status()}if action == "recent":return {"ok": True, "documents": wopi_store.get_recent_documents()}+ if action == "open_documents":+ return {"ok": True, "documents": wopi_store.get_open_documents(limit=24)}+ if action == "close":+ closed = wopi_store.close_session(+ session_id=str(input.get("session_id") or ""),+ file_id=str(input.get("file_id") or ""),+ )+ return {"ok": True, "closed": closed, "documents": wopi_store.get_open_documents(limit=24)}if action == "create":doc = wopi_store.create_document(kind=str(input.get("kind") or "document"),@@ -34,7 +42,12 @@ class OfficeSession(ApiHandler):)return await self._open_document(doc, input, request)if action == "open":- doc = wopi_store.register_document(str(input.get("path") or ""))+ file_id = str(input.get("file_id") or "").strip()+ doc = (+ wopi_store.get_document(file_id)+ if file_id+ else wopi_store.register_document(str(input.get("path") or ""))+ )return await self._open_document(doc, input, request)return {"ok": False, "error": f"Unsupported office session action: {action}"}@@ -74,6 +87,7 @@ class OfficeSession(ApiHandler):return {"ok": True,"file_id": doc["file_id"],+ "session_id": session["session_id"],"iframe_action": iframe_action,"access_token": session["access_token"],"access_token_ttl": session["access_token_ttl"],diff --git a/plugins/_office/helpers/wopi_store.py b/plugins/_office/helpers/wopi_store.pyindex d7a738727..96aacce7e 100644--- a/plugins/_office/helpers/wopi_store.py+++ b/plugins/_office/helpers/wopi_store.py@@ -221,6 +221,7 @@ def get_recent_documents(limit: int = 12) -> list[dict[str, Any]]:def get_open_documents(limit: int = 6) -> list[dict[str, Any]]:with connect() as conn:+ _clear_expired_sessions(conn)rows = conn.execute("""SELECT@@ -240,6 +241,38 @@ def get_open_documents(limit: int = 6) -> list[dict[str, Any]]:return [dict(row) for row in rows]+def close_session(session_id: str = "", file_id: str = "") -> int:+ session_id = str(session_id or "").strip()+ file_id = str(file_id or "").strip()+ if not session_id and not file_id:+ return 0++ with connect() as conn:+ _clear_expired_sessions(conn)+ if session_id:+ row = conn.execute("SELECT * FROM sessions WHERE session_id = ?", (session_id,)).fetchone()+ if not row:+ return 0+ conn.execute("DELETE FROM tokens WHERE session_id = ?", (session_id,))+ conn.execute("DELETE FROM sessions WHERE session_id = ?", (session_id,))+ conn.execute("DELETE FROM locks WHERE session_id = ?", (session_id,))+ conn.execute(+ "INSERT INTO events (file_id, event_type, payload, created_at) VALUES (?, ?, ?, ?)",+ (row["file_id"], "close_session", json.dumps({"session_id": session_id}), now()),+ )+ return 1++ rows = conn.execute("SELECT session_id FROM sessions WHERE file_id = ?", (file_id,)).fetchall()+ conn.execute("DELETE FROM tokens WHERE file_id = ?", (file_id,))+ conn.execute("DELETE FROM sessions WHERE file_id = ?", (file_id,))+ conn.execute("DELETE FROM locks WHERE file_id = ?", (file_id,))+ conn.execute(+ "INSERT INTO events (file_id, event_type, payload, created_at) VALUES (?, ?, ?, ?)",+ (file_id, "close_document_sessions", json.dumps({"closed": len(rows)}), now()),+ )+ return len(rows)++def create_session(file_id: str, user_id: str, permission: str, origin: str, ttl_seconds: int = DEFAULT_TTL_SECONDS) -> dict[str, Any]:permission = "write" if permission == "write" else "read"token = secrets.token_urlsafe(32)@@ -493,6 +526,13 @@ def _clear_expired_locks(conn: sqlite3.Connection) -> None:conn.execute("DELETE FROM locks WHERE expires_at < ?", (now(),))+def _clear_expired_sessions(conn: sqlite3.Connection) -> None:+ current = now()+ conn.execute("DELETE FROM tokens WHERE expires_at < ?", (current,))+ conn.execute("DELETE FROM sessions WHERE expires_at < ?", (current,))+ conn.execute("DELETE FROM locks WHERE expires_at < ?", (current,))++def _record_version(conn: sqlite3.Connection, file_id: str, path: Path, version: str, data: bytes) -> None:if not data:returndiff --git a/plugins/_office/webui/office-panel.html b/plugins/_office/webui/office-panel.htmlindex 957949601..5a3e69766 100644--- a/plugins/_office/webui/office-panel.html+++ b/plugins/_office/webui/office-panel.html@@ -38,11 +38,49 @@<button type="button" class="office-icon-button" title="Save" @click="$store.office.save()" :disabled="!$store.office.session"><span class="material-symbols-outlined">save</span></button>+ <button+ type="button"+ class="office-icon-button"+ title="Close file"+ aria-label="Close file"+ :disabled="!$store.office.session"+ @click="$confirmClick($event, () => $store.office.closeFile())"+ >+ <span class="material-symbols-outlined">close</span>+ </button><button type="button" class="office-icon-button" title="Refresh status" @click="$store.office.refresh()"><span class="material-symbols-outlined">refresh</span></button></div>+ <div class="office-tabs" x-show="$store.office.tabs.length" role="tablist" aria-label="Open Office files" style="display: none;">+ <template x-for="tab in $store.office.tabs" :key="tab.tab_id">+ <div class="office-tab-shell" :class="{ 'is-active': $store.office.isActiveTab(tab) }">+ <button+ type="button"+ class="office-tab"+ role="tab"+ :aria-selected="$store.office.isActiveTab(tab).toString()"+ :title="$store.office.tabLabel(tab)"+ @click="$store.office.selectTab(tab.tab_id)"+ >+ <span class="material-symbols-outlined office-tab-icon" aria-hidden="true" x-text="$store.office.tabIcon(tab)"></span>+ <span class="office-tab-title" x-text="$store.office.tabTitle(tab)"></span>+ </button>+ <button+ type="button"+ class="office-tab-close"+ :title="'Close ' + $store.office.tabLabel(tab)"+ :aria-label="'Close ' + $store.office.tabLabel(tab)"+ :disabled="$store.office.loading"+ @click.stop="$confirmClick($event, () => $store.office.closeTab(tab.tab_id))"+ >+ <span class="material-symbols-outlined">close</span>+ </button>+ </div>+ </template>+ </div>+<div class="office-status-line" x-show="$store.office.message || $store.office.error || $store.office.loading" style="display: none;"><span class="material-symbols-outlined" :class="{ spinning: $store.office.loading }" x-text="$store.office.loading ? 'progress_activity' : ($store.office.error ? 'error' : 'check_circle')"></span><span x-text="$store.office.error || $store.office.message || 'Working...'"></span>@@ -85,11 +123,27 @@<span>Presentation</span></button></div>+ <div class="office-recent" x-show="$store.office.openDocuments.length">+ <div class="office-list-label">Open files</div>+ <template x-for="doc in $store.office.openDocuments" :key="doc.file_id">+ <button type="button" class="office-recent-row" :title="doc.path" @click="$store.office.openPath(doc.path)">+ <span class="material-symbols-outlined" x-text="$store.office.tabIcon(doc)"></span>+ <span class="office-recent-text">+ <span x-text="$store.office.openDocumentLabel(doc)"></span>+ <small x-text="$store.office.openDocumentMeta(doc)"></small>+ </span>+ </button>+ </template>+ </div><div class="office-recent" x-show="$store.office.recent.length">+ <div class="office-list-label">Recent files</div><template x-for="doc in $store.office.recent" :key="doc.file_id"><button type="button" class="office-recent-row" :title="doc.path" @click="$store.office.openPath(doc.path)">- <span class="material-symbols-outlined">description</span>- <span x-text="doc.basename"></span>+ <span class="material-symbols-outlined" x-text="$store.office.tabIcon(doc)"></span>+ <span class="office-recent-text">+ <span x-text="doc.basename"></span>+ <small x-text="String(doc.extension || '').toUpperCase()"></small>+ </span></button></template></div>@@ -140,6 +194,14 @@background: color-mix(in srgb, var(--color-background) 94%, #000 6%);}+ .modal.modal-floating {+ pointer-events: none;+ }++ .modal.modal-floating .modal-inner {+ pointer-events: auto;+ }+.modal-inner.office-modal .modal-header {min-height: 34px;padding: 0.35rem 0.75rem 0.35rem 1rem;@@ -200,6 +262,136 @@overflow-x: auto;}+ .office-tabs {+ --office-tab-height: 34px;+ --office-tab-close-size: 27px;+ display: flex;+ align-items: end;+ gap: 4px;+ min-height: 39px;+ min-width: 0;+ padding: 5px 9px 0;+ border-bottom: 1px solid color-mix(in srgb, var(--color-border) 58%, transparent);+ background: color-mix(in srgb, var(--color-background) 92%, #000 8%);+ overflow-x: auto;+ overflow-y: hidden;+ scrollbar-width: thin;+ }++ .office-tabs::-webkit-scrollbar {+ height: 4px;+ }++ .office-tabs::-webkit-scrollbar-track {+ background: transparent;+ }++ .office-tabs::-webkit-scrollbar-thumb {+ background: color-mix(in srgb, var(--color-border) 76%, transparent);+ border-radius: 999px;+ }++ .office-tab-shell {+ flex: 0 1 220px;+ position: relative;+ display: grid;+ grid-template-columns: minmax(0, 1fr) var(--office-tab-close-size);+ align-items: center;+ gap: 3px;+ min-width: 132px;+ max-width: 260px;+ height: var(--office-tab-height);+ padding: 0 6px 0 10px;+ border: 1px solid transparent;+ border-radius: 7px 7px 0 0;+ opacity: 0.72;+ transition: border-color 0.16s ease, opacity 0.16s ease, background-color 0.16s ease;+ }++ .office-tab-shell:hover,+ .office-tab-shell:focus-within {+ opacity: 0.94;+ border-color: color-mix(in srgb, var(--color-border) 78%, transparent);+ }++ .office-tab-shell.is-active {+ z-index: 2;+ margin-bottom: -1px;+ opacity: 1;+ border-color: color-mix(in srgb, var(--color-border) 68%, transparent);+ background: color-mix(in srgb, var(--color-panel) 72%, transparent);+ }++ .office-tab,+ .office-tab-close {+ appearance: none;+ border: 0;+ background: transparent;+ color: inherit;+ font: inherit;+ cursor: pointer;+ }++ .office-tab {+ display: inline-flex;+ align-items: center;+ justify-content: flex-start;+ gap: 8px;+ min-width: 0;+ width: 100%;+ height: 100%;+ padding: 0;+ text-align: left;+ }++ .office-tab-icon {+ flex: 0 0 auto;+ color: color-mix(in srgb, var(--color-text) 72%, var(--color-primary) 28%);+ font-size: 18px;+ line-height: 1;+ }++ .office-tab-title {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ font-size: 0.84rem;+ font-weight: 650;+ }++ .office-tab-close {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: var(--office-tab-close-size);+ min-width: var(--office-tab-close-size);+ height: var(--office-tab-close-size);+ min-height: var(--office-tab-close-size);+ padding: 0;+ border-radius: 6px;+ color: color-mix(in srgb, var(--color-text) 52%, var(--color-primary) 48%);+ opacity: 0.74;+ }++ .office-tab-close:hover,+ .office-tab-close.confirming {+ opacity: 1;+ background: color-mix(in srgb, var(--color-background-hover) 70%, transparent);+ color: var(--color-text);+ }++ .office-tab-close:focus-visible,+ .office-tab:focus-visible {+ outline: 1px solid color-mix(in srgb, var(--color-primary) 70%, transparent);+ outline-offset: 1px;+ }++ .office-tab-close .material-symbols-outlined {+ font-size: 15px;+ line-height: 1;+ }+.office-toolbar-spacer {flex: 1 1 auto;min-width: 8px;@@ -392,6 +584,14 @@max-width: 720px;}+ .office-list-label {+ margin-top: 2px;+ color: var(--color-text-muted);+ font-size: 0.76rem;+ font-weight: 650;+ text-transform: uppercase;+ }+.office-recent-row {justify-content: flex-start;min-height: 36px;@@ -399,12 +599,25 @@text-align: left;}- .office-recent-row span:last-child {+ .office-recent-text {+ display: grid;+ min-width: 0;+ gap: 1px;+ line-height: 1.2;+ }++ .office-recent-text > span,+ .office-recent-text > small {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}+ .office-recent-text > small {+ color: var(--color-text-muted);+ font-size: 0.72rem;+ }+.office-frame-wrap {display: flex;position: absolute;@@ -443,6 +656,10 @@.office-health-pill span:last-child {display: none;}+ .office-tab-shell {+ flex-basis: 152px;+ min-width: 116px;+ }.office-create-tile {min-width: 104px;}@@ -455,6 +672,10 @@.office-health-pill span:last-child {display: none;}+ .office-tab-shell {+ flex-basis: 152px;+ min-width: 116px;+ }.office-create-tile {min-width: 104px;}diff --git a/plugins/_office/webui/office-store.js b/plugins/_office/webui/office-store.jsindex 8f24f7e6b..530e1a2ca 100644--- a/plugins/_office/webui/office-store.js+++ b/plugins/_office/webui/office-store.js@@ -23,10 +23,39 @@ function parseMessage(data) {return data && typeof data === "object" ? data : {};}+function nextAnimationFrame() {+ return new Promise((resolve) => {+ const schedule = globalThis.requestAnimationFrame || ((callback) => globalThis.setTimeout(callback, 16));+ schedule(() => resolve());+ });+}++function normalizeTabId(value) {+ return String(value || "").trim();+}++function makeTabId(session) {+ return normalizeTabId(session?.session_id)+ || normalizeTabId(session?.file_id)+ || `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;+}++function sameDocument(left = {}, right = {}) {+ const leftFileId = normalizeTabId(left.file_id);+ const rightFileId = normalizeTabId(right.file_id);+ if (leftFileId && rightFileId) return leftFileId === rightFileId;+ const leftPath = String(left.path || "").trim();+ const rightPath = String(right.path || "").trim();+ return Boolean(leftPath && rightPath && leftPath === rightPath);+}+const model = {status: null,logs: null,recent: [],+ openDocuments: [],+ tabs: [],+ activeTabId: "",session: null,loading: false,error: "",@@ -42,6 +71,7 @@ const model = {_frameOrigin: "",_mode: "canvas",_floatingCleanup: null,+ _saveWaiters: [],async init(element = null) {return await this.onMount(element, { mode: "canvas" });@@ -62,6 +92,7 @@ const model = {this.setupCanvasSurface(element);}await this.refresh();+ this.ensureActiveTab();if (this.session && this._root) {await this.restartFrameLoad();}@@ -69,8 +100,13 @@ const model = {async onOpen(payload = {}) {await this.refresh();- if (payload?.path) {- await this.openPath(payload.path);+ if (payload?.path || payload?.file_id) {+ await this.openSession({+ action: "open",+ path: payload.path || "",+ file_id: payload.file_id || "",+ mode: "edit",+ });} else if (this.session && !this.frameReady) {await this.restartFrameLoad();}@@ -89,6 +125,8 @@ const model = {this.status = await callJsonApi("/plugins/_office/office_session", { action: "status" });const recent = await callJsonApi("/plugins/_office/office_session", { action: "recent" });this.recent = recent?.documents || [];+ const openDocuments = await callJsonApi("/plugins/_office/office_session", { action: "open_documents" });+ this.openDocuments = openDocuments?.documents || [];if (!this.status?.healthy) {const logs = await callJsonApi("/plugins/_office/collabora_logs", {});this.logs = logs;@@ -134,6 +172,7 @@ const model = {this.error = "";this.message = "";try {+ await this.save({ wait: true, timeoutMs: 900 });await this.prepareBrowserHostForEditor();const response = await callJsonApi("/plugins/_office/office_session", payload);if (!response?.ok) {@@ -141,14 +180,7 @@ const model = {if (response?.status) this.status = response.status;return;}- this.clearFrameTimers();- this.session = response;- this.frameReady = false;- this._frameOrigin = "";- this._frameAttempt = 0;- this._frameRecoveryTried = false;- await this.submitFrame();- this.scheduleFrameWatch();+ await this.activateSession(response);await this.refresh();} catch (error) {this.error = error instanceof Error ? error.message : String(error);@@ -157,8 +189,32 @@ const model = {}},+ async activateSession(response) {+ const tab = this.normalizeTab(response);+ const existingIndex = this.findTabIndexForSession(tab);+ if (existingIndex >= 0) {+ const previous = this.tabs[existingIndex];+ if (previous?.session_id && previous.session_id !== tab.session_id) {+ await this.closeBackendSession(previous);+ }+ this.tabs.splice(existingIndex, 1, tab);+ } else {+ this.tabs.push(tab);+ }+ this.activeTabId = tab.tab_id;+ this.syncActiveSession();+ this.frameReady = false;+ this._frameOrigin = "";+ this._frameAttempt = 0;+ this._frameRecoveryTried = false;+ this.clearFrameTimers();+ await this.submitFrame();+ this.scheduleFrameWatch();+ },+async submitFrame() {- await new Promise((resolve) => requestAnimationFrame(resolve));+ await nextAnimationFrame();+ this.syncActiveSession();const session = this.session;const frame = this.activeFrame();if (!session || !frame?.name) return;@@ -185,6 +241,8 @@ const model = {},async restartFrameLoad() {+ this.syncActiveSession();+ if (!this.session) return;this.frameReady = false;this._frameOrigin = "";this._frameAttempt = 0;@@ -254,24 +312,192 @@ const model = {frame?.contentWindow?.postMessage(JSON.stringify(message), targetOrigin);},- save() {- this.postToFrame({- MessageId: "Action_Save",- Values: {- DontTerminateEdit: true,- DontSaveIfUnmodified: true,- },+ async save(options = {}) {+ const { wait = false, timeoutMs = 1500 } = options;+ if (!this.session || !this.activeFrame() || !this.frameReady) return true;+ if (!wait) {+ this.postToFrame({+ MessageId: "Action_Save",+ Values: {+ DontTerminateEdit: true,+ DontSaveIfUnmodified: true,+ },+ });+ return true;+ }+ return await new Promise((resolve) => {+ const timeout = globalThis.setTimeout(() => {+ this._saveWaiters = this._saveWaiters.filter((waiter) => waiter !== done);+ resolve(false);+ }, timeoutMs);+ const done = (ok) => {+ globalThis.clearTimeout(timeout);+ resolve(ok);+ };+ this._saveWaiters.push(done);+ this.postToFrame({+ MessageId: "Action_Save",+ Values: {+ DontTerminateEdit: true,+ DontSaveIfUnmodified: true,+ },+ });});},+ resolveSaveWaiters(ok = true) {+ const waiters = this._saveWaiters.splice(0);+ for (const waiter of waiters) waiter(ok);+ },+closeFile() {- this.save();- this.session = null;- this.frameReady = false;- this._frameOrigin = "";- this._frameAttempt = 0;- this._frameRecoveryTried = false;- this.clearFrameTimers();+ return this.closeTab(this.activeTabId);+ },++ blankFrame() {+ const frame = this.activeFrame();+ if (frame) {+ frame.src = "about:blank";+ }+ },++ async closeTab(tabId = this.activeTabId, options = {}) {+ const normalized = normalizeTabId(tabId);+ const index = this.tabs.findIndex((tab) => tab.tab_id === normalized);+ if (index < 0) return;++ const tab = this.tabs[index];+ const wasActive = tab.tab_id === this.activeTabId;+ if (wasActive && !options.skipSave) {+ await this.save({ wait: true, timeoutMs: 1200 });+ }+ await this.closeBackendSession(tab);+ this.tabs.splice(index, 1);++ if (!this.tabs.length) {+ this.activeTabId = "";+ this.session = null;+ this.frameReady = false;+ this._frameOrigin = "";+ this._frameAttempt = 0;+ this._frameRecoveryTried = false;+ this.clearFrameTimers();+ this.blankFrame();+ await this.refresh();+ return;+ }++ if (wasActive) {+ const nextTab = this.tabs[Math.min(index, this.tabs.length - 1)];+ this.activeTabId = nextTab.tab_id;+ this.syncActiveSession();+ await this.restartFrameLoad();+ } else {+ this.syncActiveSession();+ }+ await this.refresh();+ },++ async closeBackendSession(tab) {+ if (!tab?.session_id && !tab?.file_id) return;+ try {+ await callJsonApi("/plugins/_office/office_session", {+ action: "close",+ session_id: tab.session_id || "",+ file_id: tab.session_id ? "" : (tab.file_id || ""),+ });+ } catch (error) {+ console.warn("Office session close skipped", error);+ }+ },++ async selectTab(tabId) {+ const tab = this.tabById(tabId);+ if (!tab) return;+ if (tab.tab_id === this.activeTabId && this.session) return;+ await this.save({ wait: true, timeoutMs: 900 });+ this.activeTabId = tab.tab_id;+ this.syncActiveSession();+ await this.restartFrameLoad();+ },++ normalizeTab(session) {+ const tabId = makeTabId(session);+ return {+ ...session,+ tab_id: tabId,+ session_id: normalizeTabId(session?.session_id) || tabId,+ title: String(session?.title || session?.basename || session?.path || "Office file"),+ opened_at: session?.opened_at || Date.now(),+ };+ },++ findTabIndexForSession(session) {+ return this.tabs.findIndex((tab) => sameDocument(tab, session));+ },++ tabById(tabId) {+ const normalized = normalizeTabId(tabId);+ return this.tabs.find((tab) => tab.tab_id === normalized) || null;+ },++ activeTab() {+ return this.tabById(this.activeTabId) || this.tabs[0] || null;+ },++ ensureActiveTab() {+ if (!this.tabs.length) {+ this.activeTabId = "";+ this.session = null;+ return;+ }+ if (!this.tabById(this.activeTabId)) {+ this.activeTabId = this.tabs[0].tab_id;+ }+ this.syncActiveSession();+ },++ syncActiveSession() {+ this.session = this.activeTab();+ },++ isActiveTab(tab) {+ return Boolean(tab?.tab_id && tab.tab_id === this.activeTabId);+ },++ tabTitle(tab) {+ const title = String(tab?.title || tab?.basename || "").trim();+ if (title) return title;+ const path = String(tab?.path || "").trim();+ return path.split("/").filter(Boolean).pop() || "Office file";+ },++ tabLabel(tab) {+ const extension = String(tab?.extension || "").trim().toUpperCase();+ return extension ? `${this.tabTitle(tab)} (${extension})` : this.tabTitle(tab);+ },++ tabIcon(tab) {+ const extension = String(tab?.extension || "").toLowerCase();+ if (["xlsx", "ods"].includes(extension)) return "table_chart";+ if (["pptx", "odp"].includes(extension)) return "co_present";+ if (["docx", "odt"].includes(extension)) return "article";+ return "description";+ },++ openDocumentLabel(doc) {+ const basename = String(doc?.basename || doc?.title || "").trim();+ const path = String(doc?.path || "").trim();+ return basename || path.split("/").filter(Boolean).pop() || "Office file";+ },++ openDocumentMeta(doc) {+ const sessions = Number(doc?.open_sessions || 0);+ const extension = String(doc?.extension || "").trim().toUpperCase();+ return [+ extension,+ sessions ? `${sessions} session${sessions === 1 ? "" : "s"}` : "",+ ].filter(Boolean).join(" / ");},onPostMessage(event) {@@ -287,9 +513,11 @@ const model = {if (this.message === "Still opening the editor... trying a fresh editor load.") this.message = "";this.postToFrame({ MessageId: "Host_PostmessageReady" });} else if (id === "UI_Close") {- this.session = null;+ void this.closeTab(this.activeTabId, { skipSave: true });} else if (id === "Action_Save_Resp") {- this.message = message.Values?.success === false ? "Save did not complete." : "Saved";+ const ok = message.Values?.success !== false;+ this.message = ok ? "Saved" : "Save did not complete.";+ this.resolveSaveWaiters(ok);}},diff --git a/tests/test_office_wopi_store.py b/tests/test_office_wopi_store.pyindex 279d16e49..890f853df 100644--- a/tests/test_office_wopi_store.py+++ b/tests/test_office_wopi_store.py@@ -86,6 +86,26 @@ def test_lock_conflicts_refresh_unlock_and_relock(office_state):assert current == ""+def test_close_session_revokes_token_lock_and_open_document_metadata(office_state):+ doc = wopi_store.create_document("document", "Close Test", "docx", "")+ session = wopi_store.create_session(doc["file_id"], "user-a", "write", "http://localhost:32080")+ ok, current = wopi_store.lock(doc["file_id"], "close-lock", session["session_id"], 120)+ assert ok is True+ assert current == "close-lock"++ open_docs = wopi_store.get_open_documents()+ assert len(open_docs) == 1+ assert open_docs[0]["file_id"] == doc["file_id"]+ assert open_docs[0]["open_sessions"] == 1++ assert wopi_store.close_session(session_id=session["session_id"]) == 1+ assert wopi_store.get_open_documents() == []+ assert wopi_store.get_lock(doc["file_id"]) == ""+ with pytest.raises(PermissionError):+ wopi_store.validate_token(session["access_token"], doc["file_id"])+ assert wopi_store.close_session(session_id=session["session_id"]) == 0++def test_put_file_requires_lock_and_updates_version_history(office_state):doc = wopi_store.create_document("document", "Save Test", "docx", "before")session = wopi_store.create_session(doc["file_id"], "user-a", "write", "http://localhost:32080")diff --git a/webui/components/canvas/right-canvas.css b/webui/components/canvas/right-canvas.cssindex 0360c0bfd..67248a7c9 100644--- a/webui/components/canvas/right-canvas.css+++ b/webui/components/canvas/right-canvas.css@@ -316,6 +316,10 @@ body.right-canvas-mobile-mode .right-canvas.is-closed {}body.right-canvas-mobile-mode .right-canvas-rail {+ display: flex;+}++body.right-canvas-mobile-mode .right-canvas.is-open .right-canvas-rail {display: none;}