feat(desktop): Quick Open parity and file icons for chat @ mentions

Merged
HA
24d ago
+303-68

Links

  • Issue: SUPER-2963
  • Supersedes #8986. That PR went stale against main, which already had icons in the @ file rows. This PR carries over its parity work, plus a fix for a regression found while checking it in the app.

Summary

  • Chat @ file mentions now load like Quick Open (Cmd+P): recently viewed files first, open files first among those, the same 50-result limit, and route paths like routes/$workspaceId/... stay searchable.
  • File icons now show where they were missing: file chips in sent messages, and pasted file URLs (no longer a globe). Pages and Chats rows in the @ menu now show the Paradev icon, as their link unfurls do.

Why / Context

The ticket asks whether @ loads files differently from Cmd+P (it did) and asks for extension icons in both the @ list and the link unfurl UI. Both surfaces already used the same host filesystem.searchFiles. The differences were all in the renderer:

  • bare @ showed no files
  • recent files were not ranked first
  • the limit was 20, not 50
  • the @ token stopped at $ ( ) [ ] + ~, so route paths closed the menu partway through

How It Works

  • Shared recent ordering. matchRecentFiles (in useRecentlyViewedFiles/utils) is now used by both CommandPalette and the @ provider (fileMentionMatches). It puts open files first, filters by the query, then caps the list at RECENT_DISPLAY_LIMIT. Filtering before the cap is a small change for Quick Open too: a matching recent file older than the newest ten now shows.
  • Open file paths. ChatPane builds a getOpenFilePaths getter over the same store Quick Open reads: the right pane when it's enabled, otherwise the chat's own store. It reaches the Composer through ChatPaneActions, the same way openLink does. openFilePathsIn is shared with useWorkspaceFileNavigation.
  • Stable search provider. searchFiles reads recent files from the collection and open file paths through a getter when it runs. It does not subscribe to them. A subscription to the workspace's local-state row re-rendered every chat Composer on pane focus, resize and tab switches, because that row also holds the pane layout. It also gave the providers a new identity, which restarted the open menu's search, so slow searches (1–2 s for path queries) never landed. A failed search keeps the recent matches. A draft chat (agent starting or attaching) gets the open-file getter too.
  • matchToken (chat-ui). The query may now contain $ ( ) [ ] + ~. A ) or ] that the token did not open still ends the query, so (cc @alice) and see #general] behave as before. This applies to every trigger.
  • Icons. All icons come from the resolvers link unfurls already use:
    • Files: FileIcon / getFileIcon
    • Pages and Chats: PluginIcon / getPluginIconUrl("superset")

Manual QA

Done in the desktop dev app over CDP, with real X keyboard input (xdotool) in a local workspace on /workspace. The same script ran first with the changes stashed (main) and then with them applied.

StepBefore (main)After
Bare @No Files sectionRecently viewed files listed (below Plugins, see limitations)
@ComposerSearch resultsSame results, with the recently viewed Composer.tsx first
@routes/$workspaceId/hooksMenu closes (0 options)50 files, same list and order as Cmd+P
@hooks/useChangeset20 results50 results, same as Cmd+P
Pasted https://example.com/files/report.pdf in composerGlobe iconPDF icon
Sent message with a file mention and a PDF URLFile chip has no icon; PDF has a globeTypeScript icon; PDF icon
(cc @Comp then )Menu closesMenu closes
@app/(group then )Menu closes at (Menu stays open
Pages rows / Chats rows in @No iconParadev icon

Open-files-first ordering: with matchToken.ts viewed most recently but closed, Cmd+P and a bare @ both list linkUnfurl.ts, Composer.tsx (open) before matchToken.ts.

Not checked in the app: a failed file search, and the draft-chat path. Both are small changes and I found no easy way to trigger them.

Testing

  • bun test for the v2-workspace tree, CommandPalette and AgentComposer: 1135 pass
  • bun test in packages/chat-ui: 84 pass
  • tsc --noEmit clean for apps/desktop and packages/chat-ui
  • biome check clean on the touched files
  • No new user-facing strings, so no catalog changes
  • New tests:
    • matchToken.test.ts (route characters, space, brackets it did not open)
    • matchRecentFiles.test.ts (open-first ordering, filter before the cap)
    • fileMentions.test.ts

Known Limitations

  • With a bare @, the Files section renders below the 14 plugin rows, so recent files need a scroll. That order comes from how chat-ui lays out the default list, which this PR leaves alone.
  • Recent files are read when the search runs. A file opened while the @ menu is already open appears on the next keystroke.
  • @ path searches can take several seconds to show results on a large repo. Main is about as slow on the same queries.
  • While a search loads, the menu shows the previous query's rows. This is existing chat-ui behaviour.

Summary by CodeRabbit

  • New Features
    • File mentions now include matching recent and currently open workspace files, with open files prioritized and duplicates excluded.
    • File mention chips and page mentions display more appropriate file and app icons.
  • Bug Fixes
    • File searches skip blank queries, and mention matching better handles route paths and bracketed tokens.