# Add Live Search to a Phoenix LiveView Page from a Linear Issue

An agent adds a debounced phx-change search to a LiveView profile page that filters songs by title or artist, matching % and _ literally.

[Run this on Rush](https://cloud.getrush.ai/run/add-song-search/phoenix-liveview/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent works in fly-apps/live_beats on `lib/live_beats_web/live/profile_live.ex` and `lib/live_beats/media_library.ex`. Before writing code it started Postgres and ran `mix test`, which stopped at startup: `LiveBeats.Application.load_serving/0` downloads a Whisper model through Bumblebee 0.1.2, which fails with `{:error, {:no_scheme}}` on HuggingFace's relative redirect.

`list_profile_songs/3` gains a `search` argument and an `ilike` filter on `title` or `artist`, escaping `%`, `_` and `\`. The profile page gets a form with `phx-change="search"` and `phx-debounce="300"`, a `handle_event("search", ...)` that resets the `songs` stream, and a "No songs match" line. The test in `profile_live_test.exs` drives the form with `render_change`, and `song_fixture` now passes `server_ip` as a string, because every fixture insert failed without it.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "A Linear issue labeled agent says: \"Add Live Search to a Phoenix LiveView Page. Add a search box on the profile page that filters songs by title and artist as the user types, debounced, using phx-change.\" Do the work in this repository, add tests for it, run mix test with Postgres started in the sandbox, and open a pull request that links back to the issue.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

Tried on fly-apps/live_beats at ac97804: 4 files changed, 88 insertions(+), 6 deletions(-). `mix test` cannot start on this commit, before or after the change, because of the Whisper download. With `whisper_serving? = false` set temporarily in `application.ex` and kept out of the diff, the new test passed, `3 tests, 0 failures, 2 excluded`, and the full suite went from `34 tests, 9 failures` to `35 tests, 5 failures`. The 4 fewer failures come from the `song_fixture` fix, not from search; the 5 left failed before the change, and the failing set varies between runs because a whisper transcription task sometimes crashes with `:bad_file`. There was no Linear issue to read.

For the reviewer: how to fix the startup download, by skipping the model in tests or upgrading Bumblebee. Songs inserted into the stream while a filter is active are not filtered, and the debounce was never tried in a browser.

## Run it on every Linear issue labeled agent

An automation with a `linear` trigger on `linear.issue.labeled` and the label `agent` runs the `linear-label-to-pr` recipe's prompt when someone in your Rush org labels a UI issue. This one named the profile page and the title and artist fields, so the filter matches those two only.

## Why run it on Rush?

The suite was broken before the agent arrived. The run traced the failure to a third-party download, kept its workaround out of the diff, and found the fixture bug that stopped every `song_fixture` insert.

## Frequently asked questions

### Is the whole test suite green?

No. Without the temporary workaround `mix test` exits 1 at startup, before and after. With it, 5 of 35 fail: the delete-modal stream test and four `MediaLibraryTest` comparisons, all failing before the change too.

### Why does the new test view another user's profile?

The owner's view hits the delete-modal stream failure that already broke the uploads test. The search form is the same on any profile, so the test opens `user2`'s profile, adds three songs to it and searches those.

## More Phoenix LiveView jobs

- [Add Structured Logging to a Phoenix LiveView App](https://getrush.ai/run/add-structured-logging/phoenix-liveview/)
- [Write LiveView Tests for a Phoenix App](https://getrush.ai/run/write-liveview-tests/phoenix-liveview/)
- [Add Oban Background Jobs to a Phoenix LiveView App](https://getrush.ai/run/add-background-jobs/phoenix-liveview/)

## More jobs like this: Turn a Linear label into a PR

- [Add a Native Splash Screen to a Flutter App](https://getrush.ai/run/add-splash-screen/flutter/)
- [Add a SQLite Database to a Reflex App](https://getrush.ai/run/add-sqlite-database/reflex/)
- [Add Server-Side Rendering to a Lit Component](https://getrush.ai/run/add-ssr/lit/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
