Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/desktop_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ jobs:
--exclude tauri-plugin-permissions \
--exclude tauri-plugin-screen \
--exclude tauri-plugin-settings \
--exclude tauri-plugin-shortcut \
--exclude tauri-plugin-sfx \
--exclude tauri-plugin-sidecar2 \
--exclude tauri-plugin-store2 \
Expand Down
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ tauri-plugin-relay = { path = "plugins/relay" }
tauri-plugin-screen = { path = "plugins/screen" }
tauri-plugin-settings = { path = "plugins/settings" }
tauri-plugin-sfx = { path = "plugins/sfx" }
tauri-plugin-shortcut = { path = "plugins/shortcut" }
tauri-plugin-sidecar2 = { path = "plugins/sidecar2" }
tauri-plugin-store2 = { path = "plugins/store2" }
tauri-plugin-tantivy = { path = "plugins/tantivy" }
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@hypr/plugin-relay": "workspace:*",
"@hypr/plugin-screen": "workspace:*",
"@hypr/plugin-settings": "workspace:*",
"@hypr/plugin-shortcut": "workspace:*",
"@hypr/plugin-sfx": "workspace:*",
"@hypr/plugin-store2": "workspace:*",
"@hypr/plugin-tantivy": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ tauri-plugin-sentry = { workspace = true }
tauri-plugin-settings = { workspace = true }
tauri-plugin-sfx = { workspace = true }
tauri-plugin-shell = { workspace = true }
tauri-plugin-shortcut = { workspace = true }
tauri-plugin-sidecar2 = { workspace = true }
tauri-plugin-single-instance = { workspace = true }
tauri-plugin-store = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"permissions:default",
"screen:default",
"settings:default",
"shortcut:default",
"sfx:default",
"path2:default",
"pdf:default",
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub async fn main() {
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_store2::init())
.plugin(tauri_plugin_settings::init())
.plugin(tauri_plugin_shortcut::init())
.plugin(tauri_plugin_sfx::init())
.plugin(tauri_plugin_windows::init())
.plugin(tauri_plugin_js::init())
Expand Down
11 changes: 7 additions & 4 deletions apps/desktop/src/components/main/body/empty/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AppWindowIcon } from "lucide-react";
import { useCallback, useState } from "react";
import { useHotkeys } from "react-hotkeys-hook";

import { Kbd } from "@hypr/ui/components/ui/kbd";
import { cn } from "@hypr/utils";

import { useScopedShortcut } from "../../../../hooks/useShortcutRegistry";
import { type Tab, useTabs } from "../../../../store/zustand/tabs";
import { useNewNote } from "../../shared";
import { StandardTabWrapper } from "../index";
Expand Down Expand Up @@ -77,10 +77,13 @@ function EmptyView() {
[openCurrent],
);

useHotkeys(
"mod+o",
useScopedShortcut(
"open_note_dialog",
() => setOpenNoteDialogOpen(true),
{ preventDefault: true, enableOnFormTags: true },
{
preventDefault: true,
enableOnFormTags: true,
},
[setOpenNoteDialogOpen],
);

Expand Down
228 changes: 0 additions & 228 deletions apps/desktop/src/components/main/body/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "lucide-react";
import { Reorder } from "motion/react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useHotkeys } from "react-hotkeys-hook";
import { useResizeObserver } from "usehooks-ts";
import { useShallow } from "zustand/shallow";

Expand Down Expand Up @@ -165,8 +164,6 @@ function Header({ tabs }: { tabs: Tab[] }) {
);

const setTabRef = useScrollActiveTabIntoView(regularTabs);
useTabsShortcuts();

return (
<div
data-tauri-drag-region
Expand Down Expand Up @@ -810,231 +807,6 @@ function useScrollActiveTabIntoView(tabs: Tab[]) {
return setTabRef;
}

function useTabsShortcuts() {
const {
tabs,
currentTab,
close,
select,
selectNext,
selectPrev,
restoreLastClosedTab,
openNew,
unpin,
setPendingCloseConfirmationTab,
} = useTabs(
useShallow((state) => ({
tabs: state.tabs,
currentTab: state.currentTab,
close: state.close,
select: state.select,
selectNext: state.selectNext,
selectPrev: state.selectPrev,
restoreLastClosedTab: state.restoreLastClosedTab,
openNew: state.openNew,
unpin: state.unpin,
setPendingCloseConfirmationTab: state.setPendingCloseConfirmationTab,
})),
);
const liveSessionId = useListener((state) => state.live.sessionId);
const liveStatus = useListener((state) => state.live.status);
const isListening = liveStatus === "active" || liveStatus === "finalizing";
const { chat } = useShell();

const newNote = useNewNote({ behavior: "new" });
const newNoteCurrent = useNewNote({ behavior: "current" });
const newNoteAndListen = useNewNoteAndListen();
const newEmptyTab = useNewEmptyTab();

useHotkeys(
"mod+n",
() => {
if (currentTab?.type === "empty") {
newNoteCurrent();
} else {
newNote();
}
},
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[currentTab, newNote, newNoteCurrent],
);

useHotkeys(
"mod+t",
() => newEmptyTab(),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[newEmptyTab],
);

useHotkeys(
"mod+w",
async () => {
if (currentTab) {
const isCurrentTabListening =
isListening &&
currentTab.type === "sessions" &&
currentTab.id === liveSessionId;
if (isCurrentTabListening) {
setPendingCloseConfirmationTab(currentTab);
} else if (currentTab.pinned) {
unpin(currentTab);
} else {
if (currentTab.type === "chat_support") {
chat.sendEvent({ type: "CLOSE" });
}
close(currentTab);
}
}
},
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[
currentTab,
close,
unpin,
isListening,
liveSessionId,
setPendingCloseConfirmationTab,
chat,
],
);

useHotkeys(
"mod+1, mod+2, mod+3, mod+4, mod+5, mod+6, mod+7, mod+8, mod+9",
(event) => {
const key = event.key;
const targetIndex =
key === "9" ? tabs.length - 1 : Number.parseInt(key, 10) - 1;
const target = tabs[targetIndex];
if (target) {
select(target);
}
},
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[tabs, select],
);

useHotkeys(
"mod+alt+left",
() => selectPrev(),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[selectPrev],
);

useHotkeys(
"mod+alt+right",
() => selectNext(),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[selectNext],
);

useHotkeys(
"mod+shift+t",
() => restoreLastClosedTab(),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[restoreLastClosedTab],
);

useHotkeys(
"mod+shift+c",
() => openNew({ type: "calendar" }),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[openNew],
);

useHotkeys(
"mod+shift+o",
() =>
openNew({
type: "contacts",
state: { selected: null },
}),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[openNew],
);

useHotkeys(
"mod+shift+comma",
() => openNew({ type: "ai" }),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[openNew],
);

useHotkeys(
"mod+shift+l",
() => openNew({ type: "folders", id: null }),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[openNew],
);

useHotkeys(
"mod+shift+f",
() => openNew({ type: "search" }),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[openNew],
);

useHotkeys(
"mod+shift+n",
() => newNoteAndListen(),
{
preventDefault: true,
enableOnFormTags: true,
enableOnContentEditable: true,
},
[newNoteAndListen],
);

return {};
}

function useNewEmptyTab() {
const openNew = useTabs((state) => state.openNew);

Expand Down
Loading
Loading