feat: hide Orch tab when orchestration is not enabled
- serveIndex injects <script>var ORCH_ENABLED=true;</script> before </head> when orchBroadcaster is non-nil (i.e. --orchestration active) - JS hides the Orch tab button and panel when ORCH_ENABLED is falsy, and sets --tab-count CSS var to 6 so the indicator pill stays correct - tab indicator width uses var(--tab-count, 7) — defaults to 7 when orchestration is enabled, falls back to 6 otherwise - No extra API endpoint or network request needed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
603b49e513
commit
43126abf08
2 changed files with 15 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/sipeed/picoclaw/pkg/orch"
|
"github.com/sipeed/picoclaw/pkg/orch"
|
||||||
|
|
@ -86,6 +87,9 @@ func (h *Handler) serveIndex(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
|
if h.orchBroadcaster != nil {
|
||||||
|
data = []byte(strings.Replace(string(data), "</head>", "<script>var ORCH_ENABLED=true;</script></head>", 1))
|
||||||
|
}
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
top: 2px;
|
top: 2px;
|
||||||
bottom: 2px;
|
bottom: 2px;
|
||||||
left: 2px;
|
left: 2px;
|
||||||
width: calc(100%/7 - 2px);
|
width: calc(100% / var(--tab-count, 7) - 2px);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: var(--tab-pill-bg);
|
background: var(--tab-pill-bg);
|
||||||
box-shadow: 0 0.5px 2px rgba(0,0,0,0.12), 0 0.5px 1px rgba(0,0,0,0.08);
|
box-shadow: 0 0.5px 2px rgba(0,0,0,0.12), 0 0.5px 1px rgba(0,0,0,0.08);
|
||||||
|
|
@ -941,8 +941,17 @@ let initData = tg.initData || '';
|
||||||
let selectedSkill = null;
|
let selectedSkill = null;
|
||||||
var lastSSE = { plan: 0, skills: 0, session: 0, dev: 0 };
|
var lastSSE = { plan: 0, skills: 0, session: 0, dev: 0 };
|
||||||
|
|
||||||
|
// Hide Orch tab when orchestration is not enabled (ORCH_ENABLED injected by server).
|
||||||
|
if (!window.ORCH_ENABLED) {
|
||||||
|
var orchTabBtn = document.querySelector('.tab[data-panel="orch"]');
|
||||||
|
var orchPanel = document.getElementById('orch');
|
||||||
|
if (orchTabBtn) orchTabBtn.style.display = 'none';
|
||||||
|
if (orchPanel) orchPanel.style.display = 'none';
|
||||||
|
document.documentElement.style.setProperty('--tab-count', '6');
|
||||||
|
}
|
||||||
|
|
||||||
// Tab switching — re-fetch data unless SSE delivered recently
|
// Tab switching — re-fetch data unless SSE delivered recently
|
||||||
const tabs = document.querySelectorAll('.tab');
|
const tabs = document.querySelectorAll('.tab:not([style*="display: none"])');
|
||||||
const tabIndicator = document.querySelector('.tab-indicator');
|
const tabIndicator = document.querySelector('.tab-indicator');
|
||||||
|
|
||||||
function moveIndicator(index) {
|
function moveIndicator(index) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue