Skip to content

Commit ee283e3

Browse files
committed
fix: assistant input overlap, mobile enter key, and tool result crashes
- Increase chat content spacer so the fixed input no longer overlaps the clear chat button - Only submit on Enter with physical keyboards; mobile users tap the send button - Guard all tool result components against undefined result.current - Fix collapsed return/setState bug in person-update-result
1 parent dd9a7aa commit ee283e3

12 files changed

Lines changed: 29 additions & 4 deletions

src/app/features/assistant/parts/chat-input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ function ChatInput(props: {
7171

7272
function submitOnEnter(event: React.KeyboardEvent<HTMLTextAreaElement>) {
7373
if (event.key !== "Enter") return
74-
if (event.shiftKey) return
74+
let hasPhysicalKeyboard = window.matchMedia(
75+
"(hover: hover) and (pointer: fine)",
76+
).matches
77+
if (event.shiftKey || !hasPhysicalKeyboard) return
7578

7679
event.preventDefault()
7780

src/app/features/assistant/parts/empty-chat-state.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ function EmptyChatState({
7979

8080
function submitOnEnter(event: React.KeyboardEvent<HTMLTextAreaElement>) {
8181
if (event.key !== "Enter") return
82-
if (event.shiftKey) return
82+
let hasPhysicalKeyboard = window.matchMedia(
83+
"(hover: hover) and (pointer: fine)",
84+
).matches
85+
if (event.shiftKey || !hasPhysicalKeyboard) return
8386

8487
event.preventDefault()
8588

src/app/features/assistant/parts/note-create-result.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ function NoteCreateResult({
3939
)
4040
}
4141

42+
if (!("current" in result) || !result.current) return null
43+
4244
let handleUndo = async () => {
4345
if (!me.$isLoaded) return
4446
setIsUndoing(true)

src/app/features/assistant/parts/note-delete-result.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ function NoteDeleteResult({
3737
)
3838
}
3939

40+
if (!("current" in result) || !result.current) return null
41+
4042
let handleUndo = async () => {
4143
if (!me.$isLoaded) return
4244
setIsUndoing(true)

src/app/features/assistant/parts/note-update-result.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ function NoteUpdateResult({
3838
)
3939
}
4040

41+
if (!("current" in result) || !result.current) return null
42+
4143
let handleUndo = async () => {
4244
if (!me.$isLoaded) return
4345
setIsUndoing(true)

src/app/features/assistant/parts/person-create-result.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ function PersonCreateResult({
5353
)
5454
}
5555

56+
if (!("current" in result) || !result.current) return null
57+
5658
let handleUndo = async () => {
5759
if (!me.$isLoaded) return
5860
setIsUndoing(true)

src/app/features/assistant/parts/person-delete-result.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function PersonDeleteResult({
4646
)
4747
}
4848

49+
if (!("current" in result) || !result.current) return null
50+
4951
let handleUndo = async () => {
5052
if (!me.$isLoaded) return
5153
setIsUndoing(true)

src/app/features/assistant/parts/person-update-result.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ function PersonUpdateResult({
4747
)
4848
}
4949

50+
if (!("current" in result) || !result.current) return null
51+
5052
let handleUndo = async () => {
51-
if (!me.$isLoaded) return setIsUndoing(true)
53+
if (!me.$isLoaded) return
54+
setIsUndoing(true)
5255
setDrawerOpen(false)
5356
try {
5457
await updatePerson(

src/app/features/assistant/parts/reminder-create-result.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ function ReminderCreateResult({
4949
)
5050
}
5151

52+
if (!("current" in result) || !result.current) return null
53+
5254
let handleUndo = async () => {
5355
if (!me.$isLoaded) return
5456
setIsUndoing(true)

src/app/features/assistant/parts/reminder-delete-result.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ function ReminderDeleteResult({
5555
)
5656
}
5757

58+
if (!("current" in result) || !result.current) return null
59+
5860
let handleUndo = async () => {
5961
if (!me.$isLoaded) return
6062
setIsUndoing(true)

0 commit comments

Comments
 (0)