Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix all instances of $page.url.pathname checks for tauri #45

Merged
Merged
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
28 changes: 14 additions & 14 deletions src/lib/components/ActionsMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@
let index = 0;

const isMenuActive = () => menuOpen && input === document.activeElement;
const isHomePage = () => $page.url.pathname === "/" || $page.url.pathname === "";

let actionItems = [
{
name: "Generate Title...",
icon: IconThreadTitle,
when: () => $page.url.pathname === "/",
when: isHomePage,
execute: () => {
generateThreadTitle({ threadId: $currentThread.id }).catch((error) => {
toast({
Expand All @@ -66,47 +67,46 @@
},
{
name: "Regenerate Response",
when: () => $page.url.pathname === "/",
when: isHomePage,
icon: IconRefreshOutline,
execute: currentChatThread.regenerateResponse,
},
{
name: "Enable OpenAI",
when: () => {
const oai = llmProviders.getOpenAi();
return !oai.apiKey && oai.enabled && $page.url.pathname === "/";
return !oai.apiKey && oai.enabled && isHomePage();
},
icon: IconOpenAi,
execute: () => {
showInitScreen.set(true);
},
},
{
when: () => !sys.isBrowser && $page.url.pathname === "/",
when: () => !sys.isBrowser && isHomePage(),
name: "Chat History",
icon: IconHistoryClock,
keyboard: { shortcut: "meta+p" },
execute: () => ($threadMenu.open = !$threadMenu.open),
},
{
when: () => sys.isBrowser && $page.url.pathname === "/",
when: () => sys.isBrowser && isHomePage(),
name: "Chat History",
icon: IconHistoryClock,
keyboard: { shortcut: "ctrl+p" },
execute: () => ($threadMenu.open = !$threadMenu.open),
},

{
when: () =>
!sys.isBrowser && ($page.url.pathname === "/" || !$page.url.pathname),
when: () => !sys.isBrowser && isHomePage(),
name: "New Chat",
icon: IconSparkle,
keyboard: { shortcut: "meta+n" }, // NOTE Meta key with N only works in the Tauri app. In a browser this opens a new window
altFilterText: "thread",
execute: currentThread.reset,
},
{
when: () => sys.isBrowser && $page.url.pathname === "/",
when: () => sys.isBrowser && isHomePage(),
name: "New Chat",
icon: IconSparkle,
keyboard: { shortcut: "ctrl+n" },
Expand All @@ -115,17 +115,17 @@
},

{
when: () => !sys.isBrowser && $page.url.pathname === "/",
when: () => !sys.isBrowser && isHomePage(),
name: "Choose LLM Model",
icon: IconBrain,
keyboard: { shortcut: "meta+l" }, // NOTE Meta key with N only works in the Tauri app. In a browser this opens a new window
keyboard: { shortcut: "meta+l" },
altFilterText: "thread",
execute: () => {
$modelPickerOpen = !$modelPickerOpen;
},
},
{
when: () => sys.isBrowser && $page.url.pathname === "/",
when: () => sys.isBrowser && isHomePage(),
name: "Choose LLM Model",
icon: IconBrain,
keyboard: { shortcut: "ctrl+l" },
Expand All @@ -139,13 +139,13 @@
name: "Archive Chat",
icon: IconArchiveIn,
when: () =>
!$currentThread.archived && !isNewThread($currentThread) && $page.url.pathname === "/",
!$currentThread.archived && !isNewThread($currentThread) && isHomePage(),
execute: currentThread.archive,
},
{
name: "Unarchive Chat",
icon: IconArchiveOut,
when: () => $currentThread.archived && $page.url.pathname === "/",
when: () => $currentThread.archived && isHomePage(),
execute: currentThread.unarchive,
},
{
Expand All @@ -158,7 +158,7 @@
{
name: "Back to chat",
icon: IconBrain,
when: () => $page.url.pathname !== "/",
when: () => !isHomePage(),
execute: () => {
goto("/");
},
Expand Down