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(core): name a guide from where each step happened, a page or an application

Luis Ortiz443ef4e1c312
diff --git a/packages/core/src/capture/ai/__tests__/meta.test.ts b/packages/core/src/capture/ai/__tests__/meta.test.ts
index a866b94..5c29eed 100644
--- a/packages/core/src/capture/ai/__tests__/meta.test.ts
+++ b/packages/core/src/capture/ai/__tests__/meta.test.ts
@@ -1,4 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
+import type { Step } from '@/core/guides/types';
const { generateObjectMock, generateTextMock } = vi.hoisted(() => ({
generateObjectMock: vi.fn(),
@@ -13,9 +14,9 @@ vi.mock('ai', () => ({
vi.mock('../provider', () => ({ createModel: () => ({ id: 'test-model' }) }));
-import { generateGuideMeta, parseGuideMeta } from '../meta';
+import { generateGuideMeta, guideMetaSteps, parseGuideMeta } from '../meta';
-const steps = [{ description: 'Click Directory', url: 'https://admin.okta.com/users' }];
+const steps = [{ description: 'Click Directory', place: 'https://admin.okta.com/users' }];
const UNSUPPORTED = new Error('response_format json_schema is not supported by this model');
@@ -186,3 +187,24 @@ describe('parseGuideMeta', () => {
expect(parseGuideMeta(' ')).toBeNull();
});
});
+
+describe('guideMetaSteps', () => {
+ it('places a desktop step by its application and window, since it has no address', () => {
+ const step = (over: Partial<Step>): Step => ({
+ id: 'step',
+ guideId: 'guide',
+ index: 0,
+ description: 'Click "Downloads"',
+ action: 'click',
+ url: '',
+ timestamp: 0,
+ ...over,
+ });
+ expect(
+ guideMetaSteps([
+ step({ app: { name: 'File Explorer' }, window: { title: 'Downloads' } }),
+ step({ url: 'https://example.com/a' }),
+ ]).map((entry) => entry.place),
+ ).toEqual(['File Explorer β€” Downloads', 'https://example.com/a']);
+ });
+});
diff --git a/packages/core/src/capture/ai/guide-description.ts b/packages/core/src/capture/ai/guide-description.ts
index b2d714b..d381c2b 100644
--- a/packages/core/src/capture/ai/guide-description.ts
+++ b/packages/core/src/capture/ai/guide-description.ts
@@ -14,7 +14,7 @@ export interface GenerateGuideDescriptionResponse {
type GuideMetaInputs =
| {
ok: true;
- steps: { description: string; url: string }[];
+ steps: { description: string; place: string }[];
provider: string;
model: string;
apiKey: string;
diff --git a/packages/core/src/capture/ai/meta.ts b/packages/core/src/capture/ai/meta.ts
index 3a65381..e0cbd00 100644
--- a/packages/core/src/capture/ai/meta.ts
+++ b/packages/core/src/capture/ai/meta.ts
@@ -56,7 +56,7 @@ export function parseGuideMeta(raw: string): GuideMeta | null {
}
export async function generateGuideMeta(
- steps: { description: string; url: string }[],
+ steps: { description: string; place: string }[],
provider: string,
model: string,
apiKey: string,
@@ -64,7 +64,7 @@ export async function generateGuideMeta(
): Promise<GuideMeta | null> {
if (steps.length === 0) return null;
- const formatted = steps.map((s, i) => `${i + 1}. [${s.url}] ${s.description}`).join('\n');
+ const formatted = steps.map((s, i) => `${i + 1}. [${s.place}] ${s.description}`).join('\n');
const settings = await localStorage.get(['aiLanguage']);
const locale = (settings.aiLanguage as string) || 'en';
const prompt = GUIDE_META_PROMPT.replace('{{steps}}', formatted) + getLanguageSuffix(locale);
@@ -95,9 +95,12 @@ export async function generateGuideMeta(
}
}
-export function guideMetaSteps(steps: Step[]): { description: string; url: string }[] {
+export function guideMetaSteps(steps: Step[]): { description: string; place: string }[] {
const described = actionSteps(steps)
.filter((step) => step.description)
- .map((step) => ({ description: step.description, url: step.url }));
+ .map((step) => ({
+ description: step.description,
+ place: step.url || [step.app?.name, step.window?.title].filter(Boolean).join(' β€” '),
+ }));
return described.length > 15 ? [...described.slice(0, 10), ...described.slice(-5)] : described;
}
diff --git a/packages/core/src/capture/ai/prompts.ts b/packages/core/src/capture/ai/prompts.ts
index d07b350..72759bb 100644
--- a/packages/core/src/capture/ai/prompts.ts
+++ b/packages/core/src/capture/ai/prompts.ts
@@ -10,21 +10,22 @@ Examples of good descriptions:
Write only the description, no preamble.`;
-export const GUIDE_META_PROMPT = `These are the steps of a browser workflow, with the page URL and description for each step:
+export const GUIDE_META_PROMPT = `These are the steps of a recorded workflow. Each one shows where it happened, a page URL or an application and its window, and what the user did:
{{steps}}
Write a title and a description for this workflow.
-TITLE: specific and descriptive. Mention the application or website name and the specific task performed. Reference specific pages, features, or items that were interacted with. MUST be under 60 characters.
+TITLE: specific and descriptive. Mention the application or website name and the specific task performed. Reference specific pages, features, or items that were interacted with. Only name applications, websites and items that appear in the steps. MUST be under 60 characters.
Examples of good titles:
- "Review claude-code Pull Requests"
- "Configure Slack Notification Preferences"
- "Submit Expense Report in Workday"
- "Create Repository in GitHub Organization"
+- "Export a Budget to PDF in Excel"
-DESCRIPTION: one or two sentences stating what the workflow accomplishes and who would follow it. Do not repeat the title. Do not list the individual steps. Do not mention any UI element that does not appear in the steps above.
+DESCRIPTION: one or two sentences stating what the workflow accomplishes and who would follow it. Do not repeat the title. Do not list the individual steps. Do not mention any application, website or UI element that does not appear in the steps above.
Examples of good descriptions:
- "Reset a locked-out user's password from the Okta admin panel. For IT support staff."
diff --git a/src/entrypoints/background/__tests__/guide-meta.test.ts b/src/entrypoints/background/__tests__/guide-meta.test.ts
index acb296d..f02e1d5 100644
--- a/src/entrypoints/background/__tests__/guide-meta.test.ts
+++ b/src/entrypoints/background/__tests__/guide-meta.test.ts
@@ -95,7 +95,7 @@ describe('background guide-meta', () => {
await run(GUIDE_ID);
- expect(generateGuideMetaMock.mock.calls[0][0]).toEqual([{ description: 'kept', url: 'https://example.com/a' }]);
+ expect(generateGuideMetaMock.mock.calls[0][0]).toEqual([{ description: 'kept', place: 'https://example.com/a' }]);
});
it.each(entryPoints)("%s defaults the model to the provider's own default", async (_name, run) => {