|
| 1 | +# Browser Entry Button |
| 2 | + |
| 3 | +**Branch:** `feat/browser-entry-button` |
| 4 | +**Priority:** P1 |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Goal |
| 9 | + |
| 10 | +Add a single entry button in the empty chat state that triggers browser automation setup via OpenCode command. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Implementation |
| 15 | + |
| 16 | +### Location |
| 17 | +`packages/app/src/app/pages/session.tsx` L1025-1037 |
| 18 | + |
| 19 | +### Code references |
| 20 | +- Empty state render: `packages/app/src/app/pages/session.tsx:1039-1049` |
| 21 | +- Command runner used by slash commands: `packages/app/src/app/pages/session.tsx:645-663` (`runOpenCodeCommand`) |
| 22 | +- Command registry wiring: `packages/app/src/app/pages/session.tsx:881-892` |
| 23 | +- Programmatic command execution: `packages/app/src/app/command-state.ts:293-313` |
| 24 | +- `.opencode/commands` loader: `packages/app/src/app/command-state.ts:334` |
| 25 | +- Existing button pattern: `packages/app/src/app/pages/dashboard.tsx:557` (`onClick={() => props.runCommand(command)}`) |
| 26 | +- Command write API (desktop): `packages/app/src/app/lib/tauri.ts:223` (`opencodeCommandWrite`) |
| 27 | +- Frontmatter parser: `packages/app/src/app/utils/index.ts:271` (`parseTemplateFrontmatter`) |
| 28 | + |
| 29 | +### Current empty state |
| 30 | +```tsx |
| 31 | +<Show when={props.messages.length === 0}> |
| 32 | + <div class="text-center py-16 px-6 space-y-6"> |
| 33 | + <h3 class="text-xl font-medium">Start a conversation</h3> |
| 34 | + <p class="text-gray-10 text-sm">Describe what you want to do...</p> |
| 35 | + </div> |
| 36 | +</Show> |
| 37 | +``` |
| 38 | + |
| 39 | +### Add button |
| 40 | +```tsx |
| 41 | +<Show when={props.messages.length === 0}> |
| 42 | + <div class="text-center py-16 px-6 space-y-6"> |
| 43 | + <div class="w-16 h-16 bg-gray-2 rounded-3xl mx-auto flex items-center justify-center border border-gray-6"> |
| 44 | + <Zap class="text-gray-7" /> |
| 45 | + </div> |
| 46 | + <div class="space-y-2"> |
| 47 | + <h3 class="text-xl font-medium">What do you want to do?</h3> |
| 48 | + <p class="text-gray-10 text-sm max-w-sm mx-auto"> |
| 49 | + Pick a starting point or just type below. |
| 50 | + </p> |
| 51 | + </div> |
| 52 | + <div class="flex justify-center"> |
| 53 | + <button |
| 54 | + type="button" |
| 55 | + class="px-4 py-2.5 rounded-xl border border-gray-6 bg-gray-2 text-sm text-gray-12 hover:bg-gray-3 hover:border-gray-7 transition-all" |
| 56 | + onClick={() => { |
| 57 | + void (async () => { |
| 58 | + const command = await ensureBrowserSetupCommand(); |
| 59 | + if (command) { |
| 60 | + runOpenCodeCommand(command); |
| 61 | + } |
| 62 | + })(); |
| 63 | + }} |
| 64 | + > |
| 65 | + Automate your browser |
| 66 | + </button> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | +</Show> |
| 70 | +``` |
| 71 | + |
| 72 | +**Why `runOpenCodeCommand`** |
| 73 | +- It handles `$ARGUMENTS` and opens the command run modal when needed (`session.tsx:645-663`) |
| 74 | +- Keeps behavior identical to slash commands |
| 75 | + |
| 76 | +### Create OpenCode command |
| 77 | +File: `.opencode/commands/browser-setup.md` |
| 78 | + |
| 79 | +**App template source:** `packages/app/src/app/data/commands/browser-setup.md` |
| 80 | + |
| 81 | +If the command is missing in the active workspace, the button auto-writes it via `opencodeCommandWrite` (desktop only) before running. |
| 82 | + |
| 83 | +```markdown |
| 84 | +--- |
| 85 | +name: browser-setup |
| 86 | +description: Guide user through Chrome browser automation setup |
| 87 | +--- |
| 88 | + |
| 89 | +Help the user set up browser automation. |
| 90 | + |
| 91 | +1. Ask: "Do you have Chrome installed on this computer?" |
| 92 | +2. If they say no or are unsure, guide them to install Chrome |
| 93 | +3. If yes, check if browser MCP/plugin is available |
| 94 | +4. If not available, guide them to install the OpenCode browser extension |
| 95 | +5. Once setup is complete, offer to run a simple first task (e.g., "Let's try opening a webpage") |
| 96 | +``` |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Flow (handled by LLM) |
| 101 | + |
| 102 | +1. User clicks "Automate your browser" |
| 103 | +2. Command triggers, LLM asks: "Do you have Chrome installed?" |
| 104 | +3. User answers Yes/No |
| 105 | +4. LLM guides through extension install if needed |
| 106 | +5. LLM offers first browser task |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## NOT doing |
| 111 | + |
| 112 | +- Custom guided prompts in the UI |
| 113 | +- Multiple entry buttons (start with one) |
| 114 | +- Hardcoded installation scripts |
0 commit comments