Skip to content

Commit 78eaca5

Browse files
Sinandevin-ai-integration[bot]
authored andcommitted
fix(web): address review nits on thread drop fix
Per nbrosei's review on #20024: match the comment wording to the actual staleness (first mounted thread's draft, matching threadContextDrag.ts), and drop the unmount-cleanup test, which covered listener removal that already worked before this change. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 4b55196 commit 78eaca5

2 files changed

Lines changed: 1 addition & 20 deletions

File tree

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5765,7 +5765,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
57655765

57665766
// Stable callbacks, not useEffectEvent: ChatComposer is memoized, and React
57675767
// 19.2 never refreshes an effect event's impl on memo fibers — stale closures
5768-
// here would import the dropped thread into the previous thread's draft.
5768+
// here would import the dropped thread into the first mounted thread's draft.
57695769
const attachDroppedThreadFile = useStableCallback((file: File) => addComposerAttachments([file]));
57705770
const importDroppedThread = useStableCallback(
57715771
async (ref: ScopedThreadRef, isActive: () => boolean) => {

‎apps/web/src/components/chat/threadContextDrag.test.tsx‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,4 @@ describe("useThreadContextDrop", () => {
6565
expect(drafts.get("thread-b")).toEqual(["thread-dropped"]);
6666
expect(drafts.get("thread-a")).toEqual([]);
6767
});
68-
69-
it("stops calling the drop callback once the target unmounts", async () => {
70-
const drafts = new Map<string, Array<ThreadId>>([["thread-a", []]]);
71-
const dropped: ScopedThreadRef = {
72-
environmentId: ENVIRONMENT_ID,
73-
threadId: "thread-dropped" as ThreadId,
74-
};
75-
76-
await act(() => root.render(<ComposerDropTarget draftKey="thread-a" drafts={drafts} />));
77-
const target = container.querySelector("[data-drop-target]");
78-
expect(target).not.toBeNull();
79-
await act(() => root.render(null));
80-
81-
act(() => {
82-
target!.dispatchEvent(new CustomEvent(THREAD_CONTEXT_DROP_EVENT, { detail: [dropped] }));
83-
});
84-
85-
expect(drafts.get("thread-a")).toEqual([]);
86-
});
8768
});

0 commit comments

Comments
 (0)