ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(deploy): stop the deploy pill shouting at the page it links to
Juan Denis86e44e1077fc
diff --git a/frontend/src/components/DeployPill.jsx b/frontend/src/components/DeployPill.jsxindex d47cb1ab..8e35db0f 100644--- a/frontend/src/components/DeployPill.jsx+++ b/frontend/src/components/DeployPill.jsx@@ -1,5 +1,5 @@import { useEffect, useState, useCallback } from 'react';-import { Link } from 'react-router-dom';+import { Link, useLocation } from 'react-router-dom';import { Loader2 } from 'lucide-react';import api from '../services/api';import socketService from '../services/socket';@@ -9,10 +9,19 @@ import socketService from '../services/socket';// and always find your way back to the live Deploy Console (plan 51 §1.3).// Driven by a lightweight poll of GET /deployment-jobs?status=running, refreshed// on socket reconnect and on any deploy_status event that flows through.+//+// It is a shortcut *back* to Deploy Activity, so it has nothing to offer while+// you are already there: on /deployments and /deployments/:jobId it stays out+// of the way entirely (and stops polling). Installing a database engine sends+// you straight to that console, which is how a floating "1 deploy running" tag+// ended up shouting at the page it links to.const POLL_MS = 6000;export default function DeployPill() {+ const { pathname } = useLocation();const [active, setActive] = useState([]);+ // Deploy Activity and the console are the surface this pill points at.+ const onDeploySurface = pathname === '/deployments' || pathname.startsWith('/deployments/');const refresh = useCallback(async () => {try {@@ -28,6 +37,7 @@ export default function DeployPill() {}, []);useEffect(() => {+ if (onDeploySurface) return undefined;refresh();const t = setInterval(refresh, POLL_MS);// React quickly to live status changes when a console elsewhere is streaming.@@ -38,9 +48,9 @@ export default function DeployPill() {unsubStatus();unsubConnect();};- }, [refresh]);+ }, [refresh, onDeploySurface]);- if (active.length === 0) return null;+ if (onDeploySurface || active.length === 0) return null;const count = active.length;const to = count === 1 ? `/deployments/${active[0].id}` : '/deployments';diff --git a/frontend/src/components/databases/DbBlankStates.jsx b/frontend/src/components/databases/DbBlankStates.jsxindex 4cfb5abc..4de29334 100644--- a/frontend/src/components/databases/DbBlankStates.jsx+++ b/frontend/src/components/databases/DbBlankStates.jsx@@ -1,10 +1,15 @@+import { useEffect, useState } from 'react';import { Link } from 'react-router-dom';import {- Loader2, Plus, Terminal, Table2, Activity, RefreshCw, ShieldAlert, Layers,+ Loader2, Plus, Terminal, Table2, Activity, RefreshCw, ShieldAlert, Layers, Database,} from 'lucide-react';import { Button } from '@/components/ui/button';+import api from '../../services/api';import EngineGlyph from './EngineGlyph';-import { engineLocation, engineMeta, engineTreeStatus, engineUnit, singular } from './engineHelpers';+import {+ engineInitialDatabase, engineInstanceKey, engineLocation, engineMeta,+ engineTreeStatus, engineUnit, singular,+} from './engineHelpers';// The three states the workspace can be in when there is nothing to show yet.// Each one names what is happening and offers the single next step, rather than@@ -14,6 +19,24 @@ import { engineLocation, engineMeta, engineTreeStatus, engineUnit, singular } frexport function EngineInstallingPanel({ instance, onRefresh }) {const failed = engineTreeStatus(instance) === 'failed';const meta = engineMeta(instance);+ const initialDb = engineInitialDatabase(instance);+ const appId = engineInstanceKey(instance);++ // The engine listing is a description of an Application, not of a run, so it+ // carries no job id. Resolve it from the same /deployment-jobs feed the+ // console reads — an engine install is an ordinary deployment and belongs in+ // that surface, not in a bespoke progress view here. Fail soft: without an+ // id the panel still points at Deploy Activity.+ const [jobId, setJobId] = useState(instance?.deploy_job_id || null);+ useEffect(() => {+ if (instance?.deploy_job_id) { setJobId(instance.deploy_job_id); return undefined; }+ if (appId == null) { setJobId(null); return undefined; }+ let cancelled = false;+ api.getDeploymentJobs({ appId, limit: 1 })+ .then((data) => { if (!cancelled) setJobId(data?.jobs?.[0]?.id || null); })+ .catch(() => { /* no job feed, no link */ });+ return () => { cancelled = true; };+ }, [appId, instance?.deploy_job_id]);return (<div className="dbx-blank">@@ -44,9 +67,9 @@ export function EngineInstallingPanel({ instance, onRefresh }) {)}<div className="dbx-blank__actions">- {instance.deploy_job_id && (+ {jobId && (<Button asChild size="sm">- <Link to={`/deployments/${instance.deploy_job_id}`}>+ <Link to={`/deployments/${jobId}`}><Terminal size={14} aria-hidden="true" /> View install log</Link></Button>@@ -61,10 +84,10 @@ export function EngineInstallingPanel({ instance, onRefresh }) {)}</div>- {instance.initial_database && (+ {initialDb && !failed && (<p className="dbx-blank__note"><Plus size={12} aria-hidden="true" />- {instance.initial_database} will be created once the engine reports healthy+ {initialDb} will be created once the engine reports healthy</p>)}</div>@@ -77,6 +100,7 @@ export function EngineReadyPanel({ instance, label, onNewDatabase, onOpenConsoleconst meta = engineMeta(instance);const address = engineLocation(instance);const unitOne = singular(engineUnit(instance));+ const initialDb = engineInitialDatabase(instance);return (<div className="dbx-blank">@@ -114,6 +138,15 @@ export function EngineReadyPanel({ instance, label, onNewDatabase, onOpenConsole</Button>)}</div>+ {/* The database the install was asked to seed. Naming it is what+ makes arriving here from a finished deploy feel like landing on+ the thing you created. */}+ {initialDb && (+ <p className="dbx-blank__note">+ <Database size={12} aria-hidden="true" />+ {initialDb} was created on install+ </p>+ )}{meta.protocol === 'none' && (<p className="dbx-blank__note">This engine has no browsable protocol — ServerKit runs it, but table browsingdiff --git a/frontend/src/components/databases/engineHelpers.js b/frontend/src/components/databases/engineHelpers.jsindex c28d5381..7ad16f41 100644--- a/frontend/src/components/databases/engineHelpers.js+++ b/frontend/src/components/databases/engineHelpers.js@@ -41,6 +41,18 @@ export function engineInstanceKey(instance) {return instance?.app_id ?? instance?.id ?? null;}+// The database the engine was told to create on first boot, or null.+//+// The listing does not carry an `initial_database` field — it echoes the+// non-secret install variables, and the engine block names which of them holds+// the initial database. Reading it through `database_var` keeps this true for+// any engine template rather than for the ones that happen to call it DB_NAME.+export function engineInitialDatabase(instance) {+ const name = engineMeta(instance).database_var;+ const value = name ? instance?.variables?.[name] : null;+ return value || instance?.initial_database || null;+}+// App/container status -> the tree's row status vocabulary. Deliberately// generous: the deploy pipeline and Docker each have their own words for// "not finished yet" and "broke".diff --git a/frontend/src/components/deploy-console/SuccessBanner.jsx b/frontend/src/components/deploy-console/SuccessBanner.jsxindex 28e3c33a..2cb15dea 100644--- a/frontend/src/components/deploy-console/SuccessBanner.jsx+++ b/frontend/src/components/deploy-console/SuccessBanner.jsx@@ -1,5 +1,6 @@-import { Link } from 'react-router-dom';-import { CheckCircle2, ExternalLink, LayoutGrid, ScrollText } from 'lucide-react';+import { useEffect, useState } from 'react';+import { Link, useNavigate } from 'react-router-dom';+import { CheckCircle2, Database, ExternalLink, LayoutGrid, ScrollText } from 'lucide-react';const fmtSeconds = (s) => {if (s == null) return '—';@@ -8,13 +9,44 @@ const fmtSeconds = (s) => {return `${m}m ${Math.round(s % 60)}s`;};+// Long enough to read the outcome, short enough that you don't sit waiting.+const AUTO_RETURN_SECONDS = 10;+// Completion banner (plan 51 §1.1): total duration, per-step timings, and the// payoff actions — Open app (when a live URL exists), View service, View// runtime logs.-export default function SuccessBanner({ job, appUrl }) {+//+// `engineTarget` adds one more when the run installed a database engine: the+// thing it created. That is a link first and a timed return second, because the+// log is often the reason you are still on this page — the countdown only arms+// when the console actually watched the run finish, and "Stay here" ends it for+// good.+export default function SuccessBanner({ job, appUrl, engineTarget = null, armAutoReturn = false }) {+ const navigate = useNavigate();const timings = job?.result?.step_timings || [];const appId = job?.app_id;+ const returnTo = engineTarget ? `/databases?engine=${engineTarget.appId}` : null;+ const returnLabel = engineTarget?.database || engineTarget?.name || null;++ const [stayed, setStayed] = useState(false);+ const [countdown, setCountdown] = useState(null);++ useEffect(() => {+ if (!returnTo || !armAutoReturn || stayed) return undefined;+ setCountdown(AUTO_RETURN_SECONDS);+ const timer = setInterval(() => {+ setCountdown((n) => (n == null || n <= 0 ? 0 : n - 1));+ }, 1000);+ return () => clearInterval(timer);+ }, [returnTo, armAutoReturn, stayed]);++ useEffect(() => {+ if (countdown === 0 && returnTo && !stayed) navigate(returnTo, { replace: true });+ }, [countdown, returnTo, stayed, navigate]);++ const counting = countdown != null && countdown > 0 && !stayed;+return (<div className="deploy-console__success"><div className="deploy-console__success-head">@@ -38,9 +70,42 @@ export default function SuccessBanner({ job, appUrl }) {</ul>)}+ {returnTo && (+ <div className="deploy-console__success-return">+ <span>+ {counting+ ? `Opening ${returnLabel} in Databases in ${countdown}s…`+ : `${returnLabel} is waiting in Databases.`}+ </span>+ {counting && (+ <button+ type="button"+ className="deploy-console__btn"+ onClick={() => { setStayed(true); setCountdown(null); }}+ >+ Stay here+ </button>+ )}+ </div>+ )}+<div className="deploy-console__success-actions">+ {returnTo && (+ <Link+ className="deploy-console__btn deploy-console__btn--primary"+ to={returnTo}+ title={`Open ${returnLabel} in the Database Explorer`}+ >+ <Database size={14} /> Open {returnLabel} in Databases+ </Link>+ )}{appUrl && (- <a className="deploy-console__btn deploy-console__btn--primary" href={appUrl} target="_blank" rel="noreferrer">+ <a+ className={`deploy-console__btn${returnTo ? '' : ' deploy-console__btn--primary'}`}+ href={appUrl}+ target="_blank"+ rel="noreferrer"+ ><ExternalLink size={14} /> Open app</a>)}diff --git a/frontend/src/hooks/useEngineInstallTarget.js b/frontend/src/hooks/useEngineInstallTarget.jsnew file mode 100644index 00000000..b22512a9--- /dev/null+++ b/frontend/src/hooks/useEngineInstallTarget.js@@ -0,0 +1,50 @@+import { useEffect, useState } from 'react';+import api from '../services/api';+import { engineInitialDatabase, engineInstanceKey } from '../components/databases/engineHelpers';++// Did this deployment job install a database engine, and if so where does the+// Database Explorer keep it?+//+// Installing an engine is an ordinary template install — same pipeline, same+// job, same console — so the job itself carries no "this was a database" flag+// and shouldn't. The answer comes from the engine listing instead: an installed+// engine is an Application, so matching on `app_id` is enough, and nothing here+// knows the name of a single engine.+//+// Fail soft in every direction: a job of another kind, a backend without the+// engines endpoint, or an app that simply isn't an engine all return null, and+// the caller just doesn't offer the extra way back.+export default function useEngineInstallTarget(job) {+ const [target, setTarget] = useState(null);++ const status = job?.status;+ const kind = job?.kind;+ const appId = job?.app_id ?? null;++ useEffect(() => {+ if (status !== 'succeeded' || kind !== 'template_install' || appId == null) {+ setTarget(null);+ return undefined;+ }+ let cancelled = false;+ // Identity and install variables only — no container probe needed to+ // answer "was this app an engine, and what did it seed?".+ api.getDatabaseEngines(false)+ .then((data) => {+ if (cancelled) return;+ const match = (data?.installed || []).find(+ (entry) => engineInstanceKey(entry) === appId,+ );+ if (!match) return;+ setTarget({+ appId,+ name: match.name || match.template_name || 'the engine',+ database: engineInitialDatabase(match),+ });+ })+ .catch(() => { /* no catalog, no affordance — the console still works */ });+ return () => { cancelled = true; };+ }, [status, kind, appId]);++ return target;+}diff --git a/frontend/src/pages/Databases.jsx b/frontend/src/pages/Databases.jsxindex bc22b25a..6588ad72 100644--- a/frontend/src/pages/Databases.jsx+++ b/frontend/src/pages/Databases.jsx@@ -1,5 +1,5 @@import { useState, useEffect, useMemo, useCallback, useRef } from 'react';-import { useNavigate } from 'react-router-dom';+import { useNavigate, useSearchParams } from 'react-router-dom';import {PanelLeftClose, PanelLeftOpen, Search, X, RefreshCw, Plus, Terminal,Archive, Database, Table2, Server, ChevronDown,@@ -77,6 +77,7 @@ export default function Databases() {const toast = useToast();const { confirm } = useConfirm();const navigate = useNavigate();+ const [searchParams, setSearchParams] = useSearchParams();const [status, setStatus] = useState(null);const [statusLoading, setStatusLoading] = useState(true);@@ -112,6 +113,7 @@ export default function Databases() {const [blank, setBlank] = useState(null);const newMenuRef = useRef(null);const didAutoExpand = useRef(false);+ const didDeepLink = useRef(false);useEffect(() => { localStorage.setItem(SIDEBAR_KEY, String(sidebarVisible)); }, [sidebarVisible]);@@ -356,6 +358,35 @@ export default function Databases() {}}, [statusLoading, roots, fetchChildren]);+ // Deep link from the deploy console: `/databases?engine=<app_id>` selects+ // the engine that run just installed, so finishing an install lands on the+ // thing it created rather than the generic welcome pane. Runs once and then+ // drops the parameter, so a reload or a later click on the tree isn't+ // dragged back. Fail soft — an id that resolves to nothing is just ignored.+ useEffect(() => {+ if (didDeepLink.current || enginesLoading) return;+ const raw = searchParams.get('engine');+ if (!raw) return;+ didDeepLink.current = true;++ const wanted = Number(raw);+ const node = Number.isFinite(wanted)+ ? roots.find((r) => r.instance && engineInstanceKey(r.instance) === wanted)+ : null;+ if (node) {+ // Don't let the "expand the first running engine" convenience fight+ // an explicit destination.+ didAutoExpand.current = true;+ setSelectedNode(node);+ setBlank({ kind: 'engine', instanceId: wanted });+ setActiveTabId(null);+ }++ const next = new URLSearchParams(searchParams);+ next.delete('engine');+ setSearchParams(next, { replace: true });+ }, [enginesLoading, roots, searchParams, setSearchParams]);+// ─── tabs ─────────────────────────────────────────────────const reportStatus = useCallback((tabId, s) => {setTabStatuses((prev) => ({ ...prev, [tabId]: s }));diff --git a/frontend/src/pages/DeployConsole.jsx b/frontend/src/pages/DeployConsole.jsxindex a5d920a0..77dd2e64 100644--- a/frontend/src/pages/DeployConsole.jsx+++ b/frontend/src/pages/DeployConsole.jsx@@ -2,6 +2,7 @@ import { useEffect, useMemo, useRef, useState, useCallback } from 'react';import { useParams, useNavigate, Link } from 'react-router-dom';import { ArrowLeft, Loader2, CheckCircle2, XCircle, Clock, WifiOff } from 'lucide-react';import useDeployJobStream from '../hooks/useDeployJobStream';+import useEngineInstallTarget from '../hooks/useEngineInstallTarget';import api from '../services/api';import PipelineStrip from '../components/deploy-console/PipelineStrip';import ConsoleToolbar from '../components/deploy-console/ConsoleToolbar';@@ -84,6 +85,20 @@ export default function DeployConsole() {const status = job?.status || 'pending';+ // Where to go back to when this run created something with a home of its+ // own — today, a database engine. Null for every other kind of deploy.+ const engineTarget = useEngineInstallTarget(job);++ // Did this page watch the run finish, or did we arrive at one that was+ // already over? Opening a week-old install from Deploy Activity is reading+ // history, and history must never navigate away under the reader — so the+ // timed return only arms for a run we actually saw in flight.+ const [watchedRun, setWatchedRun] = useState(false);+ useEffect(() => { setWatchedRun(false); }, [jobId]);+ useEffect(() => {+ if (job?.status === 'running' || job?.status === 'pending') setWatchedRun(true);+ }, [job?.status]);+// Live elapsed timer while running.useEffect(() => {if (status !== 'running' && status !== 'pending') return undefined;@@ -294,7 +309,12 @@ export default function DeployConsole() {)}{status === 'succeeded' && !logFocus && (- <SuccessBanner job={job} appUrl={appUrl} />+ <SuccessBanner+ job={job}+ appUrl={appUrl}+ engineTarget={engineTarget}+ armAutoReturn={watchedRun}+ />)}{!logFocus && (diff --git a/frontend/src/services/api/databases.js b/frontend/src/services/api/databases.jsindex 1d12c199..b1e2b3dd 100644--- a/frontend/src/services/api/databases.js+++ b/frontend/src/services/api/databases.js@@ -290,8 +290,12 @@ export async function launchManagedDbSso(id) {// the caller navigates to the deploy console like any other template install.//// Lifecycle (start / stop / uninstall) is app lifecycle: use the app endpoints.-export async function getDatabaseEngines() {- return this.request('/databases/engines');+//+// `live` asks the backend to probe each installed engine's container. Callers+// that only need identity and install variables (resolving which app an engine+// is, say) pass false and skip a Docker round-trip per engine.+export async function getDatabaseEngines(live = true) {+ return this.request(`/databases/engines${live ? '' : '?live=false'}`);}export async function installDatabaseEngine(payload) {diff --git a/frontend/src/styles/pages/_deploy-console.scss b/frontend/src/styles/pages/_deploy-console.scssindex d1413a9b..4c1c15df 100644--- a/frontend/src/styles/pages/_deploy-console.scss+++ b/frontend/src/styles/pages/_deploy-console.scss@@ -551,6 +551,21 @@ $dc-surface-line: rgba(255, 255, 255, 0.04);}}+ // The timed return to whatever the run created. It sits above the actions+ // and carries its own way out, so the countdown can never take the log away+ // from someone still reading it.+ &__success-return {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ justify-content: space-between;+ gap: $space-2;+ padding-top: $space-2;+ border-top: 1px solid $dc-surface-line;+ color: $text-secondary;+ font-size: $font-size-sm;+ }+// ---- shared buttons ----&__btn {display: inline-flex;