Skip to content

Auto-focus title field on new task creation#3

Open
Copilot wants to merge 2 commits intomainfrom
copilot/focus-on-title-when-creating-task
Open

Auto-focus title field on new task creation#3
Copilot wants to merge 2 commits intomainfrom
copilot/focus-on-title-when-creating-task

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

Opening the task editor for a new task required a manual tap on the title field before typing. The keyboard should open immediately.

Changes

  • TaskEditorScreen.kt: Added a FocusRequester attached to the title OutlinedTextField; when taskId == null (new task), focus is requested inside the existing LaunchedEffect(taskId) block
val titleFocusRequester = remember { FocusRequester() }

LaunchedEffect(taskId) {
    if (taskId != null) {
        viewModel.loadTask(taskId)
    } else {
        runCatching { titleFocusRequester.requestFocus() }
    }
}

runCatching guards against the edge case where requestFocus() is called before the node is attached to the layout tree. Edit flow is unaffected.

Original prompt

Give focus on title when we create a new task, so we have the keyboard open


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI changed the title [WIP] Add focus on title input when creating a new task Auto-focus title field on new task creation Mar 24, 2026
Copilot AI requested a review from benju69 March 24, 2026 11:39
@benju69 benju69 requested a review from Copilot March 25, 2026 14:36
@benju69 benju69 marked this pull request as ready for review March 25, 2026 14:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the task creation UX by automatically focusing the title field when opening the task editor for a new task, so the keyboard appears immediately.

Changes:

  • Add a FocusRequester for the title OutlinedTextField.
  • Request focus when taskId == null inside the existing LaunchedEffect(taskId).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (taskId != null) {
viewModel.loadTask(taskId)
} else {
runCatching { titleFocusRequester.requestFocus() }
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runCatching { titleFocusRequester.requestFocus() } will also swallow CancellationException, which can break coroutine cancellation for this LaunchedEffect (and potentially lead to stuck effects). Prefer a targeted try/catch that only handles the expected focus-related exception (e.g., IllegalStateException) and rethrows CancellationException (or avoid catching entirely and delay focus with awaitFrame()/yield() if attachment timing is the concern).

Suggested change
runCatching { titleFocusRequester.requestFocus() }
try {
titleFocusRequester.requestFocus()
} catch (e: IllegalStateException) {
// Ignore focus request failures, e.g., if the view is not yet attached
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants