Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
39 changes: 39 additions & 0 deletions frontend/app/modals/confirmclosetab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2025, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0

import { Modal } from "@/app/modals/modal";
import { deleteLayoutModelForTab } from "@/layout/index";
import { atoms, getApi, globalStore } from "@/store/global";
import { modalsModel } from "@/store/modalmodel";

interface ConfirmCloseTabModalProps {
tabId: string;
}

const ConfirmCloseTabModal = ({ tabId }: ConfirmCloseTabModalProps) => {
const handleConfirmClose = () => {
const ws = globalStore.get(atoms.workspace);
getApi().closeTab(ws.oid, tabId);
deleteLayoutModelForTab(tabId);
modalsModel.popModal();
};

const handleCancel = () => {
modalsModel.popModal();
};

return (
<Modal onOk={handleConfirmClose} onCancel={handleCancel} onClose={handleCancel}>
<div className="content">
<div className="modal-title">Close Tab?</div>
<div style={{ marginTop: "10px" }}>
Are you sure you want to close this tab? This action cannot be undone.
</div>
</div>
</Modal>
);
};

ConfirmCloseTabModal.displayName = "ConfirmCloseTabModal";

export { ConfirmCloseTabModal };
2 changes: 2 additions & 0 deletions frontend/app/modals/modalregistry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { UpgradeOnboardingModal } from "@/app/onboarding/onboarding-upgrade";
import { DeleteFileModal, PublishAppModal, RenameFileModal } from "@/builder/builder-apppanel";
import { SetSecretDialog } from "@/builder/tabs/builder-secrettab";
import { AboutModal } from "./about";
import { ConfirmCloseTabModal } from "./confirmclosetab";
import { UserInputModal } from "./userinputmodal";

const modalRegistry: { [key: string]: React.ComponentType<any> } = {
Expand All @@ -15,6 +16,7 @@ const modalRegistry: { [key: string]: React.ComponentType<any> } = {
[UserInputModal.displayName || "UserInputModal"]: UserInputModal,
[AboutModal.displayName || "AboutModal"]: AboutModal,
[MessageModal.displayName || "MessageModal"]: MessageModal,
[ConfirmCloseTabModal.displayName || "ConfirmCloseTabModal"]: ConfirmCloseTabModal,
[PublishAppModal.displayName || "PublishAppModal"]: PublishAppModal,
[RenameFileModal.displayName || "RenameFileModal"]: RenameFileModal,
[DeleteFileModal.displayName || "DeleteFileModal"]: DeleteFileModal,
Expand Down
7 changes: 3 additions & 4 deletions frontend/app/tab/tabbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,9 @@ const TabBar = memo(({ workspace }: TabBarProps) => {

const handleCloseTab = (event: React.MouseEvent<HTMLButtonElement, MouseEvent> | null, tabId: string) => {
event?.stopPropagation();
const ws = globalStore.get(atoms.workspace);
getApi().closeTab(ws.oid, tabId);
tabsWrapperRef.current.style.setProperty("--tabs-wrapper-transition", "width 0.3s ease");
deleteLayoutModelForTab(tabId);

// Show confirmation modal before closing
modalsModel.pushModal("ConfirmCloseTabModal", { tabId });
};
Comment on lines 621 to 626
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for other closeTab call sites
echo "=== Searching for closeTab( calls ==="
rg -n "closeTab\(" frontend || echo "No matches found"

echo ""
echo "=== Searching for ConfirmCloseTabModal references ==="
rg -n "ConfirmCloseTabModal" frontend || echo "No matches found"

echo ""
echo "=== Searching for close-tab related patterns ==="
rg -n "close.*tab\|tab.*close" frontend -i -A 2 | head -100 || echo "No matches found"

Repository: wavetermdev/waveterm

Length of output: 1064


🏁 Script executed:

# Examine the keymodel.ts file around line 135
sed -n '120,150p' frontend/app/store/keymodel.ts

Repository: wavetermdev/waveterm

Length of output: 1226


🏁 Script executed:

# Search for calls to simpleCloseStaticTab
rg -n "simpleCloseStaticTab" frontend

# Also search for tab-close related keyboard shortcuts
rg -n "KeyBinding\|keyboard" frontend/app/store/keymodel.ts | head -20

Repository: wavetermdev/waveterm

Length of output: 266


🏁 Script executed:

# Check context around line 200
echo "=== Context around line 200 ==="
sed -n '190,210p' frontend/app/store/keymodel.ts

echo ""
echo "=== Context around line 537 ==="
sed -n '525,545p' frontend/app/store/keymodel.ts

Repository: wavetermdev/waveterm

Length of output: 1645


Close handler correctly delegates to confirmation modal; keyboard shortcut ⌘⇧W still bypasses it

Routing tab closes through modalsModel.pushModal("ConfirmCloseTabModal", { tabId }) cleanly introduces confirmation for the X button close path. However, the keyboard shortcut Cmd:Shift:w (line 537 in keymodel.ts) calls simpleCloseStaticTab() directly, bypassing the confirmation modal entirely. This creates an inconsistent user experience—users get confirmation when using the UI button but not when using the keyboard shortcut.

Consider routing the keyboard shortcut through the same confirmation flow to ensure consistent behavior across all close paths.

🤖 Prompt for AI Agents
In frontend/app/tab/tabbar.tsx around lines 621-626, the close handler opens the
ConfirmCloseTabModal but the keyboard shortcut in keymodel.ts (around line 537)
currently calls simpleCloseStaticTab() directly, bypassing confirmation; update
the keyboard shortcut handler to route through the same confirmation flow by
invoking modalsModel.pushModal("ConfirmCloseTabModal", { tabId }) (or refactor
shared logic into a single closeTabRequest(tabId) function used by both the X
button and the shortcut) and ensure simpleCloseStaticTab() is only executed
after the confirmation modal resolves affirmatively.


const handlePinChange = useCallback(
Expand Down