Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: extract applyTabTransition helper, surface template errors
- Extract repeated tab UI bookkeeping into applyTabTransition()
- Add try/catch inside CreateTabFromTemplate click handler so errors
  are logged rather than silently swallowed by fireAndForget

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
  • Loading branch information
dp-pcs and claude committed Apr 30, 2026
commit d94ec6c8d3560f8b481ead9a10103613b5f78903
31 changes: 14 additions & 17 deletions frontend/app/tab/tabbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ const TabBar = memo(({ workspace, noTabs }: TabBarProps) => {
[]
);

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

const handleAddTab = (e: React.MouseEvent) => {
fireAndForget(async () => {
try {
Expand All @@ -542,11 +547,7 @@ const TabBar = memo(({ workspace, noTabs }: TabBarProps) => {
label: "New Tab",
click: () => {
env.electron.createTab();
tabsWrapperRef.current?.style.setProperty(
"--tabs-wrapper-transition",
"width 0.1s ease"
);
updateScrollDebounced();
applyTabTransition();
setNewTabIdDebounced(null);
},
},
Expand All @@ -558,12 +559,12 @@ const TabBar = memo(({ workspace, noTabs }: TabBarProps) => {
label: t.name,
click: () => {
fireAndForget(async () => {
await TabTemplateService.CreateTabFromTemplate(workspace.oid, t.oid);
tabsWrapperRef.current?.style.setProperty(
"--tabs-wrapper-transition",
"width 0.1s ease"
);
updateScrollDebounced();
try {
await TabTemplateService.CreateTabFromTemplate(workspace.oid, t.oid);
applyTabTransition();
} catch (err) {
console.error("Failed to create tab from template:", err);
}
});
},
})),
Expand All @@ -578,18 +579,14 @@ const TabBar = memo(({ workspace, noTabs }: TabBarProps) => {
];
env.showContextMenu(menu, e);
} else {
// No templates, just create a new tab directly
env.electron.createTab();
tabsWrapperRef.current?.style.setProperty("--tabs-wrapper-transition", "width 0.1s ease");
updateScrollDebounced();
applyTabTransition();
setNewTabIdDebounced(null);
}
} catch (err) {
console.error("Failed to load templates:", err);
// Fall back to creating a new tab directly
env.electron.createTab();
tabsWrapperRef.current?.style.setProperty("--tabs-wrapper-transition", "width 0.1s ease");
updateScrollDebounced();
applyTabTransition();
setNewTabIdDebounced(null);
}
});
Expand Down