diff --git a/docs/development.md b/docs/development.md index 5db7fb973..f976549ef 100644 --- a/docs/development.md +++ b/docs/development.md @@ -23,6 +23,10 @@ Desktop dev launches its desktop-managed daemon with `PASEO_NODE_ENV=development so development-only providers such as Mock Load Test are available. Packaged desktop launches always force the daemon to production mode. +The web and desktop dev launchers pass the current Git branch to Metro as +`EXPO_PUBLIC_PASEO_DEV_BUILD_LABEL`. The expanded desktop sidebar shows it in +the titlebar row. Production builds leave the variable unset and show no label. + `npm run dev` is only a shorthand for `npm run dev:server`. Keep `127.0.0.1:6767` for the packaged app and production-style `~/.paseo` state. ## Nix desktop package diff --git a/packages/app/src/components/left-sidebar.tsx b/packages/app/src/components/left-sidebar.tsx index bfb75a08e..9c0b2dd18 100644 --- a/packages/app/src/components/left-sidebar.tsx +++ b/packages/app/src/components/left-sidebar.tsx @@ -2,6 +2,7 @@ import { router, usePathname } from "expo-router"; import { CalendarClock, FolderPlus, + GitBranch, History, Home, Plus, @@ -77,6 +78,8 @@ import { SidebarWorkspaceList } from "./sidebar-workspace-list"; type SidebarTheme = ReturnType["theme"]; +const DEV_BUILD_LABEL = process.env.EXPO_PUBLIC_PASEO_DEV_BUILD_LABEL?.trim() || null; + interface SidebarSharedProps { theme: SidebarTheme; statusGroups: StatusGroup[]; @@ -853,9 +856,22 @@ function DesktopSidebar({ > - {ownsTopLeft ? ( + {ownsTopLeft || DEV_BUILD_LABEL ? ( + {DEV_BUILD_LABEL ? ( + + + + {DEV_BUILD_LABEL} + + + ) : null} ) : ( @@ -1080,9 +1096,28 @@ const styles = StyleSheet.create((theme) => ({ height: HEADER_INNER_HEIGHT, flexDirection: "row", alignItems: "center", + justifyContent: "flex-end", + paddingHorizontal: theme.spacing[3], borderBottomWidth: theme.borderWidth[1], borderBottomColor: "transparent", }, + devBuildBadge: { + maxWidth: "60%", + flexDirection: "row", + alignItems: "center", + gap: theme.spacing[1], + paddingHorizontal: theme.spacing[2], + paddingVertical: 2, + borderRadius: theme.borderRadius.full, + backgroundColor: theme.colors.accent, + }, + devBuildBadgeText: { + minWidth: 0, + flexShrink: 1, + color: theme.colors.accentForeground, + fontSize: theme.fontSize.xs, + fontWeight: theme.fontWeight.medium, + }, sidebarFooter: { flexDirection: "row", alignItems: "center", diff --git a/packages/desktop/scripts/dev-runner.mjs b/packages/desktop/scripts/dev-runner.mjs index ac96fee5a..c653f31b3 100644 --- a/packages/desktop/scripts/dev-runner.mjs +++ b/packages/desktop/scripts/dev-runner.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import net from "node:net"; import path from "node:path"; -import { spawn } from "node:child_process"; +import { execFileSync, spawn } from "node:child_process"; import { createRequire } from "node:module"; import { fileURLToPath } from "node:url"; import { createElectronSpawnOptions, resolveChildKillTarget } from "./dev-runner-config.mjs"; @@ -27,6 +27,10 @@ const colorEnv = { FORCE_COLOR: process.env.FORCE_COLOR || "1", npm_config_color: process.env.npm_config_color || "always", }; +const devBuildLabel = execFileSync("git", ["branch", "--show-current"], { + cwd: rootDir, + encoding: "utf8", +}).trim(); const children = new Map(); let stopping = false; @@ -166,6 +170,7 @@ spawnChild("metro", "npx", ["expo", "start", "--port", String(expoPort)], { ...colorEnv, BROWSER: "none", APP_VARIANT: "development", + EXPO_PUBLIC_PASEO_DEV_BUILD_LABEL: devBuildLabel, PASEO_WEB_PLATFORM: "electron", }, }); diff --git a/packages/desktop/scripts/dev.ps1 b/packages/desktop/scripts/dev.ps1 index 81f8e4ab6..edb532f86 100644 --- a/packages/desktop/scripts/dev.ps1 +++ b/packages/desktop/scripts/dev.ps1 @@ -32,6 +32,7 @@ try { # Set EXPO_DEV_URL in the environment so Electron inherits it $env:EXPO_DEV_URL = "http://localhost:$($env:EXPO_PORT)" +$env:EXPO_PUBLIC_PASEO_DEV_BUILD_LABEL = (git -C $RootDir branch --show-current).Trim() $env:PASEO_DEV_ROOT = $RootDir $env:PASEO_DEV_RUNTIME_FALLBACK_ROOT = $RootDir diff --git a/scripts/dev-app.sh b/scripts/dev-app.sh index be9857af6..a594f344f 100755 --- a/scripts/dev-app.sh +++ b/scripts/dev-app.sh @@ -12,6 +12,7 @@ configure_dev_paseo_home EXPO_PORT="${EXPO_PORT:-8081}" DAEMON_ENDPOINT="$(resolve_dev_daemon_endpoint)" +DEV_BUILD_LABEL="$(git -C "$ROOT_DIR" branch --show-current 2>/dev/null || true)" echo "══════════════════════════════════════════════════════" echo " Paseo App Dev" @@ -24,5 +25,6 @@ echo "════════════════════════ exec cross-env \ BROWSER="${BROWSER:-none}" \ APP_VARIANT=development \ + EXPO_PUBLIC_PASEO_DEV_BUILD_LABEL="$DEV_BUILD_LABEL" \ EXPO_PUBLIC_LOCAL_DAEMON="$DAEMON_ENDPOINT" \ npm run start:expo --workspace=@getpaseo/app -- --port "$EXPO_PORT" diff --git a/scripts/dev.ps1 b/scripts/dev.ps1 index 5b390407b..0e3be90c9 100644 --- a/scripts/dev.ps1 +++ b/scripts/dev.ps1 @@ -50,6 +50,7 @@ $env:PASEO_CORS_ORIGINS = "*" # Configure the app to auto-connect to this daemon on localhost $env:APP_VARIANT = "development" $env:EXPO_PUBLIC_LOCAL_DAEMON = "localhost:6768" +$env:EXPO_PUBLIC_PASEO_DEV_BUILD_LABEL = (git branch --show-current).Trim() $env:PASEO_LISTEN = "127.0.0.1:6768" $env:BROWSER = "none"