Skip to content

Commit 072df25

Browse files
committed
feat(journal-entries): final fixes & tweaks
1 parent 6428018 commit 072df25

File tree

17 files changed

+188
-147
lines changed

17 files changed

+188
-147
lines changed

apps/web/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
"@acme/auth": "workspace:*",
1919
"@acme/blocknote": "workspace:*",
2020
"@acme/db": "workspace:*",
21-
"@ai-sdk/openai": "^2.0.23",
22-
"@ai-sdk/provider-utils": "^3.0.7",
23-
"@ai-sdk/react": "2.0.29",
24-
"@assistant-ui/react": "^0.10.45",
25-
"@assistant-ui/react-ai-sdk": "^1.0.5",
26-
"@assistant-ui/react-markdown": "^0.10.9",
27-
"@assistant-ui/styles": "^0.1.18",
21+
"@ai-sdk/openai": "^2.0.27",
22+
"@ai-sdk/provider-utils": "^3.0.8",
23+
"@ai-sdk/react": "2.0.38",
24+
"@assistant-ui/react": "^0.11.0",
25+
"@assistant-ui/react-ai-sdk": "^1.1.0",
26+
"@assistant-ui/react-markdown": "^0.11.0",
27+
"@assistant-ui/styles": "^0.2.1",
2828
"@blocknote/core": "^0.35.0",
2929
"@blocknote/mantine": "^0.35.0",
3030
"@blocknote/react": "^0.35.0",
@@ -56,7 +56,7 @@
5656
"@trpc/client": "^11.4.0",
5757
"@trpc/server": "^11.4.0",
5858
"@trpc/tanstack-react-query": "^11.4.0",
59-
"ai": "^5.0.28",
59+
"ai": "^5.0.38",
6060
"class-variance-authority": "^0.7.1",
6161
"clsx": "^2.1.1",
6262
"cmdk": "^1.1.1",

apps/web/src/ai/tools/manipulate-editor.client.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ export function useManipulateEditorTool() {
99
const { getEditors } = useJournlAgentAwareness();
1010
const tool = createClientTool({
1111
execute: async (toolCall, chat) => {
12-
const editor = getEditors().get(toolCall.input.editorId);
12+
try {
13+
const editor = getEditors().get(toolCall.input.editorId);
1314

14-
if (!editor) {
15-
const availableEditors = JSON.stringify(
16-
Object.fromEntries(getEditors().entries()),
17-
);
18-
return await chat.addToolResult({
19-
output: `Editor ${toolCall.input.editorId} was not found. Please call the tool again with the available editors: ${availableEditors}`,
20-
tool: toolCall.toolName,
21-
toolCallId: toolCall.toolCallId,
22-
});
23-
}
15+
if (!editor) {
16+
const availableEditors = JSON.stringify(
17+
Object.fromEntries(getEditors().entries()),
18+
);
19+
return await chat.addToolResult({
20+
output: `Editor ${toolCall.input.editorId} was not found. Please call the tool again with the available editors: ${availableEditors}`,
21+
tool: toolCall.toolName,
22+
toolCallId: toolCall.toolCallId,
23+
});
24+
}
2425

25-
try {
2626
const aiExtension = getAIExtension(editor);
2727

2828
const result = await aiExtension.callLLM({
@@ -37,15 +37,15 @@ export function useManipulateEditorTool() {
3737

3838
const changes = await result?.llmResult.streamObjectResult?.object;
3939

40-
await chat.addToolResult({
40+
void chat.addToolResult({
4141
output: `The following changes were made to the editor: ${JSON.stringify(
4242
changes,
4343
)}`,
4444
tool: toolCall.toolName,
4545
toolCallId: toolCall.toolCallId,
4646
});
4747
} catch (error) {
48-
await chat.addToolResult({
48+
void chat.addToolResult({
4949
output: `Error when calling the tool: ${error}`,
5050
tool: toolCall.toolName,
5151
toolCallId: toolCall.toolCallId,

apps/web/src/ai/tools/navigate-journal-entry.client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function useNavigateJournalEntryTool() {
1010
execute: (toolCall, chat) => {
1111
const entry = `/journal/${toolCall.input.date}`;
1212
router.push(entry);
13-
chat.addToolResult({
13+
void chat.addToolResult({
1414
output: `Navigating to the journal entry: ${entry}`,
1515
tool: toolCall.toolName,
1616
toolCallId: toolCall.toolCallId,

apps/web/src/ai/tools/navigate-page.client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function useNavigatePageTool() {
1010
execute: (toolCall, chat) => {
1111
const page = `/pages/${toolCall.input.id}`;
1212
router.push(page);
13-
chat.addToolResult({
13+
void chat.addToolResult({
1414
output: `Navigating to the page: ${page}`,
1515
tool: toolCall.toolName,
1616
toolCallId: toolCall.toolCallId,

apps/web/src/app/(app)/@header/_components/header-search-modal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function HeaderSearchButton({
9999
<DialogTitle className="sr-only">
100100
Search pages and journal entries
101101
</DialogTitle>
102-
<div className="flex w-full items-center gap-x-2 rounded-lg border-2 bg-muted px-2 [&>div]:w-full">
102+
<div className="flex w-full items-center gap-x-2 rounded-lg border-2 bg-muted px-2 [&>div]:w-full [&>div]:px-0">
103103
<CommandInput
104104
className="flex h-10 w-full rounded-md border-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50"
105105
placeholder="Search notes..."
@@ -171,7 +171,7 @@ export function HeaderSearchButton({
171171
) : (
172172
<>
173173
<div className="text-muted-foreground text-sm">
174-
{new Date(note.updated_at).toLocaleDateString()}
174+
{new Date(note.date).toLocaleDateString()}
175175
</div>
176176
<div className="line-clamp-2 text-muted-foreground text-sm">
177177
<HighlightedText query={query} maxLength={120}>

apps/web/src/app/(app)/journal/[date]/page.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { api } from "~/trpc/server";
44
import {
55
JournalEntryAgentView,
66
JournalEntryContent,
7-
JournalEntryEditor,
87
JournalEntryHeader,
98
JournalEntryLink,
109
JournalEntryProvider,
1110
JournalEntryWrapper,
1211
} from "../_components/journal-entry-editor";
12+
import { DynamicJournalEntryEditor } from "../_components/journal-entry-editor.dynamic";
1313
import { JournalEntrySkeleton } from "../_components/journal-entry-skeleton";
1414

1515
export default async function Page({
@@ -32,7 +32,7 @@ function JournalEntryFallback({ date }: { date: string }) {
3232
entry={{ date }}
3333
>
3434
<JournalEntryHeader className="mb-6" />
35-
<JournalEntrySkeleton hasHeader={false} hasContent={true} />
35+
<JournalEntrySkeleton hasHeader={false} hasContent />
3636
</JournalEntryProvider>
3737
);
3838
}
@@ -51,7 +51,9 @@ async function SuspendedJournalEntry({ date }: { date: string }) {
5151
<JournalEntryHeader className="px-13.5" />
5252
</JournalEntryLink>
5353
<JournalEntryContent>
54-
<JournalEntryEditor />
54+
<Suspense fallback={<JournalEntrySkeleton hasContent />}>
55+
<DynamicJournalEntryEditor />
56+
</Suspense>
5557
</JournalEntryContent>
5658
</JournalEntryWrapper>
5759
<JournalEntryAgentView />
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use client";
2+
3+
import dynamic from "next/dynamic";
4+
5+
export const DynamicJournalEntryEditor = dynamic(
6+
() => import("./journal-entry-editor").then((mod) => mod.JournalEntryEditor),
7+
{
8+
ssr: false,
9+
},
10+
);

apps/web/src/app/(app)/journal/_components/journal-list-skeleton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export function JournalListSkeleton({ ...rest }: JournalFeedSkeletonProps) {
1111
<JournalEntrySkeleton hasContent={false} />
1212

1313
{/* Yesterday with content */}
14-
<JournalEntrySkeleton hasContent={true} />
14+
<JournalEntrySkeleton hasContent />
1515

1616
{/* Multiple past entries */}
1717
<JournalEntrySkeleton hasContent={false} />
18-
<JournalEntrySkeleton hasContent={true} />
18+
<JournalEntrySkeleton hasContent />
1919
<JournalEntrySkeleton hasContent={false} />
20-
<JournalEntrySkeleton hasContent={true} />
20+
<JournalEntrySkeleton hasContent />
2121
</div>
2222
</div>
2323
</div>

apps/web/src/app/(app)/journal/_components/journal-list.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { useJournlAgentAwareness } from "~/ai/agents/use-journl-agent-awareness"
99
import { useTRPC } from "~/trpc/react";
1010
import {
1111
JournalEntryContent,
12-
JournalEntryEditor,
1312
JournalEntryHeader,
1413
JournalEntryLink,
1514
JournalEntryProvider,
1615
JournalEntryWrapper,
1716
} from "./journal-entry-editor";
17+
import { DynamicJournalEntryEditor } from "./journal-entry-editor.dynamic";
1818
import { JournalEntryLoader } from "./journal-entry-loader";
1919
import { JournalListSkeleton } from "./journal-list-skeleton";
2020

@@ -108,7 +108,7 @@ export function JournalList({
108108
<JournalEntryHeader className="px-13.5" />
109109
</JournalEntryLink>
110110
<JournalEntryContent>
111-
<JournalEntryEditor
111+
<DynamicJournalEntryEditor
112112
onCreate={(newEntry) => {
113113
queryClient.setQueryData(queryOptions.queryKey, (old) => ({
114114
...old,

apps/web/src/app/(app)/pages/[id]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { notFound } from "next/navigation";
22
import { Suspense } from "react";
33
import { api } from "~/trpc/server";
44
import { DynamicPageEditor } from "../_components/page-editor.dynamic";
5+
import { PageEditorSkeleton } from "../_components/page-editor-skeleton";
56
import { PageTitleTextarea } from "../_components/page-title-textarea";
67

78
export default async function Page({
@@ -27,7 +28,7 @@ export default async function Page({
2728
}}
2829
className="mb-4 px-13 py-0"
2930
/>
30-
<Suspense>
31+
<Suspense fallback={<PageEditorSkeleton />}>
3132
<DynamicPageEditor
3233
page={{
3334
document_id: page.document_id,

0 commit comments

Comments
 (0)