GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): keep later navigation when thread deletion completes by Edge358 · Pull Request #33953 · pingdotgg/t3code

fix(web): keep later navigation when thread deletion completes #33953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
juliusmarminge merged 2 commits into pingdotgg:main from Edge358:fix-delete-keeps-later-navigation
Nov 12, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(web): keep later navigation when thread deletion completes #33953

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
b12969f
fix(web): keep later navigation when thread deletion completes
Edge358 Nov 10, 2026
2c792f3
Merge remote-tracking branch 'origin/main' into fix-delete-keeps-late…
juliusmarminge Nov 12, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

6 changes: 5 additions & 1 deletion 6 apps/web/src/hooks/useThreadActions.permissions.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ vi.mock("react", () => ({
useRef: (current: unknown) => ({ current }),
}));
vi.mock("@tanstack/react-router", () => ({
useRouter: () => ({ state: { location: { href: "/" }, matches: [] }, navigate: async () => {} }),
useRouter: () => ({
state: { location: { href: "/" }, matches: [] },
history: { subscribe: () => () => {} },
navigate: async () => {},
}),
}));
vi.mock("../state/session", () => ({
environmentSession: { sessionStateAtom: "session" },
Expand Down
10 changes: 8 additions & 2 deletions 10 apps/web/src/hooks/useThreadActions.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,16 @@ export function useThreadActions() {
sortOrder: sidebarThreadSortOrder,
now: new Date().toISOString(),
});
let navigatedDuringDelete = false;
// The missing-thread redirect and the index draft replace this entry; any other history
// action while the delete is pending is the user's own choice, which must win.
const stopWatchingHistory = router.history.subscribe(({ action }) => {
if (action.type !== "REPLACE") navigatedDuringDelete = true;
});
const deleteResult = await deleteThreadMutation({
environmentId: threadRef.environmentId,
input: { threadId: threadRef.threadId },
});
}).finally(stopWatchingHistory);
if (deleteResult._tag === "Failure") {
return deleteResult;
}
Expand All @@ -614,7 +620,7 @@ export function useThreadActions() {
clearTerminalUiState(threadRef);
clearDeletedThreadPanelState(threadRef);

if (shouldNavigateToFallback) {
if (shouldNavigateToFallback && !navigatedDuringDelete) {
const fallbackThread = fallbackThreadId
? readThreadShell(scopeThreadRef(threadRef.environmentId, fallbackThreadId))
: null;
Expand Down
37 changes: 33 additions & 4 deletions 37 apps/web/src/hooks/useThreadActions.undo.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,20 @@ const commands = vi.hoisted(() => ({
snooze: vi.fn(),
unsnooze: vi.fn(),
}));
const router = vi.hoisted(() => ({
navigate: vi.fn(async () => {}),
state: { location: { href: "/" }, matches: [{ params: {} as Record<string, string> }] },
}));
const router = vi.hoisted(() => {
const listeners = new Set<(event: { action: { type: string } }) => void>();
return {
navigate: vi.fn(async () => {}),
state: { location: { href: "/" }, matches: [{ params: {} as Record<string, string> }] },
history: {
listeners,
subscribe: (listener: (event: { action: { type: string } }) => void) => {
listeners.add(listener);
return () => listeners.delete(listener);
},
},
};
});
vi.mock("../state/use-atom-query-runner", () => ({ useAtomQueryRunner: () => vi.fn() }));
vi.mock("../state/session", async (original) => ({
...(await original<typeof import("../state/session")>()),
Expand Down Expand Up @@ -239,6 +249,25 @@ describe("archive navigation", () => {
});
});

describe("delete navigation", () => {
it.each([
{ type: "REPLACE", by: "the app's missing-thread redirect", fallsBack: true },
{ type: "PUSH", by: "the user opening another thread", fallsBack: false },
])("falls back: $fallsBack after $by while deleting", async ({ type, fallsBack }) => {
router.state.matches[0]!.params = {
environmentId: target.environmentId,
threadId: target.threadId,
};
commands.delete.mockImplementation(async () => {
for (const listener of router.history.listeners) listener({ action: { type } });
return { _tag: "Success", value: undefined };
});
expect((await useThreadActions().deleteThread(target))._tag).toBe("Success");
expect(router.navigate).toHaveBeenCalledTimes(fallsBack ? 1 : 0);
expect(router.history.listeners.size).toBe(0);
});
});

describe("settle and snooze Undo", () => {
it("un-settles from the notice and expires the Undo after a manual un-settle", async () => {
const add = vi.spyOn(toastManager, "add").mockReturnValue("toast");
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.