Skip to content

feat: add PlanDisplay wire type and inline rendering support - #1601

Merged
RealKai42 merged 11 commits into
mainfrom
kaiyi/luxembourg-v1
Mar 27, 2026
Merged

feat: add PlanDisplay wire type and inline rendering support#1601
RealKai42 merged 11 commits into
mainfrom
kaiyi/luxembourg-v1

Conversation

@RealKai42

@RealKai42 RealKai42 commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add a new PlanDisplay wire message type and support inline rendering of plan content across all UI layers.

Changes

  • Wire types: Add PlanDisplay message type to wire/types.py and update protocol serialization.
  • Plan tool: Refactor tools/plan to emit PlanDisplay wire events for inline plan content rendering.
  • Shell UI: Handle PlanDisplay events in shell visualizer and question panel.
  • ACP session: Forward PlanDisplay events in the ACP session layer.
  • Web UI: Add PlanDisplayEvent type in wireTypes.ts and handle it in useSessionStream.
  • Tests: Add wire message serialization tests for PlanDisplay.

Open with Devin

Copilot AI review requested due to automatic review settings March 27, 2026 06:33
devin-ai-integration[bot]

This comment was marked as resolved.

Copilot AI 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.

Pull request overview

Adds a new PlanDisplay wire event to render plan markdown inline across clients, and bumps the wire protocol to v1.7 to support it.

Changes:

  • Introduces PlanDisplay in Python wire types and updates protocol version to 1.7.
  • Emits and renders inline plan content in CLI UIs (shell + print JSON) and web session stream.
  • Adds serialization/deserialization coverage for the new wire message.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
web/src/hooks/wireTypes.ts Adds PlanDisplayEvent and extends the WireEvent union.
web/src/hooks/useSessionStream.ts Handles PlanDisplay by inserting an assistant message; bumps initialize protocol_version to 1.7.
tests/core/test_wire_message.py Adds snapshot + roundtrip serde test for PlanDisplay.
src/kimi_cli/wire/types.py Defines PlanDisplay model and includes it in the wire message unions/exports.
src/kimi_cli/wire/protocol.py Bumps WIRE_PROTOCOL_VERSION from 1.6 to 1.7.
src/kimi_cli/ui/shell/visualize.py Renders PlanDisplay as a Rich Panel in the shell UI.
src/kimi_cli/ui/shell/question_panel.py Extends numeric key handling to include option 6 (supports more choices + “Other”).
src/kimi_cli/ui/print/visualize.py Prints PlanDisplay as JSON in stream-json mode.
src/kimi_cli/tools/plan/init.py Emits PlanDisplay before prompting; adds “Reject and Exit” handling and refactors option flow.
src/kimi_cli/acp/session.py Adds PlanDisplay to the match, but currently does not forward it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,2 +1,2 @@
WIRE_PROTOCOL_VERSION: str = "1.6"
WIRE_PROTOCOL_VERSION: str = "1.7"

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

Bumping the wire protocol to 1.7 will break tests/docs that assert 1.6. For example, tests_e2e/test_wire_protocol.py:39/44 and :131 hardcode "1.6" and will fail once the server reports 1.7; update those expectations (and any protocol-version docs/examples) as part of this change.

Suggested change
WIRE_PROTOCOL_VERSION: str = "1.7"
WIRE_PROTOCOL_VERSION: str = "1.6"

Copilot uses AI. Check for mistakes.
Comment on lines +193 to +194
case PlanDisplay():
pass

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

This PlanDisplay branch is currently a no-op, so ACP clients will never see the inline plan content. The PR description says ACP should forward PlanDisplay events; implement forwarding here (e.g., convert to a text chunk / session_update, potentially including the file_path) instead of pass.

Copilot uses AI. Check for mistakes.
Comment thread src/kimi_cli/ui/shell/visualize.py Outdated
self.flush_content()
self.flush_finished_tool_calls()
plan_body = Markdown(msg.content)
subtitle = Text.from_markup(f"[dim]{msg.file_path}[/dim]")

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

Text.from_markup(f"[dim]{msg.file_path}[/dim]") treats the file path as Rich markup. If the path contains [/] (or other markup tokens), it can render incorrectly or inject styles. Use plain Text styling (e.g., Text(msg.file_path, style="dim")) or escape the path before passing it to from_markup.

Suggested change
subtitle = Text.from_markup(f"[dim]{msg.file_path}[/dim]")
subtitle = Text(msg.file_path, style="dim")

Copilot uses AI. Check for mistakes.
NAME = "ExitPlanMode"

_RESERVED_LABELS = {"reject", "revise", "approve"}
_RESERVED_LABELS = {"reject", "revise", "approve", "reject and exit"}

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

_RESERVED_LABELS now includes "reject and exit", but the validation error message below still only mentions Reject/Revise/Approve. Update the message so it matches the actual reserved set (and/or generate it from _RESERVED_LABELS) to avoid confusing tool authors.

Copilot uses AI. Check for mistakes.
devin-ai-integration[bot]

This comment was marked as resolved.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55c512f0cb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/kimi_cli/tools/plan/__init__.py Outdated
Comment on lines +310 to +311
"User wants to revise the plan. Stay in plan mode. "
"Wait for the user's next message with feedback before revising."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Revise immediately when feedback is already captured

This branch now instructs the model to "wait for the user's next message" even though revise feedback may already be present in the current answers payload (and is appended right below). In practice, when a user chooses Revise and types feedback in the same prompt, this wording can make the agent stall for an extra turn instead of revising right away, which regresses the plan-review flow.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8fc1270775

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +201 to 203
question="Approve this plan",
header="Plan",
body=plan_content,
options=question_options,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve plan text for clients lacking PlanDisplay handling

This change removes QuestionItem.body and relies solely on a preceding PlanDisplay event for plan content, so clients that support plan mode/questions but have not yet implemented PlanDisplay will now receive an approval prompt without any plan text to review. Because wire initialization currently does not gate this behavior by a PlanDisplay capability, this is a backward-compatibility regression for existing 1.6-style clients; keep a body fallback (or gate by negotiated capability/protocol) so users can still review the plan before approving.

Useful? React with 👍 / 👎.

turnCounterRef.current > 0
? turnCounterRef.current - 1
: undefined,
content: planPayload.content,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Surface plan file path in web PlanDisplay rendering

The web handler consumes PlanDisplay but only renders content; file_path is dropped entirely, so users cannot see which on-disk plan file they are reviewing/editing when multiple plans exist. This undermines the new event contract (content + path) and the documented UX of showing the plan path for reference, so include file_path in the rendered message metadata or visible text.

Useful? React with 👍 / 👎.

@RealKai42
RealKai42 merged commit 367cc0d into main Mar 27, 2026
19 checks passed
@RealKai42
RealKai42 deleted the kaiyi/luxembourg-v1 branch March 27, 2026 07:26
x5iu pushed a commit to x5iu/kimi-cli that referenced this pull request Mar 30, 2026
…tAI#1601)

Ported from origin/main 367cc0d.
- PlanDisplay wire type with content + file_path fields
- Plan tool sends PlanDisplay event before QuestionRequest
- Shell renders as green-bordered markdown panel
- Print mode outputs delimited plain text
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.

2 participants