Skip to content

Commit c8eda25

Browse files
SteffanDonalKatharine
authored andcommitted
Fix an issue where transcribed prompts containing double quotes cause an app hang on Android.
(Due to a Pebble app bug causing the prompt message to be dropped when double quotes are present in an app message string value) Signed-off-by: Steffan Donal <[email protected]>
1 parent 7357044 commit c8eda25

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

app/src/c/converse/conversation_manager.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "../util/memory/malloc.h"
2121
#include "../util/memory/pressure.h"
2222
#include "../util/logging.h"
23+
#include "../util/strings.h"
2324

2425
#include <pebble-events/pebble-events.h>
2526
#include <pebble.h>
@@ -106,7 +107,15 @@ void conversation_manager_add_input(ConversationManager* manager, const char* in
106107
prv_conversation_updated(manager, true);
107108
return;
108109
}
109-
dict_write_cstring(iter, MESSAGE_KEY_PROMPT, input);
110+
111+
// The Android Pebble app has a fun bug where any double-quotes in a
112+
// message will cause it to be dropped, this is a bodge workaround.
113+
char* bridge_bodge = bmalloc(strlen(input) + 1);
114+
strcpy(bridge_bodge, input);
115+
strings_fix_android_bridge_bodge(bridge_bodge);
116+
dict_write_cstring(iter, MESSAGE_KEY_PROMPT, bridge_bodge);
117+
free(bridge_bodge);
118+
110119
const char* thread_id = conversation_get_thread_id(manager->conversation);
111120
if (thread_id[0] != 0) {
112121
BOBBY_LOG(APP_LOG_LEVEL_INFO, "Continuing previous conversation %s.", thread_id);

app/src/c/util/strings.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2025 Steffan Robert William Donal
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
void strings_fix_android_bridge_bodge(char* str) {
18+
while (*str) {
19+
if (*str == '"') {
20+
*str = '\'';
21+
}
22+
str++;
23+
}
24+
}

app/src/c/util/strings.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2025 Steffan Robert William Donal
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
// Makes the passed, null-terminated string compatible when sent to
20+
// the Android Pebble app as an app message.
21+
void strings_fix_android_bridge_bodge(char* str);

0 commit comments

Comments
 (0)