feat(cosh): surface UserPromptSubmit and PostToolUse hook reason in UI#545
Open
kongche-jbw wants to merge 1 commit into
Open
feat(cosh): surface UserPromptSubmit and PostToolUse hook reason in UI#545kongche-jbw wants to merge 1 commit into
kongche-jbw wants to merge 1 commit into
Conversation
- carry PostToolUse notifications through firePostToolUseEvent output
- emit per-hook notifications via outputUpdateHandler in scheduler
- yield HookSystemMessage on UserPromptSubmit non-blocking allow
- add tests for hookSystem, coreToolScheduler and client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #421.
UserPromptSubmitandPostToolUsehooks could returna
reason(orsystemMessage) on non-blocking decisions, but theterminal UI never showed it — leaving informational warnings invisible.
This PR mirrors the #421 PreToolUse path:
firePostToolUseEvent()now carries aggregatornotifications[]onthe returned output, and
coreToolScheduleremits each one viaoutputUpdateHandler(callId, {hookName, hookMessage, decision, mergedDecision})before applying the merged block / ask / allow outcome.
UserPromptSubmitnon-blocking allow / approve now yields aHookSystemMessageevent usingsystemMessage ?? reason. Block(
Errorevent) and ask (UserPromptConfirmation) paths are unchangedbecause they already render the message.
additionalContextLLM injection is unchanged — the new path isUI-only.
Related Issue
closes #535
Type of Change
Scope
cosh(copilot-shell)sec-core(agent-sec-core)skill(os-skills)sight(agentsight)tokenless(tokenless)Checklist
cosh: Lint passes, type check passes, and tests passsec-core(Rust):cargo clippy -- -D warningsandcargo fmt --checkpasssec-core(Python): Ruff format and pytest passskill: Skill directory structure is valid and shell scripts pass syntax checksight:cargo clippy -- -D warningsandcargo fmt --checkpasstokenless:cargo clippy -- -D warningsandcargo fmt --checkpassTesting
```
npx vitest run packages/core/src/core/client.test.ts
packages/core/src/core/coreToolScheduler.test.ts
packages/core/src/hooks/hookSystem.test.ts
→ 3 files passed, 122/122 tests passed
```
Type check on the three changed test files is clean (pre-existing
third-party `@types` errors for `simple-git` / `google-auth-library` /
`@opentelemetry/exporter-metrics-otlp-http` are unrelated to this PR).
Manual verification scenarios:
reason now renders in the terminal as a `HookSystemMessage`.
reason renders as a per-hook notification on the existing tool
message UI; tool still completes successfully.
notification renders with `mergedDecision: "block"` and the
response sent to the LLM is replaced with the reason.
Additional Notes
The non-interactive JSON output adapter
(`BaseJsonOutputAdapter.processEvent` handling of `HookSystemMessage`)
is intentionally deferred; #535 scopes to the terminal UI.