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 πŸ“–

fix: offer Guide Me only where a step can actually be replayed

Luis Ortiz2727fea00378
diff --git a/AGENTS.md b/AGENTS.md
index 20f342d..14f2319 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -211,6 +211,13 @@ null.
are the reverse β€” desktop only. `inputType` is mostly DOM-only, but a desktop typing step sets it to
`password` when the field says so, because that is the one input type a screen capture can learn.
+Guide Me is the one place a `source` check is correct, through `isReplayable`. It replays against a
+live DOM, so a step is replayable only when its source is `dom` β€” or absent, which means it predates
+the field and was therefore a DOM capture. The old test was "does the step have an `elementMeta` at
+all", which was true before desktop existed and is now true of every desktop step; it left a Guide
+Me button on guides that can never be replayed. The button is not rendered at all when nothing is
+replayable, rather than rendered disabled, because on desktop it could never become enabled.
+
Consumers must not branch on `source`. Read the shared fields first and treat the DOM-only ones as
refinements: `buildFallbackDescription` reaches the same wording through `role === 'checkbox'` that
it reaches through `tag === 'input' && inputType === 'checkbox'`. Guide Me is the exception by
diff --git a/packages/core/src/guideme/__tests__/session.test.ts b/packages/core/src/guideme/__tests__/session.test.ts
new file mode 100644
index 0000000..9f87e0e
--- /dev/null
+++ b/packages/core/src/guideme/__tests__/session.test.ts
@@ -0,0 +1,30 @@
+import { describe, expect, it } from 'vitest';
+import type { Step } from '@/core/guides/types';
+import { isReplayable } from '../session';
+
+const meta = (source?: 'dom' | 'uia' | 'screen' | 'ax') =>
+ ({
+ source,
+ textContent: null,
+ ariaLabel: null,
+ placeholder: null,
+ altText: null,
+ name: null,
+ role: null,
+ rect: { x: 0, y: 0, width: 1, height: 1 },
+ devicePixelRatio: 1,
+ }) as Step['elementMeta'];
+
+describe('isReplayable', () => {
+ it('replays a DOM step, and one captured before source existed', () => {
+ expect(isReplayable({ elementMeta: meta('dom') })).toBe(true);
+ expect(isReplayable({ elementMeta: meta(undefined) })).toBe(true);
+ });
+
+ it('never replays a desktop step or one with no element at all', () => {
+ expect(isReplayable({ elementMeta: meta('uia') })).toBe(false);
+ expect(isReplayable({ elementMeta: meta('screen') })).toBe(false);
+ expect(isReplayable({ elementMeta: meta('ax') })).toBe(false);
+ expect(isReplayable({})).toBe(false);
+ });
+});
diff --git a/packages/core/src/guideme/session.ts b/packages/core/src/guideme/session.ts
index 67587a2..b1eb24a 100644
--- a/packages/core/src/guideme/session.ts
+++ b/packages/core/src/guideme/session.ts
@@ -1,5 +1,5 @@
import { localStorage } from '@/core/env';
-import type { Step } from '@/core/guides/types';
+import { type ElementMeta, elementSource, type Step } from '@/core/guides/types';
export interface GuideMeSession {
guideId: string;
@@ -62,3 +62,7 @@ export async function getSession(): Promise<GuideMeSession | null> {
}
export { BLOCKED_KEY, MANUAL_KEY, SESSION_KEY, STEP_KEY };
+
+export function isReplayable(step: { elementMeta?: ElementMeta }): boolean {
+ return step.elementMeta !== undefined && elementSource(step.elementMeta) === 'dom';
+}
diff --git a/packages/ui/src/fullview/GuideContent.tsx b/packages/ui/src/fullview/GuideContent.tsx
index fb6f1dd..9114daf 100644
--- a/packages/ui/src/fullview/GuideContent.tsx
+++ b/packages/ui/src/fullview/GuideContent.tsx
@@ -1,4 +1,5 @@
import { History, Loader2, Play, Sparkles } from 'lucide-react';
+import { isReplayable } from '@mimik/core/guideme/session';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { TypeAnimation } from 'react-type-animation';
import { i18n } from '@mimik/core/env';
@@ -462,14 +463,13 @@ export default function GuideContent({ guideId, initialStepId, initialTool }: Gu
{domain}
</span>
)}
- {!editing && !preview && viewSteps.length > 0 && (
+ {!editing && !preview && viewSteps.some(isReplayable) && (
<button
onClick={() => {
panel.open();
void send('startGuideMe', { guideId });
}}
- disabled={!viewSteps.some((s) => s.elementMeta)}
- className="inline-flex items-center gap-1.5 text-[11px] font-semibold text-primary-foreground bg-primary hover:bg-primary/90 px-3 py-0.5 rounded-full transition-colors disabled:opacity-30 disabled:cursor-not-allowed ml-auto"
+ className="inline-flex items-center gap-1.5 text-[11px] font-semibold text-primary-foreground bg-primary hover:bg-primary/90 px-3 py-0.5 rounded-full transition-colors ml-auto"
>
<Play size={11} />
{i18n.t('fullview_guideMe')}
diff --git a/src/ui/sidepanel/GuideEditor.tsx b/src/ui/sidepanel/GuideEditor.tsx
index 621a74a..e4aadaf 100644
--- a/src/ui/sidepanel/GuideEditor.tsx
+++ b/src/ui/sidepanel/GuideEditor.tsx
@@ -7,6 +7,7 @@ import StepCard from '@mimik/ui/sidepanel/StepCard';
import { ArrowLeft, Maximize2, Play } from 'lucide-react';
import { useCallback, useEffect, useState } from 'react';
import { i18n } from '#imports';
+import { isReplayable } from '@/core/guideme/session';
import { actionSteps, isBlock, stepNumbers } from '@/core/guides/blocks';
import { getGuide, onGuidesChanged } from '@/core/guides/service';
import type { Guide, Screenshot, Step } from '@/core/guides/types';
@@ -130,7 +131,7 @@ export default function GuideEditor({ guideId, onBack, onGuideMe }: GuideEditorP
{data.steps.length > 0 &&
(() => {
- const replayable = data.steps.some((s) => s.elementMeta);
+ const replayable = data.steps.some(isReplayable);
const label = i18n.t(replayable ? 'editor.guideMe' : 'editor.guideMeUnavailable');
return (
<Tooltip>