The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Merge batch 11-05 i1805: #3151 (#3165)
0xken152920bbd89b2d
diff --git a/desktop/lib/super_tabs/composer_tags.dart b/desktop/lib/super_tabs/composer_tags.dartindex 1b6f2bdd4..c8ba3fbfa 100644--- a/desktop/lib/super_tabs/composer_tags.dart+++ b/desktop/lib/super_tabs/composer_tags.dart@@ -1,3 +1,5 @@+import 'dart:async';+import 'package:flutter/material.dart';import 'package:flutter/services.dart';@@ -300,3 +302,75 @@ class SuperTabTagBackspace extends TextInputFormatter {return newValue;}}++/// Whether an input method is composing in [value] (Telex, kana, jamo): the+/// marked text is the input method's, and the box must not replace it.+bool superTabComposing(TextEditingValue value) =>+ value.composing.isValid && !value.composing.isCollapsed;++/// The writes a chat box takes from the app rather than from typing: a draft+/// saved elsewhere, a path taken back out. None replaces the box while an+/// input method composes in it, where a fresh value would drop the marked+/// range and the next diacritic would stack on text the input method no+/// longer sees (task #3245). Such a write waits and runs once composing ends,+/// worked out from the box's text then, with the caret kept.+class SuperTabComposerWrites {+ SuperTabComposerWrites(this.box) {+ box.addListener(_moved);+ }++ final TextEditingController box;++ /// The write waiting for composing to end.+ String? Function(String current)? _waiting;+ var _scheduled = false;++ /// Puts what [next] makes of the box's text into the box: now, with the+ /// caret at its end, or once composing ends, with the caret where it is.+ /// [next] answers null when it no longer applies (another chat shown).+ void write(String? Function(String current) next) {+ if (superTabComposing(box.value)) {+ _waiting = next;+ return;+ }+ _waiting = null;+ final text = next(box.text);+ if (text == null || text == box.text) return;+ box.value = TextEditingValue(+ text: text,+ selection: TextSelection.collapsed(offset: text.length),+ );+ }++ /// Drops a waiting write: the box was replaced for another chat.+ void cancel() => _waiting = null;++ void dispose() {+ _waiting = null;+ box.removeListener(_moved);+ }++ void _moved() {+ if (_waiting == null || _scheduled || superTabComposing(box.value)) {+ return;+ }+ // After the edit that ended composing has been reported, so the draft+ // [next] reads already holds what was committed.+ _scheduled = true;+ scheduleMicrotask(() {+ _scheduled = false;+ final next = _waiting;+ if (next == null || superTabComposing(box.value)) return;+ _waiting = null;+ final text = next(box.text);+ if (text == null || text == box.text) return;+ final caret = box.selection.isValid+ ? box.selection.extentOffset.clamp(0, text.length)+ : text.length;+ box.value = TextEditingValue(+ text: text,+ selection: TextSelection.collapsed(offset: caret),+ );+ });+ }+}diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dartindex 62c9f0cae..b9ddf4903 100644--- a/desktop/lib/super_tabs/view.dart+++ b/desktop/lib/super_tabs/view.dart@@ -168,6 +168,10 @@ class SuperTabView extends StatefulWidget {class _SuperTabViewState extends State<SuperTabView>with WidgetsBindingObserver {final _composer = TextEditingController();++ /// The app's own writes into [_composer], held while an input method+ /// composes in it.+ late final _composerWrites = SuperTabComposerWrites(_composer);final _focus = FocusNode(debugLabel: 'Swarm message');final _pullRequestsFocus = FocusNode(debugLabel: 'Project pull requests');final _scroll = <String, SuperTabChatScroll>{};@@ -334,6 +338,7 @@ class _SuperTabViewState extends State<SuperTabView>super.initState();WidgetsBinding.instance.addObserver(this);_composer.addListener(_composerMoved);+ _composerWrites; // listening before anything is composedc.addListener(_changed);c.addListener(_holdVoiceAway);c.buddyChatOpener = _openBuddyChat;@@ -529,11 +534,22 @@ class _SuperTabViewState extends State<SuperTabView>}_dial.cancel(); // a fling from the last conversation never scrolls this one}- if (_selected != id || _composer.text != draft) {+ if (_selected != id) {+ _composerWrites.cancel();_composer.value = TextEditingValue(text: draft,selection: TextSelection.collapsed(offset: draft.length),);+ } else if (_composer.text != draft) {+ // The draft changed under the box: shown at once, or once an input+ // method has finished composing, from the draft held then.+ _composerWrites.write(+ (_) => c.accessRevoked+ ? ''+ : c.selectedId == id+ ? c.draft(id)+ : null,+ );}_selected = id;setState(() {});@@ -1091,6 +1107,7 @@ class _SuperTabViewState extends State<SuperTabView>..dispose();_findFocus.dispose();_historyRetry?.cancel();+ _composerWrites.dispose();_composer.dispose();_mentionIndex.dispose();_dismissedMention.dispose();@@ -1363,23 +1380,30 @@ class _SuperTabViewState extends State<SuperTabView>for (final MapEntry(key: folder, value: bytes) in zipped.entries)if (files.files.any((file) => identical(file.bytes, bytes))) folder,];- final shown = c.selectedId == id;- var text = shown ? _composer.text : c.draft(id);- for (final folder in attached) {- final path = _pathText(folder);- text = text.contains('$path ')- ? text.replaceFirst('$path ', '')- : text.contains(' $path')- ? text.replaceFirst(' $path', '')- : text.replaceFirst(path, '');+ String withoutPaths(String text) {+ for (final folder in attached) {+ final path = _pathText(folder);+ text = text.contains('$path ')+ ? text.replaceFirst('$path ', '')+ : text.contains(' $path')+ ? text.replaceFirst(' $path', '')+ : text.replaceFirst(path, '');+ }+ return text;}++ final shown = c.selectedId == id;dropped.removeWhere(attached.contains);- c.setDraft(id, text);- if (shown && _composer.text != text) {- _composer.value = TextEditingValue(- text: text,- selection: TextSelection.collapsed(offset: text.length),- );+ c.setDraft(id, withoutPaths(shown ? _composer.text : c.draft(id)));+ if (shown) {+ // From the box's text when it is written: what was composed meanwhile+ // stays, the paths go.+ _composerWrites.write((current) {+ if (c.selectedId != id) return null;+ final text = withoutPaths(current);+ if (text != current) c.setDraft(id, text);+ return text;+ });}setState(() {});reportAttachProblem(diff --git a/desktop/test/super_tab_composer_ime_test.dart b/desktop/test/super_tab_composer_ime_test.dartnew file mode 100644index 000000000..816ab7a70--- /dev/null+++ b/desktop/test/super_tab_composer_ime_test.dart@@ -0,0 +1,291 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/super_tabs/controller.dart';+import 'package:harness/super_tabs/view.dart';++import 'support/super_tab_fixture.dart';++/// What an input method shows while it composes: the box's whole text and the+/// marked range it still owns ([TextRange.empty] once committed).+typedef _Step = ({String text, TextRange composing});++_Step _marked(String text, int start) =>+ (text: text, composing: TextRange(start: start, end: text.length));+_Step _plain(String text) => (text: text, composing: TextRange.empty);++/// Typed right after `@F `, where Leo saw it (task #3245).+const _before = '@F ';+const _at = _before.length;++/// Each composition as the platform reports it, and the step after which a+/// controller update lands while the input method is still composing.+final _compositions = <String, ({List<_Step> steps, int updateAfter})>{+ // Telex: a, a makes â, then the sắc tone.+ 'Telex â then a tone': (+ steps: [+ _marked('${_before}a', _at),+ _marked('$_beforeâ', _at),+ _marked('$_beforeấ', _at),+ _plain('$_beforeấ'),+ ],+ updateAfter: 1,+ ),+ // Telex: u, a backspace in the marked text, then ư.+ 'Telex u, backspace, ư': (+ steps: [+ _marked('${_before}u', _at),+ _plain(_before),+ _marked('$_beforeư', _at),+ _plain('$_beforeư'),+ ],+ updateAfter: 0,+ ),+ // Japanese: kana typed, then converted to kanji.+ 'Japanese kana to kanji': (+ steps: [+ _marked('$_beforeか', _at),+ _marked('$_beforeかん', _at),+ _marked('$_beforeかんじ', _at),+ _marked('$_before漢字', _at),+ _plain('$_before漢字'),+ ],+ updateAfter: 1,+ ),+ // Korean: jamo built into one syllable.+ 'Korean jamo to syllable': (+ steps: [+ _marked('$_beforeㅎ', _at),+ _marked('$_before하', _at),+ _marked('$_before한', _at),+ _plain('$_before한'),+ ],+ updateAfter: 1,+ ),+};++/// A chat box replaces nothing while an input method composes in it: a+/// controller update that lands mid-composition, with a saved draft a+/// keystroke behind the box, leaves every marked step as the platform sent it,+/// so the input method and the box agree on what is typed. Otherwise the next+/// diacritic lands on text the input method no longer sees and stacks.+void main() {+ final macOS = TargetPlatformVariant.only(TargetPlatform.macOS);+ final mainBox = find.byKey(const ValueKey('super-message-composer'));+ final threadBox = find.byKey(const ValueKey('super-thread-composer'));+ final line = find.byKey(const ValueKey('super-thread-line-message-1'));++ late SuperTabController shown;++ Future<ConversationServer> show(+ WidgetTester tester,+ ConversationServer server,+ ) async {+ await tester.binding.setSurfaceSize(const Size(1400, 900));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ final c = shown = server.controller();+ await c.refresh();+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: Scaffold(+ body: SuperTabView(+ controller: c,+ onInvite: () {},+ onAddAgent: (_) {},+ onOpenTerminal: (_) {},+ machineName: (_) => 'Team Mac',+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();+ return server;+ }++ /// A test that takes the view down and settles the draft save before it+ /// ends, as the chat's own tests do.+ void testBox(String description, Future<void> Function(WidgetTester) body) =>+ testWidgets(description, (tester) async {+ await body(tester);+ await tester.pumpWidget(const SizedBox());+ await shown.flush();+ shown.dispose();+ }, variant: macOS);++ TextEditingValue valueOf(WidgetTester tester, Finder box) =>+ tester.widget<TextField>(box).controller!.value;++ void send(WidgetTester tester, _Step step) =>+ tester.testTextInput.updateEditingValue(+ TextEditingValue(+ text: step.text,+ selection: TextSelection.collapsed(offset: step.text.length),+ composing: step.composing,+ ),+ );++ /// Replays [steps] into [box]; after step [updateAfter] the saved draft+ /// falls a keystroke behind ([lagDraft]) and the controller updates.+ Future<void> replay(+ WidgetTester tester,+ ConversationServer server,+ Finder box, {+ required List<_Step> steps,+ required int updateAfter,+ required void Function(String text) lagDraft,+ required String Function() draft,+ }) async {+ await tester.tap(box);+ await tester.pump();+ send(tester, _plain(_before));+ await tester.pump();+ var previous = _before;+ for (final (index, step) in steps.indexed) {+ send(tester, step);+ await tester.pump();+ expect(+ valueOf(tester, box),+ TextEditingValue(+ text: step.text,+ selection: TextSelection.collapsed(offset: step.text.length),+ composing: step.composing,+ ),+ reason: 'step ${index + 1} as the input method sent it',+ );+ if (index == updateAfter) {+ // The draft is a keystroke behind the box, and the controller+ // updates while the input method is still composing.+ lagDraft(previous);+ server.append('A reply while you type.');+ await shown.refresh();+ await tester.pump();+ expect(+ valueOf(tester, box),+ TextEditingValue(+ text: step.text,+ selection: TextSelection.collapsed(offset: step.text.length),+ composing: step.composing,+ ),+ reason: 'a controller update mid-composition replaces nothing',+ );+ }+ previous = step.text;+ }+ await tester.pump();+ final committed = steps.last.text;+ expect(valueOf(tester, box).text, committed);+ expect(+ valueOf(tester, box).selection,+ TextSelection.collapsed(offset: committed.length),+ );+ expect(draft(), committed, reason: 'the committed text is the draft');+ }++ group('main composer', () {+ for (final MapEntry(key: name, value: composition)+ in _compositions.entries) {+ testBox('$name survives a controller update', (tester) async {+ final server = await show(+ tester,+ ConversationServer()..append('Which build?'),+ );+ final id = shown.selectedId;+ await replay(+ tester,+ server,+ mainBox,+ steps: composition.steps,+ updateAfter: composition.updateAfter,+ lagDraft: (text) => shown.setDraft(id, text),+ draft: () => shown.draft(id),+ );+ });+ }++ testBox('a draft changed while nobody composes still shows at once', (+ tester,+ ) async {+ final server = await show(+ tester,+ ConversationServer()..append('Which build?'),+ );+ final id = shown.selectedId;+ await tester.tap(mainBox);+ await tester.pump();+ send(tester, _plain('xin chào'));+ await tester.pump();+ shown.setDraft(id, 'from elsewhere');+ server.append('A reply.');+ await shown.refresh();+ await tester.pump();+ expect(+ valueOf(tester, mainBox),+ const TextEditingValue(+ text: 'from elsewhere',+ selection: TextSelection.collapsed(offset: 14),+ ),+ );+ });++ testBox('a draft changed mid-composition shows once it ends, caret kept', (+ tester,+ ) async {+ final server = await show(+ tester,+ ConversationServer()..append('Which build?'),+ );+ final id = shown.selectedId;+ await tester.tap(mainBox);+ await tester.pump();+ send(tester, _marked('xin chào', 4));+ await tester.pump();+ shown.setDraft(id, 'xin chào bạn');+ server.append('A reply.');+ await shown.refresh();+ await tester.pump();+ expect(valueOf(tester, mainBox).text, 'xin chào');+ // Committed with no further edit: the draft the controller holds now+ // takes the box, and the caret stays where the person left it.+ send(tester, _plain('xin chào'));+ await tester.pump();+ expect(+ valueOf(tester, mainBox),+ const TextEditingValue(+ text: 'xin chào bạn',+ selection: TextSelection.collapsed(offset: 8),+ ),+ );+ });+ });++ group('thread reply box', () {+ ConversationServer threaded() {+ final server = ConversationServer()..threads = true;+ server.append('Should we do thread replies?');+ server.append('Yes, like Slack.');+ server.messages.last+ ..['thread'] = 'message-1'+ ..['replyTo'] = 'message-1';+ return server;+ }++ for (final MapEntry(key: name, value: composition)+ in _compositions.entries) {+ testBox('$name survives a controller update', (tester) async {+ final server = await show(tester, threaded());+ await tester.tap(line);+ await tester.pumpAndSettle();+ await replay(+ tester,+ server,+ threadBox,+ steps: composition.steps,+ updateAfter: composition.updateAfter,+ lagDraft: (text) => shown.setThreadDraft('message-1', text),+ draft: () => shown.threadDraft('message-1'),+ );+ });+ }+ });+}diff --git a/desktop/test/super_tab_folder_drop_test.dart b/desktop/test/super_tab_folder_drop_test.dartindex c94dbf7c8..cd959240b 100644--- a/desktop/test/super_tab_folder_drop_test.dart+++ b/desktop/test/super_tab_folder_drop_test.dart@@ -330,6 +330,50 @@ void main() {await close(tester, controller);});+ testWidgets('a zip that lands while an input method composes takes its '+ 'path out once composing ends', (tester) async {+ final controller = await open(tester, machineId: 'studio');+ final src = folder('src');+ File('${src.path}/main.dart').writeAsStringSync('void main() {}');+ await tester.enterText(composer, 'Look at');+ await drop(tester, [+ src.path,+ ], until: () => field(tester).text.contains(src.path));++ await tester.tap(find.text('Attach as zip'));+ await tester.pump();+ // Telex is composing `à` when the zip lands (task #3245).+ await tester.tap(composer);+ await tester.pump();+ final typed = 'Look at ${src.path} à';+ final composing = TextEditingValue(+ text: typed,+ selection: TextSelection.collapsed(offset: typed.length),+ composing: TextRange(start: typed.length - 1, end: typed.length),+ );+ tester.testTextInput.updateEditingValue(composing);+ await tester.pump();+ await settle(tester, () => names(controller).isNotEmpty);++ expect(names(controller), ['src.zip']);+ expect(+ field(tester).value,+ composing,+ reason: 'the zip replaces nothing under the marked text',+ );++ tester.testTextInput.updateEditingValue(+ TextEditingValue(+ text: typed,+ selection: TextSelection.collapsed(offset: typed.length),+ ),+ );+ await tester.pumpAndSettle();+ expect(field(tester).text, 'Look at à');+ expect(controller.draft('lead'), 'Look at à');+ await close(tester, controller);+ });+testWidgets('a folder over the attachment limit is not zipped, and its ''path stays', (tester) async {final controller = await open(tester, machineId: 'studio');diff --git a/docs/plans/2026-11-05-ime-composition-composer-plan.md b/docs/plans/2026-11-05-ime-composition-composer-plan.mdnew file mode 100644index 000000000..a319a6426--- /dev/null+++ b/docs/plans/2026-11-05-ime-composition-composer-plan.md@@ -0,0 +1,65 @@+# Typing Vietnamese, Japanese or Korean in a chat box never garbles (task #3245) Plan++> Worked by the Engineer, test first (superpowers test-driven-development): each task's failing test is committed and+> seen red before the code that passes it.++**Goal:** A controller update that lands while an input method is composing (Telex, kana to kanji, jamo to syllable)+never replaces the chat box's value, so the input method and the box keep agreeing on what is typed.++**Architecture:** One small helper in `composer_tags.dart`, `SuperTabComposerWrites`, wraps a box's+`TextEditingController`. A programmatic write goes through it: with no composing range it applies at once, as today;+while a range is active it waits and runs once composing ends, recomputed from the box's text then and keeping the+caret (clamped). The main view's draft sync and its zip-path removal use it. The thread box has no draft sync and+none of its writes can land mid-composition (Task 2), so it is only tested. Switching to another conversation or+thread still replaces the box at once.++**Tech Stack:** Flutter (pinned 3.47.2), widget tests with `tester.testTextInput.updateEditingValue` on macOS.++**Spec:** task #3245 brief (Guide2's reading of task #3069: `view.dart` draft sync replaces the value mid-composition).++## Global Constraints++- Owned files only: `desktop/lib/super_tabs/view.dart`, `thread_panel.dart`, `composer_tags.dart`, `desktop/test/`.+- Desktop only, no visible UI change. Keep the @ picker and tag backspace stepping aside while composing, and the+ Enter-during-composition tests.++## Design++N/A because nothing is stored, synced or exposed: the draft is written exactly as before, only the moment a box is+overwritten moves to the end of a composition.++## Review Focus++- The deferred write never resurrects stale text over what the person typed after it (it reads the box and draft at+ apply time).+- Conversation and thread switches still replace the box at once and drop any waiting write.++## Task 1: The main composer keeps a composition through a controller update++**Files:** `desktop/test/super_tab_composer_ime_test.dart` (new), `desktop/lib/super_tabs/view.dart`,+`desktop/lib/super_tabs/composer_tags.dart`.++**Interfaces:** `bool superTabComposing(TextEditingValue)`; `SuperTabComposerWrites(TextEditingController)` with+`write(String? Function(String current))`, `cancel()`, `dispose()`.++- [ ] Test: Telex (`a`, `â`, `ấ`; `u`, backspace, `ư`), Japanese (`か`… `漢字`) and Korean (`ㅎ`, `하`, `한`) replayed+ after `@F ` in the main box, with a controller update carrying a lagging saved draft mid-composition. Each step's+ value (text and composing range) is intact; the committed text is the draft. Run, see it fail on main.+- [ ] Code: route the draft sync and the zip-path removal through `SuperTabComposerWrites`. Run, see it pass.+- [ ] Test (`super_tab_folder_drop_test.dart`): a folder zip that lands while `à` is composed replaces nothing until+ composing ends, then takes its path out. Red with main's `view.dart`, green with the change.++## Task 2: The thread box keeps a composition the same way++**Files:** the same test file.++- [ ] Test: the same compositions in the thread reply box with controller updates mid-composition.+- [ ] Finding: it passes on main and needs no code. The thread box has no draft sync; its programmatic writes are a+ thread switch (a deliberate replace), the clear after a sent reply (Enter does not send while composing, and a+ click on Send takes focus, which ends composing in `EditableText`) and the restore after a refused reply (only+ into an empty box). The test stays as the regression guard.++## Task 3: Unchanged behaviour++- [ ] Run the composer, thread panel and composer_tags tests (including `super_tab_view_test.dart` Enter during+ composition and `super_tab_composer_newline_test.dart`) and `make check-ui-style`.