Skip to content
Merged
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
49 changes: 38 additions & 11 deletions packages/web-shell/client/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1153,23 +1153,50 @@ export function App({
if (!sidebarOptions.enabled) return undefined;
const onKey = (e: KeyboardEvent) => {
if (!isSidebarToggleShortcut(e)) return;
// The composer keeps the editor-convention behavior (VS Code toggles
// the sidebar while the editor is focused), but other editable targets
// — sidebar search, session rename, settings inputs — must not have
// the sidebar yanked around while the user is typing, matching the
// codebase's isEditableTarget convention.
const target = e.target as HTMLElement | null;
if (
isEditableTarget(target) &&
!target?.closest('[data-web-shell-composer-editor]')
) {
return;
}
e.preventDefault();
if (window.matchMedia('(max-width: 760px)').matches) {
setMobileDrawerOpen((open) => {
if (open) setForceMobileDrawer(false);
return !open;
});
// All state updates are dispatched sequentially outside the updater
// functions (React purity contract — mirrors the hamburger handler),
// which is why this effect re-binds on state changes: the listener
// closure must stay fresh.
if (
forceMobileDrawer ||
window.matchMedia('(max-width: 760px)').matches
) {
// A forced drawer on a wide viewport still belongs to the drawer
// path: collapsing the rail underneath the overlay would look like
// a no-op to the user.
if (mobileDrawerOpen) {
setMobileDrawerOpen(false);
setForceMobileDrawer(false);
} else {
setMobileDrawerOpen(true);
}
return;
}
setSidebarCollapsed((collapsed) => {
const next = !collapsed;
writeSidebarCollapsed(next);
return next;
});
const next = !sidebarCollapsed;
setSidebarCollapsed(next);
writeSidebarCollapsed(next);
};
window.addEventListener('keydown', onKey);
return () => window.removeEventListener('keydown', onKey);
}, [sidebarOptions.enabled]);
}, [
sidebarOptions.enabled,
mobileDrawerOpen,
forceMobileDrawer,
sidebarCollapsed,
]);
const customization = useMemo(
() => ({
composerTagIcons,
Expand Down
11 changes: 8 additions & 3 deletions packages/web-shell/client/hooks/useQueuedPrompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,14 @@ export function useQueuedPrompts({
const next = mergeRestoredPromptText(current, text);
if (next !== current) {
editorRef.current?.setText(next);
}
if (images && images.length > 0) {
editorRef.current?.restoreImages(images);
// Restore images only alongside a text change: restoreImages appends
// to the pasted-image list, so running it on a deduplicated restore
// (same prompt restored twice across reconnects/retries) would double
// the attachments while the text correctly stays single (#7134
// review follow-up).
if (images && images.length > 0) {
editorRef.current?.restoreImages(images);
}
}
editorRef.current?.focus();
},
Expand Down
Loading