Skip to content

The agent that turns websites into APIs!

fix: address PR review comments

kalil032162a8c0fbc23e
diff --git a/chrome-extension/src/background/service-worker.ts b/chrome-extension/src/background/service-worker.ts
index 6fe8904..806bd21 100644
--- a/chrome-extension/src/background/service-worker.ts
+++ b/chrome-extension/src/background/service-worker.ts
@@ -78,6 +78,8 @@ function broadcastMessage(message: Record<string, unknown>): void {
}
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
+ // codegenAction messages are handled by the dedicated listener below
+ if (message.type === 'codegenAction') return false
handleMessage(message)
.then(sendResponse)
.catch((error) => {
@@ -282,7 +284,7 @@ def run():
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
- page.goto("${tab.url || 'about:blank'}")
+ page.goto("${escapePythonString(tab.url || 'about:blank')}")
`
diff --git a/chrome-extension/src/components/session-selector.tsx b/chrome-extension/src/components/session-selector.tsx
index bae2e65..1f5962b 100644
--- a/chrome-extension/src/components/session-selector.tsx
+++ b/chrome-extension/src/components/session-selector.tsx
@@ -152,7 +152,7 @@ export function SessionSelector({
key={session.id}
className="group flex items-center gap-2 px-3 py-2 hover:bg-white/5 cursor-pointer transition-colors"
onClick={() => {
- if (!editingId && session.id !== activeSessionId) {
+ if (!editingId && session.id !== activeSessionId && !isCapturing) {
onSwitchSession(session.id)
setIsOpen(false)
}
diff --git a/chrome-extension/src/content/codegen-recorder.ts b/chrome-extension/src/content/codegen-recorder.ts
index 19099c6..5e382b0 100644
--- a/chrome-extension/src/content/codegen-recorder.ts
+++ b/chrome-extension/src/content/codegen-recorder.ts
@@ -161,12 +161,10 @@ function commitPendingInput() {
if (!lastInputElement) return
const selector = getSelector(lastInputElement)
- const value = escapeString(lastInputElement.value)
+ const value = lastInputElement.value
- if (value) {
- console.log('[Codegen] Fill input:', selector, 'with value:', value)
- sendAction('fill', { selector, value })
- }
+ console.log('[Codegen] Fill input:', selector, 'with value:', value)
+ sendAction('fill', { selector, value })
lastInputElement = null
if (inputTimeout) {
@@ -182,7 +180,7 @@ function handleChange(event: Event) {
if (!target || target.tagName !== 'SELECT') return
const selector = getSelector(target)
- const value = escapeString(target.value)
+ const value = target.value
sendAction('select', { selector, value })
}
@@ -240,8 +238,7 @@ function startRecording() {
isRecording = true
lastUrl = window.location.href
- // Send initial navigation
- sendAction('navigate', { url: lastUrl })
+ // Don't send initial navigation - startCodegen() already adds page.goto() in the template
document.addEventListener('click', handleClick, true)
document.addEventListener('input', handleInput, true)
diff --git a/chrome-extension/src/shared/storage.ts b/chrome-extension/src/shared/storage.ts
index eaaa1a6..39768c4 100644
--- a/chrome-extension/src/shared/storage.ts
+++ b/chrome-extension/src/shared/storage.ts
@@ -42,7 +42,7 @@ export async function saveSession(session: Session): Promise<void> {
const sessions = await getAllSessions()
const index = sessions.findIndex(s => s.id === session.id)
if (index >= 0) {
- sessions[index] = session
+ sessions[index] = { ...sessions[index], ...session }
} else {
sessions.push(session)
}
@@ -51,10 +51,14 @@ export async function saveSession(session: Session): Promise<void> {
export async function deleteSession(sessionId: string): Promise<void> {
const sessions = await getAllSessions()
+ const deleted = sessions.find(s => s.id === sessionId)
const filtered = sessions.filter(s => s.id !== sessionId)
await saveAllSessions(filtered)
- // Also clean up captured requests for this session
+ // Clean up captured requests and chat history for this session
await chrome.storage.local.remove(`capturedRequests_${sessionId}`)
+ if (deleted?.runId) {
+ await chrome.storage.local.remove(`chat_${deleted.runId}`)
+ }
}
export async function getActiveSessionId(): Promise<string | null> {
@@ -115,6 +119,8 @@ export async function saveCurrentSession(session: Partial<Session> & { runId: st
...session,
}
await saveSession(updatedSession)
+ } else {
+ console.warn('saveCurrentSession: no active session, save skipped')
}
}
diff --git a/chrome-extension/src/sidepanel/side-panel.tsx b/chrome-extension/src/sidepanel/side-panel.tsx
index fc1a7a5..1d7e3e5 100644
--- a/chrome-extension/src/sidepanel/side-panel.tsx
+++ b/chrome-extension/src/sidepanel/side-panel.tsx
@@ -117,9 +117,24 @@ export function SidePanel() {
case 'sessionSwitched':
case 'sessionDeleted':
case 'sessionRenamed':
- // Refresh sessions list
+ // Refresh sessions list and load the active session's data
chrome.runtime.sendMessage({ type: 'getState' }).then(res => {
- if (res) setState(prev => ({ ...prev, ...res }))
+ if (res) {
+ setState(prev => ({ ...prev, ...res }))
+ const sessions = res.sessions as Session[] | undefined
+ const newActiveSession = sessions?.find(s => s.id === res.activeSessionId)
+ if (newActiveSession) {
+ setMessages(newActiveSession.messages || [])
+ setCodegenSavedPath(newActiveSession.codegenSavedPath || null)
+ setCodegenVisiblePath(newActiveSession.codegenVisiblePath || null)
+ setCodegenVisibleDirectory(newActiveSession.codegenVisibleDirectory || null)
+ } else {
+ setMessages([])
+ setCodegenSavedPath(null)
+ setCodegenVisiblePath(null)
+ setCodegenVisibleDirectory(null)
+ }
+ }
})
break
case 'modeChanged':
@@ -707,9 +722,8 @@ export function SidePanel() {
name="saveLocation"
checked={settings.saveLocation !== 'downloads'}
onChange={() => {
- const customPath = prompt('Enter custom folder path:', '/Users/')
- if (customPath) {
- const newSettings = { ...settings, saveLocation: customPath }
+ if (settings.saveLocation === 'downloads') {
+ const newSettings = { ...settings, saveLocation: '/Users/' }
setSettings(newSettings)
chrome.runtime.sendMessage({ type: 'saveSettings', settings: newSettings })
}
@@ -722,8 +736,18 @@ export function SidePanel() {
{settings.saveLocation !== 'downloads' && (
<div className="mt-2 p-2 bg-background-elevated rounded-lg">
- <div className="text-xs text-white/50 mb-1">Current path:</div>
- <div className="text-xs text-white/80 font-mono break-all">{settings.saveLocation}</div>
+ <div className="text-xs text-white/50 mb-1">Custom path:</div>
+ <input
+ type="text"
+ value={settings.saveLocation}
+ onChange={(e) => {
+ const newSettings = { ...settings, saveLocation: e.target.value }
+ setSettings(newSettings)
+ chrome.runtime.sendMessage({ type: 'saveSettings', settings: newSettings })
+ }}
+ className="w-full text-xs text-white/80 font-mono bg-background border border-white/10 rounded px-2 py-1 focus:outline-none focus:border-primary"
+ placeholder="/Users/..."
+ />
</div>
)}
</div>
diff --git a/examples/mintlify/api_client.py b/examples/mintlify/api_client.py
index f6361d6..6bb4282 100644
--- a/examples/mintlify/api_client.py
+++ b/examples/mintlify/api_client.py
@@ -120,7 +120,7 @@ class MintlifyClient:
3. Asset URLs containing the subdomain
"""
try:
- response = self.session.get(self.docs_url)
+ response = self.session.get(self.docs_url, timeout=15)
response.raise_for_status()
# Try to find subdomain in HTML/JS
@@ -234,6 +234,7 @@ class MintlifyClient:
self._get_api_url(),
json=body,
stream=True,
+ timeout=30,
)
response.raise_for_status()
diff --git a/src/reverse_api/auto_engineer.py b/src/reverse_api/auto_engineer.py
index 1697bc4..179f69f 100644
--- a/src/reverse_api/auto_engineer.py
+++ b/src/reverse_api/auto_engineer.py
@@ -577,5 +577,3 @@ class OpenCodeAutoEngineer(OpenCodeEngineer):
debug_log(f"Cleaned up MCP server: {self.mcp_name}")
except Exception:
pass # Ignore cleanup errors
-
-# https://www.migros.ch/fr/category/home
\ No newline at end of file
diff --git a/src/reverse_api/native_host.py b/src/reverse_api/native_host.py
index c140c69..74e6b21 100644
--- a/src/reverse_api/native_host.py
+++ b/src/reverse_api/native_host.py
@@ -503,7 +503,7 @@ class NativeHostHandler:
try:
run_id = message.get("run_id")
script_content = message.get("script")
- filename = message.get("filename", "codegen_script.py")
+ filename = Path(message.get("filename", "codegen_script.py")).name or "codegen_script.py"
save_location = message.get("save_location", "downloads")
domain = message.get("domain")