Skip to content

feat: add display hint - #56

Merged
bobrykov merged 1 commit into
masterfrom
feat/display-hint
Jul 20, 2026
Merged

feat: add display hint#56
bobrykov merged 1 commit into
masterfrom
feat/display-hint

Conversation

@bobrykov

Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Display hint API and dispatch flow

Layer / File(s) Summary
Display hint contracts
src/tool.rs, src/observer/context.rs, CHANGELOG.md
Adds serde-tagged DisplayHint variants, with_hint(), optional hint fields, result conversions, observer context support, and non-exhaustive API documentation.
Dispatch and observer propagation
src/engine/bare/dispatch.rs, src/engine/bare.rs
Carries hints through successful tool execution, pipeline dispatch, observer notifications, and default error or blocked paths.
Constructor compatibility updates
src/middleware.rs, src/middleware/*, src/tool.rs
Updates tool and middleware fixtures to initialize display_hint, with tests covering defaults, serialization, propagation, and suppressed rendering behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Tool
  participant BareDispatch
  participant ToolDispatchResult
  participant LoopObserver
  participant ToolPostContext
  Tool->>BareDispatch: return ToolOutput with optional display_hint
  BareDispatch->>ToolDispatchResult: populate display_hint
  BareDispatch->>LoopObserver: invoke on_tool_post
  LoopObserver->>ToolPostContext: receive display_hint
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding display hints to tool output and dispatch handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 50.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/display-hint

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/engine/bare/dispatch.rs (1)

746-755: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Enforce the no-hint invariant for error dispatch results.

Both dispatch paths can propagate display_hint: Some(...) when is_error is true, contradicting the public contract and potentially misdirecting presentation layers.

  • src/engine/bare/dispatch.rs#L746-L755: set display_hint to None whenever result.is_error is true.
  • src/engine/bare/dispatch.rs#L1021-L1032: apply the same filtering when copying dispatch_result from the middleware pipeline.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engine/bare/dispatch.rs` around lines 746 - 755, Enforce the no-hint
invariant in both dispatch result construction paths: at
src/engine/bare/dispatch.rs:746-755, set display_hint to None when
result.is_error is true; at src/engine/bare/dispatch.rs:1021-1032, apply the
same filtering when copying dispatch_result from the middleware pipeline, while
preserving hints for non-error results.
🧹 Nitpick comments (2)
src/engine/bare.rs (1)

2088-2095: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression coverage for display-hint propagation.

This fixture only verifies construction with None; add a test using a non-None hint and assert that it survives successful direct/pipeline dispatch and reaches ToolPostContext, while error results remain None.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engine/bare.rs` around lines 2088 - 2095, Add regression coverage near
the existing ToolDispatchResult fixture for a non-None display hint. Exercise
both successful direct and pipeline dispatch, assert the hint reaches
ToolPostContext unchanged, and verify error results still have display_hint set
to None.
src/tool.rs (1)

190-248: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Drop the per-variant serde(rename) attributes

rename_all = "snake_case" already gives these variants the same tags, so the explicit rename = "..." attrs are redundant and can be removed to reduce maintenance surface.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tool.rs` around lines 190 - 248, Remove the per-variant serde rename
attributes from the DisplayHint enum and rely on its existing #[serde(rename_all
= "snake_case")] configuration for serialization tags. Keep all variants,
documentation, and enum-level serde attributes unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tool.rs`:
- Around line 2064-2065: Remove the duplicate #[cfg(feature = "testing")]
attribute from hinted_dispatch_setup, leaving a single testing configuration
guard.

---

Outside diff comments:
In `@src/engine/bare/dispatch.rs`:
- Around line 746-755: Enforce the no-hint invariant in both dispatch result
construction paths: at src/engine/bare/dispatch.rs:746-755, set display_hint to
None when result.is_error is true; at src/engine/bare/dispatch.rs:1021-1032,
apply the same filtering when copying dispatch_result from the middleware
pipeline, while preserving hints for non-error results.

---

Nitpick comments:
In `@src/engine/bare.rs`:
- Around line 2088-2095: Add regression coverage near the existing
ToolDispatchResult fixture for a non-None display hint. Exercise both successful
direct and pipeline dispatch, assert the hint reaches ToolPostContext unchanged,
and verify error results still have display_hint set to None.

In `@src/tool.rs`:
- Around line 190-248: Remove the per-variant serde rename attributes from the
DisplayHint enum and rely on its existing #[serde(rename_all = "snake_case")]
configuration for serialization tags. Keep all variants, documentation, and
enum-level serde attributes unchanged.
🪄 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 Plus

Run ID: 7622e6b2-ff14-4820-a893-354e27a3ff34

📥 Commits

Reviewing files that changed from the base of the PR and between 459639c and 83de323.

📒 Files selected for processing (9)
  • CHANGELOG.md
  • src/engine/bare.rs
  • src/engine/bare/dispatch.rs
  • src/middleware.rs
  • src/middleware/memoize.rs
  • src/middleware/unknown_tool.rs
  • src/middleware/verify.rs
  • src/observer/context.rs
  • src/tool.rs

Comment thread src/tool.rs
@bobrykov
bobrykov merged commit 9b1579d into master Jul 20, 2026
7 checks passed
bobrykov added a commit that referenced this pull request Aug 18, 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.

1 participant