diff --git a/packages/host/app/components/matrix/room-message-command.gts b/packages/host/app/components/matrix/room-message-command.gts index 65498df15b..97fe370aec 100644 --- a/packages/host/app/components/matrix/room-message-command.gts +++ b/packages/host/app/components/matrix/room-message-command.gts @@ -211,7 +211,6 @@ export default class RoomMessageCommand extends Component { monacoSDK=@monacoSDK language='json' readOnly=true - darkTheme=true editorDisplayOptions=this.editorDisplayOptions }} data-test-editor @@ -241,6 +240,9 @@ export default class RoomMessageCommand extends Component { {{/if}} + + {{! template-lint-disable no-whitespace-for-layout }} + {{! ignore the above error because ember-template-lint complains about the whitespace in the multi-line comment below }} } diff --git a/packages/host/app/components/matrix/room.gts b/packages/host/app/components/matrix/room.gts index 0c34cd8f9d..085adcff58 100644 --- a/packages/host/app/components/matrix/room.gts +++ b/packages/host/app/components/matrix/room.gts @@ -1,3 +1,4 @@ +import { registerDestructor } from '@ember/destroyable'; import { fn } from '@ember/helper'; import { on } from '@ember/modifier'; import { action } from '@ember/object'; @@ -235,6 +236,9 @@ export default class Room extends Component { constructor(owner: Owner, args: Signature['Args']) { super(owner, args); this.doMatrixEventFlush.perform(); + registerDestructor(this, () => { + this.scrollState().messageVisibilityObserver.disconnect(); + }); } private scrollState() { diff --git a/packages/host/app/components/operator-mode/code-editor.gts b/packages/host/app/components/operator-mode/code-editor.gts index 28d2d9ac4f..eee7177c8c 100644 --- a/packages/host/app/components/operator-mode/code-editor.gts +++ b/packages/host/app/components/operator-mode/code-editor.gts @@ -324,7 +324,15 @@ export default class CodeEditor extends Component { padding: var(--boxel-sp) 0; } - .monaco-container.readonly { + :global(.monaco-container.readonly) { + background-color: #ebeaed; + } + + :global(.monaco-container.readonly .margin) { + background-color: #ebeaed; + } + + :global(.monaco-container.readonly .monaco-editor-background) { background-color: #ebeaed; } diff --git a/packages/host/app/components/operator-mode/code-submode.gts b/packages/host/app/components/operator-mode/code-submode.gts index 18fd02aecf..9f4d175fb2 100644 --- a/packages/host/app/components/operator-mode/code-submode.gts +++ b/packages/host/app/components/operator-mode/code-submode.gts @@ -772,7 +772,6 @@ export default class CodeSubmode extends Component { {{/let}}
void; onSearchSheetClosed?: () => void; onCardSelectFromSearch: (cardId: string) => void; @@ -309,23 +308,17 @@ export default class SubmodeLayout extends Component { @onCardSelect={{this.handleCardSelectFromSearch}} @onInputInsertion={{this.storeSearchElement}} /> - {{#if (not @hideAiAssistant)}} - - - {{/if}} + + - {{#if - (and - (not @hideAiAssistant) this.operatorModeStateService.aiAssistantOpen - ) - }} + {{#if this.operatorModeStateService.aiAssistantOpen}} { onSetup, readOnly, monacoSDK, - darkTheme, editorDisplayOptions, }: Signature['Args']['Named'], ) { @@ -73,21 +71,17 @@ export default class Monaco extends Modifier { this.model.setValue(content); } } else { - monacoSDK.editor.defineTheme('boxel-theme', { + // The light theme editor is used for the main editor in code mode, + // but we also have a dark themed editor for the preview editor in AI panel. + // The latter is themed using a CSS filter as opposed to defining a new monaco theme + // because monaco does not support multiple themes on the same page (check the comment in + // room-message-command.gts for more details) + monacoSDK.editor.defineTheme('boxel-monaco-light-theme', { base: 'vs', inherit: true, rules: [], colors: { - 'editor.background': readOnly ? '#EBEAED' : '#FFFFFF', - }, - }); - - monacoSDK.editor.defineTheme('boxel-dark-theme', { - base: 'vs-dark', - inherit: true, - rules: [], - colors: { - 'editor.background': '#000000', + 'editor.background': '#FFFFFF', }, }); @@ -100,7 +94,7 @@ export default class Monaco extends Modifier { minimap: { enabled: false, }, - theme: darkTheme ? 'boxel-dark-theme' : 'boxel-theme', + theme: 'boxel-monaco-light-theme', ...editorDisplayOptions, }; diff --git a/packages/host/tests/acceptance/code-submode/editor-test.ts b/packages/host/tests/acceptance/code-submode/editor-test.ts index 52214afc0e..b7bb400e1c 100644 --- a/packages/host/tests/acceptance/code-submode/editor-test.ts +++ b/packages/host/tests/acceptance/code-submode/editor-test.ts @@ -822,7 +822,7 @@ module('Acceptance | code submode | editor tests', function (hooks) { assert.dom('[data-test-realm-indicator-not-writable]').exists(); assert.strictEqual( window - .getComputedStyle(find('.monaco-editor')!) + .getComputedStyle(find('.monaco-editor-background')!) .getPropertyValue('background-color')!, 'rgb(235, 234, 237)', // equivalent to #ebeaed 'monaco editor is greyed out when read-only', diff --git a/packages/host/tests/acceptance/operator-mode-acceptance-test.gts b/packages/host/tests/acceptance/operator-mode-acceptance-test.gts index 54875f7fca..e1bf5e0450 100644 --- a/packages/host/tests/acceptance/operator-mode-acceptance-test.gts +++ b/packages/host/tests/acceptance/operator-mode-acceptance-test.gts @@ -1186,5 +1186,26 @@ module('Acceptance | operator mode tests', function (hooks) { .hasNoClass('out-of-credit'); assert.dom('[data-test-buy-more-credits]').hasNoClass('out-of-credit'); }); + + test(`ai panel continues being open when switching to code submode`, async function (assert) { + await visitOperatorMode({ + stacks: [ + [ + { + id: `${testRealmURL}Person/fadhlan`, + format: 'isolated', + }, + ], + ], + }); + + await click('[data-test-open-ai-assistant]'); + assert.dom('[data-test-ai-assistant-panel]').exists(); + await click('[data-test-submode-switcher] button'); + await click('[data-test-boxel-menu-item-text="Code"]'); + assert.dom('[data-test-ai-assistant-panel]').exists(); + await click('[data-test-open-ai-assistant]'); + assert.dom('[data-test-ai-assistant-panel]').doesNotExist(); + }); }); });