feat(hooks): SessionStart hook でセッション ID 伝播 + CronCreate セッション問題解決 - #17
feat(hooks): SessionStart hook でセッション ID 伝播 + CronCreate セッション問題解決#17aloekun wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughセッション開始時の SessionStart フックを追加し、セッション ID を環境ファイルと実行ファイル隣の Changes
Sequence Diagram(s)sequenceDiagram
participant Claude as Claude (起動)
participant Hook as SessionStart Hook
participant Env as CLAUDE_ENV_FILE
participant FS as File System (.session-id)
participant Monitor as Post-PR Monitor
Claude->>Hook: stdin: { "session_id": "xyz..." }
Hook->>Env: append export CLAUDE_CODE_SESSION_ID='xyz...' (if set)
Hook->>FS: write "xyz..." to .session-id (first-win)
Hook->>Claude: stdout hookSpecificOutput { additionalContext: "CLAUDE_CODE_SESSION_ID=xyz..." }
Note over Monitor: 後続のモニター起動時
Monitor->>Monitor: get_main_session_id() reads env or .session-id
alt session_id present
Monitor->>Claude: run claude -p --resume <xyz...>
else no session_id
Monitor->>Claude: run claude -p --continue
end
Claude->>Monitor: response (success/failure)
alt resume failed
Monitor->>Claude: run claude -p --continue (fallback)
Claude->>Monitor: response
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.claude/hooks-config.toml:
- Around line 101-115: Revert the committed mass-commenting of
push_pipeline.steps in .claude/hooks-config.toml (restore the integration_test,
ai_review, commit_refactor entries) and instead implement a local-only bypass:
add a config flag or respect an environment variable (e.g.,
CLAUDE_LOCAL_SKIP_STEPS) that the push pipeline code checks; update the push
pipeline runner in main.rs (the code paths that interpret push_pipeline.steps /
execute_pipeline / run_steps) to skip executing steps only when that local
env/config flag is present, leaving committed config intact so CI/quality gates
run for others.
In @.claude/hooks-session-start/src/main.rs:
- Around line 57-61: The current format!-based interpolation of session_id into
output corrupts JSON and shell env lines; instead build the hookSpecificOutput
object using serde_json (e.g. construct a Map or use serde_json::json! and call
serde_json::to_string) to produce a safe JSON string for the variable output and
avoid manual string formatting of hookEventName/additionalContext; separately,
when producing the CLAUDE_ENV_FILE export lines (the code around the same block
and the lines flagged 66–84), shell-quote the session_id (use a proper
sh-quoting utility such as shlex::quote or wrap in single quotes and escape
internal single quotes) before embedding into the env export so the shell export
cannot be injected or corrupted. Ensure references: replace the format!-based
creation of output, protect session_id, and update the code that writes
CLAUDE_CODE_SESSION_ID / CLAUDE_ENV_FILE accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9c7ec37f-dc23-41cf-acdd-0c8dcefa16cb
⛔ Files ignored due to path filters (1)
.claude/hooks-session-start/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
.claude/hooks-config.toml.claude/hooks-post-pr-monitor/src/main.rs.claude/hooks-session-start/Cargo.toml.claude/hooks-session-start/src/main.rs.claude/settings.local.json.template.gitignoredocs/todo.mdpackage.json
| # >>> TEMPORARY: 初回 push 用に steps 無効化 (push 後に復元) <<< | ||
| # [[push_pipeline.steps]] | ||
| # name = "integration_test" | ||
| # type = "command" | ||
| # cmd = "pnpm test" | ||
| # | ||
| # [[push_pipeline.steps]] | ||
| # name = "ai_review" | ||
| # type = "command" | ||
| # cmd = "pnpm review:ai" | ||
| # | ||
| # [[push_pipeline.steps]] | ||
| # name = "commit_refactor" | ||
| # type = "ai" | ||
| # prompt = "optimize_commit_structure" |
There was a problem hiding this comment.
このコミット状態だと pnpm push の品質ゲートが完全に外れます。
Line 101-115 を全部コメントアウトすると、.claude/hooks-push-pipeline/src/main.rs:206-223 / 225-278 の実装上 steps=[] 扱いになり、テストも review:ai も実行せずそのまま jj git push --allow-new まで進みます。初回 push だけの一時回避なら、コミット済み設定ではなくローカル専用の切り替えにしたいです。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.claude/hooks-config.toml around lines 101 - 115, Revert the committed
mass-commenting of push_pipeline.steps in .claude/hooks-config.toml (restore the
integration_test, ai_review, commit_refactor entries) and instead implement a
local-only bypass: add a config flag or respect an environment variable (e.g.,
CLAUDE_LOCAL_SKIP_STEPS) that the push pipeline code checks; update the push
pipeline runner in main.rs (the code paths that interpret push_pipeline.steps /
execute_pipeline / run_steps) to skip executing steps only when that local
env/config flag is present, leaving committed config intact so CI/quality gates
run for others.
c4e797b to
37f418f
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.claude/hooks-session-start/src/main.rs:
- Around line 43-46: hook_input.session_id currently treats whitespace-only
strings as valid; change the match so you trim the incoming id and reject if
trimmed is empty (e.g., match Some(id) if !id.trim().is_empty() => use
id.trim().to_string(), _ => std::process::exit(0)). Ensure the stored session_id
is the trimmed value so CLAUDE_CODE_SESSION_ID and downstream
get_main_session_id() don't receive whitespace-only values that break --resume.
- Around line 121-137: The test write_to_env_file_creates_and_writes uses a
fixed tmp file name which causes collisions in parallel runs; change the test to
create a unique temp file (e.g., use tempfile::NamedTempFile or append a
uuid/pid/timestamp to std::env::temp_dir() path) and pass its path to
write_to_env_file so each test run uses an isolated file; ensure you still
remove/cleanup the file and keep the same assertions against the file contents.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f13b1187-e95b-483d-becb-b27598317f9e
⛔ Files ignored due to path filters (1)
.claude/hooks-session-start/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
.claude/hooks-config.toml.claude/hooks-post-pr-monitor/src/main.rs.claude/hooks-session-start/Cargo.toml.claude/hooks-session-start/src/main.rs.claude/settings.local.json.template.gitignoredocs/todo.mdpackage.json
✅ Files skipped from review due to trivial changes (3)
- .gitignore
- .claude/hooks-session-start/Cargo.toml
- docs/todo.md
🚧 Files skipped from review as they are similar to previous changes (4)
- .claude/settings.local.json.template
- package.json
- .claude/hooks-config.toml
- .claude/hooks-post-pr-monitor/src/main.rs
37f418f to
d895815
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
CodeRabbit レビュー上限到達のため新 PR に移行 |
SessionStart hook 新規作成 + hooks-post-pr-monitor を --resume 方式に変更
Summary by CodeRabbit
新機能
改善
Chores