Skip to content

feat(lr-c1a2): @ mention shows project-local agents in session input#228

Merged
akuehner merged 2 commits into
mainfrom
feat/lr-c1a2-at-mention-agents
Jun 11, 2026
Merged

feat(lr-c1a2): @ mention shows project-local agents in session input#228
akuehner merged 2 commits into
mainfrom
feat/lr-c1a2-at-mention-agents

Conversation

@akuehner

Copy link
Copy Markdown
Member

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

akuehner and others added 2 commits June 11, 2026 11:36
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>
@akuehner akuehner merged commit 6772ecd into main Jun 11, 2026
1 check passed
@akuehner akuehner deleted the feat/lr-c1a2-at-mention-agents branch June 11, 2026 15:49
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