Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9fae23efe | ||
|
|
4d2f16be47 | ||
|
|
c6047688a1 |
No files matched your search
@@ -25,9 +25,15 @@ interface BranchToolbarProps {
|
|||||||
envMode: "local" | "worktree";
|
envMode: "local" | "worktree";
|
||||||
onEnvModeChange: (mode: "local" | "worktree") => void;
|
onEnvModeChange: (mode: "local" | "worktree") => void;
|
||||||
envLocked: boolean;
|
envLocked: boolean;
|
||||||
|
onComposerFocusRequest?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: BranchToolbarProps) {
|
export default function BranchToolbar({
|
||||||
|
envMode,
|
||||||
|
onEnvModeChange,
|
||||||
|
envLocked,
|
||||||
|
onComposerFocusRequest,
|
||||||
|
}: BranchToolbarProps) {
|
||||||
const { state, dispatch } = useStore();
|
const { state, dispatch } = useStore();
|
||||||
const api = useNativeApi();
|
const api = useNativeApi();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
@@ -123,6 +129,7 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: B
|
|||||||
setThreadError(null);
|
setThreadError(null);
|
||||||
setThreadBranch(branch.name, null);
|
setThreadBranch(branch.name, null);
|
||||||
setIsBranchMenuOpen(false);
|
setIsBranchMenuOpen(false);
|
||||||
|
onComposerFocusRequest?.();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +142,7 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: B
|
|||||||
// Secondary worktree → point the thread at that worktree path.
|
// Secondary worktree → point the thread at that worktree path.
|
||||||
setThreadBranch(branch.name, isMainWorktree ? null : branch.worktreePath);
|
setThreadBranch(branch.name, isMainWorktree ? null : branch.worktreePath);
|
||||||
setIsBranchMenuOpen(false);
|
setIsBranchMenuOpen(false);
|
||||||
|
onComposerFocusRequest?.();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +151,7 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: B
|
|||||||
setThreadError(null);
|
setThreadError(null);
|
||||||
setThreadBranch(branch.name, activeWorktreePath);
|
setThreadBranch(branch.name, activeWorktreePath);
|
||||||
setIsBranchMenuOpen(false);
|
setIsBranchMenuOpen(false);
|
||||||
|
onComposerFocusRequest?.();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -156,6 +165,7 @@ export default function BranchToolbar({ envMode, onEnvModeChange, envLocked }: B
|
|||||||
setThreadBranch(name, activeWorktreePath);
|
setThreadBranch(name, activeWorktreePath);
|
||||||
setBranchQuery("");
|
setBranchQuery("");
|
||||||
setIsBranchMenuOpen(false);
|
setIsBranchMenuOpen(false);
|
||||||
|
onComposerFocusRequest?.();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -273,6 +273,11 @@ export default function ChatView() {
|
|||||||
const cursor = textarea.value.length;
|
const cursor = textarea.value.length;
|
||||||
textarea.setSelectionRange(cursor, cursor);
|
textarea.setSelectionRange(cursor, cursor);
|
||||||
}, []);
|
}, []);
|
||||||
|
const scheduleComposerFocus = useCallback(() => {
|
||||||
|
window.requestAnimationFrame(() => {
|
||||||
|
focusComposer();
|
||||||
|
});
|
||||||
|
}, [focusComposer]);
|
||||||
const toggleTerminalVisibility = useCallback(() => {
|
const toggleTerminalVisibility = useCallback(() => {
|
||||||
if (!activeThreadId) return;
|
if (!activeThreadId) return;
|
||||||
dispatch({
|
dispatch({
|
||||||
@@ -344,6 +349,7 @@ export default function ChatView() {
|
|||||||
const handleRuntimeModeChange = async (mode: "approval-required" | "full-access") => {
|
const handleRuntimeModeChange = async (mode: "approval-required" | "full-access") => {
|
||||||
if (mode === state.runtimeMode) return;
|
if (mode === state.runtimeMode) return;
|
||||||
dispatch({ type: "SET_RUNTIME_MODE", mode });
|
dispatch({ type: "SET_RUNTIME_MODE", mode });
|
||||||
|
scheduleComposerFocus();
|
||||||
if (!api) return;
|
if (!api) return;
|
||||||
|
|
||||||
const sessionIds = state.threads
|
const sessionIds = state.threads
|
||||||
@@ -806,14 +812,32 @@ export default function ChatView() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onModelSelect = (model: ModelSlug) => {
|
const onModelSelect = useCallback(
|
||||||
if (!activeThread) return;
|
(model: ModelSlug) => {
|
||||||
dispatch({
|
if (!activeThread) return;
|
||||||
type: "SET_THREAD_MODEL",
|
dispatch({
|
||||||
threadId: activeThread.id,
|
type: "SET_THREAD_MODEL",
|
||||||
model: resolveModelSlug(model),
|
threadId: activeThread.id,
|
||||||
});
|
model: resolveModelSlug(model),
|
||||||
};
|
});
|
||||||
|
scheduleComposerFocus();
|
||||||
|
},
|
||||||
|
[activeThread, dispatch, scheduleComposerFocus],
|
||||||
|
);
|
||||||
|
const onEffortSelect = useCallback(
|
||||||
|
(effort: ReasoningEffort) => {
|
||||||
|
setSelectedEffort(effort);
|
||||||
|
scheduleComposerFocus();
|
||||||
|
},
|
||||||
|
[scheduleComposerFocus],
|
||||||
|
);
|
||||||
|
const onEnvModeChange = useCallback(
|
||||||
|
(mode: "local" | "worktree") => {
|
||||||
|
setEnvMode(mode);
|
||||||
|
scheduleComposerFocus();
|
||||||
|
},
|
||||||
|
[scheduleComposerFocus],
|
||||||
|
);
|
||||||
|
|
||||||
const onKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
|
const onKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
|
||||||
if (e.key === "Enter" && !e.shiftKey) {
|
if (e.key === "Enter" && !e.shiftKey) {
|
||||||
@@ -1213,7 +1237,7 @@ export default function ChatView() {
|
|||||||
<Separator orientation="vertical" className="mx-0.5 h-4" />
|
<Separator orientation="vertical" className="mx-0.5 h-4" />
|
||||||
|
|
||||||
{/* Reasoning effort */}
|
{/* Reasoning effort */}
|
||||||
<ReasoningEffortPicker effort={selectedEffort} onEffortChange={setSelectedEffort} />
|
<ReasoningEffortPicker effort={selectedEffort} onEffortChange={onEffortSelect} />
|
||||||
|
|
||||||
{/* Divider */}
|
{/* Divider */}
|
||||||
<Separator orientation="vertical" className="mx-0.5 h-4" />
|
<Separator orientation="vertical" className="mx-0.5 h-4" />
|
||||||
@@ -1316,7 +1340,12 @@ export default function ChatView() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isGitRepo && (
|
{isGitRepo && (
|
||||||
<BranchToolbar envMode={envMode} onEnvModeChange={setEnvMode} envLocked={envLocked} />
|
<BranchToolbar
|
||||||
|
envMode={envMode}
|
||||||
|
onEnvModeChange={onEnvModeChange}
|
||||||
|
envLocked={envLocked}
|
||||||
|
onComposerFocusRequest={scheduleComposerFocus}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{activeThread.terminalOpen && api && activeProject && (
|
{activeThread.terminalOpen && api && activeProject && (
|
||||||
|
|||||||
Reference in new issue
Block a user