[PR #8157] fix(ui): handle async items function in useFilteredList hook #12642

Closed
opened 2026-02-16 18:17:32 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8157

State: closed
Merged: No


What does this PR do?

Fixes the empty file list issue when trying to tag files/folders in chat via the @ mention autocomplete (issue #8148).

Root Cause:
When props.items is an async function (like in the @ autocomplete which calls files.searchFilesAndDirectories), the useFilteredList hook's source function calls it without arguments. This returns a Promise, which is then passed to the fetcher as items. Since Promise is truthy, the fallback logic items ?? await props.items(needle) didn't trigger, causing the code to iterate over a Promise object instead of an array.

Fix:
Check if items is a Promise or not an array, and if so, properly call the async function with the filter parameter.

How did you verify your code works?

  • Ran npm run typecheck - passes
  • Analyzed the code flow to confirm the fix handles the async case properly

Fixes #8148


🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8157 **State:** closed **Merged:** No --- ### What does this PR do? Fixes the empty file list issue when trying to tag files/folders in chat via the `@` mention autocomplete (issue #8148). **Root Cause:** When `props.items` is an async function (like in the `@` autocomplete which calls `files.searchFilesAndDirectories`), the `useFilteredList` hook's source function calls it without arguments. This returns a Promise, which is then passed to the fetcher as `items`. Since Promise is truthy, the fallback logic `items ?? await props.items(needle)` didn't trigger, causing the code to iterate over a Promise object instead of an array. **Fix:** Check if `items` is a Promise or not an array, and if so, properly call the async function with the filter parameter. ### How did you verify your code works? - Ran `npm run typecheck` - passes - Analyzed the code flow to confirm the fix handles the async case properly Fixes #8148 --- 🤖 Generated with Claude Code
yindo added the pull-request label 2026-02-16 18:17:32 -05:00
yindo closed this issue 2026-02-16 18:17:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12642