|
| 1 | +package agents |
| 2 | + |
| 3 | +import "testing" |
| 4 | + |
| 5 | +// droidTrustDialogPane is a trimmed capture of Droid v0.178.0's interactive |
| 6 | +// "Trust this folder?" startup dialog. The pre-selected option renders as |
| 7 | +// "> 1. Trust this folder", i.e. it uses the same ">" as the real input box — |
| 8 | +// the exact shape that made the old bare-">" WaitFor mistake the dialog for the |
| 9 | +// prompt and swallow the first real prompt. |
| 10 | +const droidTrustDialogPane = `│ Trust this folder? │ |
| 11 | +│ │ |
| 12 | +│ /tmp/e2e-repo-4116086897 │ |
| 13 | +│ │ |
| 14 | +│ Droid will read, edit, and run files in this folder, and load any project │ |
| 15 | +│ configuration it defines, including hooks and MCP servers that can execute │ |
| 16 | +│ commands on your machine. │ |
| 17 | +╰──────────────────────────────────────────────────────────────────────────────╯ |
| 18 | +
|
| 19 | +> 1. Trust this folder |
| 20 | + 2. Exit without trusting |
| 21 | +
|
| 22 | +Enter to confirm · Esc to exit` |
| 23 | + |
| 24 | +// droidInteractivePromptPane is the real idle REPL after trust is granted: the |
| 25 | +// input box with a bare ">" and no dialog chrome. This must NOT be classified |
| 26 | +// as a startup dialog. |
| 27 | +const droidInteractivePromptPane = ` Auto (High) · allow all commands claude-haiku-custom (High) [custom] |
| 28 | +╭──────────────────────────────────────────────────────────────────────────────╮ |
| 29 | +│ > │ |
| 30 | +╰──────────────────────────────────────────────────────────────────────────────╯ |
| 31 | +? for help TMUX ⧉` |
| 32 | + |
| 33 | +// TestIsDroidStartupDialog_DetectsTrustDialog is the regression guard for the |
| 34 | +// Droid v0.178.0 break: the trust dialog must be recognized so StartSession |
| 35 | +// keeps sending Enter to confirm it instead of mistaking "> 1. Trust this |
| 36 | +// folder" for the interactive prompt and sending the first real prompt into a |
| 37 | +// dialog that swallows it. |
| 38 | +func TestIsDroidStartupDialog_DetectsTrustDialog(t *testing.T) { |
| 39 | + t.Parallel() |
| 40 | + if !isDroidStartupDialog(droidTrustDialogPane) { |
| 41 | + t.Fatal("trust dialog should be detected as a startup dialog") |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +// TestIsDroidStartupDialog_DetectsByOptionLabel confirms detection keys off the |
| 46 | +// "exit without trusting" option too, so a title-text change in a future Droid |
| 47 | +// release does not silently re-break the handshake. |
| 48 | +func TestIsDroidStartupDialog_DetectsByOptionLabel(t *testing.T) { |
| 49 | + t.Parallel() |
| 50 | + const optionOnly = "> 1. Trust folder\n 2. Exit without trusting" |
| 51 | + if !isDroidStartupDialog(optionOnly) { |
| 52 | + t.Fatal("the trust dialog's option labels alone should be enough to detect it") |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +// TestIsDroidStartupDialog_IgnoresInteractivePrompt ensures the real prompt is |
| 57 | +// not classified as a dialog — otherwise StartSession would loop dismissing a |
| 58 | +// dialog that isn't there and never hand back a usable session. |
| 59 | +func TestIsDroidStartupDialog_IgnoresInteractivePrompt(t *testing.T) { |
| 60 | + t.Parallel() |
| 61 | + if isDroidStartupDialog(droidInteractivePromptPane) { |
| 62 | + t.Fatal("bare interactive prompt should not be classified as a startup dialog") |
| 63 | + } |
| 64 | +} |
0 commit comments