Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(web): underline the text an input method recomposes
jeffrey80b1c12d9a19
diff --git a/apps/web/src/features/rooms/chat/message-composer.test.tsx b/apps/web/src/features/rooms/chat/message-composer.test.tsxindex 451545a6..f16745d8 100644--- a/apps/web/src/features/rooms/chat/message-composer.test.tsx+++ b/apps/web/src/features/rooms/chat/message-composer.test.tsx@@ -395,7 +395,7 @@ describe("MessageComposer", () => {editor.setSelectionRange(committed.length, committed.length);fireEvent.compositionStart(editor);fireEvent.compositionUpdate(editor, { data: "a" });- fireEvent.change(editor, {+ fireEvent.input(editor, {target: {selectionStart: committed.length + 1,value: `${committed}a`,@@ -411,6 +411,28 @@ describe("MessageComposer", () => {expect(container.querySelector(".composer-agent-mention")).not.toBeNull();});+ it("underlines the word an input method recomposes before the caret", () => {+ const { container } = render(<MessageComposer onSend={vi.fn()} />);+ const editor = screen.getByLabelText<HTMLTextAreaElement>("Message Room");++ fireEvent.change(editor, {+ target: { selectionStart: 11, value: "say hello x" },+ });+ // The keyboard takes back "hello" while the caret sits after it.+ editor.setSelectionRange(9, 9);+ fireEvent.compositionStart(editor);+ fireEvent.compositionUpdate(editor, { data: "hello" });+ fireEvent.input(editor, {+ target: { selectionStart: 9, value: "say hello x" },+ });++ expect(+ container.querySelector(".message-composer-composition"),+ ).toHaveTextContent(/^hello$/u);+ fireEvent.compositionEnd(editor);+ expect(container.querySelector(".message-composer-composition")).toBeNull();+ });+it("submits selected Actor identities and Files as one composition", () => {const onSend = vi.fn();const codex = {diff --git a/apps/web/src/features/rooms/chat/message-composer.tsx b/apps/web/src/features/rooms/chat/message-composer.tsxindex 5c58c83c..00a8e07e 100644--- a/apps/web/src/features/rooms/chat/message-composer.tsx+++ b/apps/web/src/features/rooms/chat/message-composer.tsx@@ -639,6 +639,10 @@ function ComposerEditor({const [composition, setComposition] = useState<ComposerComposition | null>(null,);+ // An input method may recompose text already in the draft, as Android+ // keyboards do when the caret backs into a word, so the composed range is+ // read from the caret after each input, never from where composition began.+ const composedLength = useRef(0);return (<div className="message-composer-editor relative"><textarea@@ -671,20 +675,27 @@ function ComposerEditor({isComposing.current = false;setComposition(null);}}- onCompositionStart={(event) => {+ onCompositionStart={() => {isComposing.current = true;- const start = event.currentTarget.selectionStart;- setComposition({ start, end: start });+ composedLength.current = 0;+ setComposition(null);}}// Input-method candidates count as typing before they commit.onCompositionUpdate={(event) => {peek.typed(event.currentTarget.value.length);- const data = event.data;- setComposition((current) =>- current- ? { start: current.start, end: current.start + data.length }- : current,- );+ composedLength.current = event.data.length;+ }}+ // Every composition step fires input, even one that leaves the value+ // as it was, which change skips.+ onInput={(event) => {+ if (!isComposing.current) return;+ const end =+ event.currentTarget.selectionStart ??+ event.currentTarget.value.length;+ setComposition({+ start: Math.max(0, end - composedLength.current),+ end,+ });}}onKeyDown={handleKeyDown}onPaste={(event) => {@@ -910,7 +921,7 @@ function ComposerHighlight({skillReferences,}: {body: string;- composition?: ComposerComposition | null;+ composition: ComposerComposition | null;documentOptions: MessageDocumentOption[];documentReferences: RoomComposerDocumentReference[];highlightContentRef: RefObject<HTMLDivElement | null>;