delete legacy ask code

This commit is contained in:
sanio 2025-07-13 10:18:29 +09:00
parent 093f233f5a
commit 3d7738826c
4 changed files with 53 additions and 161 deletions

View File

@ -231,9 +231,6 @@ class AskService {
console.log(`[AskService] Stream reading was intentionally cancelled. Reason: ${signal.reason}`); console.log(`[AskService] Stream reading was intentionally cancelled. Reason: ${signal.reason}`);
} else { } else {
console.error('[AskService] Error while processing stream:', streamError); console.error('[AskService] Error while processing stream:', streamError);
if (askWin && !askWin.isDestroyed()) {
askWin.webContents.send('ask-response-stream-error', { error: streamError.message });
}
} }
} finally { } finally {
this.state.isStreaming = false; this.state.isStreaming = false;

View File

@ -138,16 +138,9 @@ contextBridge.exposeInMainWorld('api', {
removeOnAskStateUpdate: (callback) => ipcRenderer.removeListener('ask:stateUpdate', callback), removeOnAskStateUpdate: (callback) => ipcRenderer.removeListener('ask:stateUpdate', callback),
// Listeners // Listeners
onSendQuestionToRenderer: (callback) => ipcRenderer.on('ask:sendQuestionToRenderer', callback),
removeOnSendQuestionToRenderer: (callback) => ipcRenderer.removeListener('ask:sendQuestionToRenderer', callback),
onHideTextInput: (callback) => ipcRenderer.on('hide-text-input', callback),
removeOnHideTextInput: (callback) => ipcRenderer.removeListener('hide-text-input', callback),
onShowTextInput: (callback) => ipcRenderer.on('ask:showTextInput', callback), onShowTextInput: (callback) => ipcRenderer.on('ask:showTextInput', callback),
removeOnShowTextInput: (callback) => ipcRenderer.removeListener('ask:showTextInput', callback), removeOnShowTextInput: (callback) => ipcRenderer.removeListener('ask:showTextInput', callback),
onResponseChunk: (callback) => ipcRenderer.on('ask-response-chunk', callback),
removeOnResponseChunk: (callback) => ipcRenderer.removeListener('ask-response-chunk', callback),
onResponseStreamEnd: (callback) => ipcRenderer.on('ask-response-stream-end', callback),
removeOnResponseStreamEnd: (callback) => ipcRenderer.removeListener('ask-response-stream-end', callback),
onScrollResponseUp: (callback) => ipcRenderer.on('scroll-response-up', callback), onScrollResponseUp: (callback) => ipcRenderer.on('scroll-response-up', callback),
removeOnScrollResponseUp: (callback) => ipcRenderer.removeListener('scroll-response-up', callback), removeOnScrollResponseUp: (callback) => ipcRenderer.removeListener('scroll-response-up', callback),
onScrollResponseDown: (callback) => ipcRenderer.on('scroll-response-down', callback), onScrollResponseDown: (callback) => ipcRenderer.on('scroll-response-down', callback),

View File

@ -719,15 +719,13 @@ export class AskView extends LitElement {
this.headerText = 'AI Response'; this.headerText = 'AI Response';
this.headerAnimating = false; this.headerAnimating = false;
this.isStreaming = false; this.isStreaming = false;
// this.accumulatedResponse = '';
this.marked = null; this.marked = null;
this.hljs = null; this.hljs = null;
this.DOMPurify = null; this.DOMPurify = null;
this.isLibrariesLoaded = false; this.isLibrariesLoaded = false;
// this.handleStreamChunk = this.handleStreamChunk.bind(this);
// this.handleStreamEnd = this.handleStreamEnd.bind(this);
this.handleSendText = this.handleSendText.bind(this); this.handleSendText = this.handleSendText.bind(this);
this.handleTextKeydown = this.handleTextKeydown.bind(this); this.handleTextKeydown = this.handleTextKeydown.bind(this);
this.handleCopy = this.handleCopy.bind(this); this.handleCopy = this.handleCopy.bind(this);
@ -770,12 +768,6 @@ export class AskView extends LitElement {
}; };
if (window.api) { if (window.api) {
window.api.askView.onSendQuestionToRenderer(this.handleQuestionFromAssistant);
window.api.askView.onHideTextInput(() => {
console.log('📤 Hide text input signal received');
this.showTextInput = false;
this.requestUpdate();
});
window.api.askView.onShowTextInput(() => { window.api.askView.onShowTextInput(() => {
console.log('📤 Show text input signal received'); console.log('📤 Show text input signal received');
if (!this.showTextInput) { if (!this.showTextInput) {
@ -784,9 +776,6 @@ export class AskView extends LitElement {
} }
}); });
// window.api.askView.onResponseChunk(this.handleStreamChunk);
// window.api.askView.onResponseStreamEnd(this.handleStreamEnd);
window.api.askView.onScrollResponseUp(() => this.handleScroll('up')); window.api.askView.onScrollResponseUp(() => this.handleScroll('up'));
window.api.askView.onScrollResponseDown(() => this.handleScroll('down')); window.api.askView.onScrollResponseDown(() => this.handleScroll('down'));
window.api.askView.onAskStateUpdate((event, newState) => { window.api.askView.onAskStateUpdate((event, newState) => {
@ -824,11 +813,7 @@ export class AskView extends LitElement {
if (window.api) { if (window.api) {
window.api.askView.removeOnAskStateUpdate(this.handleAskStateUpdate); window.api.askView.removeOnAskStateUpdate(this.handleAskStateUpdate);
window.api.askView.removeOnSendQuestionToRenderer(this.handleQuestionFromAssistant);
window.api.askView.removeOnHideTextInput(this.handleHideTextInput);
window.api.askView.removeOnShowTextInput(this.handleShowTextInput); window.api.askView.removeOnShowTextInput(this.handleShowTextInput);
window.api.askView.removeOnResponseChunk(this.handleStreamChunk);
window.api.askView.removeOnResponseStreamEnd(this.handleStreamEnd);
window.api.askView.removeOnScrollResponseUp(this.handleScroll); window.api.askView.removeOnScrollResponseUp(this.handleScroll);
window.api.askView.removeOnScrollResponseDown(this.handleScroll); window.api.askView.removeOnScrollResponseDown(this.handleScroll);
console.log('✅ AskView: IPC 이벤트 리스너 제거 필요'); console.log('✅ AskView: IPC 이벤트 리스너 제거 필요');
@ -917,9 +902,6 @@ export class AskView extends LitElement {
this.isStreaming = false; this.isStreaming = false;
this.headerText = 'AI Response'; this.headerText = 'AI Response';
this.showTextInput = true; this.showTextInput = true;
// this.accumulatedResponse = '';
// this.requestUpdate();
// this.renderContent();
} }
handleInputFocus() { handleInputFocus() {
@ -986,33 +968,7 @@ export class AskView extends LitElement {
} }
} }
// --- 스트리밍 처리 핸들러 ---
// handleStreamChunk(event, { token }) {
// if (!this.isStreaming) {
// this.isStreaming = true;
// this.isLoading = false;
// this.accumulatedResponse = '';
// const container = this.shadowRoot.getElementById('responseContainer');
// if (container) container.innerHTML = '';
// this.headerText = 'AI Response';
// this.headerAnimating = false;
// this.requestUpdate();
// }
// this.accumulatedResponse += token;
// this.renderContent();
// }
// handleStreamEnd() {
// this.isStreaming = false;
// this.currentResponse = this.accumulatedResponse;
// if (this.headerText !== 'AI Response') {
// this.headerText = 'AI Response';
// this.requestUpdate();
// }
// this.renderContent();
// }
// ✨ 렌더링 로직 통합
renderContent() { renderContent() {
const responseContainer = this.shadowRoot.getElementById('responseContainer'); const responseContainer = this.shadowRoot.getElementById('responseContainer');
if (!responseContainer) return; if (!responseContainer) return;
@ -1029,7 +985,6 @@ export class AskView extends LitElement {
return; return;
} }
// ✨ isStreaming이나 accumulatedResponse 대신 currentResponse를 직접 사용
let textToRender = this.fixIncompleteMarkdown(this.currentResponse); let textToRender = this.fixIncompleteMarkdown(this.currentResponse);
textToRender = this.fixIncompleteCodeBlocks(textToRender); textToRender = this.fixIncompleteCodeBlocks(textToRender);
@ -1269,32 +1224,11 @@ export class AskView extends LitElement {
textInput.value = ''; textInput.value = '';
// this.currentQuestion = text;
// this.lineCopyState = {};
// this.showTextInput = false;
// this.isLoading = true;
// this.isStreaming = false;
// this.currentResponse = '';
// this.accumulatedResponse = '';
// this.startHeaderAnimation();
// this.requestUpdate();
// this.renderContent();
if (window.api) { if (window.api) {
window.api.askView.sendMessage(text).catch(error => { window.api.askView.sendMessage(text).catch(error => {
console.error('Error sending text:', error); console.error('Error sending text:', error);
}); });
} }
// if (window.api) {
// window.api.askView.sendMessage(text).catch(error => {
// console.error('Error sending text:', error);
// this.isLoading = false;
// this.isStreaming = false;
// this.currentResponse = `Error: ${error.message}`;
// this.renderContent();
// });
// }
} }
handleTextKeydown(e) { handleTextKeydown(e) {
@ -1312,21 +1246,6 @@ export class AskView extends LitElement {
} }
} }
// updated(changedProperties) {
// super.updated(changedProperties);
// if (changedProperties.has('isLoading')) {
// this.renderContent();
// }
// if (changedProperties.has('showTextInput') || changedProperties.has('isLoading')) {
// this.adjustWindowHeightThrottled();
// }
// if (changedProperties.has('showTextInput') && this.showTextInput) {
// this.focusTextInput();
// }
// }
updated(changedProperties) { updated(changedProperties) {
super.updated(changedProperties); super.updated(changedProperties);

View File

@ -819,9 +819,9 @@ function setupIpcHandlers(movementManager) {
ipcMain.handle('toggle-all-windows-visibility', () => toggleAllWindowsVisibility()); ipcMain.handle('toggle-all-windows-visibility', () => toggleAllWindowsVisibility());
ipcMain.handle('toggle-feature', async (event, featureName) => { // ipcMain.handle('toggle-feature', async (event, featureName) => {
return toggleFeature(featureName); // return toggleFeature(featureName);
}); // });
ipcMain.on('animation-finished', (event) => { ipcMain.on('animation-finished', (event) => {
const win = BrowserWindow.fromWebContents(event.sender); const win = BrowserWindow.fromWebContents(event.sender);
@ -838,27 +838,56 @@ function setupIpcHandlers(movementManager) {
askWindow.webContents.send('window-hide-animation'); askWindow.webContents.send('window-hide-animation');
} }
}); });
// ipcMain.handle('ask:sendQuestionToMain', (event, question) => {
// console.log('📨 Main process: Sending question to AskView', question);
// toggleFeature('ask', {ask: { questionText: question }});
// return { success: true };
// });
} }
/** // /**
* // *
* @param {'listen'|'ask'|'settings'} featureName // * @param {'listen'|'ask'|'settings'} featureName
* @param {{ // * @param {{
* listen?: { targetVisibility?: 'show'|'hide' }, // * listen?: { targetVisibility?: 'show'|'hide' },
* ask?: { targetVisibility?: 'show'|'hide', questionText?: string }, // * ask?: { targetVisibility?: 'show'|'hide', questionText?: string },
* settings?: { targetVisibility?: 'show'|'hide' } // * settings?: { targetVisibility?: 'show'|'hide' }
* }} [options={}] // * }} [options={}]
*/ // */
// async function toggleFeature(featureName, options = {}) {
// if (!windowPool.get(featureName) && currentHeaderState === 'main') {
// createFeatureWindows(windowPool.get('header'));
// }
// if (featureName === 'ask') {
// let askWindow = windowPool.get('ask');
// if (!askWindow || askWindow.isDestroyed()) {
// console.log('[WindowManager] Ask window not found, creating new one');
// return;
// }
// const questionText = options?.ask?.questionText ?? null;
// const targetVisibility = options?.ask?.targetVisibility ?? null;
// if (askWindow.isVisible()) {
// if (questionText) {
// askWindow.webContents.send('ask:sendQuestionToRenderer', questionText);
// } else {
// updateLayout();
// if (targetVisibility === 'show') {
// askWindow.webContents.send('ask:showTextInput');
// } else {
// askWindow.webContents.send('window-hide-animation');
// }
// }
// } else {
// console.log('[WindowManager] Showing hidden Ask window');
// askWindow.show();
// updateLayout();
// if (questionText) {
// askWindow.webContents.send('ask:sendQuestionToRenderer', questionText);
// }
// askWindow.webContents.send('window-show-animation');
// }
// }
// }
async function toggleFeature(featureName, options = {}) { async function toggleFeature(featureName, options = {}) {
if (!windowPool.get(featureName) && currentHeaderState === 'main') { if (!windowPool.get(featureName) && currentHeaderState === 'main') {
createFeatureWindows(windowPool.get('header')); createFeatureWindows(windowPool.get('header'));
@ -871,61 +900,15 @@ async function toggleFeature(featureName, options = {}) {
console.log('[WindowManager] Ask window not found, creating new one'); console.log('[WindowManager] Ask window not found, creating new one');
return; return;
} }
const questionText = options?.ask?.questionText ?? null;
const targetVisibility = options?.ask?.targetVisibility ?? null;
if (askWindow.isVisible()) { if (askWindow.isVisible()) {
if (questionText) { askWindow.webContents.send('ask:showTextInput');
askWindow.webContents.send('ask:sendQuestionToRenderer', questionText);
} else {
updateLayout();
if (targetVisibility === 'show') {
askWindow.webContents.send('ask:showTextInput');
} else {
askWindow.webContents.send('window-hide-animation');
}
}
} else { } else {
console.log('[WindowManager] Showing hidden Ask window'); console.log('[WindowManager] Showing hidden Ask window');
askWindow.show(); askWindow.show();
updateLayout(); updateLayout();
if (questionText) {
askWindow.webContents.send('ask:sendQuestionToRenderer', questionText);
}
askWindow.webContents.send('window-show-animation'); askWindow.webContents.send('window-show-animation');
} }
} }
if (featureName === 'settings') {
const settingsWindow = windowPool.get(featureName);
if (settingsWindow) {
if (settingsWindow.isDestroyed()) {
console.error(`Window ${featureName} is destroyed, cannot toggle`);
return;
}
if (settingsWindow.isVisible()) {
if (featureName === 'settings') {
settingsWindow.webContents.send('settings-window-hide-animation');
} else {
settingsWindow.webContents.send('window-hide-animation');
}
} else {
try {
settingsWindow.show();
updateLayout();
settingsWindow.webContents.send('window-show-animation');
} catch (e) {
console.error('Error showing window:', e);
}
}
} else {
console.error(`Window not found for feature: ${featureName}`);
console.error('Available windows:', Array.from(windowPool.keys()));
}
}
} }