-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Browser Provider component (#357)
* Pass populated AWS_CA_BUNDLE env var to Flare (#341) * Add UI notification to alert user of deprecated manifest version (#312) * Add webview dependency missing logic to ViewRouter * Revert commit 'Add UI notification to alert user of deprecated manifest version' * Revert 'Pass populated AWS_CA_BUNDLE env var to Flare' --------- Co-authored-by: Jonathan Breedlove <[email protected]> Co-authored-by: Nicolas <[email protected]>
- Loading branch information
1 parent
3048ff1
commit e9c983b
Showing
5 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
plugin/src/software/aws/toolkits/eclipse/amazonq/util/ChatAssetProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package software.aws.toolkits.eclipse.amazonq.util; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Optional; | ||
|
||
import software.aws.toolkits.eclipse.amazonq.plugin.Activator; | ||
import software.aws.toolkits.eclipse.amazonq.providers.lsp.LspManagerProvider; | ||
|
||
public final class ChatAssetProvider { | ||
private WebviewAssetServer webviewAssetServer; | ||
|
||
public Optional<String> get() { | ||
var chatUiDirectory = getChatUiDirectory(); | ||
|
||
if (!isValid(chatUiDirectory)) { | ||
Activator.getLogger().error("Error loading Chat UI. If override used, please verify the override env variables else restart Eclipse"); | ||
return Optional.empty(); | ||
} | ||
|
||
String jsFile = Paths.get(chatUiDirectory.get()).resolve("amazonq-ui.js").toString(); | ||
var jsParent = Path.of(jsFile).getParent(); | ||
var jsDirectoryPath = Path.of(jsParent.toUri()).normalize().toString(); | ||
|
||
webviewAssetServer = new WebviewAssetServer(); | ||
var result = webviewAssetServer.resolve(jsDirectoryPath); | ||
if (!result) { | ||
Activator.getLogger().error(String.format( | ||
"Error loading Chat UI. Unable to find the `amazonq-ui.js` file in the directory: %s. Please verify and restart", | ||
chatUiDirectory.get())); | ||
return Optional.empty(); | ||
} | ||
|
||
String chatJsPath = webviewAssetServer.getUri() + "amazonq-ui.js"; | ||
|
||
return Optional.ofNullable(chatJsPath); | ||
} | ||
|
||
private Optional<String> getChatUiDirectory() { | ||
try { | ||
return Optional.of(LspManagerProvider.getInstance().getLspInstallation().getClientDirectory()); | ||
} catch (Exception e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
private boolean isValid(final Optional<String> chatUiDirectory) { | ||
return chatUiDirectory.isPresent() && Files.exists(Paths.get(chatUiDirectory.get())); | ||
} | ||
|
||
public void dispose() { | ||
if (webviewAssetServer != null) { | ||
webviewAssetServer.stop(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters