From c0528d938fd56c1b764d6117e36f67a495a4fcb7 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Wed, 22 Jul 2026 17:04:05 -0400 Subject: [PATCH] Fixing some latent type errors While working on removing the standalone declarations build in boxel-ui, we discovered that there are many pre-existing type errors that were being hidden behind skipLibCheck. Once you start type-checking boxel-ui directly against source, it's no longer hidden behind skipLibCheck and these errors surface. This is just a partial set of them, more need to be fixed before we can actually stop pre-building the boxel-ui declarations. --- .../src/components/circle-spinner/index.gts | 2 +- .../src/components/copy-button/index.gts | 5 +++- .../ai-assistant/code-block/actions.gts | 7 ++++- .../ai-assistant/message/aibot-message.gts | 10 +++++-- .../ai-assistant/new-session-settings.gts | 1 + .../ai-assistant/skill-menu/skill-toggle.gts | 28 +++++++++++-------- .../host/app/components/host-mode/card.gts | 2 +- .../app/components/matrix/register-user.gts | 2 +- .../components/operator-mode/code-submode.gts | 2 +- 9 files changed, 38 insertions(+), 21 deletions(-) diff --git a/packages/boxel-ui/addon/src/components/circle-spinner/index.gts b/packages/boxel-ui/addon/src/components/circle-spinner/index.gts index bd271e71bea..6b143d81a6f 100644 --- a/packages/boxel-ui/addon/src/components/circle-spinner/index.gts +++ b/packages/boxel-ui/addon/src/components/circle-spinner/index.gts @@ -3,7 +3,7 @@ import Component from '@glimmer/component'; import IconCircle from '../../icons/icon-circle.gts'; interface Signature { - Element: SVGElement; + Element: SVGSVGElement; } // eslint-disable-next-line ember/no-empty-glimmer-component-classes diff --git a/packages/boxel-ui/addon/src/components/copy-button/index.gts b/packages/boxel-ui/addon/src/components/copy-button/index.gts index 6bb3c2d5995..6a7fe6c9c7f 100644 --- a/packages/boxel-ui/addon/src/components/copy-button/index.gts +++ b/packages/boxel-ui/addon/src/components/copy-button/index.gts @@ -19,7 +19,7 @@ interface Signature { offset?: number; placement?: MiddlewareState['placement']; size?: BoxelButtonSize; - textToCopy: string; + textToCopy: string | null | undefined; tooltipText?: string; variant?: BoxelButtonKind; width?: string; @@ -31,6 +31,9 @@ export default class CopyButton extends Component { @tracked private recentlyCopied = false; @action private async copyToClipboard() { + if (this.args.textToCopy == null) { + return; + } try { await navigator.clipboard.writeText(this.args.textToCopy); this.recentlyCopied = true; diff --git a/packages/host/app/components/ai-assistant/code-block/actions.gts b/packages/host/app/components/ai-assistant/code-block/actions.gts index 395087af61f..2ee9490f653 100644 --- a/packages/host/app/components/ai-assistant/code-block/actions.gts +++ b/packages/host/app/components/ai-assistant/code-block/actions.gts @@ -1,6 +1,8 @@ import type { TemplateOnlyComponent } from '@ember/component/template-only'; import { hash } from '@ember/helper'; +import type Component from '@glimmer/component'; + import { CopyButton } from '@cardstack/boxel-ui/components'; import type { CodeData } from '@cardstack/host/lib/formatted-message/utils'; @@ -11,6 +13,9 @@ import ApplyCodePatchButton, { import type { ComponentLike } from '@glint/template'; +type AsComponentLike = + C extends Component ? ComponentLike : never; + export interface CodeBlockActionsSignature { Args: { codeData?: Partial; @@ -18,7 +23,7 @@ export interface CodeBlockActionsSignature { Blocks: { default: [ { - copyCode: CopyButton; + copyCode: AsComponentLike; applyCodePatch: ComponentLike; }, ]; diff --git a/packages/host/app/components/ai-assistant/message/aibot-message.gts b/packages/host/app/components/ai-assistant/message/aibot-message.gts index 0b3fb498237..a916b863085 100644 --- a/packages/host/app/components/ai-assistant/message/aibot-message.gts +++ b/packages/host/app/components/ai-assistant/message/aibot-message.gts @@ -287,7 +287,9 @@ class HtmlGroupCodeBlock extends Component { {{! This is just to show the ✅ icon to signalize that the code patch has been applied }} { /> - + { {{/if}} - + {{/if}} diff --git a/packages/host/app/components/ai-assistant/new-session-settings.gts b/packages/host/app/components/ai-assistant/new-session-settings.gts index 65f27e9f60e..5db1b9d3e92 100644 --- a/packages/host/app/components/ai-assistant/new-session-settings.gts +++ b/packages/host/app/components/ai-assistant/new-session-settings.gts @@ -49,6 +49,7 @@ export default class NewSessionSettings extends Component { @icon='close' @variant='ghost' @size='small' + @label='close new session options' class='new-session-settings-close-button' data-test-new-session-settings-close-button {{on 'click' @onClose}} diff --git a/packages/host/app/components/ai-assistant/skill-menu/skill-toggle.gts b/packages/host/app/components/ai-assistant/skill-menu/skill-toggle.gts index c006262d903..ad8fe399087 100644 --- a/packages/host/app/components/ai-assistant/skill-menu/skill-toggle.gts +++ b/packages/host/app/components/ai-assistant/skill-menu/skill-toggle.gts @@ -63,19 +63,23 @@ export default class SkillToggle extends Component { // Title for either skill source: `cardTitle` for a Skill card; for a skill // markdown file, the title indexed from its first heading, falling back to // the frontmatter name slug only when the file has no heading. - private get displayTitle(): string | undefined { - let card = this.card as - | { - cardTitle?: string; - title?: string; - name?: string; - frontmatter?: { name?: string }; - } - | undefined; + private get displayTitle(): string { + let card = this.card as { + cardTitle?: string; + title?: string; + name?: string; + frontmatter?: { name?: string }; + }; if (!card) { - return undefined; + return 'Untitled Skill'; } - return card.cardTitle ?? card.title ?? card.frontmatter?.name ?? card.name; + return ( + card.cardTitle ?? + card.title ?? + card.frontmatter?.name ?? + card.name ?? + 'Untitled Skill' + ); } private get isCreating() { @@ -172,7 +176,7 @@ export default class SkillToggle extends Component { { diff --git a/packages/host/app/components/matrix/register-user.gts b/packages/host/app/components/matrix/register-user.gts index a83c6cb811f..203fe2942d9 100644 --- a/packages/host/app/components/matrix/register-user.gts +++ b/packages/host/app/components/matrix/register-user.gts @@ -134,7 +134,7 @@ export default class RegisterUser extends Component { data-test-username-field id='boxel-register-username' @name='username' - autocomplete='username' + @autocomplete='username' @state={{this.usernameInputState}} @value={{this.username}} @placeholder='Your username' diff --git a/packages/host/app/components/operator-mode/code-submode.gts b/packages/host/app/components/operator-mode/code-submode.gts index 51a7d0386a8..6bfdc726f4b 100644 --- a/packages/host/app/components/operator-mode/code-submode.gts +++ b/packages/host/app/components/operator-mode/code-submode.gts @@ -912,7 +912,7 @@ export default class CodeSubmode extends Component { {{else}}