Skip to content

feat(chat): add /detect slash command for mid-session re-detection#102

Open
michaelroy-amd wants to merge 2 commits into
mainfrom
feat/chat-redetect
Open

feat(chat): add /detect slash command for mid-session re-detection#102
michaelroy-amd wants to merge 2 commits into
mainfrom
feat/chat-redetect

Conversation

@michaelroy-amd

Copy link
Copy Markdown
Member

Summary

  • Adds a /detect [accept|save|dismiss] slash command so a local chat
    engine can be re-detected after ChatConsent::Accepted, without a
    dedicated keybinding colliding with focused chat text entry.
  • Bare /detect re-runs the same probe used at startup
    (detect_local_chat: managed-services registry, then Lemonade
    :13305 / vLLM :8000 / rocm serve :11435) and echoes the result into
    the chat transcript.
  • /detect accept / /detect save / /detect dismiss route through
    the existing accept_detect_offer / save_detect_offer /
    dismiss_detect_offer reducer methods.

Root cause

Once chat is ChatConsent::Accepted, the pre-accept 'd' gate key is
unreachable: while a text field is focused a bare d keypress is
ordinary chat input, and when unfocused the global hotkey table does
not bind 'd' for the Chat tab. There was no way to react to a local
engine coming online (or changing) after the initial handshake short
of restarting the app.

Fix

  • slash.rs: new "detect" branch dispatches to the pre-existing
    AppState reducer methods used by the pre-accept offer UI, so no
    new detection or endpoint-swap plumbing was introduced.
  • app/mod.rs:
    • request_detect() now also echoes a "Detecting…" message into the
      transcript when already Accepted (previously this messaging only
      made sense pre-accept, driving the gate UI).
    • set_detect_result() echoes the found/not-found result into the
      transcript when Accepted, since draw() only renders the
      offer y/s/n prompt pre-accept (confirmed in ui/tabs/chat.rs) —
      without this the probe result would be silently discarded once
      accepted.
  • Accepting or saving a re-detected endpoint via /detect accept /
    /detect save goes through the same accept_detect_offer /
    save_detect_offer calls the initial pre-accept flow uses, so it
    raises the chat_endpoint_rebuild dispatch edge (introduced in
    PR fix(dash): rebuild live chat agent when a local endpoint is accepted #81) exactly like the initial accept does, swapping the live
    agent to the newly detected endpoint.

Coordination notes

Relates to EAI-7354.

Test Plan

  • cargo build -p rocm-dash-tui
  • cargo clippy -p rocm-dash-tui --all-targets --all-features (clean, -D warnings)
  • cargo test -p rocm-dash-tui -- --test-threads=1 (551 passed, 0 failed)
  • New tests:
    • slash_detect_probes_and_echoes_result_while_accepted
    • slash_detect_accept_raises_endpoint_rebuild_like_initial_accept
    • slash_detect_dismiss_and_unknown_subcommand

Once ChatConsent::Accepted, the pre-accept 'd' gate key is unreachable
(it's ordinary chat text when focused, and unbound when unfocused), so
there was no way to re-run local-engine detection after the initial
handshake without restarting the app.

Add a `/detect [accept|save|dismiss]` slash command that reuses the
existing request_detect/accept_detect_offer/save_detect_offer/
dismiss_detect_offer reducer methods. A bare `/detect` raises the same
probe used at startup and echoes the result into the chat transcript
(the offer y/s/n UI is never drawn once Accepted, since draw() only
renders it pre-accept). `/detect accept` and `/detect save` route
through the same code path as the initial accept, so a re-detect mid-
session raises the chat_endpoint_rebuild edge exactly like startup
does, swapping the live agent to the newly detected endpoint.

Relates to EAI-7354.

Signed-off-by: Michael Roy <michael.roy@amd.com>
… offer

Two consistency refinements to the /detect slash command:

- Lowercase the sub-command before matching, so `/detect ACCEPT` etc.
  behave like the lowercase forms — mirroring the case-insensitive
  parsing of the sibling `/permissions` and `/provider` commands.

- Emit a short hint turn when `/detect accept` or `/detect save` is
  used with no pending detected endpoint (previously a silent reducer
  no-op), pointing the user at bare `/detect` to probe first.

Relates to EAI-7354.

Signed-off-by: Michael Roy <michael.roy@amd.com>
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