[PATCH b4 v3 5/9] shazam: note subshell alternative to the --resolve two-phase model

Christian Brauner <[email protected]> Thu, 25 Jun 2026 14:09:25 +0200
Newsgroups org.kernel.linux.tools
Message-ID <[email protected]>
b4 shazam --resolve parks the conflicted git am and exits, finishing in a
separate --continue process; the review TUI resolves the same conflict
synchronously by suspending to a shell. Record a TODO to converge on that
subshell model, which would drop the persisted state file and the
--continue/--abort commands.

Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 src/b4/mbox.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/b4/mbox.py b/src/b4/mbox.py
index 374328a..7852c1a 100644
--- a/src/b4/mbox.py
+++ b/src/b4/mbox.py
@@ -1066,6 +1066,20 @@ def _begin_shazam_resolve(
     the user drives it to completion natively and nothing is silently dropped.
     The fully-applied series is merged once, by ``b4 shazam --continue``.
     """
+    # TODO: switch --resolve to a subshell model like the review TUI's
+    # _resolve_worktree_am_conflict -- suspend into a shell in the worktree
+    # (blocking subprocess.run; b4 stays the parent) and finish inline when it
+    # exits: fetch+merge on success, tear the worktree down on "git am --abort"
+    # or an unfinished am. That drops the persisted b4-shazam-state.json and the
+    # separate --continue/--abort commands, at the cost of the git-rebase-style
+    # two-phase UX. Two constraints make it robust:
+    #  - b4 must stay alive while the shell runs (no sys.exit/os.execvp until
+    #    cleanup has run); _run_shazam_merge may only execvp git-merge at the
+    #    very end, once the worktree is already dropped.
+    #  - guard the worktree with try/finally (or atexit + a SIGINT/SIGTERM
+    #    handler) so it is reclaimed even if b4 is killed while the shell is up --
+    #    a shell "trap ... EXIT" analogue. Keep it outcome-aware (finished vs
+    #    aborted), never an unconditional remove, or a half-done resolution dies.
     gwt = cex.worktree_path
     logger.critical('---')
     logger.critical(cex.output)

-- 
2.53.0