fix(web): do not reuse archived thread ids as new drafts #7183
Closedmaslinedwin(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/7183/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/hooks/useThreadActions.ts line 241Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -238,3 +238,4 @@238238 markThreadVisited(scopedThreadKey(threadRef), wokeAt);239239 }240240 refreshArchivedThreadsForEnvironment(threadRef.environmentId);241+ retireProjectDraftMappingForThread(threadRef);
- apps/web/src/hooks/useHandleNewThread.ts line 70Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -50,3 +57,14 @@5057 };5158 }525960+function resolveStoredDraftReuse(threadRef: ScopedThreadRef | null): StoredDraftReuseDecision {61+ if (threadRef === null) {62+ return "mint";63+ }64+ const draftSession = useComposerDraftStore.getState().getDraftSessionByRef(threadRef);65+ return decideStoredDraftReuse({66+ storedDraftThreadRef: threadRef,67+ liveShellExists: readThreadShell(threadRef) !== null,68+ archivedShellExists: readArchivedThreadExists(threadRef),69+ promoted: draftSession?.promotedTo != null,70+ });
- apps/web/src/composerDraftStore.ts line 2595Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2543,0 +2556,21 @@2556+ draftThread.threadId === threadRef.threadId,2557+ )2558+ .map(([draftId]) => draftId),2559+ );2560+ if (matchingDraftIds.size === 0) {2561+ return state;2562+ }2563+ const nextLogicalMappings = Object.fromEntries(2564+ Object.entries(state.logicalProjectDraftThreadKeyByLogicalProjectKey).filter(2565+ ([, draftId]) => !matchingDraftIds.has(draftId),2566+ ),2567+ ) as Record<string, string>;2568+ if (2569+ Object.keys(nextLogicalMappings).length ===2570+ Object.keys(state.logicalProjectDraftThreadKeyByLogicalProjectKey).length2571+ ) {2572+ return state;2573+ }2574+ return {2575+ logicalProjectDraftThreadKeyByLogicalProjectKey: nextLogicalMappings,2576+ };
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
dcfb5e08-4ea8-4f4f-8417-276cada5c762You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share