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
12 changes: 6 additions & 6 deletions apps/desktop/src/components/chat/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Button } from "@hypr/ui/components/ui/button";
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from "@hypr/ui/components/ui/dropdown-menu";
import { cn } from "@hypr/utils";
import { useShell } from "../../contexts/shell";
import * as persisted from "../../store/tinybase/persisted";
import * as main from "../../store/tinybase/main";

export function ChatHeader({
currentChatGroupId,
Expand Down Expand Up @@ -86,19 +86,19 @@ function ChatGroups({
}) {
const [isDropdownOpen, setIsDropdownOpen] = useState(false);

const currentChatTitle = persisted.UI.useCell(
const currentChatTitle = main.UI.useCell(
"chat_groups",
currentChatGroupId || "",
"title",
persisted.STORE_ID,
main.STORE_ID,
);
const recentChatGroupIds = persisted.UI.useSortedRowIds(
const recentChatGroupIds = main.UI.useSortedRowIds(
"chat_groups",
"created_at",
true,
0,
5,
persisted.STORE_ID,
main.STORE_ID,
);

return (
Expand Down Expand Up @@ -162,7 +162,7 @@ function ChatGroupItem({
isActive: boolean;
onSelect: (groupId: string) => void;
}) {
const chatGroup = persisted.UI.useRow("chat_groups", groupId, persisted.STORE_ID);
const chatGroup = main.UI.useRow("chat_groups", groupId, main.STORE_ID);

if (!chatGroup) {
return null;
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/components/chat/message/tool/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
CarouselNext,
CarouselPrevious,
} from "@hypr/ui/components/ui/carousel";
import * as persisted from "../../../../store/tinybase/persisted";
import * as main from "../../../../store/tinybase/main";
import { useTabs } from "../../../../store/zustand/tabs";
import { Disclosure } from "../shared";
import { ToolRenderer } from "../types";
Expand Down Expand Up @@ -91,7 +91,7 @@ function RenderContent({ part }: { part: Part }) {
}

function RenderSession({ sessionId }: { sessionId: string }) {
const session = persisted.UI.useRow("sessions", sessionId, persisted.STORE_ID);
const session = main.UI.useRow("sessions", sessionId, main.STORE_ID);
const { openNew } = useTabs();

const handleClick = useCallback(() => {
Expand Down
23 changes: 11 additions & 12 deletions apps/desktop/src/components/chat/session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { CustomChatTransport } from "../../chat/transport";
import type { HyprUIMessage } from "../../chat/types";
import { useToolRegistry } from "../../contexts/tool";
import { useLanguageModel } from "../../hooks/useLLMConnection";
import * as internal from "../../store/tinybase/internal";
import * as persisted from "../../store/tinybase/persisted";
import * as main from "../../store/tinybase/main";
import { id } from "../../utils";

interface ChatSessionProps {
Expand All @@ -29,30 +28,30 @@ export function ChatSession({
children,
}: ChatSessionProps) {
const transport = useTransport();
const store = persisted.UI.useStore(persisted.STORE_ID);
const store = main.UI.useStore(main.STORE_ID);

const { user_id } = internal.UI.useValues(internal.STORE_ID);
const { user_id } = main.UI.useValues(main.STORE_ID);

const createChatMessage = persisted.UI.useSetRowCallback(
const createChatMessage = main.UI.useSetRowCallback(
"chat_messages",
(p: Omit<persisted.ChatMessage, "user_id" | "created_at"> & { id: string }) => p.id,
(p: Omit<persisted.ChatMessage, "user_id" | "created_at"> & { id: string }) => ({
(p: Omit<main.ChatMessage, "user_id" | "created_at"> & { id: string }) => p.id,
(p: Omit<main.ChatMessage, "user_id" | "created_at"> & { id: string }) => ({
user_id,
chat_group_id: p.chat_group_id,
content: p.content,
created_at: new Date().toISOString(),
role: p.role,
metadata: JSON.stringify(p.metadata),
parts: JSON.stringify(p.parts),
} satisfies persisted.ChatMessageStorage),
} satisfies main.ChatMessageStorage),
[user_id],
persisted.STORE_ID,
main.STORE_ID,
);

const messageIds = persisted.UI.useSliceRowIds(
persisted.INDEXES.chatMessagesByGroup,
const messageIds = main.UI.useSliceRowIds(
main.INDEXES.chatMessagesByGroup,
chatGroupId ?? "",
persisted.STORE_ID,
main.STORE_ID,
);

const initialMessages = useMemo((): HyprUIMessage[] => {
Expand Down
13 changes: 6 additions & 7 deletions apps/desktop/src/components/chat/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useCallback, useRef } from "react";

import type { HyprUIMessage } from "../../chat/types";
import { useShell } from "../../contexts/shell";
import * as internal from "../../store/tinybase/internal";
import * as persisted from "../../store/tinybase/persisted";
import * as main from "../../store/tinybase/main";
import { id } from "../../utils";

import { useLanguageModel } from "../../hooks/useLLMConnection";
Expand All @@ -19,9 +18,9 @@ export function ChatView() {
const stableSessionId = useStableSessionId(groupId);
const model = useLanguageModel();

const { user_id } = internal.UI.useValues(internal.STORE_ID);
const { user_id } = main.UI.useValues(main.STORE_ID);

const createChatGroup = persisted.UI.useSetRowCallback(
const createChatGroup = main.UI.useSetRowCallback(
"chat_groups",
(p: { groupId: string; title: string }) => p.groupId,
(p: { groupId: string; title: string }) => ({
Expand All @@ -30,10 +29,10 @@ export function ChatView() {
title: p.title,
}),
[user_id],
persisted.STORE_ID,
main.STORE_ID,
);

const createChatMessage = persisted.UI.useSetRowCallback(
const createChatMessage = main.UI.useSetRowCallback(
"chat_messages",
(p: { id: string; chat_group_id: string; content: string; role: string; parts: any; metadata: any }) => p.id,
(p: { id: string; chat_group_id: string; content: string; role: string; parts: any; metadata: any }) => ({
Expand All @@ -46,7 +45,7 @@ export function ChatView() {
parts: JSON.stringify(p.parts),
}),
[user_id],
persisted.STORE_ID,
main.STORE_ID,
);

const handleSendMessage = useCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Checkbox } from "@hypr/ui/components/ui/checkbox";

import * as persisted from "../../../../store/tinybase/persisted";
import * as main from "../../../../store/tinybase/main";

export function CalendarCheckboxRow(
{ id, checked, onToggle }: { id: string; checked: boolean; onToggle: (checked: boolean) => void },
) {
const calendar = persisted.UI.useRow("calendars", id, persisted.STORE_ID);
const calendar = main.UI.useRow("calendars", id, main.STORE_ID);
return (
<div className="flex items-center space-x-2">
<Checkbox
Expand Down
16 changes: 8 additions & 8 deletions apps/desktop/src/components/main/body/calendars/calendar-day.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cn, format, getDay } from "@hypr/utils";

import { useEffect, useRef, useState } from "react";

import * as persisted from "../../../../store/tinybase/persisted";
import * as main from "../../../../store/tinybase/main";
import { TabContentCalendarDayEvents } from "./day-events";
import { TabContentCalendarDayMore } from "./day-more";
import { TabContentCalendarDaySessions } from "./day-sessions";
Expand All @@ -24,23 +24,23 @@ export function TabContentCalendarDay({
const contentRef = useRef<HTMLDivElement>(null);
const [maxVisibleItems, setMaxVisibleItems] = useState(5);

const allEventIds = persisted.UI.useSliceRowIds(
persisted.INDEXES.eventsByDate,
const allEventIds = main.UI.useSliceRowIds(
main.INDEXES.eventsByDate,
day,
persisted.STORE_ID,
main.STORE_ID,
);

const store = persisted.UI.useStore(persisted.STORE_ID);
const store = main.UI.useStore(main.STORE_ID);

const eventIds = allEventIds.filter((eventId) => {
const event = store?.getRow("events", eventId);
return event?.calendar_id && selectedCalendars.has(event.calendar_id as string);
});

const sessionIds = persisted.UI.useSliceRowIds(
persisted.INDEXES.sessionByDateWithoutEvent,
const sessionIds = main.UI.useSliceRowIds(
main.INDEXES.sessionByDateWithoutEvent,
day,
persisted.STORE_ID,
main.STORE_ID,
);

const dayNumber = format(new Date(day), "d");
Expand Down
12 changes: 6 additions & 6 deletions apps/desktop/src/components/main/body/calendars/day-events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import { cn, format, isSameDay } from "@hypr/utils";
import { Calendar, Pen, StickyNote } from "lucide-react";
import { useState } from "react";

import * as persisted from "../../../../store/tinybase/persisted";
import * as main from "../../../../store/tinybase/main";
import { useTabs } from "../../../../store/zustand/tabs";

export function TabContentCalendarDayEvents({ eventId }: { eventId: string }) {
const event = persisted.UI.useRow("events", eventId, persisted.STORE_ID);
const event = main.UI.useRow("events", eventId, main.STORE_ID);
const [open, setOpen] = useState(false);
const { openNew } = useTabs();

const title = event?.title || "Untitled Event";

const sessionIds = persisted.UI.useSliceRowIds(
persisted.INDEXES.sessionsByEvent,
const sessionIds = main.UI.useSliceRowIds(
main.INDEXES.sessionsByEvent,
eventId,
persisted.STORE_ID,
main.STORE_ID,
);
const linkedSessionId = sessionIds[0];
const linkedSession = persisted.UI.useRow("sessions", linkedSessionId || "dummy", persisted.STORE_ID);
const linkedSession = main.UI.useRow("sessions", linkedSessionId || "dummy", main.STORE_ID);

const handleOpenNote = () => {
setOpen(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { Button } from "@hypr/ui/components/ui/button";

import { StickyNote } from "lucide-react";

import * as persisted from "../../../../store/tinybase/persisted";
import * as main from "../../../../store/tinybase/main";
import { useTabs } from "../../../../store/zustand/tabs";

export function TabContentCalendarDaySessions({ sessionId }: { sessionId: string }) {
const session = persisted.UI.useRow("sessions", sessionId, persisted.STORE_ID);
const session = main.UI.useRow("sessions", sessionId, main.STORE_ID);
const { openNew } = useTabs();

const eventId = session?.event_id ?? "";
const event = persisted.UI.useRow("events", eventId, persisted.STORE_ID);
const event = main.UI.useRow("events", eventId, main.STORE_ID);

const handleClick = () => {
openNew({ type: "sessions", id: sessionId });
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/components/main/body/calendars/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { Calendar, CalendarDays, ChevronLeft, ChevronRight } from "lucide-react";
import { useState } from "react";

import * as persisted from "../../../../store/tinybase/persisted";
import * as main from "../../../../store/tinybase/main";
import { type Tab, useTabs } from "../../../../store/zustand/tabs";
import { StandardTabWrapper } from "../index";
import { type TabItem, TabItemBase } from "../shared";
Expand Down Expand Up @@ -58,7 +58,7 @@ function TabContentCalendarInner({ tab }: { tab: Extract<Tab, { type: "calendars

const { openCurrent } = useTabs();

const calendarIds = persisted.UI.useRowIds("calendars", persisted.STORE_ID);
const calendarIds = main.UI.useRowIds("calendars", main.STORE_ID);

const [selectedCalendars, setSelectedCalendars] = useState<Set<string>>(() => new Set(calendarIds));

Expand Down
Loading
Loading