Skip to content

feat(shell): enhance slash command completer and menu functionality#1431

Merged
RealKai42 merged 3 commits intomainfrom
kaiyi/stockholm-v1
Mar 13, 2026
Merged

feat(shell): enhance slash command completer and menu functionality#1431
RealKai42 merged 3 commits intomainfrom
kaiyi/stockholm-v1

Conversation

@RealKai42
Copy link
Copy Markdown
Collaborator

@RealKai42 RealKai42 commented Mar 13, 2026

Description

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation.

Open with Devin

Copilot AI review requested due to automatic review settings March 13, 2026 09:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the interactive shell UX around slash commands by tightening when slash completion triggers, ensuring canonical command names are inserted/displayed, and rendering a custom full-width completions menu consistent with the shell styling.

Changes:

  • Add SlashCommandCompleter.should_complete() to restrict completion to the “root” slash token and use canonical /name for inserted/displayed completions.
  • Introduce SlashCommandMenuControl plus wrapping/truncation helpers to render a custom completions menu with optional expanded metadata lines.
  • Expand test coverage for slash completion activation rules, canonical display, wrapping/truncation behavior, and menu rendering when no item is selected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/kimi_cli/ui/shell/prompt.py Adds stricter slash completion gating and a custom prompt-toolkit menu control/float for slash completions.
tests/ui_and_conv/test_slash_completer.py Adds new unit tests covering the updated completion logic and menu rendering helpers.

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

getattr(app.current_buffer, "complete_state", None) if app is not None else None
)
if complete_state is None or not complete_state.completions:
return UIContent()
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 8 additional findings in Devin Review.

Open in Devin Review

Comment on lines +263 to +264
if isinstance(container.alternative_content, FloatContainer):
return container.alternative_content
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.

🟡 _extract_float_container accesses non-existent alternative_content attribute on ConditionalContainer

ConditionalContainer from prompt_toolkit does not have an alternative_content attribute (confirmed with prompt_toolkit 3.0.28). If _extract_float_container encounters a ConditionalContainer whose .content is not a FloatContainer, the code at line 263 will crash with AttributeError: 'ConditionalContainer' object has no attribute 'alternative_content'. While currently unreachable in the default prompt_toolkit layout (the FloatContainer is found as child[0] of the HSplit), any layout change (e.g., a future prompt_toolkit version reordering children) would trigger the crash during prompt session initialization. The corresponding test test_find_prompt_float_container_supports_conditional_container_shape also fails with TypeError because ConditionalContainer.__init__() does not accept alternative_content as a keyword argument.

Prompt for agents
In src/kimi_cli/ui/shell/prompt.py lines 257-265, the _extract_float_container function references container.alternative_content on a ConditionalContainer, but prompt_toolkit's ConditionalContainer has no such attribute. Remove lines 263-264 (the alternative_content check) since ConditionalContainer only has a .content attribute. If you need to handle nested containers, recursively check child containers instead. Also fix the test in tests/ui_and_conv/test_slash_completer.py at line 159-171: test_find_prompt_float_container_supports_conditional_container_shape passes alternative_content= to ConditionalContainer which raises TypeError. Either remove this test or restructure it to test a valid ConditionalContainer layout (e.g., a ConditionalContainer whose .content IS a FloatContainer).
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@RealKai42 RealKai42 merged commit b856740 into main Mar 13, 2026
21 checks passed
@RealKai42 RealKai42 deleted the kaiyi/stockholm-v1 branch March 13, 2026 12:31
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