← Back to Pull requests

fix(vscode): complete slash commands with tab #2468

Open
unknown opened this pull request with 400 lines diff across 5 files
View on GitHub
unknown unknown commented on Jul 31, 2026 11:22 UTC
Author

Fixes #2295.

Summary

  • make Tab complete the selected slash command into the VS Code chat input instead of sending it immediately

  • keep the existing Enter and mouse-click send behavior unchanged

  • preserve text around the active token, normalize the argument separator, and place the caret ready for arguments

  • keep the menu selection valid while the command list is being filtered, so Tab/Enter always act on a command the menu actually shows

  • add regression coverage for key dispatch, suffix handling, caret placement, and selection bounds
  • Review follow-up

    Both review comments were addressed in 8045b5b:

  • Clamp the selected index after filtering. selectedIndex was only reset when the menu's visibility changed, so typing more characters could leave it pointing past the end of the shrunken list: the lookup returned undefined while the key was still swallowed, leaving the menu open without completing anything. The index is now reset when the filtered list changes identity, with a clamp as a same-render guard. The clamp alone was not sufficient — after narrowing and then widening the query again, the unclamped backing state resurfaced and the selection jumped back to the stale index, which now has its own test.

  • Inline the pass-through dispatcher. slash-menu-action.ts is removed and the Tab/Enter branch is inlined into handleSlashMenuKey through a shared case, per the step-down rule in AGENTS.md.
  • Rebase onto latest main

    Rebased onto the current main to clear a merge conflict that had made the PR unmergeable. The only conflict was in InputArea.tsx: main has since replaced the useMemoizedFn(...) wrappers with plain function declarations and made adjustHeight take a required textarea argument. The completion handler was adapted to match — handleSlashCommandCompletion is now a plain function and calls adjustHeight(textareaRef.current).

    Test verification (RED → GREEN)

    RED — the four selection-bounds behaviours fail on the previous commit, with the new tests applied to otherwise unmodified code:

    FAIL test/webview/useSlashMenu.test.tsx > keeps the selected index inside the list when typing narrows the commands
    FAIL test/webview/useSlashMenu.test.tsx > completes the visible command on Tab after the list shrinks
    FAIL test/webview/useSlashMenu.test.tsx > does not restore a stale selection when the list grows again
    FAIL test/webview/useSlashMenu.test.tsx > selects the visible command on Enter after the list shrinks
     Tests  4 failed | 3 passed (7)
    

    GREEN — after the fix:

     Test Files  2 passed (2)
          Tests  10 passed (10)
    

    Coverage on the changed production lines of useSlashMenu.ts is 100%.

    Full local validation for the affected package (kimi-code / apps/vscode): lint + sherif, typecheck (extension + webview), tests on both the v2 and legacy v1 engines (355 → 361 passing), and the production build all pass.

    AI assistance disclosure

    This patch and PR text were AI-assisted. The implementation was exercised with targeted regression tests and the complete local validation suite; the human contributor remains responsible for reviewing and understanding the submitted changes.

    Diff: 400 lines (+300 / -100) across 5 files Reviewer: ousamabenyounes Review duration: 176406m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.52) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 400 lines diff across 5 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #2468"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 51.7% (MEDIUM) · Higher = larger blast radius
    51.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.6% · Safe to merge
    28.6%