Skip to content

Commit 1635032

Browse files
committed
delete redundant codes
1 parent 13ad7ac commit 1635032

File tree

3 files changed

+0
-135
lines changed

3 files changed

+0
-135
lines changed

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -255,81 +255,6 @@ export function registerMessageListeners(
255255
chatStreamTokens.delete(tabId)
256256
break
257257
}
258-
case 'sendToPrompt': {
259-
languageClient.info('[VSCode Client] sendToPrompt message received, using regular chat flow')
260-
261-
// Create chat parameters from sendToPrompt message
262-
const chatParams: ChatParams = {
263-
prompt: {
264-
prompt: message.params.prompt?.prompt || message.params.prompt || '',
265-
escapedPrompt:
266-
message.params.prompt?.escapedPrompt ||
267-
message.params.prompt?.prompt ||
268-
message.params.prompt ||
269-
'',
270-
},
271-
tabId: message.params.tabId || uuidv4(),
272-
}
273-
274-
const partialResultToken = uuidv4()
275-
let lastPartialResult: ChatResult | undefined
276-
const cancellationToken = new CancellationTokenSource()
277-
chatStreamTokens.set(chatParams.tabId, cancellationToken)
278-
279-
const chatDisposable = languageClient.onProgress(chatRequestType, partialResultToken, (partialResult) =>
280-
handlePartialResult<ChatResult>(partialResult, encryptionKey, provider, chatParams.tabId).then(
281-
(result) => {
282-
lastPartialResult = result
283-
}
284-
)
285-
)
286-
287-
const editor =
288-
vscode.window.activeTextEditor ||
289-
vscode.window.visibleTextEditors.find((editor) => editor.document.languageId !== 'Log')
290-
if (editor) {
291-
chatParams.cursorState = getCursorState(editor.selections)
292-
chatParams.textDocument = { uri: editor.document.uri.toString() }
293-
}
294-
295-
const chatRequest = await encryptRequest<ChatParams>(chatParams, encryptionKey)
296-
try {
297-
const chatResult = await languageClient.sendRequest<string | ChatResult>(
298-
chatRequestType.method,
299-
{
300-
...chatRequest,
301-
partialResultToken,
302-
},
303-
cancellationToken.token
304-
)
305-
await handleCompleteResult<ChatResult>(
306-
chatResult,
307-
encryptionKey,
308-
provider,
309-
chatParams.tabId,
310-
chatDisposable
311-
)
312-
} catch (e) {
313-
const errorMsg = `Error occurred during sendToPrompt chat request: ${e}`
314-
languageClient.info(errorMsg)
315-
languageClient.info(
316-
`Last result from language server: ${JSON.stringify(lastPartialResult, undefined, 2)}`
317-
)
318-
if (!isValidResponseError(e)) {
319-
throw e
320-
}
321-
await handleCompleteResult<ChatResult>(
322-
e.data,
323-
encryptionKey,
324-
provider,
325-
chatParams.tabId,
326-
chatDisposable
327-
)
328-
} finally {
329-
chatStreamTokens.delete(chatParams.tabId)
330-
}
331-
break
332-
}
333258
case chatRequestType.method: {
334259
const chatParams: ChatParams = { ...message.params }
335260
const partialResultToken = uuidv4()

packages/core/src/amazonq/autoDebug/lsp/autoDebugLspClient.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ export class AutoDebugLspClient {
8787
return this.languageClient
8888
}
8989

90-
/**
91-
* Sends a chat message using the webview postMessage system
92-
* This uses the same approach as the working explainIssue command
93-
*/
9490
public async sendChatMessage(params: { message: string; triggerType: string; eventId: string }): Promise<boolean> {
9591
try {
9692
// Get the webview provider (stored globally during activation)

packages/core/src/amazonq/webview/ui/main.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -281,62 +281,6 @@ export class WebviewUIHandler {
281281

282282
if (command === 'aws.amazonq.sendToPrompt') {
283283
return this.messageController?.sendSelectedCodeToTab(message, command)
284-
} else if (command === 'aws.amazonq.autoDebug.sendMessage') {
285-
// **CRITICAL FIX**: Handle AutoDebug messages using the exact same flow as normal user messages
286-
// This ensures the complete message processing pipeline is used, including language server requests
287-
288-
// Generate a proper event ID for the chat prompt
289-
const eventID = `autoDebug-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
290-
291-
// Get or create a tab for the AutoDebug message
292-
let targetTabId: string | undefined
293-
const selectedTab = this.tabsStorage.getSelectedTab()
294-
295-
if (selectedTab && ['cwc', 'unknown'].includes(selectedTab.type) && selectedTab.status === 'free') {
296-
// Use existing tab
297-
targetTabId = selectedTab.id
298-
} else {
299-
// Create new tab
300-
const tabData = this.tabDataGenerator?.getTabData('cwc', false)
301-
if (tabData) {
302-
targetTabId = this.mynahUI?.updateStore('', tabData)
303-
}
304-
if (targetTabId) {
305-
this.tabsStorage.addTab({
306-
id: targetTabId,
307-
type: 'cwc',
308-
status: 'free',
309-
isSelected: true,
310-
lastCommand: command,
311-
})
312-
}
313-
}
314-
315-
if (targetTabId) {
316-
// **KEY FIX**: Use ONLY the TextMessageHandler flow - don't duplicate with MessageController
317-
// This is the exact same flow as normal user messages
318-
this.textMessageHandler?.handle(
319-
{
320-
prompt: message.body as string,
321-
escapedPrompt: message.body as string,
322-
command: undefined,
323-
context: undefined,
324-
},
325-
targetTabId,
326-
eventID
327-
)
328-
329-
this.postMessage(createOpenAgentTelemetry('cwc', 'right-click'))
330-
this.postMessage({
331-
command: 'start-chat-message-telemetry',
332-
trigger: 'onContextCommand',
333-
tabID: targetTabId,
334-
tabType: 'cwc',
335-
startTime: Date.now(),
336-
traceId: eventID,
337-
})
338-
}
339-
return targetTabId
340284
} else {
341285
const tabID = this.messageController?.sendMessageToTab(message, 'cwc', command)
342286
if (tabID && command) {

0 commit comments

Comments
 (0)