@devries-cameron20 / t3code Mirror · read-only / commits / be5a887b93
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 10:45 UTC

feat: add assembly file highlighting and language selection (#27899)

Luna committed Oct 31, 2026 at 00:29 UTC be5a887b939dadf74e62a477bbe2c805d561fe9e
7 files changed +54
apps/mobile/src/lib/highlightLanguage.ts
+1
@@ -1,3 +1,4 @@
1 +import "@t3tools/client-runtime/assembly-highlighting";
2 import { getFiletypeFromFileName } from "@pierre/diffs/utils/getFiletypeFromFileName";
3
4 import { HIGHLIGHTS_LANGUAGE_IDS } from "./highlights.generated";
apps/mobile/src/lib/highlights.test.ts
+18
@@ -2,6 +2,7 @@ import { codeToTokens } from "@pierre/highlights";
2 import { pierreDark, pierreLight } from "@pierre/highlights/themes";
3 import { describe, expect, it, vi } from "vite-plus/test";
4
5 +import { resolveHighlightLanguage } from "./highlightLanguage";
6 import { highlightCode, tokenizeCode } from "./highlights";
7
8 vi.mock("expo", async () => {
@@ -57,3 +58,20 @@ it("normalizes only requested lines from full-source records, including CRLF and
58 expect(source.highlightLine(2, "dark")?.[0]?.color).toBe("#737373");
59 expect(source.highlightLine(100, "dark")).toBeUndefined();
60 });
61 +
62 +it.each([
63 + "asm",
64 + "assembly",
65 + "s",
66 + ...["asm", "ASM", "s", "S", "nasm", "NASM"].map((ext) => `src/start.${ext}`),
67 +])("highlights assembly in %s", (hint) => {
68 + const language = resolveHighlightLanguage(
69 + hint.includes("/") ? { path: hint } : { language: hint },
70 + );
71 + const code = "mov eax, 42 ; answer\nret";
72 + for (const scheme of ["light", "dark"] as const) {
73 + const tokens = highlightCode(code, language, scheme);
74 + expect(tokens.map((line) => line.map((token) => token.content).join("")).join("\n")).toBe(code);
75 + expect(new Set(tokens.flat().map((token) => token.color)).size).toBeGreaterThan(1);
76 + }
77 +});
apps/web/src/composer-code-languages.ts
+3
@@ -1,5 +1,6 @@
1 export const CODE_BLOCK_LANGUAGES = [
2 { id: "", label: "Plain text" },
3 + { id: "asm", label: "Assembly" },
4 { id: "bash", label: "Bash" },
5 { id: "c", label: "C" },
6 { id: "cpp", label: "C++" },
@@ -43,6 +44,7 @@ export const CODE_BLOCK_LANGUAGES = [
44 export type CodeBlockLanguage = { readonly id: string; readonly label: string };
45
46 const LANGUAGE_ALIASES: Record<string, string> = {
47 + assembly: "asm",
48 cs: "csharp",
49 "c++": "cpp",
50 js: "javascript",
@@ -51,6 +53,7 @@ const LANGUAGE_ALIASES: Record<string, string> = {
53 py: "python",
54 rb: "ruby",
55 rs: "rust",
56 + s: "asm",
57 sh: "bash",
58 shell: "bash",
59 text: "",
apps/web/src/lib/syntaxHighlighting.test.ts new
+21
@@ -0,0 +1,21 @@
1 +import { getFiletypeFromFileName } from "@pierre/diffs";
2 +import { expect, it } from "vite-plus/test";
3 +
4 +import { getSyntaxHighlighterPromise } from "./syntaxHighlighting";
5 +import { DIFF_THEME_NAMES } from "./diffRendering";
6 +
7 +it.each([
8 + "asm",
9 + "assembly",
10 + "s",
11 + ...["asm", "ASM", "s", "S", "nasm", "NASM"].map((ext) => `src/start.${ext}`),
12 +])("highlights assembly in %s", async (hint) => {
13 + const language = hint.includes("/") ? getFiletypeFromFileName(hint) : hint;
14 + const highlighter = await getSyntaxHighlighterPromise(language);
15 + const code = "mov eax, 42 ; answer\nret";
16 + for (const theme of Object.values(DIFF_THEME_NAMES)) {
17 + const { tokens } = highlighter.codeToTokens(code, { lang: language, theme });
18 + expect(tokens.map((line) => line.map((token) => token.content).join("")).join("\n")).toBe(code);
19 + expect(new Set(tokens.flat().map((token) => token.color)).size).toBeGreaterThan(1);
20 + }
21 +});
apps/web/src/lib/syntaxHighlighting.ts
+1
@@ -1,3 +1,4 @@
1 +import "@t3tools/client-runtime/assembly-highlighting";
2 import {
3 getSharedHighlighter,
4 type DiffsHighlighter,
packages/client-runtime/package.json
+4
@@ -3,6 +3,10 @@
3 "private": true,
4 "type": "module",
5 "exports": {
6 + "./assembly-highlighting": {
7 + "types": "./src/assemblyHighlighting.ts",
8 + "default": "./src/assemblyHighlighting.ts"
9 + },
10 "./zip/bounded-zip": {
11 "types": "./src/zip/boundedZip.ts",
12 "default": "./src/zip/boundedZip.ts"
packages/client-runtime/src/assemblyHighlighting.ts new
+6
@@ -0,0 +1,6 @@
1 +import { setCustomExtension } from "@pierre/diffs/utils/getFiletypeFromFileName";
2 +
3 +// The default .s mapping is riscv, which the Highlights backend does not support.
4 +for (const extension of ["asm", "ASM", "s", "S", "nasm", "NASM"]) {
5 + setCustomExtension(extension, "asm");
6 +}