Skip to content

fix(extensions): adapt deprecated sidebar props instead of casting the component - #1216

Open
ShryukGrandhi wants to merge 1 commit into
modem-dev:mainfrom
ShryukGrandhi:fix/issue-764-adapt-deprecated-sidebar-props-without-e
Open

ShryukGrandhi wants to merge 1 commit into
modem-dev:mainfrom
ShryukGrandhi:fix/issue-764-adapt-deprecated-sidebar-props-without-e

Conversation

@ShryukGrandhi

Copy link
Copy Markdown

Summary

registerSidebarView is deprecated, but its contract still declares files as a mutable ExtensionDiffFile[]. Registration forwarded the legacy component to registerPane with a double cast, so at render time it received the pane props, including the host's frozen files list. A legacy sidebar that followed its declared contract and called files.sort() or files.push() threw TypeError: Attempted to assign to readonly property and was replaced by the pane error boundary.

Changes

  • Add adaptLegacySidebarComponent in packages/hunk/src/extensions/panes.ts. It maps ExtensionPaneProps to ExtensionSidebarViewProps, passes a shallow copy of files on each render, and leaves out the pane-only fields (review, reviewGeneration, placement, height, currentLine). The file views themselves stay frozen.
  • registerSidebarView uses the adapter instead of view.component as unknown as ExtensionPane["component"]. It now checks that component is a function before wrapping it, because the wrapper would otherwise get past registerPane's component check.
  • Modern panes registered with registerPane are unchanged and still receive the frozen, readonly host list.
  • Add a patch changeset.

Testing

  • New render-level test in AppHost.extension-sidebar.test.tsx: a legacy sidebar sorts and pushes onto its files, and a modern pane is mounted next to it. The legacy view renders its mutated copy (LEGACY 3 beta.txt), and the modern pane still sees the original frozen list (MODERN 2 alpha.txt frozen=true). Before the fix this test fails with Attempted to assign to readonly property.
  • New unit test in runExtension.test.ts for the prop mapping and the copy semantics. Existing registerSidebarView tests now check delegation instead of function identity.
  • bun test --timeout 30000 packages/hunk/src/ui/AppHost.extension-sidebar.test.tsx: 16 pass
  • bun test packages/hunk/src/extensions/runExtension.test.ts: 52 pass
  • bun run typecheck, bun run deps:check, oxlint --deny-warnings, and oxfmt --check on the touched files: clean
  • Running all of packages/hunk/src/extensions still shows failures in hostRuntimeModules.test.ts and the extension package-install tests. These fail the same way on unmodified main on this machine (macOS arm64), so this change doesn't cause them.

Fixes #764

…e component

Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@ShryukGrandhi is attempting to deploy a commit to the Modem Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adapt deprecated sidebar props without exposing frozen files as mutable

1 participant