Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
71beaa0
feat(shared): add project-config module for .superset/config.toml
saddlepaddle Oct 22, 2026
592ee57
feat(host-service): read .superset/config.toml for setup, archive and…
saddlepaddle Oct 23, 2026
4915427
feat(cloud): run [archive] when a cloud workspace is archived
saddlepaddle Oct 23, 2026
534422a
feat(desktop): edit the whole workspace config in Settings
saddlepaddle Oct 23, 2026
65cde6e
feat: convert this repo to config.toml and update docs and prompts
saddlepaddle Oct 23, 2026
c6625f4
fix(host-service): only the sandbox's own host-service resolves confi…
saddlepaddle Oct 23, 2026
4a97242
docs(plans): record config.toml v2 outcomes and follow-ups
saddlepaddle Oct 23, 2026
2fc3f94
Merge origin/main into superset/config-toml-v2
saddlepaddle Oct 23, 2026
0e97a4c
fix(desktop): settings search finds the Workspace config section
saddlepaddle Oct 23, 2026
af5d233
docs: show the Workspace config editor and how to check setup works
saddlepaddle Oct 23, 2026
e3325a8
feat(dev): lease cloud workspace Neon branches for 7 days
saddlepaddle Oct 23, 2026
13e40a9
fix(cloud): cap cloud [archive] at the same 60 seconds as a local arc…
saddlepaddle Oct 23, 2026
18206ad
Merge main into superset/config-toml-v2
saddlepaddle Oct 23, 2026
f163c6d
fix(config): address review findings on config.toml
saddlepaddle Oct 23, 2026
25754af
feat(config): put config.toml behind the workspace-config-toml flag
saddlepaddle Oct 24, 2026
65677bd
refactor(config): read v1 through its conversion, so config.toml is t…
saddlepaddle Oct 24, 2026
0a5ab07
Merge remote-tracking branch 'origin/main' into superset/config-toml-v2
saddlepaddle Oct 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ next-env.d.ts
# Superset (track scripts/config; ignore generated workspace artifacts)
.superset/ports.json
.superset/config.local.json
.superset/config.local.toml
.superset/attachments/

# tsbuildinfo
Expand Down
20 changes: 20 additions & 0 deletions .superset/archive.cloud.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Cloud [archive]: deletes this workspace's Neon branch before the box stops.
# Only that: the box's terminals must keep working if the archive is undone,
# and setup.cloud.sh creates the branch again on the next boot.
set -uo pipefail

SUPERSET_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# shellcheck source=/dev/null
source "$SUPERSET_SCRIPT_DIR/lib/common.sh"
# shellcheck source=/dev/null
source "$SUPERSET_SCRIPT_DIR/lib/teardown/steps.sh"

FAILED_STEPS=()
SKIPPED_STEPS=()

step_load_env || step_failed "Load environment variables"
step_delete_neon_branch || step_failed "Delete Neon branch"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Undo leaves the database deleted

archive.cloud.sh deletes the Neon branch but leaves .env unchanged. On Undo or a later resume, setup.cloud.sh sees cloud-${SUPERSET_SANDBOX_WORKSPACE_ID} in that file and returns before recreating the branch. The restored workspace keeps pointing at a deleted database. Clear the setup marker after successful deletion, or make setup check that the branch still exists.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .superset/archive.cloud.sh
Line: 18

Comment:
**Undo leaves the database deleted**

`archive.cloud.sh` deletes the Neon branch but leaves `.env` unchanged. On Undo or a later resume, `setup.cloud.sh` sees `cloud-${SUPERSET_SANDBOX_WORKSPACE_ID}` in that file and returns before recreating the branch. The restored workspace keeps pointing at a deleted database. Clear the setup marker after successful deletion, or make setup check that the branch still exists.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.


print_summary "Cloud archive"
22 changes: 22 additions & 0 deletions .superset/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# How Superset sets up, runs and archives this repository's workspaces.
# Reference: apps/docs/content/docs/setup-teardown-scripts.mdx
# config.json stays until every sandbox runs a host-service that reads this file.

[setup]
run = ["./.superset/setup.sh"]

[setup.cloud]
run = ["./.superset/setup.cloud.sh"]

[terminals.dev]
run = "bun dev"
default = true

[terminals.dev.cloud]
run = "./.superset/dev-stack.cloud.sh"

[archive]
run = ["./.superset/teardown.sh"]

[archive.cloud]
run = ["./.superset/archive.cloud.sh"]
31 changes: 31 additions & 0 deletions .superset/lib/setup/steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,30 @@ step_install_dependencies() {
return 0
}

# RFC 3339 timestamp NEON_BRANCH_LEASE_DAYS from now, empty when no lease is set.
neon_branch_lease_expiry() {
local days="${NEON_BRANCH_LEASE_DAYS:-}"
[ -n "$days" ] || return 0
date -u -d "+${days} days" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null \
|| date -u -v+"${days}"d +%Y-%m-%dT%H:%M:%SZ
}

# Push a branch's expiry NEON_BRANCH_LEASE_DAYS out. Never call
# set-expiration without --expires-at: that removes the expiry.
renew_neon_branch_lease() {
local branch_id="$1"
local lease_expiry
lease_expiry="$(neon_branch_lease_expiry)"
[ -n "$lease_expiry" ] || return 0
if neonctl branches set-expiration "$branch_id" \
--project-id "$NEON_PROJECT_ID" \
--expires-at "$lease_expiry" --output json > /dev/null; then
echo " Lease renewed until $lease_expiry"
else
warn "Could not renew the Neon branch lease (continuing)"
fi
}

step_setup_neon_branch() {
echo "🗄️ Setting up Neon branch..."

Expand Down Expand Up @@ -104,16 +128,23 @@ step_setup_neon_branch() {
# Now safe to parse with jq - use // empty for fallback
EXISTING_BRANCH=$(echo "$branches_output" | jq -r ".[] | select(.name == \"$WORKSPACE_NAME\") | .id // empty" 2>/dev/null)

local lease_expiry
lease_expiry="$(neon_branch_lease_expiry)"

if [ -n "$EXISTING_BRANCH" ]; then
echo " Using existing Neon branch..."
BRANCH_ID="$EXISTING_BRANCH"
renew_neon_branch_lease "$BRANCH_ID"
else
echo " Creating new Neon branch..."
local neon_output
local lease_args=()
[ -n "$lease_expiry" ] && lease_args=(--expires-at "$lease_expiry")
# NO 2>&1 - keep stdout (JSON) and stderr (errors) separate
if ! neon_output=$(neonctl branches create \
--project-id "$NEON_PROJECT_ID" \
--name "$WORKSPACE_NAME" \
"${lease_args[@]}" \
--output json); then
error "Failed to create Neon branch (check output above)"
return 1
Expand Down
32 changes: 26 additions & 6 deletions .superset/setup.cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,33 @@ already_set_up() {
grep -q "cloud-${SUPERSET_SANDBOX_WORKSPACE_ID}" "$ROOT_DIR/.env"
}

# Every boot renews the branch's lease, including a boot that sets up nothing.
# Returns 1 when the branch is gone ([archive] deleted it, or it expired), so
# setup runs again instead of keeping a .env for a deleted database.
renew_cloud_branch_lease() {
local branches branch_id
branches="$(neonctl branches list --project-id "${NEON_PROJECT_ID:-}" --output json)" || {
warn "Could not list Neon branches to renew the lease"
return 0
}
branch_id="$(echo "$branches" | jq -r ".[] | select(.name == \"$SUPERSET_WORKSPACE_NAME\") | .id // empty")"
if [ -z "$branch_id" ]; then
warn "No Neon branch named $SUPERSET_WORKSPACE_NAME; setting up again"
return 1
fi
renew_neon_branch_lease "$branch_id"
}

cloud_setup_main() {
if already_set_up; then
# Cloud workspaces share a display name, so the branch is named after the id.
# The whole id: the first block alone is 8 hex characters, and two
# workspaces that collided would silently share one database.
export SUPERSET_WORKSPACE_NAME="cloud-${SUPERSET_SANDBOX_WORKSPACE_ID}"
# A cloud workspace's branch expires unless a boot renews it, so a box that
# is archived or abandoned releases its branch without running any hook.
export NEON_BRANCH_LEASE_DAYS=7

if already_set_up && renew_cloud_branch_lease; then
echo "This workspace already has its database and .env"
return 0
fi
Expand All @@ -76,11 +101,6 @@ cloud_setup_main() {
. "$env_source/.env"
set +a

# Cloud workspaces share a display name, so the branch is named after the id.
# The whole id: the first block alone is 8 hex characters, and two
# workspaces that collided would silently share one database.
export SUPERSET_WORKSPACE_NAME="cloud-${SUPERSET_SANDBOX_WORKSPACE_ID}"

step_install_dependencies || step_failed "Install dependencies"
step_setup_neon_branch || step_failed "Set up Neon branch"
allocate_port_base || step_failed "Allocate port base"
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/app/api/cloud-workspaces/reap/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { z } from "zod";
import { verifyQstashRequest } from "@/lib/verifyQstash";

export const dynamic = "force-dynamic";
// The stop stage waits for the box's `[archive]` hook (up to a minute and a half).
export const maxDuration = 300;

const payloadSchema = z
.object({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Trans, useLingui } from "@lingui/react/macro";
import { FEATURE_FLAGS } from "@superset/shared/constants";
import { useQuery } from "@tanstack/react-query";
import { useNavigate } from "@tanstack/react-router";
import { useFeatureFlagEnabled } from "posthog-js/react";
import { useEffect, useMemo, useRef } from "react";
import { useHostProjects } from "renderer/hooks/host-projects/useHostProjects";
import { useHostUrl } from "renderer/hooks/host-service/useHostTargetUrl";
Expand All @@ -12,6 +14,7 @@ import { DeleteProjectSection } from "./components/DeleteProjectSection";
import { ProjectLocationSection } from "./components/ProjectLocationSection";
import { V2ProjectSettingsBody } from "./components/V2ProjectSettingsBody";
import { V2ScriptsEditor } from "./components/V2ScriptsEditor";
import { WorkspaceConfigEditor } from "./components/WorkspaceConfigEditor";

interface V2ProjectSettingsProps {
projectId: string;
Expand All @@ -27,6 +30,8 @@ export function V2ProjectSettings({
}: V2ProjectSettingsProps) {
const navigate = useNavigate();
const { t } = useLingui();
const usesConfigToml =
useFeatureFlagEnabled(FEATURE_FLAGS.WORKSPACE_CONFIG_TOML) === true;
const { machineId } = useLocalHostService();
const { currentDeviceName, localHostId, otherHosts } =
useWorkspaceHostOptions();
Expand Down Expand Up @@ -164,10 +169,16 @@ export function V2ProjectSettings({
onChanged={() => refetchHostProject()}
/>
}
usesConfigToml={usesConfigToml}
scriptsEditor={
targetHostUrl ? (
!targetHostUrl ? null : usesConfigToml ? (
<WorkspaceConfigEditor
hostUrl={targetHostUrl}
projectId={projectId}
/>
) : (
<V2ScriptsEditor hostUrl={targetHostUrl} projectId={projectId} />
) : null
)
}
dangerZone={
<DeleteProjectSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function renderBody(props: Partial<BodyProps> = {}) {
onHostProjectChanged={() => {}}
locationSection={<div data-testid="location" />}
scriptsEditor={<div data-testid="scripts" />}
usesConfigToml={false}
dangerZone={<div data-testid="danger" />}
{...props}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface V2ProjectSettingsBodyProps {
onHostProjectChanged: () => unknown;
locationSection: ReactNode;
scriptsEditor: ReactNode;
usesConfigToml: boolean;
dangerZone: ReactNode;
}

Expand All @@ -57,6 +58,7 @@ export function V2ProjectSettingsBody({
onHostProjectChanged,
locationSection,
scriptsEditor,
usesConfigToml,
dangerZone,
}: V2ProjectSettingsBodyProps) {
const { t } = useLingui();
Expand Down Expand Up @@ -256,13 +258,22 @@ export function V2ProjectSettingsBody({

{targetHostUrl && (
<SettingsSection
title={t({
message: "Project lifecycle scripts",
})}
description={t({
message:
"Commands run for workspace setup, teardown, and the Run button.",
})}
title={
usesConfigToml
? t({ message: "Workspace config" })
: t({ message: "Project lifecycle scripts" })
}
description={
usesConfigToml
? t({
message:
"The commands Superset runs to set up, run and archive this project's workspaces, from .superset/config.toml.",
})
: t({
message:
"Commands run for workspace setup, teardown, and the Run button.",
})
}
>
{scriptsEditor}
</SettingsSection>
Expand Down
Loading
Loading