fix(setup): register the SessionStart hook with a bash prefix on Windows

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 <noreply@anthropic.com>
This commit is contained in:
Garry Tan 2026-08-14 19:26:31 -07:00
parent 2e25bfdefb
commit 25f101a1a6
No known key found for this signature in database
GPG Key ID: C1F69E85C74EFE1D
2 changed files with 16 additions and 1 deletions

9
setup
View File

@ -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

View File

@ -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.