You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(code): apply SessionStart hook env to UI git/gh commands
The Commit and Create PR buttons run git/gh in the main process via
`simple-git` and `execGh`, both of which were inheriting bare `process.env`.
That ignored the env updates the Claude Agent SDK applies for each session
via SessionStart-style hooks (which the SDK writes as
`<event>-hook-N.sh` files under `<CLAUDE_CONFIG_DIR>/session-env/<sessionId>/`
and sources before its own bash tool commands).
Most visibly, when a user has the Secretive code-signing hook installed and
launches PostHog Code from the Dock (so the parent process inherits the
default macOS launchd `SSH_AUTH_SOCK`), the agent can sign commits but the
UI buttons cannot — the same `SSH_AUTH_SOCK` repoint never reached the git
subprocess they spawn.
Mirror the SDK's behavior in the main process:
- New `loadSessionEnvOverrides(sessionId)` util sources the SDK's hook files
via bash and returns the env diff (skipping shell internals).
- `AgentService.getSessionEnvForTask(taskId)` resolves the most recent active
session for a task and returns its overrides.
- Plumb an optional `env` through `@posthog/git` (`execGh`, `GitSagaInput`,
`ExecuteOptions`) so it reaches both the simple-git client and `gh`.
- `GitService.commit` and `createPr` look up the session env when a `taskId`
is present and thread it through commit / push / publish / `gh pr create`.
Generated-By: PostHog Code
Task-Id: 86938233-5c7d-4285-b996-6bd9cf09b57c
0 commit comments