fix(web): surface cwd errors in mention search and validate new-session cwd#1005
fix(web): surface cwd errors in mention search and validate new-session cwd#1005tomsen-ai wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 562096c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a03bd92c4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| */ | ||
| async function validateCwdForCreate(cwd: string): Promise<void> { | ||
| const api = getKimiWebApi(); | ||
| await api.browseFs(cwd); |
There was a problem hiding this comment.
Avoid making create depend on fs:browse
When the web app is paired with a daemon that still lacks the PRESUMED /fs:browse route, api.browseFs(cwd) throws and every create path using this helper returns through pushOperationFailure before reaching api.createSession. The surrounding workspace create code still explicitly falls back for older daemons without /workspaces, so this breaks the legacy cwd-only session creation path for that compatibility case; treat unsupported browse validation as non-blocking or rely on the daemon create path to reject bad cwd.
Useful? React with 👍 / 👎.
| await getKimiWebApi().browseFs(cwd); | ||
| } catch (err) { | ||
| const msg = err instanceof Error ? err.message : String(err); | ||
| cwdError.value = msg.includes('ENOENT') ? t('newSession.cwdNotFound') : msg; |
There was a problem hiding this comment.
Ignore stale cwd validation results
If a validation request for an older cwd is still in flight when the user edits to a different path, this callback still applies the old result when it resolves. A delayed failure for a previous missing directory can therefore leave the current valid cwd disabled with a stale error; track a validation token/current cwd before writing cwdError.
Useful? React with 👍 / 👎.
itxaiohanglover
left a comment
There was a problem hiding this comment.
Good fix — propagating errors instead of silently swallowing them is the right pattern. The changeset is well-written.
One question: the browseFs method now throws on error, but the workspace-state layer still has a defensive wrapper. Is there a risk that callers who previously relied on the empty-result fallback (instead of catching the throw) will break? If so, maybe worth adding a note in the changeset about the behavior change.
Overall solid work though.
…on cwd - Composer @-mention now shows the backend error message instead of 'no match' when fs:search fails (e.g., deleted workspace directory). - NewSessionDialog validates the working directory via browseFs before allowing creation, preventing sessions from being created in deleted directories.
2a03bd9 to
562096c
Compare
|
Thanks for the review! Good catch on the I've updated the changeset to mention that |
Related Issue
Closes #1007
Problem
@-mention shows "no match" when search fails. When the active session's working directory no longer exists, typing
@<query>in the composer triggersfs:search. The backend returns anENOENTerror, butworkspaceState.searchFilesswallowed the exception and returned an empty array. The UI then rendered the generic "无匹配" (no match) state, hiding the real problem.New sessions can be created in deleted directories. The new-session dialog validated the cwd, but the one-click "+" button in the sidebar and the onboarding composer both create sessions via
createSessionInWorkspace/startSessionAndSendPrompt, which never checked whether the directory still exists.What changed
apps/kimi-web/src/composables/client/useWorkspaceState.tssearchFilesnow propagates backend errors instead of returning[]on failure, soComposer.vuecan distinguish "no matches" from "search failed".validateCwdForCreate(cwd)and called it beforecreateSession,createSessionInWorkspace, andstartSessionAndSendPrompt.@queries short-circuit to[]to avoid exposing the backend's "query too small" validation error.apps/kimi-web/src/api/daemon/client.tsbrowseFsnow propagates errors. The folder picker already consumesworkspaceState.browseFs, which retains its defensive wrapper, so the picker behavior is unchanged.apps/kimi-web/src/components/Composer.vue/MentionMenu.vue/NewSessionDialog.vuementionErrorstate and error UI for the mention menu.browseFsand disables creation while the directory is invalid..changeset/cwd-mention-error.md@moonshot-ai/kimi-web.Verification
pnpm -C apps/kimi-web exec vue-tsc --noEmitpasses.@packagenow shows the backendENOENTmessage instead of "no match".Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.