Go to a folder by name, with g then o

Requested in #233. The `g` shortcuts cover the handful of folders every
account has -- inbox, sent, drafts -- and nothing reaches the dozens a Sieve
rule fills, which is where somebody with a real folder tree spends their time.
`g o` opens the picker, you type part of a name, and you are there.

The picker is the one the move action already uses, with one difference that
only shows up on shared mail: it selected folders by `mayAddItems`, which is
right for a destination and wrong for a place to go. A shared folder you may
read but not file into is somewhere you can visit. The right is now a
parameter, named for what it is asking rather than for which caller wants it.

Hosted in AppShell rather than in the mail view, because the `g` shortcuts are
global and the mail view is not mounted to hear about it -- pressing this from
the calendar should still take you to a folder, and now does.

`o` on its own opens a conversation and does not clash: a pending prefix is
tried before a bare key. That was already true and nothing said so, so there
are now five tests for the sequence machinery -- including that an abandoned
prefix costs the prefix and not the keystroke after it, which is the nicer
behaviour of the two and was undocumented.

Checked in a browser against the mock: opened from the calendar, filtered to a
nested folder, landed on it, and `o` still opened a conversation afterwards.

Closes #233.
This commit is contained in:
2026-09-02 13:03:55 -07:00
parent a8cf8ce3d7
commit 483aac849a
13 changed files with 149 additions and 5 deletions
+18 -1
View File
@@ -15,6 +15,7 @@ import { FilesTree } from "./files/FilesTree";
import { ContactsSidebar } from "./contacts/ContactsSidebar";
import { CalendarSidebar } from "./calendar/CalendarSidebar";
import { ShortcutsDialog, useGlobalShortcuts } from "./Shortcuts";
import { MailboxPicker } from "./mail/MailboxPicker";
import { formatSize } from "@/lib/format";
import { TranslateBoundary } from "@/ui/TranslateBoundary";
import { t } from "@/lib/i18n";
@@ -37,9 +38,15 @@ export function AppShell({ children }: { children: ReactNode }) {
const session = useSession((s) => s.session);
const logout = useSession((s) => s.logout);
const acctMenu = useMenu();
/*
* "Go to folder" (#233), hosted here rather than in the mail view because
* the `g` shortcuts are global: pressing it from the calendar should still
* take you to a folder, and the mail view is not mounted to hear about it.
*/
const [goFolder, setGoFolder] = useState(false);
const section = location.split("/")[1] || "mail";
useGlobalShortcuts({ onHelp: () => setHelpOpen(true) });
useGlobalShortcuts({ onHelp: () => setHelpOpen(true), onGoToFolder: () => setGoFolder(true) });
useEffect(() => setDrawer(false), [location]);
// Escape closes it too, for the tablet with a keyboard attached.
@@ -220,6 +227,16 @@ export function AppShell({ children }: { children: ReactNode }) {
</>
)}
<ShortcutsDialog open={helpOpen} onClose={() => setHelpOpen(false)} />
{goFolder && (
<MailboxPicker
title={t("Go to folder…")}
/* Read, not write: a shared folder you may read but not file into is
still somewhere worth going. */
need="mayReadItems"
onClose={() => setGoFolder(false)}
onPick={(id) => { setGoFolder(false); navigate(`/mail/${id}`); }}
/>
)}
</div>
);
}