GuidesUpdated

Coding agent changed the code but the browser shows the old app

Trace a stale local preview through checkout, running server, port, hot reload, browser cache and data request before asking the agent to edit again.

On this page

The agent's diff and your browser can both be real yet show different versions of the app. Say the agent changed a button label, but the preview still shows the old one. First confirm which file changed and which process serves the page; only then look at hot reload or cache. That saves you a speculative edit.

Canopy local service output and preview beside the project workspace
Canopy local service output and preview beside the project workspace

Confirm the change is in the checkout you're running

Ask the agent for the file, branch, worktree path and changed line. In that checkout, check Git status, the diff and the latest commit. An empty diff may mean the change was committed, or that you're in another worktree. Search for the new label in the file the app imports. If another agent edited the same feature elsewhere, compare paths before restarting anything.

  • Write down the text or behavior you expect to see.
  • Don't reset a checkout you can't explain.

Match the browser URL to one live server

Read the service's command, directory and printed URL in Canopy Servers or the terminal, and open that exact URL. When two worktrees run the same framework, one may move to another port or fail to start, while an old tab still points at the first. Restart the intended service only once you know its directory and command. A green process badge is weaker evidence than a successful page request from the right server.

Keep these four identifiers together while you debug a stale preview.
What changedWhat servesWhat opensWhat you observed
File, branch, worktreeCommand, directory, printed portFull local URL and browser tabExpected marker versus actual marker

Tell hot reload failure from a stale browser response

Make a harmless visible edit and watch the service log. If the server never reports it, check the watcher, the imported path, or your container and filesystem setup. Vite documents missed file changes and failed hot reloads; a case mismatch in an import is one cause.

If the server did react, reload the exact URL once. Chrome DevTools' Network panel can disable the HTTP cache while it's open. Compare the document and asset requests before clearing data. A hard reload is a diagnostic; it fixes nobody else's browser.

  • In a Next.js App Router page with stale fetched data, do a full reload; its dev Server Components HMR cache keeps fetch responses across hot updates.
  • If the app has a service worker, inspect its versions and Cache Storage in the Application panel.
  • Rule out the wrong server or port before clearing site storage.

Check whether the old value comes from data

If the new label appears but a list or count is still old, find the request that supplies it in the Network panel. Record its URL, status and a safe excerpt. Compare the frontend's API target with the backend and database you meant to run. Fresh JavaScript can still call an older backend or another test account. For a hosted Preview, check its deployment commit; local refreshes can't update a hosted build.

  • Use one test record with a recognizable, non-sensitive marker.
  • Never copy production credentials into local or preview environments.

Give the agent a diagnosis and retest the symptom

Tell the agent which boundary failed: checkout, port, file watcher, browser cache, service worker or data source. Ask for one scoped fix tied to that evidence. Then reopen the printed URL, repeat the original action and read the latest diff. If configuration changed, restart or redeploy the affected environment. The handoff names the checkout, URL, expected marker and result.

  • A refreshed label closes one symptom; test the changed interaction too.
  • If a server moved ports, record both URLs.

Copyable resources

Stale preview diagnosis card

Use a harmless visible marker; redact private URLs, tokens and response bodies before sharing.

Expected visible change: [ ]
Agent file / branch / worktree: [ ]
Git status, diff or commit showing the change: [ ]
Service command / directory / printed URL: [ ]
Browser URL opened: [ ]
Server log reported the edit? [yes / no / unknown]
Full reload changed the page? [yes / no]
HTTP cache or service worker involved? [evidence]
If data is stale, request URL / status / target: [ ]
First differing boundary and smallest fix: [ ]
Retest after last edit: [ ]

Frequently asked questions

Why does the code change appear in Git but not in my local browser?

Compare the changed checkout with the service's working directory and the browser's full URL. A different worktree or port usually shows up without touching code. Then check server reload and browser requests.

Should I clear the browser cache immediately?

No. First confirm the right server and port, then compare responses in the Network panel with cache disabled. If the app uses a service worker, inspect its cache and lifecycle before clearing site data.

Can hot reload update code while the page still shows old data?

Yes. A data request can hit another backend, and some frameworks cache fetched responses across hot updates in development. Inspect the request and do a full reload to tell the cases apart.

Will restarting the agent fix the preview?

No. Restart the service that serves the page if its process or watcher is the problem. Restarting the agent doesn't change which URL the browser opens or which backend it calls.

More questions and answers →

Sources and further reading