fix(craft): preserve session drafts and support new-tab navigation
Description
fixes: https://linear.app/onyx-app/issue/ENG-4405/a-craft-chat-cannot-be-opened-in-a-new-tab
Rename the Craft sidebar action to New Session and make it a link. Users can open it in another tab through the context menu or Ctrl/Command-click. Same-tab navigation keeps the existing unsaved-change prompt. Update the label in every locale.
Keep a separate text draft for each Craft session and for New Session. Previously, navigation could discard the welcome draft or carry one session’s text into another. Reuse the draft-storage hook with immediate writes so quick navigation preserves the latest text. Drafts survive navigation and reloads within the browser tab. Sending or successful queueing clears the saved text; rejected queueing retains it.
Draft keys include the signed-in account. Logout removes current and legacy Craft drafts, so the next account cannot restore them. Failed slash-token deletion preserves redo history.
Update the Craft feature map and test the composer with the real input component.
How Has This Been Tested?
- Composer, base input, draft storage, chat panel, editor undo/redo, and logout tests: 82 passed.
- Sidebar and translation catalog tests: 12 passed.
- Pre-commit checks, including TypeScript and type coverage, lint, formatting, translations, and feature-map integrity.
- Frontend preview on port 3011 against the local API on port 8080: Craft page and proxied health endpoint returned HTTP 200.
Additional Options
- [Optional] Please cherry-pick this PR to the latest release version.
Summary by cubic
Renames the Craft sidebar action to New Session and makes it a link, so users can open it in a new tab with Ctrl/Command-click or the browser context menu. Same-tab navigation keeps the existing unsaved-change prompt.
Keeps a separate composer text draft for each Craft session and for New Session, so navigation no longer discards the welcome draft or carries one session's text into another. Drafts survive navigation and reloads within the tab; sending or accepted queueing clears the saved text, while a rejected submission keeps the text and attachments. Paste-tile edits and slash-query removals also update the saved draft immediately.
Draft keys are scoped to the signed-in account, and logout clears current and legacy Craft drafts so the next account can't restore them. A failed slash-token deletion preserves redo history.
Summary by CodeRabbit
- New Features
- New Session navigation supports new tabs and modifier-click behavior.
- Drafts persist separately across sessions, navigation, and reloads for signed-in users.
- Failed submissions retain message text and attachments for retry.
- Unsaved-change protection remains available during same-tab navigation.
- Bug Fixes
- Attachment drafts clear when starting, switching, or ending a session.
- Composer content resets and restores correctly when switching sessions.
- Signing out clears saved Craft drafts.
- Localization
- Updated the New Session label across supported languages.