← Back to Pull requests

fix(renderer): keep the restored run's frames, candidates and publication lines (4/4) #229

Merged
constant1n0 merged 23 files (2417 lines) on Nov 30, 2026 15:02 UTC
View on GitHub
constant1n0 constant1n0 commented on Nov 30, 2026 13:49 UTC
Author

Later work left by the reviews of #222–#225: after a refused Start or restart, the restored run keeps its later frames, its candidates and its publication lines.

Chain context

  • Strategy: stacked PRs to main. This PR runs from 39ae1b2 to 2e997b8 and depends on PRs 1/4, 2/4 and 3/4.

  • Until those are merged, this PR also shows their commits. Review from 39ae1b2.
  • main (f700fd1)
     └─ PR 1/4  fix/checkpoint-restart-final-batch-a  f700fd1..de47b0d  (296 lines)
         └─ PR 2/4  fix/checkpoint-restart-final-batch-b  de47b0d..219ee2d  (795 lines)
             └─ PR 3/4  fix/checkpoint-restart-final-batch-c  219ee2d..39ae1b2  (563 lines)
                 └─ 📍 PR 4/4  fix/checkpoint-restart-final-batch-d  39ae1b2..2e997b8  (763 lines)
    

  • Size: 763 changed lines (677 added, 86 removed). That is over the 400-line budget, so size:exception is requested. About 490 lines are tests.
  • What changes

  • The restored run's frames are kept. After a refusal, frames from the run put back on screen were dropped until the next click. They now reach its transcript. They still do not touch the badge or the run's end.

  • Candidates as they stand at the refusal.

  • - The table is read through a ref, not from the click's render.
    - A candidates event from the outgoing run while the launch is pending is fetched, kept aside, and restored on refusal with the outgoing run's adapter.
    - That fetch has its own sequence counter, so it cannot cancel the new run's fetch.
    - A fetch started before the click is kept the same way.
  • Publication lines.

  • - Lines go to the run that was on screen when Publish was clicked.
    - While a launch is pending they are kept with that run's transcript, and they come back on refusal.
    - Once a launch is accepted they are dropped, as before.
  • Code structure. The candidates table has one writer, showCandidates. The outgoing record type is now OutgoingRun.

  • Regression tests from the independent verifier pin what an accepted launch keeps off screen. Two of them fail when the outgoing buffer is not released on acceptance.
  • Checks

  • Suites: npm --prefix renderer test: 1,037 passed. Lint and tsc -b are clean.

  • RED on every new rule:

  • - restored-run frames;
    - the outgoing run's candidates event;
    - a fetch started before the click;
    - the click's render;
    - publication lines.
  • Independent verification: no blockers.

  • Native review (resilience and reliability lenses): approved.
  • Risk

  • Routing while a launch is pending. The risk is which run receives frames, candidate fetches and publication lines. The existing tests of the previous restore still pass, including the one that rejects a previous run's frame during a pending spawn.
  • Out of scope (later work)

  • A kept candidates fetch that fails while the launch is pending is dropped, so a refusal restores neither the table nor an error (native review advisory).

  • A misplaced event from the outgoing or restored run does not refresh the wrong-root section.

  • A publish that fails during a pending launch still hides its error banner.
  • Diff: 2417 lines (+1986 / -431) across 23 files Reviewer: constant1n0 Review duration: 73m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.86) × (1 − Review Confidence (0.74)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.86 · 2417 lines diff across 23 files
    0.86
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.67 · 3 substantive comment(s)
    0.67
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    74%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Self Review self_review
    0.140
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    5 items
    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 13:49 UTC
    Bot

    <!-- codex-pull-request-review-summary -->
    <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5785e61d8b178a0af7c629a81df8b182ca730b66","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->

    <details>
    <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>

    This comment shows the latest Codex review activity on this pull request.

    | Review | Status | Commit | Review trigger |
    | --- | --- | --- | --- |
    | 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-30T13:53:20.778154Z">2026-11-30T13:53:20.778154Z</relative-time> | 5785e61 | PR opened |

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review" or "@codex security review".
  • Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    </details>

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 13:53 UTC
    Code Review
    renderer/src/AgentPanel.tsx:1
    @@ -3297,6 +3319,98 @@ export function AgentPanel() {
       /** True while a whole-outbox `candidates_list` is in flight (slice 5c). */
       const [isListingOutbox, setIsListingOutbox] = useState(false)
     
    +  /**
    +   * The launch generation whose run's transcript is on screen (S8): the run
    +   * a launch that started nothing put back, or else the current
    +   * generation's.
    +   */
    +  const screenGeneration = useCallback(
    +    () => restoredRunRef.current?.generation ?? spawnGenerationRef.current,
    +    [],
    +  )
    +
    +  /**
    +   * Appends `entry` to the transcript of generation `generation`'s run (S8):
    +   * on screen while that transcript is, kept aside with it while a launch
    +   * that replaced it is pending, and nowhere once a run replaced it.
    +   */
    +  const appendRunEntry = useCallback(
    +    (generation: number, entry: TranscriptItem) => {
    +      if (generation === screenGeneration()) {
    +        updateTranscript((previous) => appendTranscriptEntry(previous, entry))
    +        return
    +      }
    +      const outgoing = outgoingRunRef.current
    +      if (outgoing !== null && generation === outgoing.run.generation) {
    +        outgoing.transcript = appendTranscriptEntry(outgoing.transcript, entry)
    +      }
    +    },
    +    [screenGeneration, updateTranscript],
    +  )
    +
    +  /** Every candidates table write: rendered, and mirrored in {@link candidatesRef}. */
    +  const showCandidates = useCallback((next: CandidatesInventory | null) => {
    +    candidatesRef.current = next
    +    setCandidates(next)
    +  }, [])
    +
    +  /**
    +   * Shows a new inventory: the rows, the run id an approval request names,
    +   * and a clean slate for the rows' publication progress and the approval
    +   * block (slice 5b).
    +   */
    +  const applyInventory = useCallback(
    +    (inventory: CandidatesInventory) => {
    +      appliedInventoryRef.current += 1
    +      showCandidates(inventory)
    +      setRowPublications(EMPTY_ROW_PUBLICATIONS)
    +      setApprovingName(null)
    +      setApprovalInput('')
    +    },
    +    [showCandidates],
    +  )
    +
    +  /**
    +   * Fetches the rows behind `run`'s `candidates` event, by the run id the
    +   * shell minted (never a path), into that run's table wherever it is when
    +   * they land (S8): on screen while the run's transcript is, kept aside
    +   * with it while a launch that replaced it is pending, and nowhere once a
    +   * run replaced it -- so a response landing after the next Start never
    +   * dresses a new run in an old run's candidates. Sequenced with the fetches
    +   * for the table on screen when it starts for that table, and apart from
    +   * them when it starts for the outgoing run's; either is dropped once a
    +   * later fetch for the table on screen has started.
    +   */
    +  const fetchRunCandidates = useCallback(
    +    (run: TranscriptRun, runId: string) => {
    +      const forScreen = run.generation === screenGeneration()
    +      const screenRequest = forScreen
    +        ? (latestCandidatesRequestRef.current += 1)
    +        : latestCandidatesRequestRef.current
    +      const keptRequest = forScreen ? null : (latestKeptCandidatesRequestRef.current += 1)
    +      const isLatest = () =>
    +        mountedRef.current &&
    +        screenRequest === latestCandidatesRequestRef.current &&
    +        (keptRequest === null || keptRequest === latestKeptCandidatesRequestRef.current)

    <sub><sub>!P2 Badge</sub></sub> Sequence requests across the screen-to-outgoing transition

    When a run starts candidates fetch A while on screen, then a new launch moves it to outgoingRunRef and a later candidates event starts fetch B, A has keptRequest === null while B increments latestKeptCandidatesRequestRef. If B resolves first and A resolves afterward, this predicate still accepts A because the screen request counter never changed, allowing the older inventory to overwrite B; if the launch is refused, the restored run therefore shows stale candidates (and an older rejection can similarly surface after a newer success). Include pre-launch requests in the outgoing request ordering once their run moves off screen.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 13:53 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 5785e61d8b

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    </details>

    constant1n0 constant1n0 commented on code on Nov 30, 2026 14:35 UTC
    Code Review
    renderer/src/AgentPanel.tsx:1
    @@ -3297,6 +3319,98 @@ export function AgentPanel() {
       /** True while a whole-outbox `candidates_list` is in flight (slice 5c). */
       const [isListingOutbox, setIsListingOutbox] = useState(false)
     
    +  /**
    +   * The launch generation whose run's transcript is on screen (S8): the run
    +   * a launch that started nothing put back, or else the current
    +   * generation's.
    +   */
    +  const screenGeneration = useCallback(
    +    () => restoredRunRef.current?.generation ?? spawnGenerationRef.current,
    +    [],
    +  )
    +
    +  /**
    +   * Appends `entry` to the transcript of generation `generation`'s run (S8):
    +   * on screen while that transcript is, kept aside with it while a launch
    +   * that replaced it is pending, and nowhere once a run replaced it.
    +   */
    +  const appendRunEntry = useCallback(
    +    (generation: number, entry: TranscriptItem) => {
    +      if (generation === screenGeneration()) {
    +        updateTranscript((previous) => appendTranscriptEntry(previous, entry))
    +        return
    +      }
    +      const outgoing = outgoingRunRef.current
    +      if (outgoing !== null && generation === outgoing.run.generation) {
    +        outgoing.transcript = appendTranscriptEntry(outgoing.transcript, entry)
    +      }
    +    },
    +    [screenGeneration, updateTranscript],
    +  )
    +
    +  /** Every candidates table write: rendered, and mirrored in {@link candidatesRef}. */
    +  const showCandidates = useCallback((next: CandidatesInventory | null) => {
    +    candidatesRef.current = next
    +    setCandidates(next)
    +  }, [])
    +
    +  /**
    +   * Shows a new inventory: the rows, the run id an approval request names,
    +   * and a clean slate for the rows' publication progress and the approval
    +   * block (slice 5b).
    +   */
    +  const applyInventory = useCallback(
    +    (inventory: CandidatesInventory) => {
    +      appliedInventoryRef.current += 1
    +      showCandidates(inventory)
    +      setRowPublications(EMPTY_ROW_PUBLICATIONS)
    +      setApprovingName(null)
    +      setApprovalInput('')
    +    },
    +    [showCandidates],
    +  )
    +
    +  /**
    +   * Fetches the rows behind `run`'s `candidates` event, by the run id the
    +   * shell minted (never a path), into that run's table wherever it is when
    +   * they land (S8): on screen while the run's transcript is, kept aside
    +   * with it while a launch that replaced it is pending, and nowhere once a
    +   * run replaced it -- so a response landing after the next Start never
    +   * dresses a new run in an old run's candidates. Sequenced with the fetches
    +   * for the table on screen when it starts for that table, and apart from
    +   * them when it starts for the outgoing run's; either is dropped once a
    +   * later fetch for the table on screen has started.
    +   */
    +  const fetchRunCandidates = useCallback(
    +    (run: TranscriptRun, runId: string) => {
    +      const forScreen = run.generation === screenGeneration()
    +      const screenRequest = forScreen
    +        ? (latestCandidatesRequestRef.current += 1)
    +        : latestCandidatesRequestRef.current
    +      const keptRequest = forScreen ? null : (latestKeptCandidatesRequestRef.current += 1)
    +      const isLatest = () =>
    +        mountedRef.current &&
    +        screenRequest === latestCandidatesRequestRef.current &&
    +        (keptRequest === null || keptRequest === latestKeptCandidatesRequestRef.current)

    Thanks. This ordering needs two candidates events for the same run: the first starts the screen fetch, and the second starts the kept fetch. The shell emits that event once per run, from the run-end inventory (src-tauri/src/ipc/commands.rs:984). So a second fetch cannot start for a run whose first fetch is still in flight. We are leaving the counters as they are and have noted this as later work, in case the shell ever emits the event more than once.

    Reviewers
    Assignees
    constant1n0 constant1n0
    Labels
    risk: low confidence: 74.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 85.5% (HIGH) · Higher = larger blast radius
    85.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 74.4% · Lower = rushed or shallow review
    74.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.9% · Safe to merge
    21.9%