Skip to content

Commit 634c3b3

Browse files
CopilotYukaii
andcommitted
fix: address code review feedback - fix ref update, extract constants, improve progress tracking
Co-authored-by: Yukaii <4230968+Yukaii@users.noreply.github.com> Agent-Logs-Url: https://github.com/hackmdio/api-client/sessions/a73c91f7-229e-482d-b038-6bb8e454ab09
1 parent 341bc32 commit 634c3b3

12 files changed

Lines changed: 35 additions & 356 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ To run the book mode conference example:
5151

5252
This example demonstrates advanced usage patterns including bulk operations, team note management, and creating interconnected note structures for conferences or events.
5353

54+
### AI Conference Assistant (Web)
55+
56+
The `examples/ai-conference-assistant/` directory contains a web-based AI assistant that helps create book-mode conference notes through a chat interface:
57+
58+
- **Chat Interface**: Conversational AI (powered by Vercel AI SDK) guides you through conference note creation
59+
- **Frontend API Key Entry**: Provide your HackMD and OpenAI API keys from the browser — no server-side secrets needed
60+
- **Session Data Analysis**: Upload conference session JSON; the AI uses a jq-like tool to efficiently analyze data shape
61+
- **Reference Note Fetching**: Point the AI to existing HackMD notes to replicate formatting from previous conferences
62+
- **Markdown Preview**: Preview the generated homepage and all session pages before creating
63+
- **Rate-Limit-Aware Creation**: Batch note creation with configurable delay and real-time SSE progress tracking
64+
65+
To run the AI conference assistant:
66+
67+
1. Navigate to the example directory: `cd examples/ai-conference-assistant`
68+
2. Install dependencies: `npm install`
69+
3. Start the development server: `npm run dev`
70+
4. Open [http://localhost:3000](http://localhost:3000) and enter your credentials
71+
72+
See [examples/ai-conference-assistant/README.md](./examples/ai-conference-assistant/README.md) for full documentation.
73+
5474
## LICENSE
5575

5676
MIT

examples/ai-conference-assistant/public/file.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/ai-conference-assistant/public/globe.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/ai-conference-assistant/public/next.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/ai-conference-assistant/public/vercel.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/ai-conference-assistant/public/window.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/ai-conference-assistant/src/app/api/create-notes/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ export async function POST(req: Request) {
144144
`/${shortId}`,
145145
)
146146
}
147-
// Remove any remaining unresolved placeholders (failed sessions)
148-
homepageContent = homepageContent.replace(/\/{noteUrl:[^}]+}/g, '#')
147+
// Remove lines with unresolved placeholders (failed sessions)
148+
homepageContent = homepageContent.replace(/^.*\/{noteUrl:[^}]+}.*\n?/gm, '')
149149

150150
const mainNote = await client.createTeamNote(config.teamPath, {
151151
title: homepage.title,

examples/ai-conference-assistant/src/app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useState, useRef } from 'react'
3+
import { useState, useRef, useEffect } from 'react'
44
import { SetupPanel } from '@/components/setup-panel'
55
import { ChatPanel } from '@/components/chat-panel'
66
import { PreviewPanel } from '@/components/preview-panel'
@@ -26,7 +26,7 @@ export default function Home() {
2626
const [showProgress, setShowProgress] = useState(false)
2727
const [previewPage, setPreviewPage] = useState<{ title: string; content: string } | null>(null)
2828
const sessionDataRef = useRef(sessionData)
29-
sessionDataRef.current = sessionData
29+
useEffect(() => { sessionDataRef.current = sessionData }, [sessionData])
3030

3131
if (!config) {
3232
return <SetupPanel onConfigured={setConfig} />

examples/ai-conference-assistant/src/components/chat-panel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function ChatPanel({
2525
generatedData,
2626
}: ChatPanelProps) {
2727
const [fileUploaded, setFileUploaded] = useState(false)
28+
const [sessionDataSent, setSessionDataSent] = useState(false)
2829
const [inputValue, setInputValue] = useState('')
2930
const messagesEndRef = useRef<HTMLDivElement>(null)
3031
const fileInputRef = useRef<HTMLInputElement>(null)
@@ -77,10 +78,11 @@ export function ChatPanel({
7778
if (
7879
fileUploaded &&
7980
sessionData.current &&
80-
!messages.some(m => m.parts?.some(p => p.type === 'text' && p.text.includes('[Session data uploaded')))
81+
!sessionDataSent
8182
) {
8283
const count = JSON.parse(sessionData.current).length
8384
text = `${inputValue}\n\n[Session data uploaded - ${count} sessions]\n<session_data>\n${sessionData.current}\n</session_data>`
85+
setSessionDataSent(true)
8486
}
8587

8688
sendMessage({ text })

examples/ai-conference-assistant/src/components/progress-modal.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,23 @@ export function ProgressModal({ config, generatedData, onClose }: ProgressModalP
105105
setCurrent(event.current)
106106

107107
if (event.noteCreated) {
108+
const created = event.noteCreated
108109
setLogs(prev => [
109110
...prev,
110111
{
111112
type: 'success',
112-
text: `✅ ${event.noteCreated!.title}${event.noteCreated!.url}`,
113+
text: `✅ ${created.title}${created.url}`,
113114
},
114115
])
115116
}
116117

117118
if (event.error) {
119+
const err = event.error
118120
setLogs(prev => [
119121
...prev,
120122
{
121123
type: 'error',
122-
text: `❌ ${event.error!.title || 'Error'}: ${event.error!.message}`,
124+
text: `❌ ${err.title || 'Error'}: ${err.message}`,
123125
},
124126
])
125127
}

0 commit comments

Comments
 (0)