Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

feat(desktop): queue step descriptions and settle them before the guide is named

Luis Ortizb18b1df3ced9
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index e164893..fab4432 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -272,7 +272,9 @@ async function onOverlayCommand(command: OverlayCommand): Promise<void> {
await recorder?.drain();
if (command === 'stop' && steps.length > 0) finished = guideId;
if (finished) {
- await ask(mainWindow?.webContents ?? null, 'mimik:capture:finishGuide', finished).catch(() => undefined);
+ await ask(mainWindow?.webContents ?? null, 'mimik:capture:finishGuide', finished, 45_000).catch(
+ () => undefined,
+ );
}
guideId = null;
}
diff --git a/apps/desktop/src/renderer/ai/name-guide.ts b/apps/desktop/src/renderer/ai/name-guide.ts
index 5009c0c..1bfbbea 100644
--- a/apps/desktop/src/renderer/ai/name-guide.ts
+++ b/apps/desktop/src/renderer/ai/name-guide.ts
@@ -1,14 +1,11 @@
-import { type GuideMeta, generateGuideMeta, guideMetaSteps } from '@mimik/core/capture/ai/meta';
-import type { Step } from '@mimik/core/guides/types';
-import { credentials } from './credentials';
+import { resolveGuideMetaInputs } from '@mimik/core/capture/ai/guide-description';
+import { type GuideMeta, generateGuideMeta } from '@mimik/core/capture/ai/meta';
-export async function nameGuide(steps: Step[]): Promise<GuideMeta | null> {
- const keys = await credentials();
- if (!keys) return null;
- const described = guideMetaSteps(steps);
- if (described.length === 0) return null;
+export async function nameGuide(guideId: string): Promise<GuideMeta | null> {
+ const inputs = await resolveGuideMetaInputs(guideId);
+ if (!inputs.ok) return null;
try {
- return await generateGuideMeta(described, keys.provider, keys.model, keys.apiKey, keys.baseUrl);
+ return await generateGuideMeta(inputs.steps, inputs.provider, inputs.model, inputs.apiKey, inputs.baseUrl);
} catch {
return null;
}
diff --git a/apps/desktop/src/renderer/capture-host.ts b/apps/desktop/src/renderer/capture-host.ts
index a480c16..3a55d07 100644
--- a/apps/desktop/src/renderer/capture-host.ts
+++ b/apps/desktop/src/renderer/capture-host.ts
@@ -1,3 +1,4 @@
+import { settleDescriptions } from '@mimik/core/capture/ai/settle-descriptions';
import type { CaptureStepData } from '@mimik/core/capture/sink';
import { i18n } from '@mimik/core/env';
import {
@@ -30,7 +31,8 @@ window.mimik.onRequest('mimik:capture:finishGuide', async (payload) => {
const app = steps.find((step) => step.app?.name)?.app?.name;
await updateGuideTitle(guideId, app ? i18n.t('desktop.guideInApp', [app]) : i18n.t('background.newGuide'));
- const meta = await nameGuide(steps);
+ await settleDescriptions(guideId);
+ const meta = await nameGuide(guideId);
if (meta?.title) await updateGuideTitle(guideId, meta.title);
if (meta?.description) await updateGuideDescription(guideId, meta.description);
return true;
diff --git a/apps/desktop/src/renderer/capture-sink.ts b/apps/desktop/src/renderer/capture-sink.ts
index a1e2946..658c629 100644
--- a/apps/desktop/src/renderer/capture-sink.ts
+++ b/apps/desktop/src/renderer/capture-sink.ts
@@ -1,3 +1,4 @@
+import { queueDescription } from '@mimik/core/capture/ai/description-queue';
import type {
CaptureSink,
CaptureStepData,
@@ -83,7 +84,8 @@ export class DesktopCaptureSink implements CaptureSink {
await addStepToGuide(data.guideId, stepId);
if (pending) {
- void describeStep(data.action, meta).then(async ({ text, failure }) => {
+ queueDescription(data.guideId, async () => {
+ const { text, failure } = await describeStep(data.action, meta);
if (text) await updateStepDescription(stepId, text, 'ai');
await clearStepAiPending(stepId);
window.mimik.capture.described(stepId, text, failure);