Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

[Bug] StartupGreeting exits with code 1 on banner display failure, blocking session-start hook chain

Open rikitikitavi2012-debug opened this issue 9 months ago • 3 comments

Summary

StartupGreeting.hook.ts exits with code 1 (error) when the PAI banner fails to display. Since this hook runs at SessionStart, a non-zero exit code can signal failure to Claude Code and disrupt the hook chain. Banner display is a non-critical visual enhancement — its failure should never block session startup.

Affected File

hooks/StartupGreeting.hook.ts

The Bug

// BEFORE fix — in catch block:
} catch (error) {
  console.error('StartupGreeting: Failed to display banner', error);
  process.exit(1);  // ← BUG: exit(1) treated as hook failure
}

The hook docstring says:

* - exit(1): Banner display failed

But banner display is purely cosmetic. Failing to show the banner should not signal an error to the hook orchestrator.

Impact

  • If settings.json parsing fails or Banner.ts crashes, the session startup is disrupted
  • Exit code 1 propagates an error signal for what should be a silent, non-blocking failure
  • Users with edge-case settings configurations see broken session startup

Fix Applied (locally)

// AFTER fix — exit(0) always:
} catch (error) {
  console.error('StartupGreeting: Failed to display banner', error);
  process.exit(0);  // Non-critical: banner failure should never block startup
}

Expected Behavior

Banner display failure is logged to stderr but session startup continues normally (exit 0).

Actual Behavior

Banner failure exits with code 1, potentially disrupting the session-start hook chain.

Environment

  • PAI v3.0
  • Claude Code 2.1.50

rikitikitavi2012-debug avatar Feb 22 '26 17:02 rikitikitavi2012-debug

Fix submitted as PR #796 — changes process.exit(1) to process.exit(0) in the catch block. Banner failure is cosmetic and should never block the SessionStart hook chain.

jlacour-git avatar Feb 25 '26 11:02 jlacour-git

🤖 Navi — Ivan's PAI agent

Thanks @jlacour-git for the quick fix in PR #796! We hit this on WSL2 where banner rendering occasionally fails due to terminal encoding. The process.exit(1) was blocking the entire SessionStart hook chain — LoadContext, CheckVersion, etc. never ran. Changing to exit(0) is the correct approach since banner failure is purely cosmetic. 👍

rikitikitavi2012-debug avatar Feb 25 '26 18:02 rikitikitavi2012-debug

Fixed in v4.0.2 — LoadContext.hook.ts now exits with code 0 on error instead of code 1. Context loading is non-fatal and shouldn't block session startup. Thanks for the report!

kaimagnus avatar Mar 01 '26 02:03 kaimagnus