Skip to content

fix(cli): point to stacks left on other branches (CLI-2980) - #7670

Open
7ttp wants to merge 6 commits into
developfrom
7ttp/cli-2548-add-supabase-stack-prune-for-orphaned-stacks-followup
Open

7ttp wants to merge 6 commits into
developfrom
7ttp/cli-2548-add-supabase-stack-prune-for-orphaned-stacks-followup

Conversation

@7ttp

@7ttp 7ttp commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

TL;DR

names a project's stacks on other branches when stack status finds none or stack start creates one, and points port conflicts at the holder

whats broken?

after git init, stack status could not find the old stack although stack list still showed it. starting again while the old one ran hit a port conflict whose advice targeted the wrong stack

now fixed by:

when no stack matches, stack status suggests --stack <short id> for this project's stacks with the same name on other branches, and stack start prints the same list before it creates a stack. port conflicts now say supabase stack stop --stack <id> for the holder. existing users see the extra start line only when such stacks exist

ref:

@7ttp 7ttp self-assigned this Nov 17, 2026
@7ttp
7ttp requested a review from a team as a code owner November 17, 2026 13:29
@7ttp
7ttp requested a review from kanadgupta November 17, 2026 13:29

@github-actions github-actions Bot left a comment

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.

🤖 AI Review

Both independent reviews completed. Code inspection confirms one maintainability nit; no correctness or safety defects were verified. Tests were not run.

Findings

Severity Location Category Sources Claim
⚪ NIT apps/cli/src/commands/experimental/stack/prune/prune.handler.ts:65 maintainability claude The orphan predicate duplicates the ordinary-workspace sentinel and part of Git repository detection from the stack identity implementation, creating a small maintenance risk if identity semantics change.

Stats

Claude findings: 1 · Codex findings: 0 · Confirmed: 1 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

@github-actions

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit c8507d3 against develop at 5f6bde3 · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 280 ms 267 ms no real change
supabase --help help 407 ms 412 ms no real change
supabase init init 426 ms 451 ms no real change (+6%, within normal variation)
supabase migration new bench migration-new 479 ms 456 ms no real change
supabase config convert config-convert 363 ms 425 ms no real change (+17%, within normal variation)
supabase config validate config-validate 279 ms 291 ms no real change
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 316 ms 336 ms no real change (+6%, within normal variation)
supabase projects list projects-list 397 ms 413 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 436 ms 491 ms no real change (+13%, within normal variation)

API calls: unchanged for all 9 commands.

Binary size: 135.2 MB, unchanged.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 230-487 ms 226-337 ms -13 ms (-5%) within noise
supabase --help help 298-502 ms 263-460 ms +6 ms (+1%) within noise
supabase init init 308-529 ms 315-651 ms +25 ms (+6%) within noise
supabase migration new bench migration-new 387-659 ms 374-512 ms -23 ms (-5%) within noise
supabase config convert config-convert 302-402 ms 350-580 ms +61 ms (+17%) within noise
supabase config validate config-validate 240-355 ms 256-397 ms +13 ms (+5%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 277-480 ms 264-421 ms +19 ms (+6%) within noise
supabase projects list projects-list 319-477 ms 282-496 ms +16 ms (+4%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 402-736 ms 342-639 ms +56 ms (+13%) within noise

API calls per command

Command Workload Before After Endpoint changes
supabase --version version 0 0
supabase --help help 0 0
supabase init init 0 0
supabase migration new bench migration-new 0 0
supabase config convert config-convert 0 0
supabase config validate config-validate 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 2 2
supabase projects list projects-list 1 1
supabase functions list --project-ref replayfixtureprojref functions-list 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Workflow run

Comment /bench to run the lightweight benchmark (this comment) again on the latest commit, or /bench full to also run the integration-heavy benchmark, which posts in its own comment.

@kanadgupta kanadgupta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good to me but tagging @jgoux for an additional set of eyes to confirm that this is indeed what the expected behavior should be. imo, the issue is correct that stack status and stack list should behave the same way but i'm not sure that these types of stacks (i.e., stacks with a git init in the same directory) should be considered eligible for pruning 🧐

@kanadgupta
kanadgupta requested a review from jgoux November 18, 2026 19:54
@jgoux

jgoux commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Thanks for digging into this! I share Kanad's hesitation: I don't think these stacks should be eligible for pruning.

  • Today prune selects on a filesystem fact: the project directory is gone, so nothing can select that stack by project any more. After git init the directory and its stack both still exist; the stack just isn't the default selection anymore, exactly like the stack of a branch you're not currently on, which prune keeps on purpose. The carve-out this PR needs for a repository created in a parent directory is a sign the line is arbitrary.
  • It's also the stack most likely to hold data people want (init → start → seed → git init later), and existing prune --yes runs would start deleting it without a prompt.

I think #7568 is really a discoverability problem, so the fix belongs in selection rather than cleanup:

  • When stack status finds no stack, or stack start is about to create one, list the saved stacks with the same project root and name under other branch contexts, with --stack <id> to inspect, resume or destroy them. stack list stays global and status stays scoped to the selected stack, so they still answer different questions, but status would no longer hide the old one.
  • The port conflict only happens while the old stack is still running: a cleanly stopped stack's fixed ports are released or reclaimed (reserveCandidate in packages/stack/src/Ports.ts). The conflict message currently says to run supabase stack stop in that project, which after git init selects the new stack. It should point at the holder instead: supabase stack stop --stack <holder-id>.

Small note: the docs here mention stack destroy --stack-id <id>, but develop now selects with --stack <id>.

I'd suggest closing this one in favor of a PR with the status/start hint and the conflict-message fix. Happy to help scope it!

@7ttp 7ttp changed the title feat(cli): prune stacks orphaned by git init (CLI-2980) fix(cli): point to stacks left on other branches (CLI-2980) Nov 18, 2026
@7ttp

7ttp commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

makes sense 🤔, reworked it in cc65200:

  • dropped the prune change
  • stack status (when it finds no stack) and stack start (before it creates one) now list this project's
    same-name stacks on other branches as --stack <short id> (<branch>)
  • the port conflict now says supabase stack stop --stack <holder-id>

@7ttp
7ttp requested a review from kanadgupta November 19, 2026 12:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stack: keep a project directory's stack across git branch changes, and add a prune command for stacks that no longer match a directory

3 participants