@nimiplatform/app-tools 0.13.1 → 0.16.0-rc.9

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 (100) hide show
  1. package/README.md +65 -8
  2. package/bin/nimi-app.mjs +26 -10
  3. package/lib/app-access-declaration.mjs +3 -0
  4. package/lib/app-dependency-combinations.mjs +70 -20
  5. package/lib/app-doctor-update.mjs +95 -36
  6. package/lib/app-host-support.mjs +6 -0
  7. package/lib/app-icons.mjs +181 -0
  8. package/lib/app-identifiers.mjs +27 -0
  9. package/lib/app-info.mjs +21 -33
  10. package/lib/app-lifecycle-guidance.mjs +2 -1
  11. package/lib/app-pack.mjs +14 -36
  12. package/lib/app-project-lifecycle.mjs +141 -243
  13. package/lib/app-scaffold-capabilities.mjs +13 -109
  14. package/lib/app-scaffold-profiles.mjs +108 -117
  15. package/lib/app-scaffold.mjs +70 -165
  16. package/lib/app-toolchain-updates.mjs +45 -0
  17. package/lib/canonical-capability-ids.generated.mjs +2 -0
  18. package/lib/development-environment.d.mts +10 -0
  19. package/lib/development-environment.mjs +39 -0
  20. package/lib/hosted-web-release.mjs +98 -0
  21. package/lib/index.mjs +40 -1
  22. package/lib/mobile-development.mjs +19 -0
  23. package/lib/realm-environments.generated.mjs +5 -0
  24. package/lib/web-coordination.mjs +59 -0
  25. package/lib/web-development.d.mts +23 -0
  26. package/lib/web-development.mjs +118 -0
  27. package/lib/web-scaffold.mjs +125 -0
  28. package/package.json +39 -27
  29. package/scripts/dev-shell.mjs +4 -1
  30. package/scripts/sync-scaffold-versions.mjs +0 -2
  31. package/skills/nimi-app-lifecycle/SKILL.md +13 -5
  32. package/skills/nimi-app-lifecycle/references/acceptance.md +6 -2
  33. package/skills/nimi-app-lifecycle/references/adapt.md +7 -3
  34. package/skills/nimi-app-lifecycle/references/audit.md +3 -2
  35. package/skills/nimi-app-lifecycle/references/create.md +8 -2
  36. package/skills/nimi-app-lifecycle/references/release.md +2 -0
  37. package/skills/nimi-app-lifecycle/references/upgrade-platform.md +15 -1
  38. package/templates/app-source/src/ai-studio-core/ai-studio-core.css +87 -52
  39. package/templates/app-source/src/ai-studio-core/history-policy.ts +45 -11
  40. package/templates/app-source/src/ai-studio-core/history.ts +22 -11
  41. package/templates/app-source/src/ai-studio-core/host-context.tsx +9 -4
  42. package/templates/app-source/src/ai-studio-core/index.ts +2 -0
  43. package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +15 -5
  44. package/templates/app-source/src/ai-studio-core/job-recovery.ts +2 -2
  45. package/templates/app-source/src/ai-studio-core/messages/en.json +79 -19
  46. package/templates/app-source/src/ai-studio-core/messages/zh.json +79 -19
  47. package/templates/app-source/src/ai-studio-core/module-registration.ts +1 -0
  48. package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +40 -5
  49. package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +12 -6
  50. package/templates/app-source/src/ai-studio-core/parameters.ts +4 -0
  51. package/templates/app-source/src/ai-studio-core/prompt-drafts.ts +42 -0
  52. package/templates/app-source/src/ai-studio-core/runtime-types.ts +9 -2
  53. package/templates/app-source/src/ai-studio-core/runtime.ts +8 -4
  54. package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +98 -90
  55. package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +1 -1
  56. package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +205 -48
  57. package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +1 -0
  58. package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +36 -14
  59. package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +102 -77
  60. package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +62 -16
  61. package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +2 -0
  62. package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +12 -21
  63. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +26 -9
  64. package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +3 -3
  65. package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +182 -81
  66. package/templates/app-source/src/ai-studio-core/workspace.tsx +49 -22
  67. package/templates/app-source/src/product-modules/agent-center/index.tsx +2 -3
  68. package/templates/app-source/src/product-modules/agent-conversation/index.tsx +2 -3
  69. package/templates/app-source/src/studio-modules/studio-create/messages/en.json +17 -3
  70. package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +17 -3
  71. package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +33 -1
  72. package/templates/app-source/src/studio-modules/studio-create/parameters.ts +3 -1
  73. package/templates/app-source/src/studio-modules/studio-create/runtime.ts +47 -4
  74. package/templates/app-source/src/studio-modules/studio-media/messages/en.json +59 -8
  75. package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +59 -8
  76. package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +2 -1
  77. package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +271 -83
  78. package/templates/app-source/src/studio-modules/studio-media/parameters.ts +120 -2
  79. package/templates/app-source/src/studio-modules/studio-media/registration.ts +1 -0
  80. package/templates/app-source/src/studio-modules/studio-media/runtime.ts +24 -14
  81. package/templates/app-source/src/studio-modules/studio-voice/descriptors.ts +1 -1
  82. package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +3 -2
  83. package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +3 -2
  84. package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +46 -23
  85. package/templates/app-source/src/studio-modules/studio-voice/registration.ts +2 -1
  86. package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +2 -2
  87. package/templates/app-source/src/workbench-core/workbench-core.tsx +27 -3
  88. package/templates/default-starter/AGENTS.md +8 -5
  89. package/templates/default-starter/NIMI_APP.md +7 -0
  90. package/templates/default-starter/README.md +3 -1
  91. package/templates/default-starter/src/shell/App.tsx +12 -20
  92. package/templates/default-starter/src/shell/auth/local-app-client.ts +6 -15
  93. package/templates/default-starter/src/shell/auth/runtime-platform.ts +7 -107
  94. package/templates/default-starter/src/shell/workbench-target-adapter.ts +9 -126
  95. package/templates/default-starter.manifest.json +4 -16
  96. package/templates/hosted-web-release.yml +88 -0
  97. package/templates/default-starter/src-tauri/Cargo.toml +0 -17
  98. package/templates/default-starter/src-tauri/build.rs +0 -32
  99. package/templates/default-starter/src-tauri/capabilities/default.json +0 -7
  100. package/templates/default-starter/src-tauri/tauri.conf.json +0 -26
@@ -1,5 +1,4 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { openNimiLocalAppAssetMediaUrl } from '@nimiplatform/kit/shell/renderer/bridge';
3
2
  import type { StudioTypedOutput } from './runtime-types.js';
4
3
  import { useAIStudioHost } from './host-context.js';
5
4
 
@@ -13,15 +12,16 @@ export function VisionLocateResultView({ output }: { output: Extract<StudioTyped
13
12
  useEffect(() => {
14
13
  setRetained(null); setImageFailed(false);
15
14
  if (!source) return undefined;
15
+ const controller = new AbortController();
16
16
  let active = true; let revoke: (() => Promise<void>) | undefined;
17
17
  void (async () => {
18
18
  const stat = await host.sdk.assets.stat(source.relativePath);
19
19
  if (stat.sha256 !== source.sha256 || stat.sizeBytes !== source.sizeBytes || stat.mediaType !== source.mediaType) throw new Error('Saved source image changed');
20
- const handle = await openNimiLocalAppAssetMediaUrl(source.relativePath);
20
+ const handle = await host.app.commands.openAssetMediaUrl(source.relativePath, controller.signal);
21
21
  revoke = handle.revoke;
22
22
  if (active) setRetained({ sourceKey, url: handle.url }); else await handle.revoke();
23
23
  })().catch(() => { if (active) setImageFailed(true); });
24
- return () => { active = false; if (revoke) void revoke(); };
24
+ return () => { active = false; controller.abort(); if (revoke) void revoke(); };
25
25
  }, [source, sourceKey, host]);
26
26
  const imageUrl = source ? retained?.sourceKey === sourceKey ? retained.url : null : output.imagePreviewUrl;
27
27
  const { width, height, locations, imageArtifactId } = output.result;
@@ -1,7 +1,7 @@
1
1
  import { StudioJobRecoveryPanel } from './job-recovery-panel.js';
2
2
  import { isStudioJobRecoveryCapability } from './job-recovery.js';
3
- import { Suspense, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
4
- import { Button, IconButton, LoadingSkeleton, nimiToast, OverlayShell, StatusBadge, Tooltip } from '@nimiplatform/kit/ui';
3
+ import { Suspense, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
4
+ import { Button, IconButton, LoadingSkeleton, InlineAlert, nimiToast, OverlayShell, StatusBadge, Tooltip } from '@nimiplatform/kit/ui';
5
5
  import { PanelRight, SquarePen } from 'lucide-react';
6
6
  import { createBrowserDataUrlAttachmentAdapter, useChatComposer, type BrowserDataUrlAttachment } from '@nimiplatform/kit/features/chat/headless';
7
7
  import { notifyStudioAIConfigChanged } from './ai-config.js';
@@ -9,7 +9,7 @@ import { useAIStudioHost } from './host-context.js';
9
9
  import type { StudioCapabilityRegistration } from './module-registration.js';
10
10
  import type { StudioParameterValue } from './parameters.js';
11
11
  import type { StudioCapabilityRunResult, StudioRuntimeInspection } from './runtime-types.js';
12
- import { getStudioRunIntentLabel, restoreStudioCapabilityRunResult, type StudioRunConfigSnapshot, type StudioRunHistory, type StudioRunHistoryRecord } from './history.js';
12
+ import { restoreStudioCapabilityRunResult, type StudioRunConfigSnapshot, type StudioRunHistory, type StudioRunHistoryRecord } from './history.js';
13
13
  import { CapabilityRunHistory, DrawerErrorBoundary, downloadTextFile, resultPlainText, statusForCapability, type CapabilityStatus, type SectionAITestingProps } from './section-ai-testing-surface.js';
14
14
  import { TextStudioComposer, TextStudioStartState } from './section-ai-testing-composer.js';
15
15
  import { ScenarioJobStatus } from '@nimiplatform/sdk/runtime/generated';
@@ -21,8 +21,8 @@ import {
21
21
  } from './section-ai-testing-input.js';
22
22
  import { TextStudioResultState } from './section-ai-testing-result.js';
23
23
  import { readStudioTextReplayMedia, readStudioLocateReplayImage } from './text-media-replay.js';
24
- import { revealStudioAsset } from './section-ai-testing-output.js';
25
- import { canConfigureRunTarget, createRunConfigSnapshot, effectiveTextStudioPromptStyle, textStudioDirectiveForTarget, textStudioRunTargetIntentSummary, textStudioRuntimePrompt, useStudioRunTargetSummary, type TextStudioActiveRun } from './section-ai-testing-run.js';
24
+ import { exportStudioAsset } from './section-ai-testing-output.js';
25
+ import { canConfigureRunTarget, createRunConfigSnapshot, effectiveTextStudioPromptStyle, studioConfiguredTargetLabel, textStudioDirectiveForTarget, textStudioRunTargetIntentSummary, textStudioRuntimePrompt, useStudioRunTargetSummary, type TextStudioActiveRun } from './section-ai-testing-run.js';
26
26
  import { StudioCapabilityParameterContext, StudioHistoryLoadContext, StudioHistoryPanelContext } from './contexts.js';
27
27
 
28
28
  // Admission pill labels are keyed by the typed status so locale changes do not
@@ -70,22 +70,37 @@ function TextStudioShell({
70
70
  const ParameterPanel = registration.parameterPanel;
71
71
  const profile = registration.profile;
72
72
  const preset = registration.preset;
73
- const [prompt, setPrompt] = useState(() => (
74
- rendererHost.app.projection.promptDraft({
75
- surfaceId: 'ai-capabilities',
76
- capabilityId: capability.id,
77
- scenarioId: preset.id,
78
- }, draftPersistence).prompt ?? preset.prompt
79
- ));
73
+ const [prompt, setPrompt] = useState(preset.prompt);
74
+ const promptEditRevision = useRef(0);
75
+ const [draftError, setDraftError] = useState<string | null>(null);
80
76
  const [context, setContext] = useState('');
81
77
  const [executingRun, setExecutingRun] = useState<TextStudioActiveRun | null>(null);
82
78
  const [cancelRequested, setCancelRequested] = useState(false);
83
79
  const [streamingText, setStreamingText] = useState<string | null>(null);
84
- const [mediaInputState, setMediaInputState] = useState<'checking' | 'supported' | 'unsupported' | 'unavailable'>('checking');
80
+ const inputPreparationsRef = useRef(new Map<string, number>());
81
+ const [inputPreparations, setInputPreparations] = useState<ReadonlyMap<string, number>>(inputPreparationsRef.current);
82
+ const startInputPreparation = useCallback(() => {
83
+ const id = capability.id;
84
+ const update = (delta: number) => {
85
+ const next = new Map(inputPreparationsRef.current);
86
+ const count = (next.get(id) ?? 0) + delta;
87
+ if (count > 0) next.set(id, count);
88
+ else next.delete(id);
89
+ inputPreparationsRef.current = next;
90
+ setInputPreparations(next);
91
+ };
92
+ update(1);
93
+ return () => update(-1);
94
+ }, [capability.id]);
95
+ const preparingInput = inputPreparations.has(capability.id);
85
96
  const [activeRun, setActiveRun] = useState<TextStudioActiveRun | null>(null);
86
97
  const [sessionRuns, setSessionRuns] = useState<Record<string, TextStudioActiveRun>>({});
87
98
  const historyPanel = useContext(StudioHistoryPanelContext);
88
- const historyCollapsed = historyPanel?.collapsed ?? true;
99
+ const workspaceRef = useRef<HTMLDivElement>(null);
100
+ const historyToggleRef = useRef<HTMLButtonElement>(null);
101
+ const [compactHistory, setCompactHistory] = useState(false);
102
+ const [compactHistoryOpen, setCompactHistoryOpen] = useState(false);
103
+ const historyCollapsed = compactHistory ? !compactHistoryOpen : historyPanel?.collapsed ?? true;
89
104
  const runSeqRef = useRef(0);
90
105
  const [observationIssue, setObservationIssue] = useState(false);
91
106
  const abortControllerRef = useRef<{ runId: string; controller: AbortController; observation: AbortController } | null>(null);
@@ -104,25 +119,6 @@ function TextStudioShell({
104
119
  onTextChange: updatePrompt,
105
120
  disabled: running,
106
121
  });
107
- useEffect(() => {
108
- if (capability.id !== 'text.generate') return;
109
- let disposed = false;
110
- let generation = 0;
111
- const refresh = () => {
112
- const current = ++generation;
113
- setMediaInputState('checking');
114
- void rendererHost.sdk.aiConfig.getSnapshot().then((snapshot) => {
115
- if (!disposed && generation === current) {
116
- setMediaInputState(textStudioMediaInputAvailable(snapshot, composerState.attachments[0]?.mimeType) ? 'supported' : 'unsupported');
117
- }
118
- }, () => {
119
- if (!disposed && generation === current) setMediaInputState('unavailable');
120
- });
121
- };
122
- refresh();
123
- const unsubscribe = rendererHost.app.events.subscribeAIConfigRefresh(refresh);
124
- return () => { disposed = true; generation += 1; unsubscribe(); };
125
- }, [capability.id, rendererHost, composerState.attachments[0]?.mimeType]);
126
122
  const hasRequiredImage = capability.id !== 'vision.locate'
127
123
  || (composerState.attachments.length === 1 && composerState.attachments[0]?.kind === 'image');
128
124
  const hasActiveRun = Boolean(displayedRun);
@@ -133,7 +129,6 @@ function TextStudioShell({
133
129
  ))
134
130
  : null)
135
131
  : lastResult?.capabilityId === capability.id ? lastResult : null;
136
- const headerResult = hasActiveRun ? currentResult : null;
137
132
  const savedTextMedia = (currentResult?.ok && (currentResult.output.kind === 'text' || currentResult.output.kind === 'vision-locate') ? currentResult.output.sourceImage : undefined)
138
133
  ?? displayedRun?.replayMedia;
139
134
  const displayedAttachmentCount = displayedRun?.record?.runConfig?.promptControls.attachmentCount
@@ -144,7 +139,12 @@ function TextStudioShell({
144
139
  (displayedAttachmentCount === 0 && !savedTextMedia) ||
145
140
  (displayedAttachmentCount <= 1 && Boolean(savedTextMedia) && displayedRun?.record?.status !== 'unavailable');
146
141
  const runTarget = useStudioRunTargetSummary(registration, runtime);
147
- const admission = statusForCapability(registration, runTarget, headerResult, t);
142
+ const admission = statusForCapability(registration, runTarget, null, t);
143
+ const mediaInputState = runTarget.snapshot
144
+ ? (textStudioMediaInputAvailable(runTarget.snapshot, composerState.attachments[0]?.mimeType) ? 'supported' : 'unsupported')
145
+ : (runTarget.configReadFailed ? 'unavailable' : 'checking');
146
+ const canRetryPreparation = capability.execution === 'runtime-sdk'
147
+ && (runTarget.status === 'checking' || runTarget.status === 'not-admitted' || runTarget.configReadFailed);
148
148
  const requiresPrompt = profile.inputKind !== 'none';
149
149
  const supportsMedia = profile.supportsAttachments;
150
150
  const attachmentBlocked = capability.id === 'text.generate' && composerState.attachments.length > 0 && mediaInputState !== 'supported';
@@ -154,13 +154,16 @@ function TextStudioShell({
154
154
  capabilityParameters,
155
155
  ), [capabilityParameters, registration.parameters, runTarget.source]);
156
156
  const parameterSummary = registration.parameters.summarize(effectiveCapabilityParameters);
157
- const hasAlternativeInput = registration.parameters.hasAlternativeInput(capabilityParameters);
157
+ const hasAlternativeInput = registration.parameters.hasAlternativeInput(effectiveCapabilityParameters);
158
+ const promptEnabled = profile.inputKind !== 'url' || runtime?.mode !== 'remote-app';
159
+ const inputIssueKey = registration.parameters.requiredInputIssue?.(effectiveCapabilityParameters);
158
160
  const recordedInput = registration.parameters.recordedInput;
159
161
  const displayedRunPrompt = displayedRun?.prompt;
160
162
  // A parameter-owned input reruns the displayed run's recorded request, which
161
163
  // stays valid however the current parameters have changed since.
162
164
  const displayedRunParameters = useMemo(() => {
163
165
  if (!displayedRun || displayedRun.record?.status === 'unavailable' || displayedRun.record?.inputTruncated) return null;
166
+ if (displayedRun.submittedParameters) return displayedRun.submittedParameters;
164
167
  if (registration.parameters.restoreRecordedParameters) {
165
168
  return registration.parameters.restoreRecordedParameters(
166
169
  displayedRun.record?.runConfig?.target.params,
@@ -196,6 +199,19 @@ function TextStudioShell({
196
199
  const replayAssetsAvailable = replayAssetPaths.length === 0
197
200
  || (replayAssets?.key === replayAssetKey && replayAssets.available);
198
201
 
202
+ useEffect(() => {
203
+ const workspace = workspaceRef.current;
204
+ if (!workspace || typeof ResizeObserver === 'undefined') return;
205
+ const observer = new ResizeObserver(([entry]) => {
206
+ if (!entry) return;
207
+ const compact = entry.contentRect.width <= 1080;
208
+ setCompactHistory(compact);
209
+ if (!compact) setCompactHistoryOpen(false);
210
+ });
211
+ observer.observe(workspace);
212
+ return () => observer.disconnect();
213
+ }, []);
214
+
199
215
  useEffect(() => {
200
216
  const error = historyLoad?.error ?? null;
201
217
  if (!error) {
@@ -204,28 +220,36 @@ function TextStudioShell({
204
220
  }
205
221
  if (expandedHistoryErrorRef.current === error) return;
206
222
  expandedHistoryErrorRef.current = error;
207
- historyPanel?.setCollapsed(false);
208
- }, [historyLoad?.error, historyPanel]);
223
+ if (compactHistory) setCompactHistoryOpen(true);
224
+ else historyPanel?.setCollapsed(false);
225
+ }, [historyLoad?.error, historyPanel, compactHistory]);
209
226
 
210
227
  function updatePrompt(nextPrompt: string) {
228
+ const editRevision = ++promptEditRevision.current;
211
229
  setPrompt(nextPrompt);
230
+ setDraftError(null);
212
231
  void rendererHost.app.commands.savePromptDraft({
213
232
  surfaceId: 'ai-capabilities',
214
233
  capabilityId: capability.id,
215
234
  scenarioId: preset.id,
216
- }, nextPrompt, draftPersistence);
235
+ }, nextPrompt, draftPersistence).catch(error => { if (editRevision === promptEditRevision.current) setDraftError(error instanceof Error ? error.message : String(error)); });
217
236
  }
218
237
 
219
238
  useEffect(() => {
220
239
  abortControllerRef.current?.observation.abort('studio-capability-changed');
221
240
  abortControllerRef.current = null;
222
- const draft = rendererHost.app.projection.promptDraft({
241
+ let active = true;
242
+ const editRevision = ++promptEditRevision.current;
243
+ setDraftError(null);
244
+ void rendererHost.app.projection.promptDraft({
223
245
  surfaceId: 'ai-capabilities',
224
246
  capabilityId: capability.id,
225
247
  scenarioId: preset.id,
226
- }, draftPersistence);
248
+ }, draftPersistence).then(draft => {
249
+ if (active && editRevision === promptEditRevision.current) setPrompt(draft.prompt ?? preset.prompt);
250
+ }).catch(error => { if (active) setDraftError(error instanceof Error ? error.message : String(error)); });
227
251
  runSeqRef.current += 1;
228
- setPrompt(draft.prompt ?? preset.prompt);
252
+ setPrompt(preset.prompt);
229
253
  setContext('');
230
254
  setActiveRun(null);
231
255
  setSessionRuns({});
@@ -233,9 +257,11 @@ function TextStudioShell({
233
257
  setCancelRequested(false);
234
258
  setObservationIssue(false);
235
259
  setStreamingText(null);
260
+ return () => { active = false; };
236
261
  }, [capability.id, draftPersistence, preset, rendererHost]);
237
262
 
238
263
  useEffect(() => () => {
264
+ promptEditRevision.current += 1;
239
265
  runSeqRef.current += 1;
240
266
  abortControllerRef.current?.observation.abort('studio-view-closed');
241
267
  }, []);
@@ -248,6 +274,7 @@ function TextStudioShell({
248
274
 
249
275
  async function run(nextPrompt = prompt, nextContext = context, replay = false) {
250
276
  if (abortControllerRef.current) return;
277
+ if (!replay && inputPreparationsRef.current.has(capability.id)) return;
251
278
  if (replay && !textMediaReplayable) return;
252
279
  if (replay && (!displayedRunReplayable || !replayAssetsAvailable)) return;
253
280
  const replayTextMedia = replay && (capability.id === 'text.generate' || capability.id === 'vision.locate');
@@ -258,13 +285,14 @@ function TextStudioShell({
258
285
  const runEffectiveParameters = replay && registration.parameters.restoreRecordedParameters
259
286
  ? runParameters
260
287
  : registration.parameters.project(runTarget.source, runParameters);
261
- const runHasAlternativeInput = registration.parameters.hasAlternativeInput(runParameters);
288
+ if (registration.parameters.requiredInputIssue?.(runEffectiveParameters)) return;
289
+ const runHasAlternativeInput = registration.parameters.hasAlternativeInput(runEffectiveParameters);
262
290
  // Raw document inputs retain their original whitespace so annotation
263
291
  // offsets refer to the exact text the user entered. A parameter-owned input
264
292
  // records its complete encoded request.
265
293
  const displayPrompt = recordedInput
266
294
  ? (runHasAlternativeInput ? recordedInput.encode(runEffectiveParameters) : '')
267
- : profile.rawPrompt ? nextPrompt : nextPrompt.trim();
295
+ : !promptEnabled ? '' : profile.rawPrompt ? nextPrompt : nextPrompt.trim();
268
296
  if (!hasStudioCapabilityRunInput({ requiresPrompt, prompt: displayPrompt, hasAlternativeInput: runHasAlternativeInput })) return;
269
297
  if ((capability.id === 'music.transcribe' || capability.id === 'audio.voice.convert' || capability.id === 'audio.separate') && !runHasAlternativeInput) return;
270
298
  if (profile.requiresParameterInput && !runHasAlternativeInput) return;
@@ -275,13 +303,18 @@ function TextStudioShell({
275
303
  const abortController = new AbortController();
276
304
  const observationController = new AbortController();
277
305
  const startedAt = rendererHost.clock.now();
306
+ // Capture the submitted file and controls independently of later draft edits.
307
+ // Persisted history still receives only the contract's summary below.
308
+ const submittedParameters = structuredClone(runEffectiveParameters);
278
309
  const pendingRun: TextStudioActiveRun = {
279
310
  attachmentCount,
311
+ submittedParameters,
280
312
  ...(replayTextMedia && savedTextMedia ? { replayMedia: savedTextMedia } : {}),
281
313
  id: `pending-${startedAt}`,
282
314
  prompt: displayPrompt || (runHasAlternativeInput ? '' : preset.prompt),
283
315
  context: nextContext.trim(),
284
316
  createdAt: new Date(startedAt).toISOString(),
317
+ configuredTarget: { source: runTarget.source, targetLabel: runTarget.targetLabel },
285
318
  result: null,
286
319
  record: null,
287
320
  error: null,
@@ -296,7 +329,7 @@ function TextStudioShell({
296
329
  promptStyle: profile.controls.includes('tone') || profile.controls.includes('length')
297
330
  ? effectiveTextStudioPromptStyle(runTarget) : null,
298
331
  context: nextContext, attachmentCount,
299
- requestParameters: registration.parameters.summarize(runEffectiveParameters),
332
+ requestParameters: registration.parameters.summarize(submittedParameters),
300
333
  });
301
334
  try {
302
335
  let result: StudioCapabilityRunResult;
@@ -311,7 +344,8 @@ function TextStudioShell({
311
344
  }
312
345
  }
313
346
  abortController.signal.throwIfAborted();
314
- const isStreaming = capability.id === 'chat.stream';
347
+ const isStreaming = capability.id === 'chat.stream'
348
+ || (capability.id === 'text.tools' && submittedParameters.delivery === 'stream');
315
349
  if (isStreaming) setStreamingText('');
316
350
  const directive = textStudioDirectiveForTarget(runTarget, profile);
317
351
  if (capability.id === 'text.generate' && runAttachments.length > 0 &&
@@ -327,7 +361,7 @@ function TextStudioShell({
327
361
  recordedRunConfig: runConfig,
328
362
  recordedCreatedAt: pendingRun.createdAt,
329
363
  recordedPrompt: displayPrompt,
330
- prompt: (capability.id === 'world.generate' && runHasAlternativeInput && !displayPrompt && !nextContext.trim()) || usesVerbatimStudioPrompt(capability.id) || profile.rawPrompt || recordedInput
364
+ prompt: ((capability.id === 'world.generate' || capability.id === 'video.generate') && runHasAlternativeInput && !displayPrompt && !nextContext.trim()) || usesVerbatimStudioPrompt(capability.id) || profile.rawPrompt || recordedInput
331
365
  ? displayPrompt
332
366
  : textStudioRuntimePrompt(displayPrompt, nextContext, directive),
333
367
  scenarioId: preset.id,
@@ -335,7 +369,7 @@ function TextStudioShell({
335
369
  if (runSeqRef.current === runSeq) setStreamingText(text);
336
370
  } : undefined,
337
371
  attachments: supportsMedia ? runAttachments : undefined,
338
- parameters: runEffectiveParameters,
372
+ parameters: submittedParameters,
339
373
  signal: abortController.signal,
340
374
  observationSignal: observationController.signal,
341
375
  onObservation: response => {
@@ -374,12 +408,22 @@ function TextStudioShell({
374
408
  result,
375
409
  record,
376
410
  };
377
- setSessionRuns((current) => ({ ...current, [finishedRun.id]: finishedRun }));
378
- setActiveRun(finishedRun);
411
+ setSessionRuns((current) => {
412
+ // Retain source bytes only for the latest completed submission, not
413
+ // once per history entry throughout a long-running Studio session.
414
+ const next: Record<string, TextStudioActiveRun> = {};
415
+ for (const [id, previous] of Object.entries(current)) {
416
+ next[id] = { ...previous };
417
+ delete next[id].submittedParameters;
418
+ }
419
+ next[finishedRun.id] = finishedRun;
420
+ return next;
421
+ });
422
+ setActiveRun(current => current?.id === pendingRun.id ? finishedRun : current);
379
423
  } catch (error) {
380
424
  if (runSeq !== runSeqRef.current) return;
381
425
  const message = error instanceof Error ? error.message : String(error || 'Runtime call failed.');
382
- setActiveRun({ ...pendingRun, error: message });
426
+ setActiveRun(current => current?.id === pendingRun.id ? { ...pendingRun, error: message } : current);
383
427
  } finally {
384
428
  if (runSeq === runSeqRef.current) {
385
429
  if (abortControllerRef.current?.controller === abortController) abortControllerRef.current = null;
@@ -413,12 +457,12 @@ function TextStudioShell({
413
457
  if (currentResult.ok && currentResult.output.kind === 'artifacts') {
414
458
  const artifact = currentResult.output.firstArtifact;
415
459
  if (artifact?.relativePath) {
416
- await revealStudioAsset(rendererHost, artifact.relativePath);
460
+ await exportStudioAsset(rendererHost, artifact.relativePath);
417
461
  }
418
462
  return;
419
463
  }
420
464
  if (currentResult.ok && currentResult.output.kind === 'text-annotation') {
421
- await revealStudioAsset(rendererHost, currentResult.output.document.relativePath);
465
+ await exportStudioAsset(rendererHost, currentResult.output.document.relativePath);
422
466
  return;
423
467
  }
424
468
  const stamp = new Date(rendererHost.clock.now()).toISOString().replace(/[:.]/g, '-');
@@ -448,7 +492,10 @@ function TextStudioShell({
448
492
 
449
493
  function useHistoryRunAsDraft(record: StudioRunHistoryRecord) {
450
494
  if (record.inputTruncated || record.status === 'unavailable') return;
451
- if (registration.parameters.restoreRecordedParameters) {
495
+ const submittedParameters = sessionRuns[record.id]?.submittedParameters;
496
+ if (submittedParameters && parameterStore) {
497
+ parameterStore.setParameters(capability.id, structuredClone(submittedParameters));
498
+ } else if (registration.parameters.restoreRecordedParameters) {
452
499
  const snapshot = record.runConfig?.target.params;
453
500
  const restored = registration.parameters.restoreRecordedParameters(snapshot, record.result, record.prompt);
454
501
  if (!restored || !parameterStore) return;
@@ -458,12 +505,12 @@ function TextStudioShell({
458
505
  const restored = recordedInput.decode(record.prompt);
459
506
  if (!restored || !parameterStore) return;
460
507
  parameterStore.setParameters(capability.id, { ...capabilityParameters, ...restored });
461
- setActiveRun(null);
508
+ handleNewRun();
462
509
  return;
463
510
  }
464
511
  updatePrompt(record.prompt);
465
512
  setContext(record.runConfig?.promptControls.context ?? '');
466
- setActiveRun(null);
513
+ handleNewRun();
467
514
  }
468
515
 
469
516
  const historyPreviewId = useRef<string | null>(null);
@@ -495,8 +542,8 @@ function TextStudioShell({
495
542
  : 'Studio.profiles.textGenerate.imageTargetUnsupported') : undefined}
496
543
  onOpenAttachmentPicker={composerState.openAttachmentPicker}
497
544
  onRemoveAttachment={composerState.removeAttachment}
498
- canDispatch={runTarget.canDispatch}
499
- canConfigureIntent={canConfigureRunTarget(runTarget)}
545
+ canDispatch={runTarget.canDispatch && !preparingInput}
546
+ canConfigureIntent={!runTarget.configReadFailed && canConfigureRunTarget(runTarget)}
500
547
  intentConfigurable={capability.execution === 'runtime-sdk'}
501
548
  compact={Boolean(activeRun)}
502
549
  parameterPanel={parameterStore && capability.execution === 'runtime-sdk' && ParameterPanel ? (
@@ -505,26 +552,41 @@ function TextStudioShell({
505
552
  contract={registration.parameters}
506
553
  source={runTarget.source}
507
554
  parameters={capabilityParameters}
508
- disabled={running}
555
+ disabled={running || preparingInput}
509
556
  onChange={(next) => parameterStore.setParameters(capability.id, next)}
557
+ onInputPreparationStart={startInputPreparation}
510
558
  />
511
559
  ) : undefined}
512
560
  parametersActive={Object.keys(parameterSummary).length > 0}
513
561
  hasAlternativeInput={hasAlternativeInput}
562
+ promptEnabled={promptEnabled}
563
+ inputIssue={inputIssueKey ? t(inputIssueKey) : undefined}
514
564
  onPromptChange={updatePrompt}
515
565
  onContextChange={setContext}
516
566
  onOpenIntentConfig={onOpenConfig}
517
567
  onSubmit={() => void run()}
518
568
  />
519
569
  );
520
- const showAdmissionBadge = true;
521
-
522
570
  function handleHistoryCollapseToggle() {
523
- historyPanel?.setCollapsed(!historyCollapsed);
571
+ if (compactHistory) setCompactHistoryOpen((open) => !open);
572
+ else historyPanel?.setCollapsed(!historyCollapsed);
573
+ }
574
+
575
+ function closeCompactHistory() {
576
+ setCompactHistoryOpen(false);
577
+ historyToggleRef.current?.focus();
578
+ }
579
+
580
+ function selectHistoryRecord(record: StudioRunHistoryRecord) {
581
+ onSelectHistoryRun(record);
582
+ if (compactHistory) closeCompactHistory();
524
583
  }
525
584
 
526
585
  function handleNewRun() {
527
586
  setActiveRun(null);
587
+ workspaceRef.current?.ownerDocument.defaultView?.requestAnimationFrame(() => {
588
+ workspaceRef.current?.querySelector<HTMLElement>('.studio-start')?.focus();
589
+ });
528
590
  }
529
591
 
530
592
  function handleCancel() {
@@ -536,17 +598,43 @@ function TextStudioShell({
536
598
 
537
599
  return (
538
600
  <div className={hasActiveRun ? 'studio studio--has-run' : 'studio studio--landing'}>
539
- <div className="studio__workspace studio__workspace--with-history">
601
+ <div
602
+ ref={workspaceRef}
603
+ className={compactHistory ? 'studio__workspace studio__workspace--overlay-history' : 'studio__workspace studio__workspace--with-history'}
604
+ >
540
605
  <div className="studio__primary">
541
606
  <header className="studio__head">
542
- <div className="studio__title">
543
- {showAdmissionBadge ? (
607
+ <div className="studio__heading">
608
+ <div className="studio__title">
609
+ <h2>{t(capability.labelKey)}</h2>
610
+ {capability.capabilityContract ? <code>{capability.capabilityContract}</code> : null}
611
+ </div>
612
+ <div className="studio__status" role="status">
613
+ {capability.execution === 'runtime-sdk' ? (
614
+ <span className="studio__runtime-state">
615
+ {t(runtime?.status === 'connected' ? 'Studio.run.runtimeConnected'
616
+ : runtime ? 'Studio.run.runtimeUnavailable' : 'Studio.run.runtimeChecking')}
617
+ </span>
618
+ ) : null}
544
619
  <StatusBadge tone={admission.tone} shape="dot">
545
620
  {t(registration.profile.statusLabelKey ?? ADMISSION_STATUS_LABEL_KEY[admission.label] ?? admission.label)}
546
621
  </StatusBadge>
547
- ) : null}
622
+ {runTarget.configReadFailed && runtime?.status === 'connected' ? (
623
+ <span className="studio__runtime-state">{t('Studio.run.aiConfigLoadFailed')}</span>
624
+ ) : null}
625
+ {runTarget.status === 'blocked' && runTarget.source !== 'unknown' ? (
626
+ <span className="studio__runtime-state">{runTarget.detail}</span>
627
+ ) : null}
628
+ </div>
548
629
  </div>
549
630
  <div className="studio__head-actions">
631
+ {canRetryPreparation ? (
632
+ <Button type="button" size="sm" tone="secondary" onClick={() => {
633
+ if (workspaceRef.current) notifyStudioAIConfigChanged(workspaceRef.current);
634
+ }}>
635
+ {t('Studio.run.retryPreparation')}
636
+ </Button>
637
+ ) : null}
550
638
  {headerActions}
551
639
  {executingRun && !displayingExecution ? (
552
640
  <Button size="sm" tone="secondary" onClick={() => setActiveRun(executingRun)}>
@@ -554,22 +642,23 @@ function TextStudioShell({
554
642
  </Button>
555
643
  ) : null}
556
644
  {hasActiveRun ? (
557
- <Tooltip content={t('StudioShell.newRun')} placement="bottom">
558
- <IconButton
559
- type="button"
560
- className="studio-history-toggle"
561
- aria-label={t('StudioShell.newRun')}
562
- onClick={handleNewRun}
563
- disabled={running}
564
- icon={<SquarePen size={17} strokeWidth={1.8} aria-hidden="true" />}
565
- />
566
- </Tooltip>
645
+ <Button
646
+ type="button"
647
+ size="sm"
648
+ tone="secondary"
649
+ onClick={handleNewRun}
650
+ disabled={running}
651
+ leadingIcon={<SquarePen size={15} aria-hidden="true" />}
652
+ >
653
+ {t('StudioShell.newRun')}
654
+ </Button>
567
655
  ) : null}
568
656
  <Tooltip
569
657
  content={historyCollapsed ? t('StudioShell.showHistory') : t('StudioShell.hideHistory')}
570
658
  placement="bottom"
571
659
  >
572
660
  <IconButton
661
+ ref={historyToggleRef}
573
662
  type="button"
574
663
  className={historyCollapsed ? 'studio-history-toggle' : 'studio-history-toggle studio-history-toggle--expanded'}
575
664
  aria-label={historyCollapsed ? t('StudioShell.showHistory') : t('StudioShell.hideHistory')}
@@ -579,6 +668,7 @@ function TextStudioShell({
579
668
  />
580
669
  </Tooltip>
581
670
  </div>
671
+ {draftError ? <InlineAlert className="studio__head-alert" tone="warning">{draftError}</InlineAlert> : null}
582
672
  </header>
583
673
  <main className="studio__stage">
584
674
  {hasActiveRun && displayedRun ? (
@@ -586,10 +676,12 @@ function TextStudioShell({
586
676
  registration={registration}
587
677
  activeRun={displayedRun}
588
678
  admission={admission}
589
- intentLabel={displayedRun.record ? getStudioRunIntentLabel(displayedRun.record) : runTarget.intentLabel}
679
+ intentLabel={studioConfiguredTargetLabel(displayedRun.record?.runConfig?.target ?? displayedRun.configuredTarget, t)}
590
680
  running={displayingExecution}
591
- canRegenerate={!running && (capability.id !== 'vision.locate' || Boolean(savedTextMedia)) && textMediaReplayable && displayedRunReplayable && replayAssetsAvailable}
592
- regenerateHint={!running && !textMediaReplayable ? t('Studio.profiles.textGenerate.savedMediaUnavailable')
681
+ canRestoreInputs={displayedRunParameters !== null}
682
+ canRegenerate={!running && runTarget.canDispatch && (capability.id !== 'vision.locate' || Boolean(savedTextMedia)) && textMediaReplayable && displayedRunReplayable && replayAssetsAvailable}
683
+ regenerateHint={currentResult && !currentResult.ok && currentResult.reason === 'input-invalid' ? undefined
684
+ : !running && !textMediaReplayable ? t('Studio.profiles.textGenerate.savedMediaUnavailable')
593
685
  : !running && replayAssetsChecking ? t('StudioShell.historyInputsChecking')
594
686
  : !running && (!displayedRunReplayable || !replayAssetsAvailable) ? t('StudioShell.historyInputsUnavailable') : undefined}
595
687
  cancelRequested={displayingExecution && cancelRequested}
@@ -616,13 +708,22 @@ function TextStudioShell({
616
708
  />
617
709
  )}
618
710
  {displayingExecution && observationIssue ? <p role="status">{t('Music.observationIssue')}</p> : null}
619
- {isStudioJobRecoveryCapability(capability.id) ? <StudioJobRecoveryPanel key={capability.id} capability={capability.id} disabled={running} /> : null}
711
+ {isStudioJobRecoveryCapability(capability.id) ? (
712
+ <StudioJobRecoveryPanel
713
+ key={capability.id}
714
+ capability={capability.id}
715
+ disabled={running}
716
+ history={history?.[capability.id]}
717
+ onSelectHistoryRun={selectHistoryRecord}
718
+ />
719
+ ) : null}
620
720
  </main>
621
721
  </div>
622
722
  <CapabilityRunHistory
623
723
  history={history}
624
724
  activeRunId={displayedRun?.id ?? null}
625
- onSelectRun={onSelectHistoryRun}
725
+ onSelectRun={selectHistoryRecord}
726
+ onClose={compactHistory ? closeCompactHistory : undefined}
626
727
  collapsed={historyCollapsed}
627
728
  currentCapabilityId={capability.id}
628
729
  registrations={registrations}