Skip to content

Commit 60f4cf2

Browse files
mreiderclaude
andcommitted
Gate builder AI guide on explicit session state
The AI guide was inferring login state from page DOM alone, so on non-login landing pages it would acknowledge login was needed AND ask "what do you want to build?" in the same message, violating the one-step-at-a-time rule. Builder now passes "Saved session for this site: yes|no" in the page context. The system prompt's Step 1/2 boundary is rewritten around that flag — when no session is saved, the response must be login instructions and {{DONE}} only, no capability suggestions in the same message. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 96f3763 commit 60f4cf2

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

electron/ai.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,23 @@ Each response should advance exactly ONE step. Never combine steps. Never show s
1111
## Step-by-step flow
1212
1313
**Step 1 — Login check:**
14-
When first analyzing a page, check if it's a DEDICATED login page — meaning a password field is the main content and the page's purpose is authentication. A "sign in" link in a nav bar or header does NOT mean login is needed — that's just a normal page with a login link. If the user message says they're already logged in or have a saved session, skip to Step 2. If it IS a login page:
15-
- Tell the user to log in normally — complete all steps including 2FA, security questions, or any other verification the site requires.
16-
- Assure them: Purroxy never sees their credentials. Everything stays in the browser. The session is encrypted and stored locally on their machine so future automations can run without logging in again.
17-
- Tell them to click Done once they're fully logged in.
18-
- Show ONLY the {{DONE}} button. No suggestions, no analysis.
19-
If NO login is needed: skip to Step 2.
14+
Look at the "Saved session for this site" line in your page context.
15+
16+
- **"Saved session for this site: yes"** → skip to Step 2. Do NOT ask the user to log in again.
17+
- **"Saved session for this site: no"** → you MUST gate on login before doing anything else, UNLESS the site is plainly public-read (news, weather, search, docs) AND the current page shows no "Sign in" / "Log in" / "My Account" affordance anywhere. When in doubt, assume login is needed.
18+
19+
When login is needed, your entire response is ONLY:
20+
- One sentence: the USER should log in through the site's own flow (including 2FA, security questions, whatever the site asks for).
21+
- One sentence reassuring them Purroxy never sees their credentials — session is encrypted and stored locally so future runs don't need it.
22+
- One sentence telling them to click Done once they're fully logged in.
23+
- The {{DONE}} button on its own line.
24+
25+
Do NOT in the same message analyze the page, suggest capabilities, say "we're not on a login page", or ask what they want to build. Those come AFTER "[Session saved]". Never combine login instructions with capability suggestions — that is the most common failure mode and users hate it.
2026
2127
IMPORTANT: Never say "I" will log in or "I" will save. The USER logs in. The USER clicks Done. Purroxy stores the session — not you.
2228
2329
**Step 2 — Analyze & suggest:**
24-
After the user logs in (you'll see "[Session saved]"), OR if no login was needed, analyze the page and suggest 3-5 capabilities. Keep each suggestion to one line. Do NOT include a record button yet. Ask which one they'd like to build, or let them type their own.
30+
Only enter this step when either (a) "Saved session for this site: yes", or (b) you've seen "[Session saved]" in the conversation. Analyze the page and suggest 3-5 capabilities. Keep each suggestion to one line. Do NOT include a record button yet. Ask which one they'd like to build, or let them type their own.
2531
2632
**Step 2.5 — Check for duplicates:**
2733
When the user picks a capability to build, FIRST check the "Existing capabilities for this site" in your context. If a matching or very similar capability already exists, tell them and offer two options:

src/views/Builder.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ export default function Builder() {
114114
context += `\n\nExisting capabilities for this site:\n${siteCaps.map(c => `- "${c.name}": ${c.description}`).join('\n')}`
115115
}
116116

117+
// Tell the AI whether a session is already saved. Without this, it has to
118+
// guess from page DOM alone and sometimes asks "what do you want to build?"
119+
// before the user has logged in.
120+
const hasSavedSession = sessionSaved || !!(siteProfile && (siteProfile as any).sessionEncrypted)
121+
context += `\n\nSaved session for this site: ${hasSavedSession ? 'yes' : 'no'}`
122+
117123
const currentActions = actionsRef.current
118124
if (currentActions.length > 0) {
119125
const recent = currentActions.slice(-20)

0 commit comments

Comments
 (0)