fix(ai): hide the /ask slash command from the composer list when AI is off (LC-686) #655

Merged
longjacksonle merged 1 commit from fix/LC-686-ai-menu-gate into main 2026-08-09 05:21:52 +02:00

Sibling gap to the menu-item fix in this PR: the per-message AI actions now hide when the AI flag is off, but the /ask slash command still appeared in the composer's slash autocomplete, /help, and the argument-hint bar. The route (assistant::handle_ask) already refuses with 403 when AI is unavailable, so this closes the UI half so /ask is not advertised when it cannot run - consistent with Catch me up and the AI menu items.

  • commands::BuiltinCommand gains an llm_only flag, set on ask. visible_commands / exact_command drop llm_only builtins unless AI is available for the viewer's room.
  • New slash::ai_slash_available(state, user, room_id) mirrors the menu items' [data-lc-llm] gate exactly: runtime flag on, an LLM configured, and the viewer privileged in this room (a privilege-lookup error degrades to hidden).
  • The autocomplete query carries room_id (the composer passes {{ room.id }} on both the list and hint requests); absent room_id (older clients) hides the AI command, the safe default. The /help dispatch path computes availability from its room too.

Dispatch is unchanged: typing /ask still routes to handle_ask, which enforces the real flag + role + room-assistant-enabled gate server-side. routes_slash integration tests pass (none asserted /ask in the list).

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01PBAyCesyqJkZ5JgixXf9Lf

Sibling gap to the menu-item fix in this PR: the per-message AI actions now hide when the AI flag is off, but the /ask slash command still appeared in the composer's slash autocomplete, /help, and the argument-hint bar. The route (assistant::handle_ask) already refuses with 403 when AI is unavailable, so this closes the UI half so /ask is not advertised when it cannot run - consistent with Catch me up and the AI menu items. - commands::BuiltinCommand gains an `llm_only` flag, set on `ask`. visible_commands / exact_command drop llm_only builtins unless AI is available for the viewer's room. - New slash::ai_slash_available(state, user, room_id) mirrors the menu items' [data-lc-llm] gate exactly: runtime flag on, an LLM configured, and the viewer privileged in this room (a privilege-lookup error degrades to hidden). - The autocomplete query carries room_id (the composer passes {{ room.id }} on both the list and hint requests); absent room_id (older clients) hides the AI command, the safe default. The /help dispatch path computes availability from its room too. Dispatch is unchanged: typing /ask still routes to handle_ask, which enforces the real flag + role + room-assistant-enabled gate server-side. routes_slash integration tests pass (none asserted /ask in the list). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PBAyCesyqJkZ5JgixXf9Lf
fix(ai): hide the /ask slash command from the composer list when AI is off (LC-686)
All checks were successful
check-secrets / Nosey parker (push) Successful in 4s
check-secrets / TruffleHog (push) Successful in 4s
check-secrets / Kingfisher (push) Successful in 5s
check-secrets / Nosey parker (pull_request) Successful in 3s
check-secrets / TruffleHog (pull_request) Successful in 6s
Check / clippy + fmt + tests (pull_request) Successful in 6m3s
Create release / Create release from merged PR (pull_request) Has been skipped
check-secrets / Kingfisher (pull_request) Successful in 12s
58391a0bb5
Sibling gap to the menu-item fix in this PR: the per-message AI actions now hide when the AI flag is off, but the /ask slash command still appeared in the composer's slash autocomplete, /help, and the argument-hint bar. The route (assistant::handle_ask) already refuses with 403 when AI is unavailable, so this closes the UI half so /ask is not advertised when it cannot run - consistent with Catch me up and the AI menu items.

- commands::BuiltinCommand gains an `llm_only` flag, set on `ask`. visible_commands / exact_command drop llm_only builtins unless AI is available for the viewer's room.
- New slash::ai_slash_available(state, user, room_id) mirrors the menu items' [data-lc-llm] gate exactly: runtime flag on, an LLM configured, and the viewer privileged in this room (a privilege-lookup error degrades to hidden).
- The autocomplete query carries room_id (the composer passes {{ room.id }} on both the list and hint requests); absent room_id (older clients) hides the AI command, the safe default. The /help dispatch path computes availability from its room too.

Dispatch is unchanged: typing /ask still routes to handle_ask, which enforces the real flag + role + room-assistant-enabled gate server-side. routes_slash integration tests pass (none asserted /ask in the list).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PBAyCesyqJkZ5JgixXf9Lf
longjacksonle scheduled this pull request to auto merge when all checks succeed 2026-08-09 05:15:48 +02:00
longjacksonle deleted branch fix/LC-686-ai-menu-gate 2026-08-09 05:21:52 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/lets-chat!655
No description provided.