mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
feat(p2): add a + button to sidebar folders to start a new session there
This commit is contained in:
parent
55a5c69145
commit
5a31a6d5f4
4 changed files with 97 additions and 39 deletions
|
|
@ -178,12 +178,20 @@ function Sidebar() {
|
|||
);
|
||||
const renamed = renaming && list?.find((each) => each.id === renaming.session);
|
||||
const branch = renamed?.branches.find((each) => each.conversation === renaming?.conversation);
|
||||
const { setChoice } = useNewSessionState();
|
||||
const { setChoice, setLocation } = useNewSessionState();
|
||||
const onNew = useCallback(() => {
|
||||
setChoice(undefined);
|
||||
navigate({});
|
||||
setTimeout(() => document.querySelector<HTMLTextAreaElement>(".composer textarea")?.focus(), 50);
|
||||
}, [setChoice]);
|
||||
// A folder's "+": the new session starts in that folder's location.
|
||||
const onNewIn = useCallback(
|
||||
(env: string | null, cwd: string) => {
|
||||
setLocation({ env, cwd });
|
||||
onNew();
|
||||
},
|
||||
[setLocation, onNew],
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<Drawer
|
||||
|
|
@ -196,6 +204,7 @@ function Sidebar() {
|
|||
onBranch={owner ? onBranch : undefined}
|
||||
onRenameBranch={owner ? onRenameBranch : undefined}
|
||||
onNew={onNew}
|
||||
onNewIn={owner ? onNewIn : undefined}
|
||||
onCollapse={toggleSidebar}
|
||||
onSearch={search ? onSearch : undefined}
|
||||
onRestore={onRestore}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue