From d223d3c4a7842465b97e9eb31e56bf1b00a29a7c Mon Sep 17 00:00:00 2001 From: Hassan Abdel-Rahman Date: Wed, 27 Nov 2024 13:53:42 -0500 Subject: [PATCH] cleanup --- .../components/operator-mode/code-submode.gts | 55 ------------------- .../operator-mode/interact-submode.gts | 1 - .../components/operator-mode/stack-item.gts | 2 +- packages/host/app/resources/card-resource.ts | 2 +- 4 files changed, 2 insertions(+), 58 deletions(-) diff --git a/packages/host/app/components/operator-mode/code-submode.gts b/packages/host/app/components/operator-mode/code-submode.gts index 0871d39eb1..9e69c424b5 100644 --- a/packages/host/app/components/operator-mode/code-submode.gts +++ b/packages/host/app/components/operator-mode/code-submode.gts @@ -32,7 +32,6 @@ import { type ResolvedCodeRef, PermissionsContextName, } from '@cardstack/runtime-common'; -// import { SerializedError } from '@cardstack/runtime-common/error'; import { isEquivalentBodyPosition } from '@cardstack/runtime-common/schema-analysis-plugin'; import RecentFiles from '@cardstack/host/components/editor/recent-files'; @@ -311,58 +310,6 @@ export default class CodeSubmode extends Component { return null; } - // private get fileErrorMessages(): string[] { - // if (this.isCard) { - // if (this.cardResource.cardError) { - // try { - // return this.card - // let error = this.cardResource.cardError; - - // // if (error.responseText) { - // // let parsedError = JSON.parse(error.responseText); - - // // handle instance errors - // if (parsedError.errors.find((e: any) => e.message)) { - // return parsedError.errors.map((e: any) => e.message); - // } - - // // otherwise handle module errors - // let allDetails = parsedError.errors - // .concat( - // ...parsedError.errors.map( - // (e: SerializedError) => e.additionalErrors, - // ), - // ) - // .map((e: SerializedError) => e.detail); - - // // There’s often a pair of errors where one has an unhelpful prefix like this: - // // cannot return card from index: Not Found - http://test-realm/test/non-card not found - // // http://test-realm/test/non-card not found - - // let detailsWithoutDuplicateSuffixes = allDetails.reduce( - // (details: string[], currentDetail: string) => { - // return [ - // ...details.filter( - // (existingDetail) => !existingDetail.endsWith(currentDetail), - // ), - // currentDetail, - // ]; - // }, - // [], - // ); - - // return detailsWithoutDuplicateSuffixes; - // } - // } catch (e) { - // console.log('Error extracting card preview errors', e); - // return []; - // } - // } - // } - - // return []; - // } - private get currentOpenFile() { return this.operatorModeStateService.openFile.current; } @@ -855,12 +802,10 @@ export default class CodeSubmode extends Component {
- {{!-- {{#each this.fileErrorMessages as |error|}} --}}
{{this.cardResource.cardError.message}}
- {{!-- {{/each}} --}} {{else if this.fileIncompatibilityMessage}} diff --git a/packages/host/app/components/operator-mode/interact-submode.gts b/packages/host/app/components/operator-mode/interact-submode.gts index ef02e19f72..15aa8499a1 100644 --- a/packages/host/app/components/operator-mode/interact-submode.gts +++ b/packages/host/app/components/operator-mode/interact-submode.gts @@ -341,7 +341,6 @@ export default class InteractSubmode extends Component { } private close = task(async (item: StackItem) => { - // TODO test that a card error stack item can be closed if (item.cardError) { this.operatorModeStateService.trimItemsFromStack(item); return; diff --git a/packages/host/app/components/operator-mode/stack-item.gts b/packages/host/app/components/operator-mode/stack-item.gts index 15f15dca97..cf3c435c30 100644 --- a/packages/host/app/components/operator-mode/stack-item.gts +++ b/packages/host/app/components/operator-mode/stack-item.gts @@ -375,6 +375,7 @@ export default class OperatorModeStackItem extends Component { private subscribeToCard = task(async () => { await this.args.item.ready(); // TODO how do we make sure that this is called after the error is cleared? + // Address this as part of SSE support for card errors if (!this.cardError) { this.subscribedCard = this.card; let api = this.args.item.api; @@ -610,7 +611,6 @@ export default class OperatorModeStackItem extends Component { data-test-stack-card-header />
- {{! TODO confirm that we render this in edit format of the stack item !}} {{#if this.lastKnownGoodHtml}} {{else}} diff --git a/packages/host/app/resources/card-resource.ts b/packages/host/app/resources/card-resource.ts index ae9976d17c..044495db07 100644 --- a/packages/host/app/resources/card-resource.ts +++ b/packages/host/app/resources/card-resource.ts @@ -207,7 +207,7 @@ export class CardResource extends Resource { return; } realmSubscribers.set(this, { - // TODO HASSAN NEXT TASK: FIGURE OUT HOW TO GO IN AN OUT OF ERRORS VIA SSE + // TODO figure out how to go in an out of errors via SSE unsubscribe: this.messageService.subscribe( realmURL.href, ({ type, data: dataStr }) => {