kimi-code icon indicating copy to clipboard operation
kimi-code copied to clipboard

web: `@` file mention always shows "无匹配" (no match) on the new-session composer

Open JoeSio opened this issue 4 months ago • 2 comments

What version of Kimi Code is running?

0.31.0

Which open platform/subscription were you using?

Kimi Code subscription (kimi.com), OAuth login — provider: managed:kimi-code

Which model were you using?

kimi-code/k3-256k (shown as "K3-256k" in the status line; not a model-related bug)

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What issue are you seeing?

In the web UI (kimi web), typing @ in the composer on the home / new-session screen always shows "无匹配" ("no match"), even though the workspace directory contains many matching files. The same @ query works fine in the TUI in the same directory, and it also works in the web UI once you are inside an actual session.

Root cause, from reading the web bundle served by kimi web (0.31.0) and probing the local API:

  • The composer's mention loader calls the session-scoped endpoint POST /api/v1/sessions/{session_id}/fs:search and returns an empty list when there is no active session:
async function us(query) {
  const sid = store.activeSessionId;
  if (!sid) return [];            // → popup shows "无匹配"
  try {
    return (await api.searchFiles(sid, { query, limit: 20 })).items;
  } catch { return [] }           // any request error also silently → "无匹配"
}
  • Since 0.20.2 ("a new session is now created only when the first message is sent"), the new-session composer has no session yet, so @ can never return results there.
  • The lab

What steps can reproduce the bug?

  1. In a terminal, cd into any directory containing files (e.g. a git repo).
  2. Run kimi web; the browser opens the web UI.
  3. On the home / new-session composer (before any message is sent), type @a (or @ plus any substring of existing files).
  4. The mention popup shows 无匹配 ("no match").
  5. Now open any existing session from the sidebar (or send the first message) and type the same @a → file suggestions appear correctly.

Verified via API: after creating a session in the same workspace, POST /api/v1/sessions/{id}/fs:search with {"query":"a","limit":5} returns matching files. Session id / context usage not applicable — the bug occurs precisely because no session exists yet.

What is the expected behavior?

On the new-session composer, @ should either:

  • search the workspace directory that kimi web already registered (its launch cwd), even before the session is materialized, or
  • show an honest empty-state hint such as "send a message to start a session before referencing files" instead of "no match".

Also, request errors in the mention loader should not be silently swallowed into the same "no match" state.

Additional information

  • Not terminal-specific: the terminal only hosts the server process; the composer runs in the browser.
  • The TUI is unaffected — @ completion works there because a TUI session is bound to its working directory from the start.
  • Bare @ with an empty query is rejected by the API (query must be ≥ 1 character), which hits the same swallowed-error path.
  • Related past fixes in the changelog: 0.21.0 ("Fix @ file mentions not opening when typed inside a slash command argument") and 0.23.0 ("Fix @ file completion missing deeply nested files in large projects").

JoeSio avatar Jul 30 '26 14:07 JoeSio

Looks like this is already being fixed in https://github.com/MoonshotAI/kimi-code/pull/2308 (workspace-scoped fs:search + web fallback when there is no activeSessionId). Linking here so the issue tracks that PR as well.

mangeshraut712 avatar Jul 30 '26 18:07 mangeshraut712

Fixed

liruifengv avatar Aug 01 '26 03:08 liruifengv