From 36767bd27b6e5a970a31433710e4879da84641fd Mon Sep 17 00:00:00 2001 From: LegGasai Date: Wed, 11 Nov 2026 16:40:53 +0800 Subject: [PATCH] fix(forge): narrow changes tab navigation params on the fields read Depending on the Session panel brings the file and Browser params types into the forge program, so reading lens and path off the params union no longer type-checks; narrow with in checks as the file preview body does. --- .../experimental/client-ui-forge/src/client/ChangesTab.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/experimental/client-ui-forge/src/client/ChangesTab.tsx b/packages/experimental/client-ui-forge/src/client/ChangesTab.tsx index 3d71b1cd4d..924e6cbead 100644 --- a/packages/experimental/client-ui-forge/src/client/ChangesTab.tsx +++ b/packages/experimental/client-ui-forge/src/client/ChangesTab.tsx @@ -619,9 +619,12 @@ export function ChangesTab({ useEffect(() => { if (choices?.navigated === navigation.revision) return actions.navigated(tab.id, navigation.revision) - const lensParam = navigation.params?.lens + // Every tab of this kind is a `forge-changes` resource address, so its params are that type's; the union is + // narrowed on the field read, not validated. + const params = navigation.params + const lensParam = params !== undefined && 'lens' in params ? params.lens : undefined if (lensParam !== undefined) actions.filtered(tab.id, lensParam) - const path = navigation.params?.path + const path = params !== undefined && 'path' in params ? params.path : undefined if (path === undefined) return setTreeState(value => ({ ...value, selected: path })) setChosen(value => ({ ...value, [path]: true }))