Revert "fix: attach inline prompt to cell.inputArea (under the editor), not cell.node"

This reverts commit 8ed55c43c7.
This commit is contained in:
tao.chen
2026-07-23 17:56:09 +08:00
parent 8ed55c43c7
commit 02cedac138
2 changed files with 6 additions and 7 deletions
+5 -6
View File
@@ -87,7 +87,6 @@ function makeFakeCell(
const cell = new (CodeCell as unknown as new () => CodeCell)(); const cell = new (CodeCell as unknown as new () => CodeCell)();
(cell as any).model = model; (cell as any).model = model;
(cell as any).node = document.createElement('div'); (cell as any).node = document.createElement('div');
(cell as any).inputArea = { node: document.createElement('div') };
const notebook: any = { widgets: [] as CodeCell[] }; const notebook: any = { widgets: [] as CodeCell[] };
const panel: any = { const panel: any = {
@@ -128,7 +127,7 @@ describe('OpenCodeCellActions', () => {
const actions = new OpenCodeCellActions(cell); const actions = new OpenCodeCellActions(cell);
const btns = actions.node.querySelectorAll('button'); const btns = actions.node.querySelectorAll('button');
expect(btns.length).toBe(1); expect(btns.length).toBe(1);
expect(btns[0].textContent).toContain('AI'); expect(btns[0].textContent).toContain('🪄');
}); });
it('disables the button when notebook panel cannot be resolved', () => { it('disables the button when notebook panel cannot be resolved', () => {
@@ -155,7 +154,7 @@ describe('OpenCodeCellActions', () => {
const btn = actions.node.querySelector('button') as HTMLButtonElement; const btn = actions.node.querySelector('button') as HTMLButtonElement;
btn.click(); btn.click();
const prompt = cell.inputArea!.node.querySelector( const prompt = cell.node.querySelector(
'.opencode-inline-prompt' '.opencode-inline-prompt'
) as HTMLElement; ) as HTMLElement;
expect(prompt).not.toBeNull(); expect(prompt).not.toBeNull();
@@ -170,7 +169,7 @@ describe('OpenCodeCellActions', () => {
const btn = actions.node.querySelector('button') as HTMLButtonElement; const btn = actions.node.querySelector('button') as HTMLButtonElement;
btn.click(); btn.click();
btn.click(); btn.click();
expect(cell.inputArea!.node.querySelector('.opencode-inline-prompt')).toBeNull(); expect(cell.node.querySelector('.opencode-inline-prompt')).toBeNull();
}); });
it('disconnects model signals on dispose', () => { it('disconnects model signals on dispose', () => {
@@ -197,7 +196,7 @@ describe('OpenCodeCellActions', () => {
const btn = actions.node.querySelector('button') as HTMLButtonElement; const btn = actions.node.querySelector('button') as HTMLButtonElement;
btn.click(); btn.click();
const select = cell.inputArea!.node.querySelector( const select = cell.node.querySelector(
'.opencode-inline-prompt .opencode-model-select' '.opencode-inline-prompt .opencode-model-select'
) as HTMLSelectElement; ) as HTMLSelectElement;
expect(select).not.toBeNull(); expect(select).not.toBeNull();
@@ -220,7 +219,7 @@ describe('OpenCodeCellActions', () => {
btn.click(); btn.click();
expect( expect(
cell.inputArea!.node.querySelector('.opencode-inline-prompt .opencode-model-select') cell.node.querySelector('.opencode-inline-prompt .opencode-model-select')
).toBeNull(); ).toBeNull();
}); });
}); });
+1 -1
View File
@@ -121,7 +121,7 @@ export class OpenCodeCellActions extends Widget {
this._hidePrompt(); this._hidePrompt();
} }
}); });
Widget.attach(prompt, this._cell.inputArea?.node ?? this._cell.node); Widget.attach(prompt, this._cell.node);
this._prompt = prompt; this._prompt = prompt;
} }