-
Notifications
You must be signed in to change notification settings - Fork 51
[flight-booking-app] Add loading and error UI, add sleep and approval tools #24
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
Conversation
… tools Signed-off-by: Peter Wielander <[email protected]>
Signed-off-by: Peter Wielander <[email protected]>
…st without checking response status or handling errors, leading to silent failures and confusing user experience Co-authored-by: VaguelySerious <[email protected]>
… - the type annotation includes 'price: number', but the destructuring pattern doesn't extract it, causing the price parameter to be accepted but never used. Co-authored-by: VaguelySerious <[email protected]>
…nts/use-multi-turn-chat` that cannot be found. This is a missing module import that needs to be corrected or the file needs to be created.
This commit fixes the issue reported at app/page.tsx:25
## Unused import causes TypeScript compilation failure
**What fails:** TypeScript compiler fails when building the flight-booking-app with Next.js due to a missing module that was imported but never used.
**How to reproduce:**
```bash
cd flight-booking-app
pnpm install
pnpm run build
```
**Result (before fix):**
```
./app/page.tsx:25:34
Type error: Cannot find module '@/components/use-multi-turn-chat' or its corresponding type declarations.
[0m [90m 23 |[39m [36mimport[39m type { [33mMyUIMessage[39m } [36mfrom[39m [32m"@/schemas/chat"[33m[39m
[90m 24 |[39m [36mimport[39m { [33mBookingApproval[39m } [36mfrom[39m [32m"@/components/booking-approval"[33m[39m
[31m[1m>[22m[39m[90m 25 |[39m [36mimport[39m { useMultiTurnChat } [36mfrom[39m [32m"@/components/use-multi-turn-chat"[33m[39m
```
**Root cause:** Line 25 of `app/page.tsx` imports `useMultiTurnChat` from a non-existent module. The hook is imported but never used anywhere in the component.
**Fix:** Removed the unused import statement on line 25.
**Result (after fix):** Build completes successfully with all static pages generated.
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: VaguelySerious <[email protected]>
| export async function POST(request: Request) { | ||
| const { toolCallId, approved, comment } = await request.json(); | ||
| // Schema validation happens automatically | ||
| // Can throw a zod schema validation error, or a | ||
| await bookingApprovalHook.resume(toolCallId, { | ||
| approved, | ||
| comment, | ||
| }); | ||
| return Response.json({ success: true }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should just use webhook (with custom token mode if needed) since the API route isn't really doing much
seems simpler
imo only use hook when you need more control. recommend webhook preferably whenever we can (and make recs if there's something missing from webhook api we can improve)
| import { defineHook } from 'workflow'; | ||
| import { z } from 'zod'; | ||
|
|
||
| export const bookingApprovalHook = defineHook({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment re: using webhook instead :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webhook should support zod schemas too with validation
| sleep: { | ||
| description: 'Pause execution for a specified duration', | ||
| inputSchema: z.object({ | ||
| durationMs: z.number().describe('Duration to sleep in milliseconds'), | ||
| }), | ||
| execute: executeSleep, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for future, we should really ship @workflow/ai/tools with sleepTool amongst other tools (just like @cramforce shipped bashtool for just bash). We can write a nicer, longer description with example usage to encourage the patterns we like
pranaygp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great but would love if we can change hook to webhook
|
Will do the webhook change in #23 |
This PR adds example tool definitions for
sleepand for a human-approval tool using workflow hooks.It also polishes the loading and error UI states.