Registry Mirror
Skip to content

Conversation

@Pruthvirajcodes

@Pruthvirajcodes Pruthvirajcodes commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Archiving the thread you have open is meant to leave you on a new-thread draft in that thread's project. When another project has more recent activity, you land on a draft in that other project instead. If you then type a message, it starts a thread in the wrong project.

Archive starts the draft navigation (handleNewThread in useThreadActions.archiveThread). While that navigation is still loading, the shell stream drops the archived thread. The route matches still name the archived thread, so the missing-thread redirect in ThreadRouteView fires with navigate({ to: "/", replace: true }). That replaces the in-flight draft navigation, and the index opens a draft in the most recently active project.

Change

ThreadRouteView skips the missing-thread redirect while a navigation is loading (useRouterState({ select: (state) => state.isLoading })). navigating is in the effect's dependencies, so a thread that is still missing once the navigation settles redirects as before. This covers a direct link to an archived or deleted thread, and a thread deleted from another client.

Scope

  • One file in apps/web, a small fix for an obvious bug, so it needs no issue under CONTRIBUTING.md.
  • Undo after archive has a separate bug, fixed in its own PR (fix(web): undoing an archive reopens the archived thread #49103).
  • One ordering is not covered. If the stream drops the thread before the archive reply arrives, no navigation is in flight yet. I didn't see that ordering in the app; the drop always came after the draft navigation started.

Verification

  • scenarios:prove with the scenario below: the scenario fails on base b46456401b and passes on head 74cdfadb49.
    • Two projects, alpha and beta. An old alpha thread is open, and beta has the most recent thread.
    • I archived the open alpha thread from its context menu.
    • On base the draft is in beta (expected "beta" to be "alpha"). With the fix it is in alpha.
Before (main) After
Before: after archiving the alpha thread, the draft asks What should we build in beta? After: the draft asks What should we build in alpha?
  • vp run check:changed passes: format, lint, knip, typecheck (2 packages), react compiler.
  • No unit test. ThreadRouteView has no test, and useThreadActions.undo.test.ts mocks the router, so it can't see the redirect. A browser test would need a real router with a gated beforeLoad and about eight mocked entity hooks. I used the real-app scenario as the proof instead. I can add the browser test if you want a regression guard.
  • A separate review pass checked isLoading in router-core:
    • It is set in the same tick as the history push and cleared in the same batch that commits the new matches.
    • Intent preloads don't touch it.
    • Every load reaches onReady or a redirect, so it can't get stuck and suppress the redirect for good.
    • The delete flow, and the href check from fix(web): keep later navigation when thread archival completes #24109, behave as before.
Scenario source (scripts/scenarios/archive-open-thread-keeps-its-project.e2e.ts)
/// <reference lib="dom" />
import { expect } from "e2e";

import { test, WEB } from "./t3.ts";

test(
  "Archiving the open thread starts the next thread in its own project",
  WEB,
  async ({ t3, app, browser, screen }) => {
    const alpha = await t3.project("alpha");
    const beta = await t3.project("beta");
    const old = await t3.thread({ project: alpha, title: "Old alpha thread", messages: ["hello"] });
    // The other project has the most recent activity.
    await t3.thread({ project: beta, title: "Recent beta thread", messages: ["hello"] });
    await t3.open(old);

    const row = browser.locator(`li[data-thread-item$=":${old.threadId}"]`);
    await row.waitFor();
    await browser.evaluate((id) => {
      const target = document.querySelector(`li[data-thread-item$=":${id}"] [role="button"]`)!;
      const box = target.getBoundingClientRect();
      target.dispatchEvent(
        new MouseEvent("contextmenu", {
          bubbles: true,
          cancelable: true,
          button: 2,
          clientX: box.x + 30,
          clientY: box.y + 10,
        }),
      );
      return null;
    }, old.threadId);
    await screen.getByRole("menuitem", "Archive thread").click();

    await expect(row).toHaveCount(0);
    await expect(screen.getByRole("textbox", "Message New thread")).toBeVisible();
    // The redirect that follows the archive lands within this time.
    await browser.evaluate(
      () =>
        new Promise<null>((resolve) => {
          // @effect-diagnostics-next-line globalTimers:off - This callback runs inside the browser.
          setTimeout(() => resolve(null), 1500);
        }),
    );
    await app.screenshot("after-archive");
    const draftProject = () =>
      browser.evaluate(
        () =>
          document.body.textContent
            ?.replace(/\s+/g, " ")
            .match(/What should we build in ?(\w+)\?/)?.[1] ?? null,
      );
    expect(await draftProject()).toBe("alpha");
  },
);

Written by Claude Opus 5.5 in Claude Code (running in T3 Code), with Claude Fable 5.2 subagents for finding the bug and code review.

🤖 Generated with Claude Code

Archive opens a draft in the archived thread's project, but while that
navigation loaded, the shell stream dropped the archived thread and the
route's missing-thread redirect replaced it with the index, which opens a
draft in the most recently active project instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Dec 5, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 74cdfad

Macroscope's review found this PR approvable — The change preserves an in-progress navigation when the open thread becomes missing, keeping archive navigation on the project's draft. Its scope is limited to the client-side fallback redirect, with no changes to stored data or archive behavior.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ThreadRouteView now avoids redirecting home while the router is loading. During an archive request, archiveThread tracks history actions and navigates to a draft only if no non-REPLACE action occurred. Tests cover replacement and push navigation.

Changes: Thread Navigation

Layer / File(s) Summary
Check navigation state before redirecting
apps/web/src/components/ThreadRouteView.tsx
ThreadRouteView reads the router loading state and uses it to guard the missing-thread redirect. The effect dependencies include the loading state.
Preserve navigation during archive
apps/web/src/hooks/useThreadActions.ts, apps/web/src/hooks/useThreadActions.undo.test.ts
archiveThread tracks non-REPLACE history actions while the archive request is pending. It navigates to a draft only when the archived thread was on the current route and no such action occurred. Tests cover REPLACE and PUSH actions with different destinations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: stienswout

Merge Risk: Minimal · up to f8476

Archiving an open thread now keeps the draft of the archived thread's own project instead of landing in another project's draft. Direct links to missing threads still redirect home. A rare case remains where a replacing navigation made during the archive request could be overridden, but the user can recover from it. Nothing blocks merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (archiving the open thread keeps its project's new-thread draft) and matches the main change: ThreadRouteView skips the missing-thread redirect while navigation loads, and arch…
Description check Passed The description follows the repository template: it has Problem, Change, Scope, and Verification sections, and the problem and cause are explained with reproduction steps. The Verification section giv…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (archiving the open thread keeps its project's new-thread draft) and matches the main change: ThreadRouteView skips the missing-thread redirect while navigation loads, and archiveThread now watches history so the draft lands in the archived thread's project. It is specific and follows the conventional commit style of the repository template.

Full details: Description check

Explanation

The description follows the repository template: it has Problem, Change, Scope, and Verification sections, and the problem and cause are explained with reproduction steps. The Verification section gives a real-app scenario with before and after results, names the failing and passing commits, and says what was not tested (no unit test, reasoning for skipping it). Minor gaps: the Scope section cites a linked undo PR (#49103) but the author does not link an issue for the bug, and the template asks for the issue or a reason for none, which the author gives. The description also says the ordering where the stream drops the thread before the archive reply is not covered, while the PR objectives say the commit adds handling for that ordering. This conflict should be resolved by updating the description.

Resolution

Update the Scope and Change sections to match the commit that handles the drop-before-reply ordering, since the description still lists it as uncovered. Optionally add a short note on the archive history-watch change in useThreadActions.ts.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e85060b and f8476b5.

Files selected for processing: 2

  • apps/web/src/hooks/useThreadActions.ts
  • apps/web/src/hooks/useThreadActions.undo.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 5, 2026
juliusmarminge and others added 2 commits December 5, 2026 00:11
…ject-draft

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ands first

When the shell drops the archived thread before the archive reply arrives, the missing-thread effect replaces the route with / and archive's href check took that as the user leaving, so the index opened the most recently active project's draft. Archive now watches history like delete does: only a non-REPLACE entry during the request counts as the user navigating away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Create alpha and its one-message Old alpha thread; then create beta and its newer one-message Recent beta thread. Open alpha directly, right-click its sidebar row, choose Archive thread, wait for the New thread composer and another 1.5 seconds, then inspect the project heading.

Environment on both sides: real web dev app, automated Chromium, 1280×800, light theme; fresh synthetic projects and Replay (dev) turns.

Scenario: Archiving the open alpha thread keeps the new draft in alpha

Proven: the scenario fails on base 276d1ee5fa and passes on head f8476b541d.

Base 276d1ee5fa Head f8476b541d
Result ❌ failed
ASSERTION_FAILED: expect.toContainText failed
locator: getByRole("heading", name: /What should we build/)
expected: text containing "alpha"
observed: text "What should we build in beta ?" (match count 1)
✅ passed
open alpha before archive Base 276d1ee5fa: open alpha before archive Head f8476b541d: open alpha before archive
draft after archiving alpha Base 276d1ee5fa: draft after archiving alpha Head f8476b541d: draft after archiving alpha
failure Base 276d1ee5fa: failure
Recording Before After
Archive interaction Base recording Head recording

Scenario source

Not shown:

  • Desktop shell and mobile were not exercised; this proof covers the shared web UI in Chromium.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 5, 2026
@juliusmarminge
juliusmarminge merged commit 7df5c0f into pingdotgg:main Dec 5, 2026
56 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants