diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aafab75..271d482c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Keep `Kaoto backend` output log available when Kaoto backend native executable cannot be launched. It allows to have more information what can be the issue. - Upgrade embedded Kaoto [UI](https://github.com/KaotoIO/kaoto-ui/releases/tag/v0.6.1) to 0.6.1 and [backend](https://github.com/KaotoIO/kaoto-backend/releases/tag/v0.6.2) to 0.6.2 - Open Kaoto editor by default for `*.camel.(yaml|yml)` files +- Avoid wipeout of content on restart with opened editors #144 # 0.2.0 diff --git a/package.json b/package.json index 767e947f..ee2efe7a 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@kie-tools-core/workspace": "^0.26.0", "@patternfly/react-core": "4.267.6", "@redhat-developer/vscode-redhat-telemetry": "^0.5.4", + "async-wait-until": "^2.0.12", "react": "18.2.0", "react-dom": "18.2.0" }, diff --git a/src/extension/extension.ts b/src/extension/extension.ts index 8e7592ea..b33d3126 100644 --- a/src/extension/extension.ts +++ b/src/extension/extension.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { waitUntil } from 'async-wait-until'; import { backendI18nDefaults, backendI18nDictionaries } from "@kie-tools-core/backend/dist/i18n"; import { VsCodeBackendProxy } from "@kie-tools-core/backend/dist/vscode"; import { EditorEnvelopeLocator, EnvelopeContentType, EnvelopeMapping } from "@kie-tools-core/editor/dist/api"; @@ -31,6 +32,7 @@ let telemetryService: TelemetryService; let backendProcess: child_process.ChildProcessWithoutNullStreams | undefined; let kaotoBackendOutputChannel: vscode.OutputChannel | undefined; +let kaotoBackendWarmedUp: boolean = false; export async function activate(context: vscode.ExtensionContext) { console.info("Kaoto Editor extension is alive."); @@ -57,6 +59,9 @@ export async function activate(context: vscode.ExtensionContext) { if (kaotoBackendOutputChannel) { const dec = new TextDecoder("utf-8"); const text = dec.decode(data); + if (!kaotoBackendWarmedUp && text.includes('Catalog class io.kaoto.backend.api.metadata.catalog.StepCatalog_Subclass warmed up in')) { + kaotoBackendWarmedUp = true; + } kaotoBackendOutputChannel.append(text); } }); @@ -71,6 +76,12 @@ export async function activate(context: vscode.ExtensionContext) { const backendI18n = new I18n(backendI18nDefaults, backendI18nDictionaries, vscode.env.language); backendProxy = new VsCodeBackendProxy(context, backendI18n); + try { + await waitUntil(() => kaotoBackendWarmedUp, { timeout: 30000}); + } catch { + kaotoBackendOutputChannel.append('Kaoto backend failed to warm up in 30 seconds.\n'); + } + KogitoVsCode.startExtension({ extensionName: "redhat.vscode-kaoto", context: context, @@ -88,8 +99,6 @@ export async function activate(context: vscode.ExtensionContext) { ]), backendProxy: backendProxy, }); - - console.info("Extension is successfully setup."); const redhatService = await getRedHatService(context); telemetryService = await redhatService.getTelemetryService(); @@ -106,6 +115,7 @@ function getBinaryName(): string { } export function deactivate() { + kaotoBackendWarmedUp = false; if (backendProcess !== undefined) { if (kaotoBackendOutputChannel !== undefined) { kaotoBackendOutputChannel.append(`Kaoto backend is stopped during VS Code extension deactivation.`); diff --git a/yarn.lock b/yarn.lock index 8912fa56..13c8d51a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1099,6 +1099,11 @@ assertion-error@^1.1.0: resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== +async-wait-until@^2.0.12: + version "2.0.12" + resolved "https://registry.yarnpkg.com/async-wait-until/-/async-wait-until-2.0.12.tgz#8a94683bf29e74642a8bcbb9385f6ea330d4383f" + integrity sha512-SXy/vDs6UPJMG6YeEYOQ4ilA/JnGxk187KPGqFx9O+qVxsjkSl+jH+3P50qSNyMpEmDgr8qOFGOKCJckWb1i7A== + async@^2.6.4: version "2.6.4" resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221"