feat(lr-c1a2): @ mention shows project-local agents in session input#228
Merged
Conversation
When the user types @ in the session input, an inline autocomplete
dropdown now lists all agents installed in the project's .claude/agents/
directory, plus Codex (when not already in a Codex session). Selecting
an agent opens a new session with that agentName — the same action as
the "Agent Chat" button. Graceful empty state: no menu shown when no
agents are installed and Codex is suppressed.
Backend:
- lib/agents.js: add readProjectAgents(projectDir) — scans
.claude/agents/*.md and returns [{name, slug, description}] from
frontmatter, falling back to slug when name is absent.
- lib/project-sessions.js: handle get_agents c2s message; responds
with project_agents_list carrying the local agent array.
- lib/ws-schema.js: register get_agents (c2s) and project_agents_list
(s2c) message types.
Frontend:
- lib/public/modules/at-agents.js: new module — inline @ dropdown for
project agents + Codex. Keyboard nav (Up/Down/Enter/Tab/Esc). Calls
new_session on selection. Requests agents via get_agents WS message.
- lib/public/modules/input.js: import at-agents; show/hide agent menu
alongside mention menu on @ input; route keydown to agentMenuKeydown
(takes priority over user mention); request project agents on init.
- lib/public/modules/app-messages.js: handle project_agents_list;
call requestProjectAgents on session_switched to pre-populate cache.
- lib/public/css/at-agents.css: dropdown styling.
- lib/public/style.css: import at-agents.css.
Tests: test/agents-read-project.test.js — 12 new tests covering
readProjectAgents for input validation, missing directory, empty dir,
frontmatter parsing, non-.md file filtering, and sort order.
289/289 tests pass.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dedup, traversal test Nit 1 + 3 (overlapping dropdowns + keyboard lock): in input.js, show the agent menu first when @ is typed; only fall through to showMentionMenu() if the agent menu ends up empty (isAgentMenuActive() returns false after showAgentMenu). The two menus are now mutually exclusive, so keyboard routing via agentMenuKeydown never blocks the mention menu. Nit 2 (Codex duplicate): remove CODEX_ENTRY from at-agents.js entirely. The agent @ menu now shows only named agents from .claude/agents/. Codex remains available via the mention menu (plain:codex), where its in-session semantics are correct. Also removes the unused store.js import and simplifies the _render badge to always emit "agent". Nit 4 (missing traversal test): add a test in agents-read-project.test.js proving that a traversal-style projectDir (e.g. paths with ../../ segments) passed to readProjectAgents() returns [] safely and never throws. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary\n\nWhen the user types @ in the session input, an inline autocomplete dropdown lists all agents in .claude/agents/ (name + description from frontmatter) plus Codex. Selecting an agent opens a new session with that agentName. Graceful empty state: no menu when no agents installed.\n\n## Changes\n\nBackend: readProjectAgents(projectDir) in agents.js; get_agents/project_agents_list WS round-trip in project-sessions.js; ws-schema.js updated.\n\nFrontend: at-agents.js new inline dropdown module; input.js @ event + keydown routing; app-messages.js project_agents_list handler + prefetch on session_switched; at-agents.css styling.\n\nTests: 12 new tests for readProjectAgents in agents-read-project.test.js. 289/289 tests pass.\n\nTask: lr-c1a2