Revert "feat: AI entry button at the cell's bottom-right + clear input after success"
This reverts commit fd30e53e25.
This commit is contained in:
@@ -194,11 +194,8 @@ describe('OpenCodeCellActions', () => {
|
||||
|
||||
it('renders a single AI button', () => {
|
||||
const cell = makeFakeCell('x = 1');
|
||||
// Constructing the actions widget has the side effect of appending
|
||||
// the floating AI button to cell.node; the widget reference itself
|
||||
// is not needed in this test.
|
||||
new OpenCodeCellActions(cell);
|
||||
const btns = cell.node.querySelectorAll('button.opencode-cell-ai-btn');
|
||||
const actions = new OpenCodeCellActions(cell);
|
||||
const btns = actions.node.querySelectorAll('button');
|
||||
expect(btns.length).toBe(1);
|
||||
expect(btns[0].textContent).toContain('AI');
|
||||
});
|
||||
@@ -213,11 +210,8 @@ describe('OpenCodeCellActions', () => {
|
||||
contentChanged: { connect: jest.fn(), disconnect: jest.fn() },
|
||||
stateChanged: { connect: jest.fn(), disconnect: jest.fn() }
|
||||
};
|
||||
(cell as any).node = document.createElement('div');
|
||||
new OpenCodeCellActions(cell);
|
||||
const btn = cell.node.querySelector(
|
||||
'button.opencode-cell-ai-btn'
|
||||
) as HTMLButtonElement;
|
||||
const actions = new OpenCodeCellActions(cell);
|
||||
const btn = actions.node.querySelector('button') as HTMLButtonElement;
|
||||
expect(btn.disabled).toBe(true);
|
||||
});
|
||||
|
||||
@@ -227,7 +221,7 @@ describe('OpenCodeCellActions', () => {
|
||||
Object.defineProperty(actions, 'parent', { value: cell, configurable: true });
|
||||
(actions as any).onAfterAttach({} as any);
|
||||
|
||||
const btn = cell.node.querySelector('button.opencode-cell-ai-btn') as HTMLButtonElement;
|
||||
const btn = actions.node.querySelector('button') as HTMLButtonElement;
|
||||
btn.click();
|
||||
|
||||
const prompt = cell.node.querySelector(
|
||||
@@ -242,7 +236,7 @@ describe('OpenCodeCellActions', () => {
|
||||
Object.defineProperty(actions, 'parent', { value: cell, configurable: true });
|
||||
(actions as any).onAfterAttach({} as any);
|
||||
|
||||
const btn = cell.node.querySelector('button.opencode-cell-ai-btn') as HTMLButtonElement;
|
||||
const btn = actions.node.querySelector('button') as HTMLButtonElement;
|
||||
btn.click();
|
||||
btn.click();
|
||||
expect(cell.node.querySelector('.opencode-inline-prompt')).toBeNull();
|
||||
@@ -280,7 +274,7 @@ describe('OpenCodeCellActions', () => {
|
||||
Object.defineProperty(actions, 'parent', { value: cell, configurable: true });
|
||||
(actions as any).onAfterAttach({} as any);
|
||||
|
||||
const btn = cell.node.querySelector('button.opencode-cell-ai-btn') as HTMLButtonElement;
|
||||
const btn = actions.node.querySelector('button') as HTMLButtonElement;
|
||||
btn.click();
|
||||
|
||||
const prompt = cell.node.querySelector(
|
||||
@@ -325,7 +319,7 @@ describe('OpenCodeCellActions', () => {
|
||||
Object.defineProperty(actions, 'parent', { value: cell, configurable: true });
|
||||
(actions as any).onAfterAttach({} as any);
|
||||
|
||||
const btn = cell.node.querySelector('button.opencode-cell-ai-btn') as HTMLButtonElement;
|
||||
const btn = actions.node.querySelector('button') as HTMLButtonElement;
|
||||
btn.click();
|
||||
|
||||
const modelSel = cell.node.querySelector(
|
||||
@@ -354,7 +348,7 @@ describe('OpenCodeCellActions', () => {
|
||||
Object.defineProperty(actions, 'parent', { value: cell, configurable: true });
|
||||
(actions as any).onAfterAttach({} as any);
|
||||
|
||||
const btn = cell.node.querySelector('button.opencode-cell-ai-btn') as HTMLButtonElement;
|
||||
const btn = actions.node.querySelector('button') as HTMLButtonElement;
|
||||
btn.click();
|
||||
|
||||
const prompt = cell.node.querySelector(
|
||||
@@ -390,7 +384,7 @@ describe('OpenCodeCellActions', () => {
|
||||
Object.defineProperty(actions, 'parent', { value: cell, configurable: true });
|
||||
(actions as any).onAfterAttach({} as any);
|
||||
|
||||
const btn = cell.node.querySelector('button.opencode-cell-ai-btn') as HTMLButtonElement;
|
||||
const btn = actions.node.querySelector('button') as HTMLButtonElement;
|
||||
btn.click();
|
||||
|
||||
expect(
|
||||
@@ -409,7 +403,7 @@ describe('OpenCodeCellActions', () => {
|
||||
// has a target and the cell source check has a baseline).
|
||||
Object.defineProperty(actions, 'parent', { value: cell, configurable: true });
|
||||
(actions as any).onAfterAttach({} as any);
|
||||
const btn = cell.node.querySelector('button.opencode-cell-ai-btn') as HTMLButtonElement;
|
||||
const btn = actions.node.querySelector('button') as HTMLButtonElement;
|
||||
btn.click();
|
||||
|
||||
// The history refresh on show is async; spy on _refreshHistory to
|
||||
@@ -428,34 +422,6 @@ describe('OpenCodeCellActions', () => {
|
||||
// A history refresh was triggered (to pick up the new assistant msg).
|
||||
expect(refreshSpy).toHaveBeenCalledWith('foo.ipynb');
|
||||
});
|
||||
|
||||
it('clears the input textarea after a successful response', () => {
|
||||
setOpenCodeProviders(null);
|
||||
const cell = makeFakeCell('x = 1');
|
||||
const actions = new OpenCodeCellActions(cell);
|
||||
Object.defineProperty(actions, 'parent', { value: cell, configurable: true });
|
||||
(actions as any).onAfterAttach({} as any);
|
||||
|
||||
// Open the prompt and type something into the textarea.
|
||||
const aiBtn = cell.node.querySelector(
|
||||
'button.opencode-cell-ai-btn'
|
||||
) as HTMLButtonElement;
|
||||
aiBtn.click();
|
||||
const prompt = (actions as any)._prompt;
|
||||
expect(prompt).not.toBeNull();
|
||||
const textarea = prompt._textarea as HTMLTextAreaElement;
|
||||
textarea.value = 'make it faster';
|
||||
|
||||
// A successful response clears the input so the user can type a
|
||||
// follow-up message.
|
||||
(actions as any)._handleResponse({
|
||||
ok: true,
|
||||
markdown: 'ok',
|
||||
sessionId: 'ses-1',
|
||||
notebookPath: 'foo.ipynb'
|
||||
});
|
||||
expect(textarea.value).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('OpenCodeInlinePrompt', () => {
|
||||
|
||||
Reference in New Issue
Block a user