flow-extension/launch.sh
type-two 501431bf59 Flow rinse: browser downloads, fast-fail, autoStart, launcher + self-healing launchd
- background.js: chrome.downloads via page session (no CSP/base64)
- content.js: fast-fail on Flow error banner, image vs video timeouts, autoStart
- local_server_example.py: /enqueue + /save, downloads/ output, resume-skip
- launch.sh: idempotent server-up + caffeinate + single-tab focus
- install.sh + plist: self-healing agent every 10 min (TCC-safe App Support copy)
- flowclient.py: enqueue/wait_for helper for game projects
- README: full setup + macOS TCC gotcha

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 01:20:32 +10:00

58 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# One-command Flow rinse launcher (macOS). Not headless — Brave must be logged in —
# but fully unattended once the tab is open and Auto-start is ticked in the popup.
#
# ./launch.sh https://labs.google/fx/tools/flow/project/XXXXXXXX
# FLOW_URL=... ./launch.sh
#
# Does three things: start the queue server if it's down, keep the Mac awake, and
# open OR focus a single Flow tab in Brave (never spawns duplicates).
#
# Scheduled every 10 min via launchd for self-healing (see install.sh).
# NOTE: launchd can't execute scripts inside ~/Documents (macOS TCC blocks it),
# so the agent runs a COPY at "~/Library/Application Support/flowrinse/" —
# after editing this file or local_server_example.py, re-run ./install.sh to resync.
set -e
DIR="$(cd "$(dirname "$0")" && pwd)"
URL="${1:-$FLOW_URL}"
if [ -z "$URL" ]; then
echo "Usage: ./launch.sh <flow_project_url> (or set FLOW_URL)"
exit 1
fi
# 1. queue server on 8017 (nc check avoids consuming a task via /next-task)
if ! nc -z localhost 8017 2>/dev/null; then
( cd "$DIR" && caffeinate -s python3 -B local_server_example.py >/tmp/flowrinse.log 2>&1 & )
echo "started queue server + caffeinate (log: /tmp/flowrinse.log)"
sleep 1
else
echo "queue server already up on 8017"
fi
# 2. open or focus ONE Flow tab (reuses an existing one so it can't double-run).
# Only `activate` (steal system focus) when opening fresh — on the 10-min launchd
# tick an existing tab is re-selected inside Brave without yanking you out of
# whatever you're doing. Selecting the tab also keeps Memory Saver from discarding it.
osascript <<OSA
tell application "Brave Browser"
set found to false
repeat with w in windows
set i to 0
repeat with t in tabs of w
set i to i + 1
if (URL of t) contains "tools/flow/project" then
set active tab index of w to i
set index of w to 1
set found to true
end if
end repeat
end repeat
if not found then
activate
open location "$URL"
end if
end tell
OSA
echo "Brave focused on Flow. With Auto-start ticked, the rinse begins on load."