fix: update grok session after new - #2683
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughGrok integration version 2 reports the session-start source. Terminal state handling updates same-owner Grok sessions after ChangesGrok session identity
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant GrokCLI
participant GrokHook
participant Herdr
participant TerminalState
GrokCLI->>GrokHook: Emit session payload with source "new"
GrokHook->>Herdr: Report session ID and session_start_source
Herdr->>TerminalState: Process session identity
TerminalState->>TerminalState: Replace same-owner Grok session
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/integration/assets/grok/herdr-agent-state.ps1 (1)
44-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename the argument array variable.
Line 44 overwrites PowerShell's automatic
$argsvariable. Use a dedicated variable such as$herdrArgs. This avoids changing automatic parameter state and removes the PSScriptAnalyzer warnings on Lines 44 and 52.Proposed fix
-$args = @( +$herdrArgs = @( "pane", "report-agent-session", $env:HERDR_PANE_ID, "--source", "herdr:grok", "--agent", "grok", "--seq", "$seq", "--agent-session-id", "$sessionId" ) if (-not [string]::IsNullOrWhiteSpace($sessionStartSource)) { - $args += @("--session-start-source", "$sessionStartSource") + $herdrArgs += @("--session-start-source", "$sessionStartSource") } try { - & $herdr `@args` 2>$null | Out-Null + & $herdr `@herdrArgs` 2>$null | Out-NullSource: Linters/SAST tools
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4400930c-fd6e-4f4d-9647-f2010500722a
📒 Files selected for processing (11)
docs/next/CHANGELOG.mddocs/next/website/src/content/docs/integrations.mdxdocs/next/website/src/content/docs/ja/integrations.mdxdocs/next/website/src/content/docs/session-state.mdxdocs/next/website/src/content/docs/zh-cn/integrations.mdxsrc/integration/assets/grok/herdr-agent-state.ps1src/integration/assets/grok/herdr-agent-state.shsrc/integration/mod.rssrc/integration/tests.rssrc/terminal/state.rstests/cli/hooks.rs
|
Agreed, renamed the PowerShell argument array to avoid shadowing the automatic |
Greptile SummaryThe PR updates the Grok integration so SessionStart reports carry their source and a same-owner
Confidence Score: 5/5The PR appears safe to merge, with the new same-owner Grok replacement path retaining the intended different-owner protection. Both platform hook transports match the existing API and CLI contracts, the integration version is synchronized with the changed assets, and the state logic narrowly enables Grok
|
| Filename | Overview |
|---|---|
| src/integration/assets/grok/herdr-agent-state.sh | Forwards a nonempty Grok SessionStart source in the Unix JSON-RPC payload while preserving existing session-id selection. |
| src/integration/assets/grok/herdr-agent-state.ps1 | Adds the equivalent Windows CLI argument using a safely constructed argument array. |
| src/terminal/state.rs | Allows same-owner Grok session replacement only for new while explicitly retaining the different-owner guard. |
| src/integration/mod.rs | Bumps the embedded Grok integration version to ensure behaviorally stale installations are reported as outdated. |
| src/integration/tests.rs | Extends version, asset-content, and current/outdated status coverage for Grok integration v2. |
| tests/cli/hooks.rs | Verifies that the Unix Grok hook reports both the new session id and new SessionStart source. |
Sequence Diagram
sequenceDiagram
participant Grok as Grok CLI
participant Hook as Grok SessionStart hook
participant API as pane.report_agent_session
participant State as TerminalState
participant Persist as Persisted session identity
Grok->>Hook: "SessionStart(source="new", session id)"
Hook->>API: "session_start_source="new""
API->>State: set session ref for session start
alt Existing session has same Grok owner
State->>Persist: Replace with new Grok session id
else Existing session has different owner
State-->>Persist: Preserve existing owner and identity
end
Reviews (1): Last reviewed commit: "fix: avoid powershell args shadowing" | Re-trigger Greptile
Summary
SessionStart.sourcethrough the native session hook on Unix and Windowsnewsession replacements while preserving different-owner guardsChecks
cargo test --test cli grok_hook_reports_new_session_source -- --nocapturecargo test grok_new_session -- --nocapturecargo test grok_v1_integration_status_is_outdated -- --nocapturecargo test grok_v2_integration_status_is_current -- --nocapturecargo test bundled_integration_asset_versions_match_expected_versions -- --nocapturecargo test bundled_integration_assets_report_session_refs -- --nocapturecargo clippy --all-targets --locked -- -D warningslive_server_holds_one_pty_master_fd_per_panetest failed identically on unchanged master because its replacement server did not appearrefs #2681