Skip to content

Commit fec6436

Browse files
committed
fix(editor): address post-rebase review feedback
Restore IME-safe enter handling, touch paste access, and pending JSON edits after the re_editor migration. Also align empty-message saves across edit surfaces.
1 parent 25c6855 commit fec6436

File tree

6 files changed

+387
-251
lines changed

6 files changed

+387
-251
lines changed

lib/desktop/message_edit_dialog.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ class _MessageEditDesktopDialogState extends State<_MessageEditDesktopDialog> {
9494
TextButton.icon(
9595
onPressed: () {
9696
final text = _controller.text.trim();
97-
// TODO: Provide user feedback (disable button or show snackbar) when content is empty.
98-
if (text.isEmpty) return;
9997
Navigator.of(context).pop<MessageEditResult>(
10098
MessageEditResult(content: text, shouldSend: true),
10199
);
@@ -117,8 +115,6 @@ class _MessageEditDesktopDialogState extends State<_MessageEditDesktopDialog> {
117115
TextButton.icon(
118116
onPressed: () {
119117
final text = _controller.text.trim();
120-
// TODO: Provide user feedback (disable button or show snackbar) when content is empty.
121-
if (text.isEmpty) return;
122118
Navigator.of(context).pop<MessageEditResult>(
123119
MessageEditResult(content: text, shouldSend: false),
124120
);
@@ -151,7 +147,9 @@ class _MessageEditDesktopDialogState extends State<_MessageEditDesktopDialog> {
151147
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
152148
child: Container(
153149
decoration: BoxDecoration(
154-
color: isDark ? Colors.white10 : const Color(0xFFF7F7F9),
150+
color: isDark
151+
? Colors.white10
152+
: const Color(0xFFF7F7F9),
155153
borderRadius: BorderRadius.circular(12),
156154
border: Border.all(
157155
color: cs.outlineVariant.withValues(alpha: 0.18),

lib/desktop/setting/providers_pane.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ class _DesktopProviderDetailPaneState
808808
final CodeLineEditingController _saJsonCtrl = CodeLineEditingController();
809809
final TextEditingController _apiPathCtrl = TextEditingController();
810810
Timer? _saJsonSaveTimer;
811-
String _lastSavedSaJson = '';
811+
String _lastPersistedSaJson = '';
812812

813813
void _syncCtrl(TextEditingController c, String newText) {
814814
final v = c.value;
@@ -826,20 +826,26 @@ class _DesktopProviderDetailPaneState
826826
c.setTextSafely(newText);
827827
}
828828

829+
bool _hasPendingSaJsonChanges() {
830+
return _saJsonSaveTimer != null || _saJsonCtrl.text != _lastPersistedSaJson;
831+
}
832+
829833
void _syncControllersFromConfig(ProviderConfig cfg) {
830834
_syncCtrl(_apiKeyCtrl, cfg.apiKey);
831835
_syncCtrl(_baseUrlCtrl, cfg.baseUrl);
832836
_syncCtrl(_apiPathCtrl, cfg.chatPath ?? '/chat/completions');
833837
_syncCtrl(_locationCtrl, cfg.location ?? '');
834838
_syncCtrl(_projectIdCtrl, cfg.projectId ?? '');
835-
_syncCodeCtrl(_saJsonCtrl, cfg.serviceAccountJson ?? '');
836-
_lastSavedSaJson = cfg.serviceAccountJson ?? '';
839+
final persistedSaJson = cfg.serviceAccountJson ?? '';
840+
if (!_saJsonCtrl.isComposing && !_hasPendingSaJsonChanges()) {
841+
_syncCodeCtrl(_saJsonCtrl, persistedSaJson);
842+
}
843+
_lastPersistedSaJson = persistedSaJson;
837844
}
838845

839846
Future<void> _saveSaJsonNow(SettingsProvider sp) async {
840847
final text = _saJsonCtrl.text;
841-
if (text == _lastSavedSaJson) return;
842-
_lastSavedSaJson = text;
848+
if (text == _lastPersistedSaJson) return;
843849
final old = sp.getProviderConfig(
844850
widget.providerKey,
845851
defaultName: widget.displayName,
@@ -848,6 +854,7 @@ class _DesktopProviderDetailPaneState
848854
widget.providerKey,
849855
old.copyWith(serviceAccountJson: text),
850856
);
857+
_lastPersistedSaJson = text;
851858
}
852859

853860
void _scheduleSaJsonSave(SettingsProvider sp) {
@@ -1515,7 +1522,8 @@ class _DesktopProviderDetailPaneState
15151522
},
15161523
child: Container(
15171524
decoration: BoxDecoration(
1518-
color: Theme.of(context).brightness == Brightness.dark
1525+
color:
1526+
Theme.of(context).brightness == Brightness.dark
15191527
? Colors.white10
15201528
: const Color(0xFFF7F7F9),
15211529
borderRadius: BorderRadius.circular(10),

lib/features/chat/pages/message_edit_page.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class _MessageEditPageState extends State<MessageEditPage> {
5252
padding: const EdgeInsets.all(16),
5353
child: Container(
5454
decoration: BoxDecoration(
55-
color: Theme.of(context).brightness == Brightness.dark ? Colors.white10 : const Color(0xFFF2F3F5),
55+
color: Theme.of(context).brightness == Brightness.dark
56+
? Colors.white10
57+
: const Color(0xFFF2F3F5),
5658
borderRadius: BorderRadius.circular(12),
5759
),
5860
clipBehavior: Clip.antiAlias,

lib/features/chat/widgets/message_edit_sheet.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ class _MessageEditSheetState extends State<_MessageEditSheet> {
9999
onTap: () {
100100
Haptics.light();
101101
final text = _controller.text.trim();
102-
// TODO: Provide user feedback (disable button or show snackbar) when content is empty.
103-
if (text.isEmpty) return;
104102
Navigator.of(context).pop<MessageEditResult>(
105103
MessageEditResult(content: text, shouldSend: true),
106104
);
@@ -140,8 +138,6 @@ class _MessageEditSheetState extends State<_MessageEditSheet> {
140138
onTap: () {
141139
Haptics.light();
142140
final text = _controller.text.trim();
143-
// TODO: Provide user feedback (disable button or show snackbar) when content is empty.
144-
if (text.isEmpty) return;
145141
Navigator.of(context).pop<MessageEditResult>(
146142
MessageEditResult(content: text, shouldSend: false),
147143
);
@@ -172,7 +168,9 @@ class _MessageEditSheetState extends State<_MessageEditSheet> {
172168
Expanded(
173169
child: Container(
174170
decoration: BoxDecoration(
175-
color: Theme.of(context).brightness == Brightness.dark ? Colors.white10 : const Color(0xFFF2F3F5),
171+
color: Theme.of(context).brightness == Brightness.dark
172+
? Colors.white10
173+
: const Color(0xFFF2F3F5),
176174
borderRadius: BorderRadius.circular(20),
177175
),
178176
clipBehavior: Clip.antiAlias,

0 commit comments

Comments
 (0)