Fix chat composer: enable send without a session, grow input, left-align title - #9
Conversation
…ign title - Send button never enabled in workspaces with no existing chat session; create a session on first send instead of requiring one up front - Composer text field now grows vertically (1-5 lines) instead of scrolling text off-screen horizontally - Left-align the branch name under the workspace title in the nav bar Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QgZomS1NFK9xx5dbtvzLQJ
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
📝 WalkthroughWalkthrough
ChangesChatView behavior
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@PiMobile/Views/ChatView.swift`:
- Line 166: Update the canSend validation and the draft validation at the
submission site around Line 224 to trim using .whitespacesAndNewlines, ensuring
drafts containing only spaces or line breaks are rejected before enabling or
submitting.
- Around line 227-240: Update the send flow in ChatView’s Task around api.send
to handle failures explicitly instead of discarding them: catch the send error,
set running = false, restore draft from the original text, and use any existing
user-visible failure feedback mechanism. Preserve the successful-send behavior
and session creation flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8600cad1-3a11-4630-9aee-e918168103a0
📒 Files selected for processing (1)
PiMobile/Views/ChatView.swift
| } | ||
|
|
||
| private var canSend: Bool { !draft.trimmingCharacters(in: .whitespaces).isEmpty && !running && sessionId != nil } | ||
| private var canSend: Bool { !draft.trimmingCharacters(in: .whitespaces).isEmpty && !running } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reject newline-only drafts.
A vertical TextField can contain only line breaks, but .whitespaces does not trim them. The send button becomes enabled and Line 224 submits an effectively blank message. Use .whitespacesAndNewline in both locations.
Also applies to: 224-224
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@PiMobile/Views/ChatView.swift` at line 166, Update the canSend validation and
the draft validation at the submission site around Line 224 to trim using
.whitespacesAndNewlines, ensuring drafts containing only spaces or line breaks
are rejected before enabling or submitting.
| Task { | ||
| try? await api.send(sessionId: sessionId, text: text, model: model) | ||
| // A workspace with no chats yet has no session — create one on first send. | ||
| var sid = sessionId | ||
| if sid == nil, let s = try? await api.createSession(workspaceId: workspace.id) { | ||
| sessions.insert(s, at: 0) | ||
| session = s | ||
| sid = s.id | ||
| } | ||
| guard let sid else { | ||
| running = false | ||
| draft = text | ||
| return | ||
| } | ||
| try? await api.send(sessionId: sid, text: text, model: model) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Restore the draft when sending fails.
try? await api.send(...) discards errors after clearing draft; a network/API failure permanently loses the message. Handle the error, set running = false, and restore the draft (with user-visible failure feedback if available).
Proposed fix
- try? await api.send(sessionId: sid, text: text, model: model)
+ do {
+ try await api.send(sessionId: sid, text: text, model: model)
+ } catch {
+ running = false
+ draft = text
+ return
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Task { | |
| try? await api.send(sessionId: sessionId, text: text, model: model) | |
| // A workspace with no chats yet has no session — create one on first send. | |
| var sid = sessionId | |
| if sid == nil, let s = try? await api.createSession(workspaceId: workspace.id) { | |
| sessions.insert(s, at: 0) | |
| session = s | |
| sid = s.id | |
| } | |
| guard let sid else { | |
| running = false | |
| draft = text | |
| return | |
| } | |
| try? await api.send(sessionId: sid, text: text, model: model) | |
| Task { | |
| // A workspace with no chats yet has no session — create one on first send. | |
| var sid = sessionId | |
| if sid == nil, let s = try? await api.createSession(workspaceId: workspace.id) { | |
| sessions.insert(s, at: 0) | |
| session = s | |
| sid = s.id | |
| } | |
| guard let sid else { | |
| running = false | |
| draft = text | |
| return | |
| } | |
| do { | |
| try await api.send(sessionId: sid, text: text, model: model) | |
| } catch { | |
| running = false | |
| draft = text | |
| return | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@PiMobile/Views/ChatView.swift` around lines 227 - 240, Update the send flow
in ChatView’s Task around api.send to handle failures explicitly instead of
discarding them: catch the send error, set running = false, restore draft from
the original text, and use any existing user-visible failure feedback mechanism.
Preserve the successful-send behavior and session creation flow.
Fixes three messaging UI bugs in
ChatView:canSendrequired an existing chat session, but a workspace with no chats has none, so the button stayed disabled forever. Sending now works with just text in the field; a session is created automatically on first send (and the draft is restored if creation fails).axis: .vertical,lineLimit(1...5)) instead of pushing text off-screen horizontally.main) sits flush under the workspace name.🤖 Generated with Claude Code
https://claude.ai/code/session_01QgZomS1NFK9xx5dbtvzLQJ
Generated by Claude Code
Summary by CodeRabbit
New Features
Improvements