From 25f101a1a6d31da52ac2b7644e3a083eeeb487b8 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Fri, 14 Aug 2026 19:26:31 -0700 Subject: [PATCH] fix(setup): register the SessionStart hook with a bash prefix on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows can't execute an extensionless bash script directly — registering the bare gstack-session-update path made the hook pop the "Select an app" dialog on every session start (or silently never run), so team-mode auto-upgrade was dead on Windows installs. Companion to the hooks' spawn-bin routing: same defect class at the registration site. Contributed by @NikhileshNanduri (PR #1813; VERSION/CHANGELOG collateral stripped). Co-Authored-By: Claude Fable 5 --- setup | 9 ++++++++- test/setup-windows-fallback.test.ts | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/setup b/setup index c28b44a71..49f05ffc2 100755 --- a/setup +++ b/setup @@ -1293,7 +1293,14 @@ rm -f /tmp/gstack-latest-version # 10. Team mode: register/unregister SessionStart hook SETTINGS_HOOK="$SOURCE_GSTACK_DIR/bin/gstack-settings-hook" -HOOK_CMD="$SOURCE_GSTACK_DIR/bin/gstack-session-update" +# On Windows (Git Bash / MSYS2 / Cygwin), extensionless scripts can't be +# launched directly by the OS — the file-association dialog appears instead. +# Prefix with 'bash' so Claude Code's hook runner invokes Git Bash explicitly. +if [ "$IS_WINDOWS" -eq 1 ]; then + HOOK_CMD="bash $SOURCE_GSTACK_DIR/bin/gstack-session-update" +else + HOOK_CMD="$SOURCE_GSTACK_DIR/bin/gstack-session-update" +fi if [ "$TEAM_MODE" -eq 1 ]; then "$GSTACK_CONFIG" set auto_upgrade true 2>/dev/null || true diff --git a/test/setup-windows-fallback.test.ts b/test/setup-windows-fallback.test.ts index cc04fbbd7..142bb7912 100644 --- a/test/setup-windows-fallback.test.ts +++ b/test/setup-windows-fallback.test.ts @@ -55,6 +55,14 @@ describe('setup: _link_or_copy invariant (D7)', () => { const fnBody = SETUP_SRC.slice(fnStart, fnEnd); expect(fnBody).toContain('_print_windows_copy_note_once'); }); + + test('SessionStart HOOK_CMD is prefixed with bash on Windows (D7-session-hook)', () => { + const hookStart = SETUP_SRC.indexOf('# 10. Team mode: register/unregister SessionStart hook'); + const hookEnd = SETUP_SRC.indexOf('\nif [ "$TEAM_MODE" -eq 1 ]', hookStart); + const hookSection = SETUP_SRC.slice(hookStart, hookEnd); + expect(hookSection).toContain('IS_WINDOWS'); + expect(hookSection).toContain('bash $SOURCE_GSTACK_DIR/bin/gstack-session-update'); + }); }); // Behavior matrix uses Unix `ln -snf` semantics in the IS_WINDOWS=0 cells.