Repository navigation
fix(extensions): adapt deprecated sidebar props instead of casting the component - #1216
Open
ShryukGrandhi wants to merge 1 commit into
Conversation
…e component Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
Contributor
|
PR author is not in the allowed authors list. |
|
@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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
registerSidebarViewis deprecated, but its contract still declaresfilesas a mutableExtensionDiffFile[]. Registration forwarded the legacy component toregisterPanewith a double cast, so at render time it received the pane props, including the host's frozenfileslist. A legacy sidebar that followed its declared contract and calledfiles.sort()orfiles.push()threwTypeError: Attempted to assign to readonly propertyand was replaced by the pane error boundary.Changes
adaptLegacySidebarComponentinpackages/hunk/src/extensions/panes.ts. It mapsExtensionPanePropstoExtensionSidebarViewProps, passes a shallow copy offileson each render, and leaves out the pane-only fields (review,reviewGeneration,placement,height,currentLine). The file views themselves stay frozen.registerSidebarViewuses the adapter instead ofview.component as unknown as ExtensionPane["component"]. It now checks thatcomponentis a function before wrapping it, because the wrapper would otherwise get pastregisterPane's component check.registerPaneare unchanged and still receive the frozen, readonly host list.Testing
AppHost.extension-sidebar.test.tsx: a legacy sidebar sorts and pushes onto itsfiles, 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 withAttempted to assign to readonly property.runExtension.test.tsfor the prop mapping and the copy semantics. ExistingregisterSidebarViewtests now check delegation instead of function identity.bun test --timeout 30000 packages/hunk/src/ui/AppHost.extension-sidebar.test.tsx: 16 passbun test packages/hunk/src/extensions/runExtension.test.ts: 52 passbun run typecheck,bun run deps:check,oxlint --deny-warnings, andoxfmt --checkon the touched files: cleanpackages/hunk/src/extensionsstill shows failures inhostRuntimeModules.test.tsand the extension package-install tests. These fail the same way on unmodifiedmainon this machine (macOS arm64), so this change doesn't cause them.Fixes #764