[codex] Clear stale queued comment targets (#4234)

## Thinking Path

> - Paperclip orchestrates AI agents for zero-human companies.
> - Operators interact with agent work through issue threads and queued
comments.
> - When the selected comment target becomes stale, the composer can
keep pointing at an invalid target after thread state changes.
> - That makes follow-up comments easier to misroute and harder to
reason about.
> - This pull request clears stale queued comment targets and covers the
behavior with tests.
> - The benefit is more predictable issue-thread commenting during live
agent work.

## What Changed

- Clears queued comment targets when they no longer match the current
issue thread state.
- Adjusts issue detail comment-target handling to avoid stale target
reuse.
- Adds regression tests for optimistic issue comment target behavior.

## Verification

- `pnpm exec vitest run ui/src/lib/optimistic-issue-comments.test.ts`

## Risks

- Low risk; scoped to comment-target state handling in the issue UI.
- No migrations.

> Checked `ROADMAP.md`; this is a focused UI reliability fix, not a new
roadmap-level feature.

## Model Used

- OpenAI Codex, GPT-5-based coding agent, tool-enabled repository
editing and local test execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] If this change affects the UI, I have included before/after
screenshots
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] I will address all Greptile and reviewer comments before
requesting merge
This commit is contained in:
Dotta 2026-04-21 16:50:26 -05:00 committed by GitHub
parent bcbbb41a4b
commit 014aa0eb2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 13 deletions

View file

@ -720,7 +720,7 @@ describe("optimistic issue comments", () => {
const result = applyLocalQueuedIssueCommentState(comment, {
queuedTargetRunId: "run-1",
hasLiveRuns: true,
targetRunIsLive: true,
runningRunId: "run-1",
});
@ -746,10 +746,31 @@ describe("optimistic issue comments", () => {
const result = applyLocalQueuedIssueCommentState(comment, {
queuedTargetRunId: "run-1",
hasLiveRuns: false,
targetRunIsLive: false,
runningRunId: null,
});
expect(result).toBe(comment);
});
it("does not keep local queued state when a different run is live", () => {
const comment = {
id: "comment-1",
companyId: "company-1",
issueId: "issue-1",
authorAgentId: null,
authorUserId: "board-1",
body: "Follow up after the active run",
createdAt: new Date("2026-03-28T16:20:05.000Z"),
updatedAt: new Date("2026-03-28T16:20:05.000Z"),
};
const result = applyLocalQueuedIssueCommentState(comment, {
queuedTargetRunId: "run-1",
targetRunIsLive: true,
runningRunId: "run-2",
});
expect(result).toBe(comment);
});
});