Skip to content

finding(app-shell): useReconcileOnError's ui as unknown[] is a redundant assertion on the exact seam objectui#8342 was about #8379

Description

@os-justin

Found while fixing objectui#8342 (PR #8377) — useReconcileOnError is the one real in-repo consumer of the hook member that card is about, so it got read closely. Filed unassigned and NOT fixed there: it is a different package and outside that card's scope.

Filed by the objectui#8342 dev, Claude Code session session_01YBWFb5YgMU5dw8p2VKj16S.

What

packages/app-shell/src/hooks/useReconcileOnError.ts:74

        const ui = toUIMessages(conv?.messages);
        if (isReconcilableCompletedTurn(ui) && setMessagesRef.current) {
          setMessagesRef.current(ui as unknown[]);

setMessagesRef is declared React.MutableRefObject of ((m: unknown[]) => void) or undefined, and toUIMessages returns an array of a concrete hydrated-message type. An array of anything is already assignable to unknown[], so the assertion converts nothing.

Measured

On PR #8377's head (5f9345554), with the dependency closure built:

  • anchor setMessagesRef.current(ui as unknown[]); present exactly once; after rewriting it to setMessagesRef.current(ui); the old spelling had 0 hits, the new one 1, and git hash-object differed from git rev-parse HEAD:PATH — the mutation reached disk.
  • tsc --noEmit in packages/app-shell: exit 0, zero error TS lines.
  • Restored by state: git diff HEAD empty and the blob equal again.

Why it is not merely cosmetic

This is an assertion sitting on a published-package boundary, on the exact call objectui#8342 found to be lying. It costs nothing today and it is precisely the thing that would swallow the signal tomorrow: if toUIMessages's return type is ever narrowed, or if the sink's parameter is ever tightened (which is what option A on objectui#8342 would have done), as unknown[] erases the diagnostic that should have fired at this exact line — the same failure class as objectui#4424, where a cast on the same seam deleted capability with the compiler agreeing.

Deleting it makes the compiler answer the question instead of being told not to.

Not yet measured

Only tsc --noEmit for packages/app-shell was run. tsc -p tsconfig.test.json, pnpm --filter @object-ui/app-shell test, and app-shell's own dependents are still owed by whoever takes it.

Related: objectui#8342, objectui#4424, objectui#4437.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions