Conversation
Co-authored-by: benju69 <2486590+benju69@users.noreply.github.com> Agent-Logs-Url: https://github.com/benju69/Tasks/sessions/3067a909-666e-4d5f-95dd-6f002766a3f4
There was a problem hiding this comment.
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
FocusRequesterfor the titleOutlinedTextField. - Request focus when
taskId == nullinside the existingLaunchedEffect(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() } |
There was a problem hiding this comment.
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).
| runCatching { titleFocusRequester.requestFocus() } | |
| try { | |
| titleFocusRequester.requestFocus() | |
| } catch (e: IllegalStateException) { | |
| // Ignore focus request failures, e.g., if the view is not yet attached | |
| } |
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 aFocusRequesterattached to the titleOutlinedTextField; whentaskId == null(new task), focus is requested inside the existingLaunchedEffect(taskId)blockrunCatchingguards against the edge case whererequestFocus()is called before the node is attached to the layout tree. Edit flow is unaffected.Original prompt
⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.