|
45 | 45 | 'Demonstrates parallel execution, automatic retries, and dependency management—all core pgflow features.', |
46 | 46 | reliabilityFeatures: [ |
47 | 47 | { |
48 | | - setting: 'maxAttempts: 3', |
| 48 | + setting: 'maxAttempts: 2', |
49 | 49 | explanation: 'Automatically retries failed steps up to 3 times before giving up' |
50 | 50 | } |
51 | 51 | ], |
|
157 | 157 | let panelElement: HTMLElement | undefined = $state(undefined); |
158 | 158 | let highlightedInput = $state<string>(''); |
159 | 159 | let highlightedOutput = $state<string>(''); |
| 160 | + let isMobile = $state(false); |
| 161 | +
|
| 162 | + // Detect mobile viewport |
| 163 | + if (typeof window !== 'undefined') { |
| 164 | + const mediaQuery = window.matchMedia('(max-width: 767px)'); |
| 165 | + isMobile = mediaQuery.matches; |
| 166 | +
|
| 167 | + const updateMobile = (e: MediaQueryListEvent) => { |
| 168 | + isMobile = e.matches; |
| 169 | + }; |
| 170 | +
|
| 171 | + mediaQuery.addEventListener('change', updateMobile); |
| 172 | + } |
160 | 173 |
|
161 | 174 | // Replace long strings with placeholders for mobile display |
162 | 175 | function truncateDeep(obj: unknown, maxLength = 80): unknown { |
|
183 | 196 | $effect(() => { |
184 | 197 | const input = stepInput; |
185 | 198 | if (input) { |
186 | | - const truncated = truncateDeep(input); |
| 199 | + // Mobile: 50 chars, Desktop: 500 chars |
| 200 | + const maxLength = isMobile ? 50 : 500; |
| 201 | + const truncated = truncateDeep(input, maxLength); |
187 | 202 | const jsonString = JSON.stringify(truncated, null, 2); |
188 | 203 | codeToHtml(jsonString, { |
189 | 204 | lang: 'json', |
|
200 | 215 | $effect(() => { |
201 | 216 | const output = stepOutput; |
202 | 217 | if (output) { |
203 | | - const truncated = truncateDeep(output); |
| 218 | + // Mobile: 50 chars, Desktop: 500 chars |
| 219 | + const maxLength = isMobile ? 50 : 500; |
| 220 | + const truncated = truncateDeep(output, maxLength); |
204 | 221 | const jsonString = JSON.stringify(truncated, null, 2); |
205 | 222 | codeToHtml(jsonString, { |
206 | 223 | lang: 'json', |
|
338 | 355 | </div> |
339 | 356 | {/if} |
340 | 357 |
|
341 | | - <div class="explanation-content text-sm p-4 space-y-3"> |
| 358 | + <div class="explanation-content text-sm p-4 pb-24 md:pb-4 space-y-3"> |
342 | 359 | {#if currentStepInfo} |
343 | 360 | {#key selectedStep} |
344 | 361 | <div in:fade={{ duration: 300, delay: 150 }} out:fade={{ duration: 150 }}> |
|
523 | 540 | {/key} |
524 | 541 | {:else} |
525 | 542 | <!-- Flow-level view --> |
526 | | - <div class="space-y-3"> |
| 543 | + <div class="space-y-4"> |
527 | 544 | <!-- What it does --> |
528 | | - <div class="bg-accent/30 rounded-lg p-3 border border-accent"> |
529 | | - <p class="text-sm text-foreground leading-relaxed mb-2">{flowInfo.description}</p> |
530 | | - <p class="text-xs text-muted-foreground">{flowInfo.whatItDoes}</p> |
531 | | - </div> |
| 545 | + <p class="text-foreground leading-relaxed"> |
| 546 | + Processes web articles by fetching content, generating summaries and keywords in |
| 547 | + parallel, then publishing the results. Demonstrates parallel execution, automatic |
| 548 | + retries, and dependency management. |
| 549 | + </p> |
532 | 550 |
|
533 | 551 | <!-- How orchestration works (collapsible) --> |
534 | | - <details class="flow-orchestration-explainer"> |
| 552 | + <details |
| 553 | + class="concept-explainer bg-background/50 border border-border rounded-lg" |
| 554 | + open |
| 555 | + > |
535 | 556 | <summary |
536 | | - class="font-semibold text-sm text-primary cursor-pointer hover:text-primary/80 flex items-center gap-2 mb-2" |
| 557 | + class="font-semibold text-sm text-foreground cursor-pointer hover:bg-background/80 flex items-center gap-2 p-3 rounded-lg transition-colors" |
537 | 558 | > |
538 | | - <span>⚙️</span> How SQL Core orchestrates this flow |
| 559 | + <span class="concept-caret">▸</span> |
| 560 | + <span class="flex-1">How pgflow orchestrates this flow</span> |
539 | 561 | </summary> |
540 | | - <div |
541 | | - class="text-xs text-muted-foreground leading-relaxed bg-secondary/30 rounded p-3 space-y-2" |
542 | | - > |
| 562 | + <div class="text-xs text-muted-foreground leading-relaxed px-3 pb-3 space-y-2"> |
543 | 563 | <p> |
544 | | - When you call <code class="bg-muted px-1 rounded font-mono" |
545 | | - >start_flow('article_flow', {'{url}'})</code |
546 | | - >, SQL Core creates a run and initializes state rows for each step. Root steps (no |
547 | | - dependencies) get messages pushed to the queue immediately. |
| 564 | + <code class="bg-muted px-1 rounded font-mono">start_flow()</code> creates a run and |
| 565 | + initializes state for each step. Root steps (no dependencies) get tasks queued |
| 566 | + immediately. |
548 | 567 | </p> |
549 | 568 | <p> |
550 | | - As Workers execute handlers and call <code class="bg-muted px-1 rounded font-mono" |
551 | | - >complete_task()</code |
552 | | - >, SQL Core acknowledges completion, saves outputs, checks dependent steps, and |
553 | | - starts those with all dependencies satisfied. The run completes when |
| 569 | + <strong>Edge Function worker</strong> polls the queue, calls |
| 570 | + <code class="bg-muted px-1 rounded font-mono">start_tasks()</code> to reserve tasks, |
| 571 | + executes handlers, then calls |
| 572 | + <code class="bg-muted px-1 rounded font-mono">complete_task()</code> to save outputs. |
| 573 | + </p> |
| 574 | + <p> |
| 575 | + <strong>SQL Core</strong> checks dependencies after each completion, creates tasks for |
| 576 | + steps with all dependencies met, and marks the run complete when |
554 | 577 | <code class="bg-muted px-1 rounded font-mono">remaining_steps = 0</code>. |
555 | 578 | </p> |
556 | | - <p class="text-muted-foreground/80 italic"> |
557 | | - This demo uses Supabase Realtime to broadcast graph state changes from SQL Core back |
558 | | - to the browser in real-time. |
| 579 | + <p> |
| 580 | + <strong>Supabase Realtime</strong> broadcasts state changes back to this UI for live |
| 581 | + updates. |
559 | 582 | </p> |
560 | 583 | </div> |
561 | 584 | </details> |
562 | 585 |
|
563 | 586 | <!-- Reliability Features --> |
564 | 587 | <div> |
565 | | - <div class="font-semibold text-muted-foreground mb-1.5 text-sm flex items-center gap-2"> |
566 | | - <span>🛡️</span> Reliability Configuration |
| 588 | + <div class="font-semibold text-muted-foreground mb-1.5 text-sm"> |
| 589 | + Reliability Configuration |
567 | 590 | </div> |
568 | 591 | <div class="space-y-2"> |
569 | 592 | {#each flowInfo.reliabilityFeatures as feature (feature.setting)} |
|
0 commit comments