Skip to content

Commit b3a843a

Browse files
authored
Add timed refresh to Cloud9 CodeWhisperer view after load (#4155)
## Problem The nodes in the CodeWhisperer view in Cloud9 sometimes don't work. * Analyzing the browser console shows that the extension host disposes creates commands for the nodes and disposes them (these have a number tied to them as an "ID"). * Most of the time, the view picks up the most recent copy of the commands (the browser console shows the ID being executed when the node is clicked) * Sometimes, this is tied to the ID that's disposed. In these cases, the node actions won't work, with no error feedback (outside the browser console) ## Solution Force a refresh of the CodeWhisperer view in Cloud9 only, 5 seconds after the end of the `extension.ts` `activate()` function. * This disposes the actions and presumably recreates the nodes in the view * It's hard to tell if this is truly a workaround/fix: since the error is sporadic, and the node never works _immediately_ during load (it always takes a second or two at least), we can't tell for sure if the view is going to recover on its own or continue to fail.
1 parent fd27a81 commit b3a843a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/extension.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import { registerWebviewErrorHandler } from './webviews/server'
7878
import { initializeManifestPaths } from './extensionShared'
7979
import { ChildProcess } from './shared/utilities/childProcess'
8080
import { initializeNetworkAgent } from './codewhisperer/client/agent'
81+
import { Timeout } from './shared/utilities/timeoutUtils'
8182

8283
let localize: nls.LocalizeFunc
8384

@@ -283,6 +284,18 @@ export async function activate(context: vscode.ExtensionContext) {
283284
if (!isReleaseVersion()) {
284285
globals.telemetry.assertPassiveTelemetry(globals.didReload)
285286
}
287+
// HACK: Cloud9 currently has some issues with the Codewhisperer view,
288+
// where `getChildren` calls are executed on load but the UI doesn't respond
289+
// (the extension host disposes the commands and recreates them,
290+
// but the nodes remain tied to the old commands).
291+
// This forces a refresh after 5 seconds to ensure a refresh happens at the end of initial extension load.
292+
// If the issue is due to activity on the views,
293+
// this should be fired after planned activities have finished.
294+
if (isCloud9()) {
295+
new Timeout(5000).onCompletion(() => {
296+
vscode.commands.executeCommand('aws.codeWhisperer.refresh')
297+
})
298+
}
286299
} catch (error) {
287300
const stacktrace = (error as Error).stack?.split('\n')
288301
// truncate if the stacktrace is unusually long

0 commit comments

Comments
 (0)