@agent-native/core 0.144.0 → 0.144.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/actions/migrate-first-party-analytics-to-bigquery.ts +1 -1
  3. package/corpus/templates/analytics/server/lib/first-party-analytics-backend.ts +36 -14
  4. package/corpus/templates/clips/app/components/player/player-controls.tsx +0 -3
  5. package/corpus/templates/clips/app/components/player/scrubber.tsx +2 -33
  6. package/corpus/templates/clips/app/components/player/video-player.tsx +58 -11
  7. package/corpus/templates/clips/changelog/2026-08-06-trimmed-clips-play-on-a-clean-timeline-without-cut-markers.md +6 -0
  8. package/corpus/templates/dispatch/AGENTS.md +8 -1
  9. package/corpus/templates/dispatch/app/dispatch-extensions.tsx +1 -0
  10. package/corpus/templates/dispatch/app/hooks/use-navigation-state.ts +30 -15
  11. package/corpus/templates/dispatch/app/i18n-data.ts +131 -0
  12. package/corpus/templates/dispatch/app/routes/admin._index.tsx +4 -0
  13. package/corpus/templates/dispatch/app/routes/admin.agents.tsx +1 -0
  14. package/corpus/templates/dispatch/app/routes/admin.approvals.tsx +1 -0
  15. package/corpus/templates/dispatch/app/routes/admin.apps.$appId.tsx +1 -0
  16. package/corpus/templates/dispatch/app/routes/admin.apps.tsx +1 -0
  17. package/corpus/templates/dispatch/app/routes/admin.audit.tsx +1 -0
  18. package/corpus/templates/dispatch/app/routes/admin.automations.tsx +1 -0
  19. package/corpus/templates/dispatch/app/routes/admin.destinations.tsx +4 -0
  20. package/corpus/templates/dispatch/app/routes/admin.dreams.tsx +1 -0
  21. package/corpus/templates/dispatch/app/routes/admin.identities.tsx +1 -0
  22. package/corpus/templates/dispatch/app/routes/admin.integrations.tsx +4 -0
  23. package/corpus/templates/dispatch/app/routes/admin.messaging.tsx +1 -0
  24. package/corpus/templates/dispatch/app/routes/admin.metrics.tsx +1 -0
  25. package/corpus/templates/dispatch/app/routes/admin.new-app.tsx +1 -0
  26. package/corpus/templates/dispatch/app/routes/admin.operations.tsx +1 -0
  27. package/corpus/templates/dispatch/app/routes/admin.thread-debug.tsx +4 -0
  28. package/corpus/templates/dispatch/app/routes/admin.transactional-email.$appId.$id.tsx +4 -0
  29. package/corpus/templates/dispatch/app/routes/admin.transactional-email.tsx +4 -0
  30. package/corpus/templates/dispatch/app/routes/admin.tsx +1 -0
  31. package/corpus/templates/dispatch/app/routes/admin.vault.tsx +1 -0
  32. package/corpus/templates/dispatch/app/routes/admin.workspace.tsx +1 -0
  33. package/corpus/templates/dispatch/changelog/2026-08-06-dispatch-keeps-everyday-navigation-focused-while-management-.md +6 -0
  34. package/corpus/templates/slides/AGENTS.md +10 -12
  35. package/corpus/templates/slides/actions/export-pptx.ts +68 -0
  36. package/corpus/templates/slides/actions/get-deck.ts +12 -0
  37. package/corpus/templates/slides/actions/import-file.ts +130 -55
  38. package/corpus/templates/slides/actions/import-pptx.ts +108 -8
  39. package/corpus/templates/slides/actions/patch-deck.ts +51 -0
  40. package/corpus/templates/slides/actions/update-slide.ts +29 -3
  41. package/corpus/templates/slides/app/components/onboarding/FirstDeckOnboardingFlow.tsx +11 -0
  42. package/corpus/templates/slides/app/lib/create-deck-generation.ts +72 -11
  43. package/corpus/templates/slides/app/lib/import-uploaded-deck.ts +89 -0
  44. package/corpus/templates/slides/app/pages/Index.tsx +85 -18
  45. package/corpus/templates/slides/changelog/2026-08-06-uploaded-decks-keep-their-slides-and-visuals-when-you-improv.md +6 -0
  46. package/corpus/templates/slides/server/handlers/import/html-converter.ts +13 -2
  47. package/corpus/templates/slides/server/lib/chat-attachments.ts +2 -2
  48. package/corpus/templates/slides/server/lib/source-import.ts +167 -0
  49. package/corpus/templates/slides/server/plugins/agent-chat.ts +8 -0
  50. package/dist/client/analytics/index.d.ts +1 -1
  51. package/dist/client/analytics/index.js +1 -1
  52. package/dist/client/analytics-session.d.ts +13 -0
  53. package/dist/client/analytics-session.js +57 -0
  54. package/dist/client/analytics.d.ts +1 -0
  55. package/dist/client/analytics.js +1 -0
  56. package/dist/client/index.d.ts +1 -1
  57. package/dist/client/index.js +1 -1
  58. package/dist/client/track.js +7 -0
  59. package/dist/client/use-action.js +10 -1
  60. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  61. package/dist/jobs/scheduler.js +79 -23
  62. package/dist/mcp/screen-memory-stdio.d.ts +7 -7
  63. package/dist/notifications/routes.d.ts +3 -3
  64. package/dist/provider-api/actions/custom-provider-registration.d.ts +2 -2
  65. package/dist/resources/handlers.d.ts +1 -1
  66. package/dist/secrets/routes.d.ts +9 -9
  67. package/dist/server/action-routes.js +4 -2
  68. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  69. package/dist/server/agent-run-context.d.ts +4 -2
  70. package/dist/server/agent-run-context.js +5 -3
  71. package/dist/server/core-routes-plugin.js +2 -0
  72. package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +5 -1
  73. package/dist/templates/workspace-core/.agents/skills/tracking/SKILL.md +20 -3
  74. package/dist/tracking/index.d.ts +1 -1
  75. package/dist/tracking/providers.js +12 -1
  76. package/dist/tracking/registry.d.ts +12 -2
  77. package/dist/tracking/registry.js +27 -3
  78. package/dist/tracking/types.d.ts +8 -0
  79. package/docs/content/creating-templates.mdx +1 -1
  80. package/docs/content/getting-started-actions.mdx +38 -189
  81. package/docs/content/getting-started-database.mdx +80 -164
  82. package/docs/content/getting-started-pages.mdx +44 -155
  83. package/docs/content/getting-started.mdx +26 -106
  84. package/docs/content/observability.mdx +16 -0
  85. package/docs/content/tracking.mdx +17 -2
  86. package/package.json +1 -1
  87. package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +5 -1
  88. package/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +20 -3
@@ -6,6 +6,10 @@ import type { NewDeckReferenceSelection } from "@/components/editor/NewDeckRefer
6
6
  import type { UploadedFile } from "@/components/editor/PromptDialog";
7
7
  import type { Deck, DeckPersistenceResult } from "@/context/DeckContext";
8
8
  import { createDeckAgentMessage } from "@/lib/agent-visible-message";
9
+ import {
10
+ importUploadedDeckIntoDeck,
11
+ type ImportedSourceDeck,
12
+ } from "@/lib/import-uploaded-deck";
9
13
 
10
14
  interface DesignSystemGenerationContextResult {
11
15
  agentContext?: string;
@@ -85,6 +89,7 @@ async function loadReferenceDeckGenerationContext(
85
89
  function describeUploadedFilesForAgent(
86
90
  files: UploadedFile[],
87
91
  deckId: string,
92
+ importedSourceDeck?: ImportedSourceDeck | null,
88
93
  ): string {
89
94
  if (files.length === 0) return "";
90
95
  const fileList = files
@@ -93,14 +98,21 @@ function describeUploadedFilesForAgent(
93
98
  `- ${file.originalName} (${file.type}, ${(file.size / 1024).toFixed(1)}KB) at path: ${file.path}${file.url ? `; embeddable URL: ${file.url}` : ""}`,
94
99
  )
95
100
  .join("\n");
101
+ const sourceFile = importedSourceDeck?.file;
96
102
  return [
97
103
  "",
98
- `The user uploaded ${files.length} file(s). These paths are real uploaded files; process them with import actions before using their contents:`,
104
+ importedSourceDeck
105
+ ? `The user uploaded ${files.length} file(s). The ${sourceFile?.originalName ?? importedSourceDeck.format.toUpperCase()} source deck has already been imported into target deck ${deckId} with ${importedSourceDeck.slideCount} source slide(s); do not import it again.`
106
+ : `The user uploaded ${files.length} file(s). These paths are real uploaded files; process them with import actions before using their contents:`,
99
107
  fileList,
100
108
  "",
101
109
  "File handling rules:",
102
- `- PPTX files: call \`import-pptx --filePath \"<path>\" --deckId ${deckId}\` before adding or editing slides.`,
103
- `- PDF and DOCX files: call \`import-file --filePath \"<path>\" --format auto --deckId ${deckId}\` and use the returned extracted text as source material. For a visual PDF whose original layout should be preserved, pass \`--importIntoDeck true\` instead of rebuilding the pages from extracted text.`,
110
+ importedSourceDeck
111
+ ? "- The imported source deck is the canonical source. Preserve its slide count, order, IDs, factual copy, notes, imagery, charts, tables, diagrams, and freeform objects while improving styling. Use update-slide on existing slide IDs; do not rebuild it with add-slide."
112
+ : `- PPTX files: call \`import-pptx --filePath \"<path>\" --deckId ${deckId}\` before adding or editing slides.`,
113
+ importedSourceDeck
114
+ ? "- For a PDF source, keep the original full-page image in every slide and add restrained design-system chrome around it without obscuring source content. Never OCR-reconstruct a source-faithful page from extracted text."
115
+ : `- PDF and DOCX files: call \`import-file --filePath \"<path>\" --format auto --deckId ${deckId}\` and use the returned extracted text as source material. For a visual PDF whose original layout should be preserved, pass \`--importIntoDeck true\` instead of rebuilding the pages from extracted text.`,
104
116
  "- Text-like files: use the uploaded-text-file blocks already included in the prompt; do not call import-file for them.",
105
117
  '- Image files with an embeddable URL can be inserted directly into slide HTML as `<img src="...">` or used as visual references.',
106
118
  "- Image files without a URL are visual/reference assets only; do not claim to have processed a PPTX/PDF/DOCX unless the relevant import action succeeds.",
@@ -161,6 +173,11 @@ export interface StartDeckGenerationOptions {
161
173
  files: UploadedFile[],
162
174
  failure: DeckPersistenceResult,
163
175
  ) => void;
176
+ onSetupFailure: (
177
+ prompt: string,
178
+ files: UploadedFile[],
179
+ failure: unknown,
180
+ ) => void;
164
181
  }
165
182
 
166
183
  /** Create the optimistic deck, hydrate references, and start the agent run. */
@@ -181,6 +198,7 @@ export async function startDeckGeneration({
181
198
  onPromptClosed,
182
199
  onUnauthenticated,
183
200
  onPersistenceFailure,
201
+ onSetupFailure,
184
202
  }: StartDeckGenerationOptions): Promise<
185
203
  "started" | "failed" | "unauthenticated"
186
204
  > {
@@ -215,7 +233,6 @@ export async function startDeckGeneration({
215
233
  });
216
234
  if (!deck) return "failed";
217
235
  const deckId = deck.id;
218
- onPromptClosed();
219
236
 
220
237
  const persisted = await ensureDeckPersisted(deck.id);
221
238
  if (!persisted.persisted) {
@@ -224,6 +241,20 @@ export async function startDeckGeneration({
224
241
  return "failed";
225
242
  }
226
243
 
244
+ let importedSourceDeck: ImportedSourceDeck | null = null;
245
+ try {
246
+ importedSourceDeck = await importUploadedDeckIntoDeck(
247
+ filesForGeneration,
248
+ deckId,
249
+ );
250
+ } catch (error) {
251
+ deleteDeck(deckId);
252
+ onSetupFailure(prompt, filesForGeneration, error);
253
+ return "failed";
254
+ }
255
+
256
+ onPromptClosed();
257
+
227
258
  navigate(`/deck/${deck.id}`, { flushSync: true });
228
259
 
229
260
  const trimmedPrompt = prompt.trim();
@@ -231,7 +262,11 @@ export async function startDeckGeneration({
231
262
  const googleDocUrls = hasImportedGoogleDocContext
232
263
  ? []
233
264
  : extractGoogleDocUrls(trimmedPrompt);
234
- const fileContext = describeUploadedFilesForAgent(filesForGeneration, deckId);
265
+ const fileContext = describeUploadedFilesForAgent(
266
+ filesForGeneration,
267
+ deckId,
268
+ importedSourceDeck,
269
+ );
235
270
  const googleDocContext =
236
271
  googleDocUrls.length > 0
237
272
  ? [
@@ -260,7 +295,9 @@ export async function startDeckGeneration({
260
295
  : [
261
296
  "",
262
297
  "Design system selection:",
263
- "- None selected. Do not apply a design system unless the user asks for one.",
298
+ "- No design system was selected in the picker.",
299
+ "- Before generating a bare or on-brand deck, call `get-workspace-defaults`. If it returns a usable design system, patch this deck with that designSystemId, call `get-design-system`, and follow its exact tokens, assets, and custom instructions.",
300
+ "- If no workspace default exists, use the product's configured design-system action and report the missing configuration instead of inventing a generic Builder-like palette.",
264
301
  ].join("\n");
265
302
  const referenceSource = referenceSelection.referenceSource;
266
303
  const referenceSourceContext = referenceSource
@@ -275,21 +312,45 @@ export async function startDeckGeneration({
275
312
  : "Use the Figma source as the design reference. If Builder or Figma access is required, report the exact connection step instead of guessing.",
276
313
  ].join("\n")
277
314
  : "";
315
+ const sourceDeckContext = importedSourceDeck
316
+ ? [
317
+ "",
318
+ "Source-preserving improvement mode:",
319
+ `- The target deck already contains ${importedSourceDeck.slideCount} imported source slides. Treat those slides as the user's complete source, not as inspiration for a new deck.`,
320
+ "- Keep the exact source slide count, order, IDs, factual meaning, notes, images, charts, tables, diagrams, and freeform objects unless the user explicitly asks to change one of them.",
321
+ "- Read `get-deck` before editing, load the linked design system with `get-design-system`, then use one `update-slide` call per existing slide ID for bounded visual improvements. Keep every original `<img>` source and enough original factual copy for each slide; for PDF slides, use restrained design-system chrome around the page without obscuring it.",
322
+ "- Do not call `add-slide`, delete slides, reorder slides, or replace source images with generic cards. Do not claim success until `get-deck` verifies the same slide IDs and count after the edits.",
323
+ "- If `get-deck` reports partial source fidelity or skipped images, stop and report the exact warning instead of claiming a reliable restyle.",
324
+ ].join("\n")
325
+ : "";
326
+ const sourceModeInstructions = importedSourceDeck
327
+ ? [
328
+ "The request is an in-place visual improvement of an imported source deck. Make a coherent style pass across every existing slide while preserving all source content and media.",
329
+ "Do not use the new-deck add-slide workflow for this source-preserving request.",
330
+ ]
331
+ : [
332
+ "Start a `manage-progress` run so progress appears in the app header. Add the first slide as soon as it is ready, then continue one slide at a time so the editor visibly fills in.",
333
+ `After reading any requested or imported source material, but before adding the first slide, choose a concise, specific deck title from the user's request and source material. Call \`patch-deck\` with \`deckId: \"${deckId}\"\` and \`operations: [{ \"op\": \"patch-deck-fields\", \"fields\": { \"title\": \"<generated title>\" } }]\`. Include only \`title\` in \`fields\`; omit all other optional fields. Never leave a generated deck named \"Untitled Deck\" or another placeholder.`,
334
+ "If the user asks for a standalone visual, diagram, hero, one-pager, poster, or a couple of visuals, create only the requested one/few polished visual slides. Do not pad the result into a full presentation.",
335
+ "If the request is for a presentation or deck and does not explicitly ask for one slide, infer a coherent multi-slide outline from the scope and keep adding slides until that outline is complete. Do not stop after the first slide just because the prompt has few explicit instructions.",
336
+ `Add slides ONE AT A TIME using the \`add-slide\` action with --deckId=${deckId}. Wait for each \`add-slide\` result before calling it again; do not batch or parallelize slide writes.`,
337
+ "Use create-deck and add-slide for this already-created deck. Do not call the legacy generate-slides-ai action: it returns Markdown drafts rather than persisted rendered slide HTML. Treat each successful add-slide result as confirmation to continue with the next planned slide.",
338
+ ].join("\n");
278
339
 
279
340
  const context = [
280
- `The user just created a new empty deck (id: "${deckId}") and wants to create a presentation or standalone visual.`,
341
+ importedSourceDeck
342
+ ? `The user uploaded a source presentation into target deck (id: "${deckId}") and wants a reliable visual improvement.`
343
+ : `The user just created a new empty deck (id: "${deckId}") and wants to create a presentation or standalone visual.`,
281
344
  "The visible user message above contains the user's request and/or pasted source material for the deck. Treat pasted memo content as source material even if the user did not explicitly say they are pasting it.",
282
345
  googleDocContext,
283
346
  fileContext,
284
347
  referenceDeckContext,
285
348
  designSystemContext,
286
349
  referenceSourceContext,
350
+ sourceDeckContext,
287
351
  "",
288
352
  "Before generating, if the request or selected references leave a meaningful choice unresolved, use the `ask-question` tool to ask one concise, prompt-specific question in the inline guided-question flow. Generate the question wording and 2 to 4 options from the user's request and selected references, like Claude's design-question flow; do not use a fixed generic questionnaire. Ask only a choice that materially affects the deck, such as audience, tone, structure, or length. If the prompt already makes the choice clear, do not ask it again. Wait for the user's answer or skip before adding slides.",
289
- "Start a `manage-progress` run so progress appears in the app header. Add the first slide as soon as it is ready, then continue one slide at a time so the editor visibly fills in.",
290
- `After reading any requested or imported source material, but before adding the first slide, choose a concise, specific deck title from the user's request and source material. Call \`patch-deck\` with \`deckId: \"${deckId}\"\` and \`operations: [{ \"op\": \"patch-deck-fields\", \"fields\": { \"title\": \"<generated title>\" } }]\`. Include only \`title\` in \`fields\`; omit all other optional fields. Never leave a generated deck named \"Untitled Deck\" or another placeholder.`,
291
- "If the user asks for a standalone visual, diagram, hero, one-pager, poster, or a couple of visuals, create only the requested one/few polished visual slides. Do not pad the result into a full presentation.",
292
- `Add slides ONE AT A TIME using the \`add-slide\` action with --deckId=${deckId}. Wait for each \`add-slide\` result before calling it again; do not batch or parallelize slide writes.`,
353
+ sourceModeInstructions,
293
354
  "If the user asked for a specific slide count, keep going sequentially until that count is reached unless a tool error blocks you.",
294
355
  "Every slide is rendered into a fixed native canvas (default 16:9 is 960x540 CSS pixels, with 740x380px available inside standard 80px 110px padding). Keep the main content within that fit budget; split dense source material across more slides instead of packing it tightly. Never use zoom, transform: scale(), clipping, or scroll overflow to hide content overflow, and keep body text at least 16px.",
295
356
  "Each slide's --content must be full HTML. Slide HTML templates are in your AGENTS.md.",
@@ -0,0 +1,89 @@
1
+ import { callAction } from "@agent-native/core/client/hooks";
2
+
3
+ import type { UploadedFile } from "@/components/editor/PromptDialog";
4
+
5
+ export type ImportedSourceDeck = {
6
+ file: UploadedFile;
7
+ format: "pdf" | "pptx";
8
+ slideCount: number;
9
+ imagesSkipped: number;
10
+ };
11
+
12
+ function sourceFormat(file: UploadedFile): "pdf" | "pptx" | null {
13
+ const name = file.originalName.toLowerCase();
14
+ if (name.endsWith(".pptx")) return "pptx";
15
+ if (name.endsWith(".pdf")) return "pdf";
16
+ return null;
17
+ }
18
+
19
+ function actionResultRecord(value: unknown): Record<string, unknown> {
20
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
21
+ throw new Error("The uploaded presentation import returned no result.");
22
+ }
23
+ return value as Record<string, unknown>;
24
+ }
25
+
26
+ /**
27
+ * Imports the user's source deck into the already-persisted target deck before
28
+ * the agent run starts. This keeps the agent on the source slide IDs and
29
+ * preserves source-native images instead of asking it to reconstruct a deck
30
+ * from extracted text.
31
+ */
32
+ export async function importUploadedDeckIntoDeck(
33
+ files: UploadedFile[],
34
+ deckId: string,
35
+ ): Promise<ImportedSourceDeck | null> {
36
+ const deckFiles = files.filter((file) => sourceFormat(file));
37
+ if (deckFiles.length === 0) return null;
38
+ if (deckFiles.length > 1) {
39
+ throw new Error(
40
+ "Upload one presentation at a time when asking Slides to improve it. Multiple source decks cannot be merged safely without losing slide order or content.",
41
+ );
42
+ }
43
+
44
+ const file = deckFiles[0];
45
+ if (!file) return null;
46
+ const format = sourceFormat(file);
47
+ if (!format) return null;
48
+
49
+ const result = actionResultRecord(
50
+ await callAction(
51
+ format === "pptx" ? "import-pptx" : "import-file",
52
+ format === "pptx"
53
+ ? { filePath: file.path, deckId }
54
+ : {
55
+ filePath: file.path,
56
+ format: "pdf",
57
+ deckId,
58
+ importIntoDeck: true,
59
+ },
60
+ ),
61
+ );
62
+ if (result.imported !== true || result.deckId !== deckId) {
63
+ throw new Error(
64
+ `The ${format.toUpperCase()} source deck was not imported into the target deck, so no source-preserving improvement was started.`,
65
+ );
66
+ }
67
+
68
+ const slideCount = result.slideCount;
69
+ if (typeof slideCount !== "number" || !Number.isInteger(slideCount)) {
70
+ throw new Error(
71
+ `The ${format.toUpperCase()} import did not report a reliable slide count, so no source-preserving improvement was started.`,
72
+ );
73
+ }
74
+ if (slideCount < 1) {
75
+ throw new Error(
76
+ `The ${format.toUpperCase()} source deck contained no importable slides.`,
77
+ );
78
+ }
79
+
80
+ const imagesSkipped =
81
+ typeof result.imagesSkipped === "number" ? result.imagesSkipped : 0;
82
+ if (imagesSkipped > 0) {
83
+ throw new Error(
84
+ `The ${format.toUpperCase()} source deck could not preserve ${imagesSkipped} image(s), so Slides stopped before restyling it. Re-export the deck with browser-renderable images, or upload a PDF for source-faithful page preservation.`,
85
+ );
86
+ }
87
+
88
+ return { file, format, slideCount, imagesSkipped };
89
+ }
@@ -52,6 +52,10 @@ import { useWorkspaceDefaults } from "@/hooks/use-workspace-defaults";
52
52
  import { createDeckAgentMessage } from "@/lib/agent-visible-message";
53
53
  import { savePromptToComposerDraft } from "@/lib/composer-draft";
54
54
  import { sortDecksByRecency } from "@/lib/deck-sorting";
55
+ import {
56
+ importUploadedDeckIntoDeck,
57
+ type ImportedSourceDeck,
58
+ } from "@/lib/import-uploaded-deck";
55
59
  import {
56
60
  readRecentReferences,
57
61
  rememberRecentReference,
@@ -181,6 +185,7 @@ async function loadReferenceDeckGenerationContext(
181
185
  function describeUploadedFilesForAgent(
182
186
  files: UploadedFile[],
183
187
  deckId: string,
188
+ importedSourceDeck?: ImportedSourceDeck | null,
184
189
  ): string {
185
190
  if (files.length === 0) return "";
186
191
  const fileList = files
@@ -191,12 +196,18 @@ function describeUploadedFilesForAgent(
191
196
  .join("\n");
192
197
  return [
193
198
  "",
194
- `The user uploaded ${files.length} file(s). These paths are real uploaded files; process them with import actions before using their contents:`,
199
+ importedSourceDeck
200
+ ? `The user uploaded ${files.length} file(s). The ${importedSourceDeck.file.originalName} source deck has already been imported into target deck ${deckId} with ${importedSourceDeck.slideCount} source slide(s); do not import it again.`
201
+ : `The user uploaded ${files.length} file(s). These paths are real uploaded files; process them with import actions before using their contents:`,
195
202
  fileList,
196
203
  "",
197
204
  "File handling rules:",
198
- `- PPTX files: call \`import-pptx --filePath "<path>" --deckId ${deckId}\` before adding or editing slides.`,
199
- `- PDF and DOCX files: call \`import-file --filePath "<path>" --format auto --deckId ${deckId}\` and use the returned extracted text as source material. For a visual PDF whose original layout should be preserved, pass \`--importIntoDeck true\` instead of rebuilding the pages from extracted text.`,
205
+ importedSourceDeck
206
+ ? "- The imported source deck is the canonical source. Preserve its slide count, order, IDs, factual copy, notes, imagery, charts, tables, diagrams, and freeform objects while improving styling. Use update-slide on existing slide IDs; do not rebuild it with add-slide."
207
+ : `- PPTX files: call \`import-pptx --filePath "<path>" --deckId ${deckId}\` before adding or editing slides.`,
208
+ importedSourceDeck
209
+ ? "- For a PDF source, keep the original full-page image in every slide and add restrained design-system chrome around it without obscuring source content. Never OCR-reconstruct a source-faithful page from extracted text."
210
+ : `- PDF and DOCX files: call \`import-file --filePath "<path>" --format auto --deckId ${deckId}\` and use the returned extracted text as source material. For a visual PDF whose original layout should be preserved, pass \`--importIntoDeck true\` instead of rebuilding the pages from extracted text.`,
200
211
  "- Text-like files: use the uploaded-text-file blocks already included in the prompt; do not call import-file for them.",
201
212
  '- Image files with an embeddable URL can be inserted directly into slide HTML as `<img src="...">` or used as visual references.',
202
213
  "- Image files without a URL are visual/reference assets only; do not claim to have processed a PPTX/PDF/DOCX unless the relevant import action succeeds.",
@@ -555,11 +566,15 @@ export default function Index() {
555
566
  const designSystemId =
556
567
  referenceSelection.designSystemId !== undefined
557
568
  ? referenceSelection.designSystemId
558
- : selectedDesignSystemId;
569
+ : selectedDesignSystemId && selectedDesignSystemId !== "none"
570
+ ? selectedDesignSystemId
571
+ : null;
559
572
  const referenceDeckId =
560
573
  referenceSelection.referenceDeckId !== undefined
561
574
  ? referenceSelection.referenceDeckId
562
- : selectedReferenceDeckId;
575
+ : selectedReferenceDeckId && selectedReferenceDeckId !== "none"
576
+ ? selectedReferenceDeckId
577
+ : null;
563
578
  const selectedDesignSystem = designSystemId
564
579
  ? designSystems.find((ds) => ds.id === designSystemId)
565
580
  : undefined;
@@ -591,6 +606,28 @@ export default function Index() {
591
606
  return;
592
607
  }
593
608
 
609
+ let importedSourceDeck: ImportedSourceDeck | null = null;
610
+ try {
611
+ importedSourceDeck = await importUploadedDeckIntoDeck(
612
+ filesForGeneration,
613
+ deckId,
614
+ );
615
+ } catch (error) {
616
+ if (!savePromptForRetry(prompt)) {
617
+ setNewDeckInitialPrompt({ text: prompt, key: Date.now() });
618
+ }
619
+ setNewDeckRetryFiles(filesForGeneration);
620
+ deleteDeck(deckId);
621
+ toast.error(t("home.generationStartFailed"), {
622
+ description:
623
+ error instanceof Error
624
+ ? error.message
625
+ : t("home.generationStartFailedDescription"),
626
+ });
627
+ setShowNewDeckPrompt(true);
628
+ return;
629
+ }
630
+
594
631
  clearPendingPromptForRetry();
595
632
  setNewDeckInitialPrompt(null);
596
633
  setNewDeckRetryFiles([]);
@@ -604,6 +641,7 @@ export default function Index() {
604
641
  const fileContext = describeUploadedFilesForAgent(
605
642
  filesForGeneration,
606
643
  deckId,
644
+ importedSourceDeck,
607
645
  );
608
646
  const googleDocContext =
609
647
  googleDocUrls.length > 0
@@ -633,7 +671,9 @@ export default function Index() {
633
671
  : [
634
672
  "",
635
673
  "Design system selection:",
636
- "- None selected. Do not apply a design system unless the user asks for one.",
674
+ "- No design system was selected in the picker.",
675
+ "- Before generating a bare or on-brand deck, call `get-workspace-defaults`. If it returns a usable design system, patch this deck with that designSystemId, call `get-design-system`, and follow its exact tokens, assets, and custom instructions.",
676
+ "- If no workspace default exists, report the missing configuration instead of inventing a generic Builder-like palette.",
637
677
  ].join("\n");
638
678
  const referenceSource = referenceSelection.referenceSource;
639
679
  const referenceSourceContext = referenceSource
@@ -648,27 +688,49 @@ export default function Index() {
648
688
  : "Use the Figma source as the design reference. If Builder or Figma access is required, report the exact connection step instead of guessing.",
649
689
  ].join("\n")
650
690
  : "";
691
+ const sourceDeckContext = importedSourceDeck
692
+ ? [
693
+ "",
694
+ "Source-preserving improvement mode:",
695
+ `- The target deck already contains ${importedSourceDeck.slideCount} imported source slides. Treat those slides as the user's complete source, not as inspiration for a new deck.`,
696
+ "- Keep the exact source slide count, order, IDs, factual meaning, notes, images, charts, tables, diagrams, and freeform objects unless the user explicitly asks to change one of them.",
697
+ "- Read `get-deck` before editing, load the linked design system with `get-design-system`, then use one `update-slide` call per existing slide ID for bounded visual improvements. Keep every original `<img>` source and enough original factual copy for each slide; for PDF slides, use restrained design-system chrome around the page without obscuring it.",
698
+ "- Do not call `add-slide`, delete slides, reorder slides, or replace source images with generic cards. Do not claim success until `get-deck` verifies the same slide IDs and count after the edits.",
699
+ "- If `get-deck` reports partial source fidelity or skipped images, stop and report the exact warning instead of claiming a reliable restyle.",
700
+ ].join("\n")
701
+ : "";
702
+ const sourceModeInstructions = importedSourceDeck
703
+ ? [
704
+ "The request is an in-place visual improvement of an imported source deck. Make a coherent style pass across every existing slide while preserving all source content and media.",
705
+ "Do not use the new-deck add-slide workflow for this source-preserving request.",
706
+ ].join("\n")
707
+ : [
708
+ "Start a `manage-progress` run so progress appears in the app header. Add the first slide as soon as it is ready, then continue one slide at a time so the editor visibly fills in.",
709
+ "After reading any requested or imported source material, but before adding the first slide, choose a concise, specific deck title from the user's request and source material. Call `patch-deck` with `deckId: \"" +
710
+ deckId +
711
+ '\"` and `operations: [{ "op": "patch-deck-fields", "fields": { "title": "<generated title>" } }]`. Include only `title` in `fields`; omit all other optional fields. Never leave a generated deck named "Untitled Deck" or another placeholder.',
712
+ "If the user asks for a standalone visual, diagram, hero, one-pager, poster, or a couple of visuals, create only the requested one/few polished visual slides. Do not pad the result into a full presentation.",
713
+ "If the request is for a presentation or deck and does not explicitly ask for one slide, infer a coherent multi-slide outline from the scope and keep adding slides until that outline is complete. Do not stop after the first slide just because the prompt has few explicit instructions.",
714
+ "Add slides ONE AT A TIME using the `add-slide` action with --deckId=" +
715
+ deckId +
716
+ ". Wait for each `add-slide` result before calling it again; do not batch or parallelize slide writes.",
717
+ "Use create-deck and add-slide for this already-created deck. Do not call the legacy generate-slides-ai action: it returns Markdown drafts rather than persisted rendered slide HTML. Treat each successful add-slide result as confirmation to continue with the next planned slide.",
718
+ ].join("\n");
651
719
 
652
720
  const context = [
653
- `The user just created a new empty deck (id: "${deckId}") and wants to create a presentation or standalone visual.`,
721
+ importedSourceDeck
722
+ ? `The user uploaded a source presentation into target deck (id: "${deckId}") and wants a reliable visual improvement.`
723
+ : `The user just created a new empty deck (id: "${deckId}") and wants to create a presentation or standalone visual.`,
654
724
  "The visible user message above contains the user's request and/or pasted source material for the deck. Treat pasted memo content as source material even if the user did not explicitly say they are pasting it.",
655
725
  googleDocContext,
656
726
  fileContext,
657
727
  referenceDeckContext,
658
728
  designSystemContext,
659
729
  referenceSourceContext,
730
+ sourceDeckContext,
660
731
  "",
661
732
  "Before generating, if the request or selected references leave a meaningful choice unresolved, use the `ask-question` tool to ask one concise, prompt-specific question in the inline guided-question flow. Generate the question wording and 2 to 4 options from the user's request and selected references, like Claude's design-question flow; do not use a fixed generic questionnaire. Ask only a choice that materially affects the deck, such as audience, tone, structure, or length. If the prompt already makes the choice clear, do not ask it again. Wait for the user's answer or skip before adding slides.",
662
- "Start a `manage-progress` run so progress appears in the app header. Add the first slide as soon as it is ready, then continue one slide at a time so the editor visibly fills in.",
663
- "After reading any requested or imported source material, but before adding the first slide, choose a concise, specific deck title from the user's request and source material. Call `patch-deck` with `deckId: \"" +
664
- deckId +
665
- '"` and `operations: [{ "op": "patch-deck-fields", "fields": { "title": "<generated title>" } }]`. Include only `title` in `fields`; omit all other optional fields. Never leave a generated deck named "Untitled Deck" or another placeholder.',
666
- "If the user asks for a standalone visual, diagram, hero, one-pager, poster, or a couple of visuals, create only the requested one/few polished visual slides. Do not pad the result into a full presentation.",
667
- "If the request is for a presentation or deck and does not explicitly ask for one slide, infer a coherent multi-slide outline from the scope and keep adding slides until that outline is complete. Do not stop after the first slide just because the prompt has few explicit instructions.",
668
- "Add slides ONE AT A TIME using the `add-slide` action with --deckId=" +
669
- deckId +
670
- ". Wait for each `add-slide` result before calling it again; do not batch or parallelize slide writes.",
671
- "Use create-deck and add-slide for this already-created deck. Do not call the legacy generate-slides-ai action: it returns Markdown drafts rather than persisted rendered slide HTML. Treat each successful add-slide result as confirmation to continue with the next planned slide.",
733
+ sourceModeInstructions,
672
734
  "If the user asked for a specific slide count, keep going sequentially until that count is reached unless a tool error blocks you.",
673
735
  "Every slide is rendered into a fixed native canvas (default 16:9 is 960x540 CSS pixels, with 740x380px available inside standard 80px 110px padding). Keep the main content within that fit budget; split dense source material across more slides instead of packing it tightly. Never use zoom, transform: scale(), clipping, or scroll overflow to hide content overflow, and keep body text at least 16px.",
674
736
  "Each slide's --content must be full HTML. Slide HTML templates are in your AGENTS.md.",
@@ -724,6 +786,7 @@ export default function Index() {
724
786
  if (selection.kind === "pptx") {
725
787
  const imported = (await callAction("import-pptx", {
726
788
  filePath: file.path,
789
+ designSystemId: initialDesignSystemId,
727
790
  })) as { id?: unknown };
728
791
  if (typeof imported.id !== "string" || !imported.id) {
729
792
  throw new Error("The PowerPoint presentation did not create a deck.");
@@ -735,7 +798,10 @@ export default function Index() {
735
798
 
736
799
  let deck: ReturnType<typeof createDeck> | undefined;
737
800
  flushSync(() => {
738
- deck = createDeck(undefined, { noDefaultSlides: true });
801
+ deck = createDeck(undefined, {
802
+ noDefaultSlides: true,
803
+ designSystemId: initialDesignSystemId,
804
+ });
739
805
  });
740
806
  if (!deck) throw new Error("The PDF deck could not be created.");
741
807
 
@@ -776,6 +842,7 @@ export default function Index() {
776
842
  navigate,
777
843
  reloadDecks,
778
844
  session,
845
+ initialDesignSystemId,
779
846
  ],
780
847
  );
781
848
 
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: fixed
3
+ date: 2026-08-06
4
+ ---
5
+
6
+ Uploaded decks keep their slides and visuals when you improve and export them
@@ -53,8 +53,19 @@ export function buildFullBleedImageSlideHtml(
53
53
  }
54
54
 
55
55
  /** Render a rasterized source page without changing its layout or text. */
56
- export function buildFullPageImageSlideHtml(imageUrl: string): string {
57
- return `<div class="fmd-slide" style="position: relative; width: 100%; height: 100%; overflow: hidden; background: hsl(var(--background));">
56
+ export function buildFullPageImageSlideHtml(
57
+ imageUrl: string,
58
+ sourceWidth?: number,
59
+ sourceHeight?: number,
60
+ ): string {
61
+ const sourceDimensions =
62
+ Number.isFinite(sourceWidth) &&
63
+ Number.isFinite(sourceHeight) &&
64
+ sourceWidth! > 0 &&
65
+ sourceHeight! > 0
66
+ ? ` data-source-width="${sourceWidth}" data-source-height="${sourceHeight}"`
67
+ : "";
68
+ return `<div class="fmd-slide fmd-imported-pdf" data-imported-pdf="true"${sourceDimensions} style="position: relative; width: 100%; height: 100%; overflow: hidden; background: hsl(var(--background));">
58
69
  <img src="${esc(imageUrl)}" alt="" style="position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;" />
59
70
  </div>`;
60
71
  }
@@ -119,8 +119,8 @@ export async function prepareSlidesChatAttachments(args: {
119
119
  "",
120
120
  "File handling rules:",
121
121
  "- If the request refers to the current or visible deck, call `view-screen` first to confirm the active deckId, then pass that deckId to import or slide-edit actions.",
122
- '- PPTX files: call `import-pptx --filePath "<path>" --deckId <deckId>` when updating the visible deck, or omit deckId only when the user explicitly wants a new deck.',
123
- '- PDF and DOCX files: call `import-file --filePath "<path>" --format auto --deckId <deckId>` and use the returned extracted text as source material before creating editable slides. For a visual PDF that the user wants preserved, beautified, or restyled from its original layout, pass `--importIntoDeck true` so each page is imported source-faithfully first; the source text is persisted in slide notes for later inspection.',
122
+ '- PPTX files: when the user wants the visible deck improved, call `import-pptx --filePath "<path>" --deckId <deckId>` first, then edit those imported slide IDs in place with update-slide. Do not rebuild the source deck with add-slide.',
123
+ '- PDF and DOCX files: call `import-file --filePath "<path>" --format auto --deckId <deckId>` and use the returned extracted text as source material before creating editable slides. For a visual PDF that the user wants preserved, beautified, or restyled from its original layout, pass `--importIntoDeck true` so each page is imported source-faithfully first; keep the full-page image and style around it, with source text persisted in slide notes for inspection.',
124
124
  '- Figma `.fig` files: call `import-file --filePath "<path>" --format fig` to start Builder design-system indexing. Do not create a local design system directly from the upload.',
125
125
  "- For deck-generation requests, start mutating promptly: create or update the first slide as soon as source material is extracted, then continue slide-by-slide with add-slide/update-slide.",
126
126
  '- Image files with an embeddable URL can be inserted directly into slide HTML as `<img src="...">` or used as visual references.',