diff --git a/src/compose_farm/web/static/app.js b/src/compose_farm/web/static/app.js index ba065de..0fac750 100644 --- a/src/compose_farm/web/static/app.js +++ b/src/compose_farm/web/static/app.js @@ -523,9 +523,15 @@ function playFabIntro() { let originalTheme = null; // Store theme when palette opens for preview/restore const post = (url) => () => htmx.ajax('POST', url, {swap: 'none'}); - const nav = (url) => () => { + const nav = (url, afterNav) => () => { + // Set hash before HTMX swap so inline scripts can read it + const hashIndex = url.indexOf('#'); + if (hashIndex !== -1) { + window.location.hash = url.substring(hashIndex); + } htmx.ajax('GET', url, {target: '#main-content', select: '#main-content', swap: 'outerHTML'}).then(() => { history.pushState({}, '', url); + afterNav?.(); }); }; // Navigate to dashboard (if needed) and trigger action @@ -573,6 +579,7 @@ function playFabIntro() { cmd('app', 'Theme', 'Change color theme', openThemePicker, icons.palette), cmd('app', 'Dashboard', 'Go to dashboard', nav('/'), icons.home), cmd('app', 'Console', 'Go to console', nav('/console'), icons.terminal), + cmd('app', 'Edit Config', 'Edit compose-farm.yaml', nav('/console#editor'), icons.file_code), cmd('app', 'Docs', 'Open documentation', openExternal('https://compose-farm.nijho.lt/'), icons.book_open), ]; diff --git a/src/compose_farm/web/templates/console.html b/src/compose_farm/web/templates/console.html index 33c6a79..98d0516 100644 --- a/src/compose_farm/web/templates/console.html +++ b/src/compose_farm/web/templates/console.html @@ -97,7 +97,10 @@ function connectConsole() { consoleWs.onopen = () => { statusEl.textContent = `Connected to ${host}`; sendSize(term.cols, term.rows); - term.focus(); + // Focus terminal unless #editor hash is present (command palette Edit Config) + if (window.location.hash !== '#editor') { + term.focus(); + } // Auto-load the default file once editor is ready const pathInput = document.getElementById('console-file-path'); if (pathInput && pathInput.value) { @@ -133,6 +136,14 @@ function initConsoleEditor() { loadMonaco(() => { consoleEditor = createEditor(editorEl, '', 'plaintext', { onSave: saveFile }); + // Focus editor if #editor hash is present (command palette Edit Config) + if (window.location.hash === '#editor') { + // Small delay for Monaco to fully initialize before focusing + setTimeout(() => { + consoleEditor.focus(); + editorEl.scrollIntoView({ behavior: 'smooth', block: 'center' }); + }, 100); + } }); } diff --git a/src/compose_farm/web/templates/partials/command_palette.html b/src/compose_farm/web/templates/partials/command_palette.html index 707afaf..8f505bb 100644 --- a/src/compose_farm/web/templates/partials/command_palette.html +++ b/src/compose_farm/web/templates/partials/command_palette.html @@ -1,4 +1,4 @@ -{% from "partials/icons.html" import search, play, square, rotate_cw, cloud_download, refresh_cw, file_text, check, home, terminal, box, palette, book_open %} +{% from "partials/icons.html" import search, play, square, rotate_cw, cloud_download, refresh_cw, file_text, file_code, check, home, terminal, box, palette, book_open %}