Skip to content

Commit 3af3c14

Browse files
committed
ui tweaks
1 parent 69f05ad commit 3af3c14

File tree

7 files changed

+164
-102
lines changed

7 files changed

+164
-102
lines changed

src/renderer/components/MainLayout.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useState } from "react";
44
import { useHotkeys } from "react-hotkeys-hook";
55
import { RecordingsView } from "@/renderer/features/recordings";
66
import { useIntegrations } from "../hooks/useIntegrations";
7+
import { useLayoutStore } from "../stores/layoutStore";
78
import { useTabStore } from "../stores/tabStore";
89
import { CommandMenu } from "./command";
910
import { SettingsView } from "./SettingsView";
@@ -16,6 +17,7 @@ import { TaskList } from "./tasks/TaskList";
1617
export function MainLayout() {
1718
const { activeTabId, tabs, createTab, setActiveTab, closeTab } =
1819
useTabStore();
20+
const { setCliMode } = useLayoutStore();
1921
useIntegrations();
2022
const [commandMenuOpen, setCommandMenuOpen] = useState(false);
2123
const [taskCreateOpen, setTaskCreateOpen] = useState(false);
@@ -37,6 +39,20 @@ export function MainLayout() {
3739
}
3840
}, [tabs, activeTabId, setActiveTab, createTab, closeTab]);
3941

42+
const handleFocusTaskMode = useCallback(() => {
43+
// Find the Tasks tab or use the first task-list tab
44+
const tasksTab = tabs.find((tab) => tab.type === "task-list");
45+
46+
if (tasksTab) {
47+
setActiveTab(tasksTab.id);
48+
}
49+
50+
// Switch to task mode
51+
setCliMode("task");
52+
53+
// Note: The auto-focus effect in CliTaskPanel will handle focusing the editor
54+
}, [tabs, setActiveTab, setCliMode]);
55+
4056
useHotkeys("mod+k", () => setCommandMenuOpen((prev) => !prev), {
4157
enabled: !commandMenuOpen,
4258
});
@@ -46,7 +62,7 @@ export function MainLayout() {
4662
useHotkeys("mod+p", () => setCommandMenuOpen((prev) => !prev), {
4763
enabled: !commandMenuOpen,
4864
});
49-
useHotkeys("mod+n", () => setTaskCreateOpen(true));
65+
useHotkeys("mod+n", () => handleFocusTaskMode());
5066
useHotkeys("mod+,", () => handleOpenSettings());
5167

5268
useEffect(() => {
@@ -88,10 +104,7 @@ export function MainLayout() {
88104

89105
<Box flexGrow="1" overflow="hidden">
90106
{activeTab?.type === "task-list" && (
91-
<TaskList
92-
onSelectTask={handleSelectTask}
93-
onNewTask={() => setTaskCreateOpen(true)}
94-
/>
107+
<TaskList onSelectTask={handleSelectTask} />
95108
)}
96109

97110
{activeTab?.type === "task-detail" && activeTab.data ? (
@@ -105,11 +118,7 @@ export function MainLayout() {
105118

106119
<StatusBar onOpenSettings={handleOpenSettings} />
107120

108-
<CommandMenu
109-
open={commandMenuOpen}
110-
onOpenChange={setCommandMenuOpen}
111-
onCreateTask={() => setTaskCreateOpen(true)}
112-
/>
121+
<CommandMenu open={commandMenuOpen} onOpenChange={setCommandMenuOpen} />
113122
<TaskCreate open={taskCreateOpen} onOpenChange={setTaskCreateOpen} />
114123
</Flex>
115124
);

src/renderer/components/ShellTerminal.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,23 @@ export function ShellTerminal({ cwd }: ShellTerminalProps) {
4545
}, [cliMode]);
4646

4747
useEffect(() => {
48-
if (!terminalRef.current) return;
48+
console.log("[ShellTerminal] Effect running", {
49+
hasRef: !!terminalRef.current,
50+
hasTerminal: !!terminal.current,
51+
});
52+
53+
if (!terminalRef.current) {
54+
console.log("[ShellTerminal] No terminalRef, returning");
55+
return;
56+
}
57+
58+
// Don't recreate if already exists
59+
if (terminal.current) {
60+
console.log("[ShellTerminal] Terminal already exists, returning");
61+
return;
62+
}
63+
64+
console.log("[ShellTerminal] Creating terminal...");
4965

5066
// Generate unique session ID for this effect run using cryptographically secure random
5167
const sessionId = `shell-${Date.now()}-${secureRandomString(7)}`;
@@ -84,7 +100,7 @@ export function ShellTerminal({ cwd }: ShellTerminalProps) {
84100
) {
85101
// Manually trigger mode switch since event won't bubble to global handler
86102
event.preventDefault();
87-
setCliMode(cliMode === "task" ? "shell" : "task");
103+
setCliMode((current) => (current === "task" ? "shell" : "task"));
88104
return false; // Don't let xterm handle this
89105
}
90106
// Let xterm handle everything else normally
@@ -154,6 +170,7 @@ export function ShellTerminal({ cwd }: ShellTerminalProps) {
154170

155171
// Cleanup
156172
return () => {
173+
console.log("[ShellTerminal] Cleanup running, disposing terminal");
157174
window.removeEventListener("resize", handleResize);
158175
disposable.dispose();
159176
unsubscribeData?.();
@@ -162,8 +179,13 @@ export function ShellTerminal({ cwd }: ShellTerminalProps) {
162179
console.error("Failed to destroy shell session:", error);
163180
});
164181
term.dispose();
182+
terminal.current = null;
183+
fitAddon.current = null;
184+
console.log(
185+
"[ShellTerminal] Cleanup complete, terminal.current set to null",
186+
);
165187
};
166-
}, [cwd, cliMode, setCliMode]);
188+
}, [cwd, setCliMode]);
167189

168190
return (
169191
<Box

src/renderer/components/command/CommandMenu.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,19 @@ import { useCallback, useEffect, useRef } from "react";
55
import { useHotkeys } from "react-hotkeys-hook";
66
import type { Task } from "@/shared/types";
77
import { useTasks } from "../../hooks/useTasks";
8+
import { useLayoutStore } from "../../stores/layoutStore";
89
import { useTabStore } from "../../stores/tabStore";
910
import { Command } from "./Command";
1011
import { CommandKeyHints } from "./CommandKeyHints";
1112

1213
interface CommandMenuProps {
1314
open: boolean;
1415
onOpenChange: (open: boolean) => void;
15-
onCreateTask?: () => void;
1616
}
1717

18-
export function CommandMenu({
19-
open,
20-
onOpenChange,
21-
onCreateTask,
22-
}: CommandMenuProps) {
18+
export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
2319
const { tabs, setActiveTab, createTab } = useTabStore();
20+
const { setCliMode } = useLayoutStore();
2421
const { data: tasks = [] } = useTasks();
2522
const commandRef = useRef<HTMLDivElement>(null);
2623

@@ -96,8 +93,20 @@ export function CommandMenu({
9693
};
9794

9895
const handleCreateTask = () => {
96+
// Find the Tasks tab or use the first task-list tab
97+
const tasksTab = tabs.find((tab) => tab.type === "task-list");
98+
99+
if (tasksTab) {
100+
setActiveTab(tasksTab.id);
101+
}
102+
103+
// Switch to task mode
104+
setCliMode("task");
105+
106+
// Close the command menu
99107
onOpenChange(false);
100-
onCreateTask?.();
108+
109+
// Note: The auto-focus effect in CliTaskPanel will handle focusing the editor
101110
};
102111

103112
const handleNavigateToTask = (task: {

0 commit comments

Comments
 (0)