Skip to content

Commit 0ef7dd8

Browse files
committed
refactor: minor cleanup
1 parent bd1f6b7 commit 0ef7dd8

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

.agents/migration_plan_autocomplete.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
1. **不使用 wrapper/适配层**,直接在各 service 中调用 `autocomplete()` API
2323
2. 消费者代码需要适配:传入容器 `<div>` 而非 `<input>`,通过 API/回调读写值
2424
3. 增量迁移:每个使用点独立迁移,逐一验证
25+
4. **优先保留旧版业务逻辑与交互语义**:迁移时默认以旧版 `autocomplete.js` 行为为准,不主动重设计状态流或交互。
26+
5. **只有在新旧包能力或生命周期模型存在冲突、无法直接一一映射时,才允许添加补丁逻辑**;这类补丁的目标不是“接近”,而是尽可能恢复与旧版完全相同的 behavior。
2527

2628
### 涉及的功能区域
2729
1. **属性名称自动补全**`attribute_autocomplete.ts``attribute_detail.ts``RelationMap.tsx`
@@ -138,12 +140,22 @@
138140

139141
---
140142

141-
### Step 4: 迁移辅助函数
143+
### Step 4: 迁移辅助函数 ✅ 完成
142144
**文件变更:**
143145
- `apps/client/src/services/note_autocomplete.ts``clearText`, `setText`, `showRecentNotes` 等函数
144146

145147
**说明:**
146148
这些函数使用旧库的操作 API(`$el.autocomplete("val", value)` 等),需要改为新库的 `api.setQuery()` / `api.setIsOpen()` / `api.refresh()`
149+
这一步与 **Step 3.4** 有交叉,但并不重复:
150+
- **Step 3.4** 关注的是 IME、快捷键、按钮点击后的交互语义是否与旧版一致
151+
- **Step 4** 关注的是 helper 函数本身是否已经彻底切到新 API,而不再依赖旧版 `.autocomplete("...")`
152+
153+
**当前完成情况:**
154+
-`clearText()` 已改为通过 headless instance 清空 query、关闭面板并触发 `change`
155+
-`setText()` 已改为通过 `showQuery()` 驱动 `setQuery()` / `refresh()`
156+
-`showRecentNotes()` 已改为走 `openRecentNotes()`,不再依赖旧版 `.autocomplete("open")`
157+
-`showAllCommands()` 已改为直接设置 `">"` query 打开命令面板
158+
-`fullTextSearch()` 已改为使用新状态流重跑全文搜索
147159

148160
**验证方式:**
149161
- 最近笔记按钮 → 下拉菜单正常打开

apps/client/src/services/note_autocomplete.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ interface ManagedInstance {
6363
panelEl: HTMLElement;
6464
clearCursor: () => void;
6565
isPanelOpen: () => boolean;
66-
getQuery: () => string;
6766
suppressNextClosedReset: () => void;
6867
showQuery: (query: string) => void;
6968
openRecentNotes: () => void;
@@ -189,7 +188,7 @@ function createSuggestionSource(options: Options, onSelectItem: (item: Suggestio
189188
return {
190189
sourceId: "note-suggestions",
191190
async getItems({ query }: { query: string }) {
192-
return await fetchSuggestions(query, options);
191+
return await fetchResolvedSuggestions(query, options);
193192
},
194193
getItemInputValue({ item }: { item: Suggestion }) {
195194
return getSuggestionInputValue(item);
@@ -789,7 +788,6 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
789788
panelEl,
790789
clearCursor,
791790
isPanelOpen: () => wasPanelOpen,
792-
getQuery: () => currentQuery,
793791
suppressNextClosedReset,
794792
showQuery,
795793
openRecentNotes,

0 commit comments

Comments
 (0)