fix(frontend): preserve composer drafts across remounts - #3035
fix(frontend): preserve composer drafts across remounts#3035Alphaxiaoteng wants to merge 2 commits into
Conversation
Co-Authored-By: OpenAI Codex <noreply@openai.com>
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="frontend/tests/MessageComposer.spec.tsx">
<violation number="1" location="frontend/tests/MessageComposer.spec.tsx:143">
P3: The session-isolation test only checks that a new session shows an empty draft; it never switches back to session 'a' to confirm the original draft is still retained. Since the PR's stated goal is to "isolate drafts between sessions" (each session keeps its own draft), a regression that clears the draft globally on session change would pass this test. Add a follow-up assertion that rerendering with sessionId 'a' restores 'draft message'.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| }); | ||
| view.rerender(<ComposerOwners sessionId="b" />); | ||
|
|
||
| await waitFor(() => { |
There was a problem hiding this comment.
P3: The session-isolation test only checks that a new session shows an empty draft; it never switches back to session 'a' to confirm the original draft is still retained. Since the PR's stated goal is to "isolate drafts between sessions" (each session keeps its own draft), a regression that clears the draft globally on session change would pass this test. Add a follow-up assertion that rerendering with sessionId 'a' restores 'draft message'.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/tests/MessageComposer.spec.tsx, line 143:
<comment>The session-isolation test only checks that a new session shows an empty draft; it never switches back to session 'a' to confirm the original draft is still retained. Since the PR's stated goal is to "isolate drafts between sessions" (each session keeps its own draft), a regression that clears the draft globally on session change would pass this test. Add a follow-up assertion that rerendering with sessionId 'a' restores 'draft message'.</comment>
<file context>
@@ -0,0 +1,172 @@
+ });
+ view.rerender(<ComposerOwners sessionId="b" />);
+
+ await waitFor(() => {
+ expect(screen.getByRole('textbox')).toHaveValue('');
+ });
</file context>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
|
Addressed the review in 89b1968:
Reverified on the new head: focused composer tests 4/4, full frontend suite 36/36, type-check, lint, Prettier, complete recursive production build, and |
Summary
Inputcontrolled by that single source of truth while preserving reset, command, favorite, and URL-prompt behaviorRegression evidence
With the new owner-swap test kept in place and the composer temporarily restored to local state, the test failed as expected:
The URL-prompt boundary also failed before its guard was added:
The first bounded-state revision also proved that merely hiding a stale session record was insufficient: switching
a → b → arestoreddraft message. The final implementation clears that single record when the session changes.Verification
pnpm --filter @chainlit/app test -- tests/MessageComposer.spec.tsx— 4 passedpnpm --filter @chainlit/app test— 6 files, 36 tests passedpnpm type-check— frontend and react-client passed; copilot reports its repository-configured skippnpm lintandpnpm lint:fix— passedpnpm format-checkandpnpm format— passedpnpm build— react-client, frontend, and copilot production builds passedgit diff --check— passedPrior work and AI assistance
PR #3028 previously explored the same session-scoped state direction and was closed by its author before maintainer review. Thank you to @Iams4kura for that public investigation. This PR independently re-ran the baseline, adds explicit owner-level, session-lifecycle, and URL-prompt regressions, and follows this repository's required AI attribution. OpenAI Codex assisted with implementation and review; both commits include the required
Co-Authored-Bytrailer.