Skip to content

Commit c085cbe

Browse files
committed
more instructions
1 parent 30b2da0 commit c085cbe

File tree

19 files changed

+58
-25
lines changed

19 files changed

+58
-25
lines changed

exercises/03.complex/01.problem.iframe/app/routes/ui/journal-viewer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ function SummarizeEntryButtonImpl({
330330
const handleSummarize = () => {
331331
startTransition(async () => {
332332
try {
333-
// Get the full entry content first
334333
throw new Error('Sending prompts is not yet supported')
335334
} catch (err) {
336335
showBoundary(err)

exercises/03.complex/01.solution.iframe/app/routes/ui/journal-viewer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ function SummarizeEntryButtonImpl({
330330
const handleSummarize = () => {
331331
startTransition(async () => {
332332
try {
333-
// Get the full entry content first
334333
throw new Error('Sending prompts is not yet supported')
335334
} catch (err) {
336335
showBoundary(err)

exercises/03.complex/02.problem.ready/app/routes/ui/journal-viewer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ function SummarizeEntryButtonImpl({
341341
const handleSummarize = () => {
342342
startTransition(async () => {
343343
try {
344-
// Get the full entry content first
345344
throw new Error('Sending prompts is not yet supported')
346345
} catch (err) {
347346
showBoundary(err)

exercises/03.complex/02.solution.ready/app/routes/ui/journal-viewer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ function SummarizeEntryButtonImpl({
334334
const handleSummarize = () => {
335335
startTransition(async () => {
336336
try {
337-
// Get the full entry content first
338337
throw new Error('Sending prompts is not yet supported')
339338
} catch (err) {
340339
showBoundary(err)

exercises/03.complex/03.problem.sizing/app/routes/ui/journal-viewer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ function SummarizeEntryButtonImpl({
334334
const handleSummarize = () => {
335335
startTransition(async () => {
336336
try {
337-
// Get the full entry content first
338337
throw new Error('Sending prompts is not yet supported')
339338
} catch (err) {
340339
showBoundary(err)

exercises/03.complex/03.solution.sizing/app/routes/ui/journal-viewer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ function SummarizeEntryButtonImpl({
334334
const handleSummarize = () => {
335335
startTransition(async () => {
336336
try {
337-
// Get the full entry content first
338337
throw new Error('Sending prompts is not yet supported')
339338
} catch (err) {
340339
showBoundary(err)

exercises/03.complex/04.problem.dynamic-sizing/app/routes/ui/journal-viewer.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export default function JournalViewer({ loaderData }: Route.ComponentProps) {
2020

2121
useEffect(() => {
2222
window.parent.postMessage({ type: 'ui-lifecycle-iframe-ready' }, '*')
23+
24+
// 🐨 get the height of the document.documentElement
25+
// 🐨 get the width of the document.documentElement
26+
// 🐨 call window.parent.postMessage with the type 'ui-size-change' and the payload { height, width }
27+
// 🐨 set the targetOrigin to '*'
2328
}, [])
2429

2530
const handleEntryDeleted = (entryId: number) => {
@@ -334,7 +339,6 @@ function SummarizeEntryButtonImpl({
334339
const handleSummarize = () => {
335340
startTransition(async () => {
336341
try {
337-
// Get the full entry content first
338342
throw new Error('Sending prompts is not yet supported')
339343
} catch (err) {
340344
showBoundary(err)

exercises/03.complex/04.solution.dynamic-sizing/app/routes/ui/journal-viewer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ function SummarizeEntryButtonImpl({
342342
const handleSummarize = () => {
343343
startTransition(async () => {
344344
try {
345-
// Get the full entry content first
346345
throw new Error('Sending prompts is not yet supported')
347346
} catch (err) {
348347
showBoundary(err)

exercises/04.interactive/01.problem.links/app/routes/ui/journal-viewer.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import {
44
useErrorBoundary,
55
type FallbackProps,
66
} from 'react-error-boundary'
7-
import { useMcpUiInit } from '#app/utils/mcp.ts'
7+
import {
8+
useMcpUiInit,
9+
// 💰 you'll want this:
10+
// sendLinkMcpMessage
11+
} from '#app/utils/mcp.ts'
812
import { useDoubleCheck } from '#app/utils/misc.ts'
913
import { type Route } from './+types/journal-viewer.tsx'
1014

@@ -155,6 +159,7 @@ function XPostLinkImpl({ entryCount }: { entryCount: number }) {
155159
const url = new URL('https://x.com/intent/post')
156160
url.searchParams.set('text', text)
157161

162+
// 🐨 replace this with await sendLinkMcpMessage(url.toString())
158163
throw new Error(`Links not yet supported`)
159164
} catch (err) {
160165
showBoundary(err)
@@ -333,7 +338,6 @@ function SummarizeEntryButtonImpl({
333338
const handleSummarize = () => {
334339
startTransition(async () => {
335340
try {
336-
// Get the full entry content first
337341
throw new Error('Sending prompts is not yet supported')
338342
} catch (err) {
339343
showBoundary(err)

exercises/04.interactive/01.problem.links/app/utils/mcp.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@ export function useMcpUiInit() {
1313
)
1414
}, [])
1515
}
16+
17+
// 🐨 export a function called sendLinkMcpMessage that takes a url string and returns a promise
18+
// 🐨 it should:
19+
// - generate a random UUID for the message id
20+
// - return a new Promise((resolve, reject) = {
21+
// - call window.parent.postMessage with the type 'link', the message id, and the payload { url } and targetOrigin '*'
22+
// - set up a function to handle the event (MessageEvent) from the parent window
23+
// - if the event.data.type is 'ui-message-response' grab the event.data's messageId and payload
24+
// - if the messageId matches the message id, remove the event listener
25+
// - if the payload.error exists, reject the promise with the error
26+
// - otherwise resolve with the payload.response
27+
// - add the "message" event listener to the window
28+
// })

0 commit comments

Comments
 (0)