Skip to content

Commit 7dd9e6c

Browse files
dp-pcsclaude
andcommitted
fix: defer scroll update until tabIds state reflects new tab
updateScrollDebounced closes over tabIds — calling it immediately after createTab/CreateTabFromTemplate uses the stale count. Move it into the useEffect([tabIds]) so it runs after React commits the updated list. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1117c9a commit 7dd9e6c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

frontend/app/tab/tabbar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ const TabBar = memo(({ workspace, noTabs }: TabBarProps) => {
143143
// Update refs when tabIds change
144144
useEffect(() => {
145145
tabRefs.current = tabIds.map((_, index) => tabRefs.current[index] || createRef());
146-
}, [tabIds]);
146+
updateScrollDebounced();
147+
}, [tabIds, updateScrollDebounced]);
147148

148149
useEffect(() => {
149150
if (!workspace) {
@@ -534,8 +535,7 @@ const TabBar = memo(({ workspace, noTabs }: TabBarProps) => {
534535

535536
const applyTabTransition = useCallback(() => {
536537
tabsWrapperRef.current?.style.setProperty("--tabs-wrapper-transition", "width 0.1s ease");
537-
updateScrollDebounced();
538-
}, [updateScrollDebounced]);
538+
}, []);
539539

540540
const handleAddTab = (e: React.MouseEvent) => {
541541
fireAndForget(async () => {

0 commit comments

Comments
 (0)