[Bug]: WebBookmarks typeahead (Alt+O / Cmd+O) is always empty due to unbound `fetchBookmarkSuggestions`

Aperta Adatta ai principianti
#3,568 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
electron, typescript

Direzione di ricerca

Inizia da frontend/app/view/webview/webview.tsx, in corrispondenza di BookmarkTypeahead e WebViewModel.fetchBookmarkSuggestions; segui il percorso della callback fino a SuggestionControlInner e verifica come viene gestito il suo contesto this. Controlla che il percorso del file dei segnalibri usato dal pulsante corrisponda a quello letto dal backend. Il lavoro è completato quando i segnalibri configurati compaiono nel typeahead di Alt+O/Cmd+O e il pulsante apre il file dei segnalibri configurato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug triage
Current Behavior

When pressing Alt+O (or Cmd+O on macOS) inside a web widget to open bookmarks, the bookmark typeahead modal appears with the search input, but the dropdown list below it remains completely blank, even when ~/.config/waveterm/bookmarks.json contains valid bookmarks.

Inspecting DevTools inside the web widget reveals an unhandled promise rejection:
TypeError: Cannot read properties of undefined (reading 'env') at fetchBookmarkSuggestions.

Expected Behavior

Configured bookmarks from ~/.config/waveterm/bookmarks.json should appear in the typeahead list when pressing Alt+O / Cmd+O.

Steps To Reproduce
  1. Add a valid bookmark to ~/.config/waveterm/bookmarks.json:
   {
     "bookmark@github": {
       "url": "https://github.com",
       "title": "GitHub"
     }
   }
  1. Open Wave Terminal and create a web block.
  2. Focus the web block and press Alt+O (Windows/Linux) or Cmd+O (macOS).
  3. The search box appears, but the list underneath is empty.
  4. Open DevTools for the web widget to observe the uncaught TypeError in the console.
Wave Version

v0.14.5

Platform

Windows

OS Version/Distribution

Windows 11

Architecture

x64

Anything else?
Root Cause

In frontend/app/view/webview/webview.tsx:

  1. fetchBookmarkSuggestions is defined as an instance method on WebViewModel:
   async fetchBookmarkSuggestions(
       query: string,
       reqContext: SuggestionRequestContext
   ): Promise<FetchSuggestionsResponse> {
       const result = await this.env.rpc.FetchSuggestionsCommand(TabRpcClient, {
           suggestiontype: "bookmark",
           query,
           widgetid: reqContext.widgetid,
           reqnum: reqContext.reqnum,
       });
       return result;
   }
  1. In BookmarkTypeahead (around line 781), it is passed to BlockHeaderSuggestionControl without binding this:
fetchSuggestions={model.fetchBookmarkSuggestions}

When invoked inside SuggestionControlInner, this is undefined, causing this.env.rpc to throw TypeError: Cannot read properties of undefined (reading 'env').

  1. In SuggestionControlInner, the promise rejection has no .catch() handler, so setFetched(true) is never reached, leaving the dropdown unrendered.
Proposed Fix
  1. Bind the method when passing it as a callback in BookmarkTypeahead:
- fetchSuggestions={model.fetchBookmarkSuggestions}
+ fetchSuggestions={model.fetchBookmarkSuggestions.bind(model)}
  1. (Bonus) Line 758 hardcodes ${env.electron.getConfigDir()}/presets/bookmarks.json for the "Open bookmarks.json" button, whereas the backend reads from
    ${env.electron.getConfigDir()}/bookmarks.json:
- const path = `${env.electron.getConfigDir()}/presets/bookmarks.json`;
+ const path = `${env.electron.getConfigDir()}/bookmarks.json`;
Lingua principale
Go
Stelle
22.7k
Fork
1.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wavetermdev/waveterm

Tutte le issue di wavetermdev/waveterm

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.