Skip to content

fix(hook): detect JetBrains run_in_terminal in Copilot hook - #2684

Closed
guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:fix/hook-copilot-jetbrains
Closed

guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:fix/hook-copilot-jetbrains

Conversation

@guyoron1

Copy link
Copy Markdown
Contributor

Summary

rtk hook copilot was a no-op in JetBrains IDEs because:

  1. detect_format() only matched toolName == "bash" — JetBrains Copilot plugin sends "run_in_terminal" instead
  2. JetBrains ignores modifiedArgs — it only honors permissionDecision, so transparent rewriting doesn't work

Fix

  • Add CopilotIde { command: String } variant to HookFormat enum
  • Detect "run_in_terminal" in the camelCase branch of detect_format(), with .trim() for JetBrains' occasional leading whitespace
  • Use deny-with-suggestion semantics: deny the original command with permissionDecisionReason: "RTK: re-run as \{rewritten}` instead."` — this is the only way to communicate the rewrite to JetBrains users
  • Deny rule matches produce a plain deny with audit log
  • Defer (no rewrite available, unsupported command, already-rtk) returns None (passthrough)

Tests added

  • test_detect_jetbrains_run_in_terminal — format detection
  • test_detect_jetbrains_command_trimmed — whitespace handling
  • test_detect_jetbrains_other_tools_passthrough — non-terminal tools ignored
  • test_detect_camelcase_bash_unchanged — existing CopilotCli path preserved
  • test_copilot_ide_deny_with_suggestion — AskRewrite produces deny + reason
  • test_copilot_ide_allow_rewrite_also_denies — AllowRewrite also denies (JetBrains limitation)
  • test_copilot_ide_already_rtk_passthrough — already-rtk commands pass through
  • test_copilot_ide_unsupported_passthrough — unsupported commands pass through

Fixes #2443

JetBrains sends toolName "run_in_terminal" instead of "bash", so
detect_format() never matched it. Additionally, JetBrains ignores
modifiedArgs and only honors permissionDecision.

Add CopilotIde variant to HookFormat with deny-with-suggestion
semantics: deny the original command but include the rewritten
command in the reason so the user can re-run it manually.

Also trims leading whitespace from toolName (JetBrains sometimes
pads it) and from the command string.

Fixes rtk-ai#2443
@guyoron1

Copy link
Copy Markdown
Contributor Author

Closing this one — it's been superseded upstream. develop now detects the JetBrains/Copilot camelCase toolName: run_in_terminal payload and returns deny-with-suggestion responses (landed via #2443/#3093), which covers everything this branch was doing. Thanks!

@guyoron1 guyoron1 closed this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk hook copilot no-op in JetBrains/IntelliJ Copilot plugin — camelCase run_in_terminal not matched, and IDE host only honors permissionDecision: deny

1 participant