fix(desktop): focus new-workspace prompt at end of existing text on remount

Merged
KI
4mo ago
+2-2

Summary

Switching back to the new-workspace composer remounts the Tiptap MarkdownEditor with the persisted draft, but the caret always landed at the start of the text. Both v2 composers now focus at the end when draft text exists, and at the start otherwise.

  • DashboardNewWorkspaceForm/PromptGroup: was hardcoded autoFocus="start" → autoFocus={prompt ? "end" : "start"}
  • NewWorkspaceScreen: promptSeed > 0 only covered the sample-prompt remount; autoFocus={draft.prompt ? "end" : "start"} subsumes it (draft is non-empty at that remount too)

autoFocus is only read at editor creation (remount via key), so the changing prop has no effect mid-typing.

Test Plan

  • Type a prompt in the new-workspace modal, close/switch away, reopen — caret is at end of text
  • Open composer with empty draft — caret at start, placeholder shown
  • Pick a sample prompt in NewWorkspaceScreen — editor remounts with caret at end
  • bun run lint and desktop typecheck pass

Summary by cubic

Fixes the new workspace prompt so the cursor lands at the end of existing draft text on remount, letting users keep typing without repositioning. If the draft is empty, the cursor starts at the beginning and the placeholder shows.

  • Bug Fixes
    • Dashboard modal prompt: autoFocus is now prompt ? "end" : "start".
    • New workspace screen: autoFocus now uses draft.prompt ? "end" : "start" instead of promptSeed, covering sample prompts and persisted drafts.

Summary by CodeRabbit

  • Bug Fixes
    • Improved cursor placement in the Markdown prompt editor.
    • Existing prompts now place the cursor at the end of the text when opened.
    • Empty prompt fields place the cursor at the beginning for immediate typing.