-
Notifications
You must be signed in to change notification settings - Fork 251
feat(amazonq): Add events to trigger file refresh on file changes in agentic #5709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
8c6014d
3307059
5583c21
f225ef4
c51bb1b
12d477b
b9db020
7019fc8
86e400f
59cc26c
f85164c
28c2d45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import com.intellij.openapi.fileEditor.FileEditorManager | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vfs.LocalFileSystem | ||
import com.intellij.openapi.vfs.VfsUtil | ||
import com.intellij.openapi.vfs.VirtualFileManager | ||
import migration.software.aws.toolkits.jetbrains.settings.AwsSettings | ||
import org.eclipse.lsp4j.ConfigurationParams | ||
|
@@ -25,6 +26,7 @@ | |
import org.eclipse.lsp4j.ShowDocumentResult | ||
import org.eclipse.lsp4j.ShowMessageRequestParams | ||
import org.slf4j.event.Level | ||
import software.amazon.awssdk.utils.UserHomeDirectoryUtils | ||
import software.aws.toolkits.core.utils.error | ||
import software.aws.toolkits.core.utils.getLogger | ||
import software.aws.toolkits.core.utils.info | ||
|
@@ -39,6 +41,8 @@ | |
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.CHAT_OPEN_TAB | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.CHAT_SEND_CONTEXT_COMMANDS | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.CHAT_SEND_UPDATE | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.CopyFileParams | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.FileParams | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GET_SERIALIZED_CHAT_REQUEST_METHOD | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GetSerializedChatResult | ||
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.OpenFileDiffParams | ||
|
@@ -59,6 +63,7 @@ | |
import java.util.UUID | ||
import java.util.concurrent.CompletableFuture | ||
import java.util.concurrent.TimeUnit | ||
import kotlin.io.path.Path | ||
|
||
/** | ||
* Concrete implementation of [AmazonQLanguageClient] to handle messages sent from server | ||
|
@@ -403,7 +408,37 @@ | |
return CompletableFuture.completedFuture(Unit) | ||
} | ||
|
||
override fun appendFile(params: FileParams) = refreshVfs(params.path) | ||
|
||
override fun createDirectory(params: FileParams) = refreshVfs(params.path) | ||
|
||
override fun removeFile(params: FileParams) = refreshVfs(params.path) | ||
|
||
override fun writeFile(params: FileParams) = refreshVfs(params.path) | ||
|
||
override fun copyFile(params: CopyFileParams) { | ||
refreshVfs(params.oldPath) | ||
return refreshVfs(params.newPath) | ||
} | ||
|
||
private fun refreshVfs(path: String) { | ||
if (Path(path).startsWith(userHomePath)) return | ||
manodnyab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try { | ||
ApplicationManager.getApplication().invokeLater { | ||
VfsUtil.markDirtyAndRefresh(false, true, true, Path(path).toFile()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. async should be fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not populate the changes immediately if we do async |
||
} | ||
} catch (e: Exception) { | ||
LOG.warn { "Could not refresh file" } | ||
manodnyab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
companion object { | ||
val userHomePath = Paths.get( | ||
Check notice on line 436 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLanguageClientImpl.kt
|
||
|
||
UserHomeDirectoryUtils.userHomeDirectory(), | ||
".aws", | ||
"amazonq", | ||
"history" | ||
) | ||
private val LOG = getLogger<AmazonQLanguageClientImpl>() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat | ||
|
||
data class CopyFileParams( | ||
val oldPath: String, | ||
val newPath: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat | ||
|
||
data class FileParams( | ||
val path: String, | ||
) |
Uh oh!
There was an error while loading. Please reload this page.