@nimiplatform/app-tools 0.14.0 → 0.16.0-rc.12

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 (99) hide show
  1. package/README.md +112 -24
  2. package/bin/nimi-app.mjs +35 -15
  3. package/lib/app-access-declaration.mjs +3 -0
  4. package/lib/app-dependency-combinations.mjs +70 -24
  5. package/lib/app-doctor-update.mjs +97 -39
  6. package/lib/app-host-support.mjs +6 -0
  7. package/lib/app-identifiers.mjs +27 -0
  8. package/lib/app-info.mjs +292 -1
  9. package/lib/app-lifecycle-guidance.mjs +1 -1
  10. package/lib/app-pack.mjs +65 -39
  11. package/lib/app-project-lifecycle.mjs +149 -244
  12. package/lib/app-scaffold-capabilities.mjs +13 -109
  13. package/lib/app-scaffold-profiles.mjs +81 -115
  14. package/lib/app-scaffold.mjs +74 -166
  15. package/lib/app-toolchain-updates.mjs +45 -0
  16. package/lib/canonical-capability-ids.generated.mjs +2 -0
  17. package/lib/development-environment.d.mts +10 -0
  18. package/lib/development-environment.mjs +39 -0
  19. package/lib/hosted-web-release.mjs +98 -0
  20. package/lib/index.mjs +43 -3
  21. package/lib/mobile-development.mjs +19 -0
  22. package/lib/realm-environments.generated.mjs +5 -0
  23. package/lib/storefront-media.mjs +154 -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 +33 -21
  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 +3 -1
  32. package/skills/nimi-app-lifecycle/references/acceptance.md +6 -2
  33. package/skills/nimi-app-lifecycle/references/adapt.md +5 -3
  34. package/skills/nimi-app-lifecycle/references/audit.md +3 -2
  35. package/skills/nimi-app-lifecycle/references/create.md +6 -2
  36. package/skills/nimi-app-lifecycle/references/release.md +10 -0
  37. package/skills/nimi-app-lifecycle/references/upgrade-platform.md +12 -7
  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 +73 -19
  46. package/templates/app-source/src/ai-studio-core/messages/zh.json +73 -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 +30 -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 +96 -75
  60. package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +59 -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 +2 -2
  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 +158 -76
  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 +12 -3
  70. package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +12 -3
  71. package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
  72. package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -1
  73. package/templates/app-source/src/studio-modules/studio-create/runtime.ts +47 -5
  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 +68 -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 +3 -3
  89. package/templates/default-starter/README.md +1 -1
  90. package/templates/default-starter/src/shell/App.tsx +6 -18
  91. package/templates/default-starter/src/shell/auth/local-app-client.ts +6 -15
  92. package/templates/default-starter/src/shell/auth/runtime-platform.ts +7 -107
  93. package/templates/default-starter/src/shell/workbench-target-adapter.ts +9 -126
  94. package/templates/default-starter.manifest.json +0 -16
  95. package/templates/hosted-web-release.yml +98 -0
  96. package/templates/default-starter/src-tauri/Cargo.toml +0 -17
  97. package/templates/default-starter/src-tauri/build.rs +0 -32
  98. package/templates/default-starter/src-tauri/capabilities/default.json +0 -7
  99. package/templates/default-starter/src-tauri/tauri.conf.json +0 -26
@@ -8,17 +8,17 @@ import { SpeechTranscriptResultView } from './section-ai-testing-transcript-resu
8
8
  import { TextExchangeResultView } from './section-ai-testing-exchange-result.js';
9
9
  import { TextDecisionResultView } from './section-ai-testing-decision-result.js';
10
10
  import { FaceSwapNotice, SessionSummaryView } from './section-ai-testing-session-result.js';
11
- import { useState, type ReactNode } from 'react';
11
+ import { useEffect, useRef, type ReactNode } from 'react';
12
12
  import { IconButton, nimiToast, StatusBadge, Tooltip } from '@nimiplatform/kit/ui';
13
- import { AlertTriangle, ChevronRight, Copy as CopyIcon, Download as DownloadIcon, FileText, FolderOpen, MessageSquare, RefreshCw, SlidersHorizontal, SquarePen } from 'lucide-react';
13
+ import { AlertTriangle, Copy as CopyIcon, Download as DownloadIcon, FileText, FolderOpen, MessageSquare, RefreshCw, SlidersHorizontal, SquarePen } from 'lucide-react';
14
14
  import { useAIStudioHost } from './host-context.js';
15
15
  import { VisionLocateResultView } from './section-ai-testing-vision-result.js';
16
16
  import type { StudioCapabilityRegistration } from './module-registration.js';
17
- import { getStudioRunHistoryExportText, formatStudioRunTimestamp, getStudioRunConfigParamRows, getStudioRunIntentLabel, getStudioRunPromptControlFacts, getStudioRunResultTags, getStudioRunStatusTone, type StudioRunConfigParamRow, type StudioRunHistoryRecord, type StudioRunHistoryResultSnapshot, type StudioRunPromptControlFact } from './history.js';
18
- import { studioNonSuccessReasonTitle, studioNonSuccessReasonUserAction, studioNonSuccessReasonUserMessage } from './non-success-presentation.js';
17
+ import { getStudioRunHistoryExportText, formatStudioRunTimestamp, getStudioRunConfigParamRows, getStudioRunPromptControlFacts, getStudioRunResultTags, getStudioRunStatusTone, type StudioRunConfigParamRow, type StudioRunHistoryRecord, type StudioRunHistoryResultSnapshot, type StudioRunPromptControlFact } from './history.js';
18
+ import { studioNonSuccessReasonTitle, studioNonSuccessReasonUserAction, studioNonSuccessReasonUserMessage, studioTerminalStatusKey } from './non-success-presentation.js';
19
19
  import { ArtifactMediaPreview, ArtifactMediaResult, RuntimeDiagnosticsActions, StudioResult, TextStudioOutputBody, downloadTextFile, statusForCapability } from './section-ai-testing-surface.js';
20
- import { EmbeddingResultBody, SpeakerEmbeddingResultBody, KnownJobNotice, revealStudioAsset } from './section-ai-testing-output.js';
21
- import type { TextStudioActiveRun } from './section-ai-testing-run.js';
20
+ import { EmbeddingResultBody, SpeakerEmbeddingResultBody, KnownJobNotice, exportStudioAsset } from './section-ai-testing-output.js';
21
+ import { studioConfiguredTargetLabel, type TextStudioActiveRun } from './section-ai-testing-run.js';
22
22
 
23
23
  function TextStudioPromptControlFacts({ facts }: { facts: readonly StudioRunPromptControlFact[] }) {
24
24
  if (facts.length === 0) return null;
@@ -69,16 +69,13 @@ function groupParamRows(rows: readonly StudioRunConfigParamRow[]): Array<{ group
69
69
  function TextStudioRequestSettings({ record }: { record: StudioRunHistoryRecord }) {
70
70
  const { translate: t } = useAIStudioHost();
71
71
  const runConfig = record.runConfig;
72
- if (!runConfig) {
73
- return null;
74
- }
75
-
76
- const paramRows = getStudioRunConfigParamRows(runConfig);
77
- const fallbackSummary = runConfig.target.paramsSummary.join(' / ');
78
- if (paramRows.length === 0 && !fallbackSummary) {
79
- return null;
80
- }
81
- const paramGroups = groupParamRows(paramRows);
72
+ const target = runConfig?.target;
73
+ const paramGroups = runConfig ? groupParamRows(getStudioRunConfigParamRows(runConfig)) : [];
74
+ const defaults = runConfig && target?.configuredDefaults
75
+ ? getStudioRunConfigParamRows(runConfig, target.configuredDefaults) : [];
76
+ const snapshot = record.result;
77
+ const jobId = snapshot && 'jobId' in snapshot ? snapshot.jobId : undefined;
78
+ const traceId = runConfig?.traceId ?? (snapshot?.ok ? snapshot.traceId : snapshot?.diagnostics?.traceId);
82
79
 
83
80
  return (
84
81
  <section className="studio-history-settings" aria-label={t('StudioShell.requestSettings')}>
@@ -86,6 +83,30 @@ function TextStudioRequestSettings({ record }: { record: StudioRunHistoryRecord
86
83
  <SlidersHorizontal size={14} aria-hidden="true" />
87
84
  <strong>{t('StudioShell.requestSettings')}</strong>
88
85
  </div>
86
+ <dl className="studio-history-settings__params">
87
+ <div>
88
+ <dt>{t('StudioShell.intentLabel')}</dt>
89
+ <dd>
90
+ {target ? studioConfiguredTargetLabel(target, t) : t('History.compareUnknown')}
91
+ {target && !target.targetLabel ? ` · ${t('StudioShell.modelNotRecorded')}` : null}
92
+ {target?.targetRef && target.targetRef !== target.targetLabel ? <><br /><code>{target.targetRef}</code></> : null}
93
+ </dd>
94
+ </div>
95
+ {jobId ? <div><dt>{t('Studio.result.jobLabel')}</dt><dd><code>{jobId}</code></dd></div> : null}
96
+ {traceId ? <div><dt>{t('Studio.result.traceLabel')}</dt><dd><code>{traceId}</code></dd></div> : null}
97
+ </dl>
98
+ <p className="studio-result__hint">{t('StudioShell.recordedConfigScope')}</p>
99
+ {paramGroups.length === 0 ? <p className="studio-result__hint">
100
+ {target?.paramsSummary.join(' / ') || t(runConfig ? 'History.compareNoParameters' : 'StudioShell.parametersNotRecorded')}
101
+ </p> : null}
102
+ {defaults.length ? (
103
+ <div className="studio-history-settings__group">
104
+ <strong className="studio-history-settings__group-title">{t('StudioShell.configuredDefaults')}</strong>
105
+ <dl className="studio-history-settings__params">
106
+ {defaults.map((row) => <div key={row.key}><dt>{row.label}</dt><dd>{row.value}</dd></div>)}
107
+ </dl>
108
+ </div>
109
+ ) : null}
89
110
  {paramGroups.map((group) => (
90
111
  <div key={group.group} className="studio-history-settings__group">
91
112
  <strong className="studio-history-settings__group-title">{group.group}</strong>
@@ -103,12 +124,6 @@ function TextStudioRequestSettings({ record }: { record: StudioRunHistoryRecord
103
124
  );
104
125
  }
105
126
 
106
- function hasTextStudioRequestSettings(record: StudioRunHistoryRecord): boolean {
107
- const runConfig = record.runConfig;
108
- if (!runConfig) return false;
109
- return getStudioRunConfigParamRows(runConfig).length > 0 || Boolean(runConfig.target.paramsSummary.join(' / '));
110
- }
111
-
112
127
  function historyNonSuccessDiagnosticsText(snapshot: Extract<StudioRunHistoryResultSnapshot, { ok: false }>): string {
113
128
  return [
114
129
  `Reason: ${snapshot.reason}`,
@@ -154,15 +169,15 @@ function TextStudioHistoryRecordResult({
154
169
  const snapshot = record.result;
155
170
  const HistoryActions = registration.historyActions;
156
171
  const blocked = snapshot && !snapshot.ok ? snapshot : null;
157
- const jobState = snapshot?.ok && 'jobState' in snapshot ? snapshot.jobState : undefined;
158
- const statusLabel = record.status === 'ready' && snapshot?.ok && (snapshot.kind === 'speaker-embedding' || (snapshot.kind === 'vision-locate' && snapshot.result))
159
- ? t('Studio.result.statCompleted')
160
- : jobState === undefined
161
- ? rendererHost.app.projection.runStatusLabel(record.status)
162
- : jobState.toUpperCase() === 'COMPLETED' ? t('Studio.result.statCompleted')
163
- : jobState || t('Studio.result.stateUnknown');
164
- const tags = blocked ? [studioNonSuccessReasonTitle(blocked.reason, t, record.capabilityId)] : getStudioRunResultTags(record);
165
- const intentLabel = getStudioRunIntentLabel(record);
172
+ const statusLabel = snapshot || record.status === 'ready'
173
+ ? t(studioTerminalStatusKey(blocked?.reason, record.capabilityId))
174
+ : rendererHost.app.projection.runStatusLabel(record.status);
175
+ const tags = blocked
176
+ ? [studioNonSuccessReasonTitle(blocked.reason, t, record.capabilityId)]
177
+ : snapshot?.ok && snapshot.kind === 'text'
178
+ ? [t('Studio.result.runtimeChip'), t('Studio.result.metricCharacters', { count: snapshot.body.length })]
179
+ : getStudioRunResultTags(record);
180
+ const intentLabel = studioConfiguredTargetLabel(record.runConfig?.target, t);
166
181
  const toneClass = historyResultToneClass(record);
167
182
  const exportText = getStudioRunHistoryExportText(record);
168
183
  const managedArtifact = snapshot?.ok && snapshot.kind === 'artifacts'
@@ -177,10 +192,8 @@ function TextStudioHistoryRecordResult({
177
192
  && Number(record.runConfig?.target.params.additionalDocuments ?? 0) > 0;
178
193
  const canUseAsDraft = !sessionOnly && !faceSwapNeedsMedia && !speakerNeedsMedia && !record.inputTruncated;
179
194
  const canReplay = canUseAsDraft && !additionalDocumentsNotRetained;
180
- const revealsManagedAsset = Boolean(managedArtifact?.relativePath);
181
- const canExport = !blocked && (revealsManagedAsset || Boolean(exportText.trim()));
182
- const hasRequestSettings = hasTextStudioRequestSettings(record);
183
- const [requestSettingsOpen, setRequestSettingsOpen] = useState(false);
195
+ const revealsManagedAsset = Boolean(managedArtifact?.relativePath) && rendererHost.app.projection.assetExportAction() === 'reveal';
196
+ const canExport = !blocked && (Boolean(managedArtifact?.relativePath) || Boolean(exportText.trim()));
184
197
  function handleCopy() {
185
198
  if (!exportText.trim()) return;
186
199
  void rendererHost.app.commands.copyText(exportText)
@@ -197,7 +210,7 @@ function TextStudioHistoryRecordResult({
197
210
  }
198
211
  function handleDownload() {
199
212
  if (managedArtifact?.relativePath) {
200
- void revealStudioAsset(rendererHost, managedArtifact.relativePath);
213
+ void exportStudioAsset(rendererHost, managedArtifact.relativePath);
201
214
  return;
202
215
  }
203
216
  const stamp = record.createdAt.replace(/[:.]/g, '-');
@@ -241,7 +254,7 @@ function TextStudioHistoryRecordResult({
241
254
  <div className="studio-history-result__head">
242
255
  <div className="studio-history-result__line">
243
256
  <StatusBadge tone={getStudioRunStatusTone(record.status)} shape="dot">
244
- {blocked ? studioNonSuccessReasonTitle(blocked.reason, t) : statusLabel}
257
+ {statusLabel}
245
258
  </StatusBadge>
246
259
  <span className="studio-history-result__title-stack">
247
260
  <time dateTime={record.createdAt}>{t('StudioShell.runLabel')} / {formatStudioRunTimestamp(record.createdAt, new Date(rendererHost.clock.now()))}</time>
@@ -251,7 +264,7 @@ function TextStudioHistoryRecordResult({
251
264
  {!blocked ? (
252
265
  <>
253
266
  <Tooltip content={t('Common.copy')} placement="top">
254
- <IconButton type="button" className="studio-result__action" onClick={handleCopy} disabled={!canExport} aria-label={t('StudioShell.copyGeneration')} icon={<CopyIcon size={16} aria-hidden="true" />} />
267
+ <IconButton type="button" className="studio-result__action" onClick={handleCopy} disabled={blocked !== null || !exportText.trim()} aria-label={t('StudioShell.copyGeneration')} icon={<CopyIcon size={16} aria-hidden="true" />} />
255
268
  </Tooltip>
256
269
  <Tooltip content={t(revealsManagedAsset ? 'StudioShell.revealAsset' : 'StudioShell.download')} placement="top">
257
270
  <IconButton type="button" className="studio-result__action" onClick={handleDownload} disabled={!canExport} aria-label={t(revealsManagedAsset ? 'StudioShell.revealGeneration' : 'StudioShell.downloadGeneration')} icon={revealsManagedAsset ? <FolderOpen size={16} aria-hidden="true" /> : <DownloadIcon size={16} aria-hidden="true" />} />
@@ -276,26 +289,13 @@ function TextStudioHistoryRecordResult({
276
289
  </div>
277
290
  <div className="studio-history-result__intent">
278
291
  <span>{t('StudioShell.intentLabel')}</span>
279
- <div className={hasRequestSettings ? 'studio-intent-pill__box' : 'studio-intent-pill__box studio-intent-pill__box--static'}>
292
+ <div className="studio-intent-pill__box studio-intent-pill__box--static">
280
293
  <Tooltip content={intentLabel} placement="top" className="min-w-0">
281
294
  <strong>{intentLabel}</strong>
282
295
  </Tooltip>
283
- {hasRequestSettings ? (
284
- <Tooltip content={requestSettingsOpen ? t('StudioShell.hideRequestSettings') : t('StudioShell.showRequestSettings')} placement="top">
285
- <IconButton
286
- type="button"
287
- className={requestSettingsOpen ? 'studio-intent-pill__trigger studio-intent-pill__trigger--open' : 'studio-intent-pill__trigger'}
288
- aria-label={requestSettingsOpen ? t('StudioShell.hideRequestSettings') : t('StudioShell.showRequestSettings')}
289
- aria-expanded={requestSettingsOpen}
290
- onClick={() => setRequestSettingsOpen((value) => !value)}
291
- icon={<ChevronRight size={15} aria-hidden="true" />}
292
- />
293
- </Tooltip>
294
- ) : null}
295
296
  </div>
296
297
  </div>
297
298
  </div>
298
- {requestSettingsOpen && hasRequestSettings ? <TextStudioRequestSettings record={record} /> : null}
299
299
  {HistoryActions ? <HistoryActions key={record.id} record={record} /> : null}
300
300
  {body}
301
301
  {additionalDocumentsNotRetained ? <p className="studio-result__hint">{t('StudioShell.historyAdditionalDocumentsNotRetained')}</p> : null}
@@ -322,7 +322,7 @@ function TextStudioHistorySnapshotBody({ snapshot, recordId, submittedParameters
322
322
  }
323
323
  if (snapshot.kind === 'speaker-embedding') return <SpeakerEmbeddingResultBody spaceId={snapshot.spaceId} vector={snapshot.vector} />;
324
324
  if (snapshot.kind === 'embedding') {
325
- return <EmbeddingResultBody spaceId={snapshot.spaceId} />;
325
+ return <EmbeddingResultBody spaceId={snapshot.spaceId} retrieval={snapshot.retrieval} />;
326
326
  }
327
327
  if (snapshot.kind === 'text-annotation') {
328
328
  return <TextAnnotationResultView output={{
@@ -449,28 +449,23 @@ export function TextStudioResultState({
449
449
  }) {
450
450
  const { translate: t } = useAIStudioHost();
451
451
  const capability = registration.descriptor;
452
+ const parameterOwnedInput = Boolean(registration.parameters.recordedInput);
453
+ const hasRecordedInput = Boolean(activeRun.prompt) && (parameterOwnedInput || registration.profile.inputKind !== 'none');
454
+ const resultScroll = useRef<HTMLDivElement>(null);
455
+ const draftDisclosure = useRef<HTMLDetailsElement>(null);
456
+ useEffect(() => {
457
+ if (resultScroll.current) resultScroll.current.scrollTop = 0;
458
+ }, [activeRun.id]);
459
+ useEffect(() => {
460
+ if (!running) return;
461
+ if (draftDisclosure.current?.open) {
462
+ draftDisclosure.current.open = false;
463
+ resultScroll.current?.focus({ preventScroll: true });
464
+ }
465
+ }, [running]);
452
466
  return (
453
467
  <section className="studio-thread" aria-label={t('StudioShell.resultAriaLabel', { capability: t(capability.labelKey) })}>
454
- <div className="studio-thread__scroll">
455
- {regenerateHint ? <p className="studio-result__hint" role="status">{regenerateHint}</p> : null}
456
- {registration.parameters.recordedInput ? (
457
- // A parameter-owned input is shown as the complete request it recorded.
458
- <article className="studio-turn studio-turn--user">
459
- <details className="studio-diag studio-turn__request">
460
- <summary>{t('StudioShell.requestLabel')}</summary>
461
- <pre className="studio-diag__json">{activeRun.prompt}</pre>
462
- </details>
463
- {activeRun.record?.inputTruncated ? <p className="studio-result__hint">{t('StudioShell.historyInputTruncated')}</p> : null}
464
- </article>
465
- ) : registration.profile.inputKind !== 'none' && activeRun.prompt ? <article className="studio-turn studio-turn--user">
466
- <div className="studio-turn__label">
467
- <MessageSquare size={14} aria-hidden="true" />
468
- <span>{t('StudioShell.promptLabel')}</span>
469
- </div>
470
- <p>{activeRun.prompt}</p>
471
- {activeRun.record?.inputTruncated ? <p className="studio-result__hint">{t('StudioShell.historyInputTruncated')}</p> : null}
472
- <TextStudioPromptSettings activeRun={activeRun} />
473
- </article> : null}
468
+ <div ref={resultScroll} className="studio-thread__scroll" tabIndex={-1}>
474
469
  <article className="studio-turn studio-turn--assistant">
475
470
  <div className="studio-turn__label">
476
471
  <FileText size={14} aria-hidden="true" />
@@ -489,7 +484,6 @@ export function TextStudioResultState({
489
484
  admission={admission}
490
485
  createdAt={activeRun.createdAt}
491
486
  intentLabel={intentLabel}
492
- requestSettings={activeRun.record && hasTextStudioRequestSettings(activeRun.record) ? <TextStudioRequestSettings record={activeRun.record} /> : null}
493
487
  streamingText={streamingText}
494
488
  jobStatus={activeRun.jobStatus}
495
489
  verboseConsole={verboseConsole}
@@ -503,9 +497,36 @@ export function TextStudioResultState({
503
497
  ) : activeRun.record ? (
504
498
  <TextStudioHistoryRecordResult registration={registration} record={activeRun.record} canRegenerate={canRegenerate} canRestoreInputs={canRestoreInputs} onRegenerate={onRegenerate} onUseAsDraft={onUseAsDraft} />
505
499
  ) : null}
500
+ {regenerateHint ? <p className="studio-result__hint" role="status">{regenerateHint}</p> : null}
506
501
  </article>
502
+ {activeRun.record ? (
503
+ <div className="studio-turn"><TextStudioRequestSettings record={activeRun.record} /></div>
504
+ ) : null}
505
+ {hasRecordedInput ? (
506
+ <details key={activeRun.id} className="studio-review-disclosure">
507
+ <summary>
508
+ <MessageSquare size={15} aria-hidden="true" />
509
+ <span>{t('StudioShell.recordedInput')}</span>
510
+ </summary>
511
+ <div className="studio-review-disclosure__body">
512
+ {parameterOwnedInput ? <pre className="studio-diag__json">{activeRun.prompt}</pre> : (
513
+ <>
514
+ <p className="studio-review-disclosure__prompt">{activeRun.prompt}</p>
515
+ <TextStudioPromptSettings activeRun={activeRun} />
516
+ </>
517
+ )}
518
+ {activeRun.record?.inputTruncated ? <p className="studio-result__hint">{t('StudioShell.historyInputTruncated')}</p> : null}
519
+ </div>
520
+ </details>
521
+ ) : null}
522
+ <details ref={draftDisclosure} className="studio-review-disclosure">
523
+ <summary>
524
+ <SquarePen size={15} aria-hidden="true" />
525
+ <span>{t('StudioShell.editNextRun')}</span>
526
+ </summary>
527
+ <div className="studio-review-disclosure__body">{composer}</div>
528
+ </details>
507
529
  </div>
508
- <div className="studio-thread__composer">{composer}</div>
509
530
  </section>
510
531
  );
511
532
  }
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useMemo, useState } from 'react';
2
- import type { NimiPortableAppAIConfig } from '@nimiplatform/sdk/ai';
2
+ import { runtimeAIConfigStructToJson, type NimiAIConfigSnapshot } from '@nimiplatform/sdk/ai';
3
3
 
4
+ import { findStudioCapabilityIntent } from './ai-config.js';
4
5
  import { useAIStudioHost } from './host-context.js';
5
6
  import type { StudioCapabilityRegistration, CapabilityStudioProfile } from './module-registration.js';
6
7
  import type { StudioCapabilityRunResult, StudioManagedArtifact, StudioRuntimeInspection } from './runtime-types.js';
@@ -30,6 +31,7 @@ export type TextStudioActiveRun = {
30
31
  prompt: string;
31
32
  context: string;
32
33
  createdAt: string;
34
+ configuredTarget?: Pick<StudioRunTargetSummary, 'source' | 'targetLabel'>;
33
35
  result: StudioCapabilityRunResult | null;
34
36
  record: StudioRunHistoryRecord | null;
35
37
  error: string | null;
@@ -58,7 +60,17 @@ export function textStudioRunTargetIntentSummary(
58
60
  runTarget: StudioRunTargetSummary,
59
61
  translate: StudioTranslate,
60
62
  ): string {
61
- return translate('Studio.composer.intentSummary', { intent: runTarget.intentLabel });
63
+ return translate('Studio.composer.intentSummary', { intent: studioConfiguredTargetLabel(runTarget, translate) });
64
+ }
65
+
66
+ export function studioConfiguredTargetLabel(
67
+ target: Pick<StudioRunTargetSummary, 'source' | 'targetLabel'> | undefined,
68
+ translate: StudioTranslate,
69
+ ): string {
70
+ const route = target?.source === 'local' ? translate('Studio.composer.routeLocal')
71
+ : target?.source === 'cloud' ? translate('Studio.composer.routeCloud')
72
+ : translate('Studio.composer.routeUnknown');
73
+ return target?.targetLabel ? `${route} · ${target.targetLabel}` : route;
62
74
  }
63
75
 
64
76
  export function canConfigureRunTarget(runTarget: StudioRunTargetSummary): boolean {
@@ -68,31 +80,31 @@ export function canConfigureRunTarget(runTarget: StudioRunTargetSummary): boolea
68
80
  export function useStudioRunTargetSummary(
69
81
  registration: StudioCapabilityRegistration,
70
82
  runtime: StudioRuntimeInspection | null,
71
- ): StudioRunTargetSummary {
83
+ ): StudioRunTargetSummary & { readonly snapshot: NimiAIConfigSnapshot | null; readonly configReadFailed: boolean } {
72
84
  const host = useAIStudioHost();
73
85
  const [configProjection, setConfigProjection] = useState<{
74
86
  state: 'loading' | 'loaded' | 'failed';
75
- config: NimiPortableAppAIConfig | null;
87
+ snapshot: NimiAIConfigSnapshot | null;
76
88
  error: string | null;
77
- }>({ state: 'loading', config: null, error: null });
89
+ }>({ state: 'loading', snapshot: null, error: null });
78
90
 
79
91
  useEffect(() => {
80
92
  let cancelled = false;
81
93
  let requestGeneration = 0;
82
94
  const refresh = () => {
83
95
  const generation = ++requestGeneration;
84
- setConfigProjection({ state: 'loading', config: null, error: null });
85
- void host.sdk.aiConfig.get()
96
+ setConfigProjection({ state: 'loading', snapshot: null, error: null });
97
+ void host.sdk.aiConfig.getSnapshot()
86
98
  .then((next) => {
87
99
  if (!cancelled && generation === requestGeneration) {
88
- setConfigProjection({ state: 'loaded', config: next, error: null });
100
+ setConfigProjection({ state: 'loaded', snapshot: next, error: null });
89
101
  }
90
102
  })
91
103
  .catch((cause) => {
92
104
  if (!cancelled && generation === requestGeneration) {
93
105
  setConfigProjection({
94
106
  state: 'failed',
95
- config: null,
107
+ snapshot: null,
96
108
  error: cause instanceof Error ? cause.message : String(cause || host.translate('Studio.run.aiConfigLoadFailed')),
97
109
  });
98
110
  }
@@ -107,13 +119,41 @@ export function useStudioRunTargetSummary(
107
119
  };
108
120
  }, [host]);
109
121
 
110
- return useMemo(() => host.app.projection.projectRunTarget({
111
- capability: registration.descriptor,
112
- runtime,
113
- config: configProjection.config,
114
- configState: configProjection.state,
115
- configError: configProjection.error,
116
- }), [configProjection, host, registration.descriptor, runtime]);
122
+ return useMemo(() => {
123
+ const { snapshot } = configProjection;
124
+ const config = snapshot?.config ?? null;
125
+ const target = host.app.projection.projectRunTarget({
126
+ capability: registration.descriptor,
127
+ runtime,
128
+ config,
129
+ configState: configProjection.state,
130
+ configError: configProjection.error,
131
+ });
132
+ const readState = { snapshot, configReadFailed: configProjection.state === 'failed' };
133
+ if (!target.capabilityContract || !target.canDispatch) return { ...target, ...readState };
134
+ const selection = snapshot?.effectiveSelections.find((item) => item.capabilityContract === target.capabilityContract);
135
+ const resource = selection?.resource;
136
+ const intent = findStudioCapabilityIntent(config, target.capabilityContract);
137
+ const configuredCloudModel = intent?.route.oneofKind === 'cloud'
138
+ ? runtimeAIConfigStructToJson(intent.route.cloud.providerModelTarget).providerModelId
139
+ : undefined;
140
+ const label = resource?.oneofKind === 'local' ? resource.local.label
141
+ : resource?.oneofKind === 'cloud' ? resource.cloud.target.label
142
+ : configuredCloudModel;
143
+ const targetLabel = typeof label === 'string' && label.trim() ? label : undefined;
144
+ const targetRef = resource?.oneofKind === 'local' ? resource.local.loadoutRef
145
+ : typeof configuredCloudModel === 'string' ? configuredCloudModel : undefined;
146
+ const recordedConfig = {
147
+ targetLabel,
148
+ targetRef,
149
+ configuredDefaults: intent ? runtimeAIConfigStructToJson(intent.defaults) : undefined,
150
+ };
151
+ if (selection && selection.state !== 'ready') {
152
+ return { ...target, ...readState, ...recordedConfig, status: 'blocked', canDispatch: false,
153
+ detail: host.translate('Studio.run.effectiveTargetUnavailable') };
154
+ }
155
+ return { ...target, ...readState, ...recordedConfig };
156
+ }, [configProjection, host, registration.descriptor, runtime]);
117
157
  }
118
158
 
119
159
  export type TextStudioPromptStyle = { tone: string; length: string };
@@ -166,6 +206,9 @@ export function createRunConfigSnapshot(input: {
166
206
  status: target.status,
167
207
  source: target.source,
168
208
  intentLabel: target.intentLabel,
209
+ ...(target.targetLabel ? { targetLabel: target.targetLabel } : {}),
210
+ ...(target.targetRef ? { targetRef: target.targetRef } : {}),
211
+ ...(target.configuredDefaults ? { configuredDefaults: target.configuredDefaults } : {}),
169
212
  detail: target.detail,
170
213
  params,
171
214
  paramsSummary: [...target.paramsSummary],
@@ -24,6 +24,8 @@ export function SessionSummaryView({ output }: { readonly output: SessionOutput
24
24
  <div><dt>{t('StudioResults.session.duration')}</dt><dd>{t('StudioResults.session.seconds', { seconds: seconds.toFixed(1) })}</dd></div>
25
25
  <div><dt>{t('StudioResults.session.terminalReason')}</dt><dd><code>{output.terminalReason}</code></dd></div>
26
26
  </dl>
27
+ {output.audioUsage ? <p className="studio-result__hint">{t(output.audioUsage.final ? 'StudioResults.session.audioUsageFinal' : 'StudioResults.session.audioUsagePartial', { seconds: output.audioUsage.audioSeconds })}</p> : null}
28
+ {output.closure ? <p className="studio-result__hint">{t(!output.closure.localResourcesReleased ? 'StudioResults.session.localClosureUnconfirmed' : output.closure.providerSessionClosed ? 'StudioResults.session.providerClosureConfirmed' : 'StudioResults.session.localClosureConfirmed')}</p> : null}
27
29
  {counters.length > 0 ? (
28
30
  <ul className="studio-voice-list">
29
31
  {counters.map(([name, count]) => (
@@ -16,7 +16,7 @@ import { VisionLocateResultView } from './section-ai-testing-vision-result.js';
16
16
  import type { StudioCapabilityRunResult } from './runtime-types.js';
17
17
  import type { StudioCapabilityDescriptor, StudioCapabilityRegistration } from './module-registration.js';
18
18
  import { formatStudioRunTimestamp } from './history.js';
19
- import { isStoppedDirectCall, studioNonSuccessNeedsTargetReselection, studioNonSuccessReasonUserAction, studioNonSuccessReasonUserMessage, type StudioTranslate } from './non-success-presentation.js';
19
+ import { isStoppedDirectCall, studioNonSuccessNeedsTargetReselection, studioNonSuccessReasonUserAction, studioNonSuccessReasonUserMessage, studioTerminalStatusKey, type StudioTranslate } from './non-success-presentation.js';
20
20
  import { countStudioWords } from './studio-directives.js';
21
21
  import type { CapabilityStatus } from './section-ai-testing-admission.js';
22
22
  import { ArtifactMediaPreview, ArtifactMediaResult, EmbeddingResultBody, SpeakerEmbeddingResultBody, KnownJobNotice, RuntimeDiagnosticsActions, formatTypedOutput, formatNonSuccessOutput, resultPlainText, TextStudioOutputBody } from './section-ai-testing-output.js';
@@ -61,7 +61,7 @@ function ReadyBody({ result }: { result: StudioCapabilityRunResult & { ok: true
61
61
  }
62
62
  if (output.kind === 'speaker-embedding') return <SpeakerEmbeddingResultBody spaceId={output.spaceId} vector={output.vector} />;
63
63
  if (output.kind === 'embedding') {
64
- return <EmbeddingResultBody spaceId={output.spaceId} />;
64
+ return <EmbeddingResultBody spaceId={output.spaceId} retrieval={output.retrieval} />;
65
65
  }
66
66
  if (output.kind === 'voice-asset') {
67
67
  return (
@@ -239,7 +239,6 @@ export function StudioResult({
239
239
  const profile = registration.profile;
240
240
  const ready = result?.ok ? result : null;
241
241
  const operationAborted = result && !result.ok && result.reason === 'operation-aborted' ? result : null;
242
- const stoppedDirectCall = Boolean(operationAborted && isStoppedDirectCall(operationAborted.reason, capability.id));
243
242
  const canceled = result && !result.ok && result.reason === 'runtime-canceled' ? result : null;
244
243
  const timedOut = result && !result.ok && result.reason === 'runtime-timeout' ? result : null;
245
244
  const blocked = result && !result.ok
@@ -248,15 +247,18 @@ export function StudioResult({
248
247
  && result.reason !== 'runtime-timeout' ? result : null;
249
248
  const plainText = ready ? resultPlainText(ready, t) : '';
250
249
  const canExport = Boolean(ready && plainText);
251
- const revealsManagedAsset = ready?.output.kind === 'artifacts' || ready?.output.kind === 'text-annotation';
250
+ const revealsManagedAsset = (ready?.output.kind === 'artifacts' || ready?.output.kind === 'text-annotation')
251
+ && rendererHost.app.projection.assetExportAction() === 'reveal';
252
252
  const displayIntentLabel = studioResultIntentLabel(result, capability, intentLabel, t);
253
253
  const [requestSettingsOpen, setRequestSettingsOpen] = useState(false);
254
254
  const hasRequestSettings = Boolean(requestSettings);
255
255
  const runTimeLabel = createdAt
256
256
  ? formatStudioRunTimestamp(createdAt, new Date(rendererHost.clock.now()))
257
257
  : running ? t('Studio.result.statRunning') : t('Studio.result.notRecorded');
258
- const statusTitleKey = cancelRequested ? 'stopping' : running ? 'runtimeRunning' : operationAborted ? (stoppedDirectCall ? 'stoppedDirectCall' : 'operationAborted') : canceled ? 'runtimeCanceled' : timedOut ? 'runtimeTimedOut' : blocked ? 'runtimeBlocked' : ready ? 'runtimeResult' : 'runtimeWaiting';
259
- const statusTitle = t(`Studio.result.status.${statusTitleKey}`);
258
+ const statusTitle = t(cancelRequested ? 'Studio.result.status.stopping'
259
+ : running ? 'Studio.result.status.runtimeRunning'
260
+ : result ? studioTerminalStatusKey(result.ok ? undefined : result.reason, capability.id)
261
+ : 'Studio.result.status.runtimeWaiting');
260
262
  const statusTone = blocked || operationAborted || canceled || timedOut ? 'warning' : ready ? 'success' : running ? 'info' : 'neutral';
261
263
  useEffect(() => {
262
264
  if (!hasRequestSettings) setRequestSettingsOpen(false);
@@ -454,23 +456,12 @@ export function StudioResult({
454
456
  }
455
457
 
456
458
  return (
457
- <Surface className="studio-result" material="glass-regular" tone="panel" elevation="floating" padding="none">
459
+ <Surface className="studio-result" tone="card" padding="none">
458
460
  <div className="studio-result__top">
459
461
  <div className="studio-result__identity">
460
- <StatusBadge
461
- tone={statusTone}
462
- shape="soft"
463
- className="grid h-11 w-11 place-items-center rounded-[var(--nimi-radius-md)] p-0"
464
- aria-hidden="true"
465
- >
466
- <Sparkles size={20} />
467
- </StatusBadge>
468
- <span className="studio-result__title-stack">
469
- <strong>{statusTitle}</strong>
470
- <span className="studio-result__time">
471
- <Clock size={14} aria-hidden="true" />
472
- <time dateTime={createdAt}>{t('Studio.result.runTimeLabel', { time: runTimeLabel })}</time>
473
- </span>
462
+ <StatusBadge tone={statusTone} shape="dot">{statusTitle}</StatusBadge>
463
+ <span className="studio-result__time">
464
+ <time dateTime={createdAt}>{t('Studio.result.runTimeLabel', { time: runTimeLabel })}</time>
474
465
  </span>
475
466
  </div>
476
467
  <div className="studio-result__actions">
@@ -78,7 +78,7 @@ export function MusicTranscriptionNotice({ value, recordId }: { readonly value?:
78
78
  const saved = await host.sdk.assets.write({ relativePath: `studio/music/exports/${crypto.randomUUID()}/${snapshot.filename}`,
79
79
  body: chunks(), mediaType: snapshot.mediaType, overwrite: false });
80
80
  setFeedback({ sourceKey: snapshot.sourceKey, exportedPath: saved.relativePath });
81
- try { await host.sdk.assets.reveal(saved.relativePath); }
81
+ try { await host.app.commands.exportAsset(saved.relativePath); }
82
82
  catch {
83
83
  setFeedback({ sourceKey: snapshot.sourceKey, exportedPath: saved.relativePath,
84
84
  error: t('Common.exportSavedRevealFailed', { path: saved.relativePath }) });
@@ -92,7 +92,7 @@ export function MusicTranscriptionNotice({ value, recordId }: { readonly value?:
92
92
  async function revealSelected() {
93
93
  const snapshot = file;
94
94
  if (!snapshot || snapshot.sourceKey !== currentSource.current) return;
95
- try { await host.sdk.assets.reveal(snapshot.path); }
95
+ try { await host.app.commands.exportAsset(snapshot.path); }
96
96
  catch { setFeedback({ sourceKey: snapshot.sourceKey, error: t('Common.assetRevealFailed', { path: snapshot.path }) }); }
97
97
  }
98
98
  if (!value) return null;
@@ -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;