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

未关闭 适合新手
#3,568 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
electron, typescript

调研方向

从 frontend/app/view/webview/webview.tsx 中的 BookmarkTypeahead 和 WebViewModel.fetchBookmarkSuggestions 开始,跟踪回调如何到达 SuggestionControlInner,并确认其 this 上下文是如何处理的。检查按钮使用的书签文件路径是否与后端读取的路径一致。配置的书签出现在 Alt+O/Cmd+O 的 typeahead 中,并且按钮能够打开配置的书签文件时,即为完成。

由索引模型根据 Issue 内容生成。

描述

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`;
主要语言
Go
星标
22.7k
派生
1.2k
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wavetermdev/waveterm 的其他 Issue

查看 wavetermdev/waveterm 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。