feat(mobile): add Copy thread ID, branch, and path to thread menus #12186
ClosedImBIOS(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/12186/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -538,3 +540,5 @@538540 () => onRegenerateThreadTitle(thread),539541 [onRegenerateThreadTitle, thread],540542 );543+ const handleCopyPath = useCallback(() => {544+ const path = resolveThreadCopyPath({ worktreePath: thread.worktreePath });@@ -0,0 +1,17 @@1+/**2+ * Strip terminal escape sequences from captured CLI stdout.3+ *4+ * OpenCode's CLI (and potentially other provider CLIs) can emit OSC title5+ * sequences (`ESC ]0;<title> BEL` / `ESC \`) and ANSI CSI color codes directly6+ * to stdout, even when stdout is a pipe. When T3 Code captures that output7+ * via `ChildProcessSpawner`, those bytes pollute structured parsing — e.g.8+ * `opencode agent list` becomes `\x1b]0;t3code: ready\x07build (primary)`9+ * instead of `build (primary)`, causing the agent inventory to store a10+ * polluted id that later fails with `Agent not found`.11+ *12+ * This is defensive for any provider CLI; the regexes are intentionally13+ * permissive and also handle Ghostty/Zsh title integrations that can leak14+ * through `shell: true` spawns.15+ */16+const OSC_RE = /\x1b\].*?(?:\x07|\x1b\\)/g;17+const CSI_RE = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
- @@ -538,3 +540,11 @@538540 () => onRegenerateThreadTitle(thread),539541 [onRegenerateThreadTitle, thread],540542 );543+ const handleCopyPath = useCallback(() => {544+ const path = resolveThreadCopyPath({ worktreePath: thread.worktreePath });545+ if (path === null) {546+ Alert.alert("Could not copy path", "This thread does not have a workspace path.");547+ return;548+ }549+ copyTextWithHaptic(path, { target: "thread path", feedback: "selection" });550+ }, [thread.worktreePath]);@@ -538,3 +540,17 @@538540 () => onRegenerateThreadTitle(thread),539541 [onRegenerateThreadTitle, thread],540542 );543+ const handleCopyPath = useCallback(() => {544+ const path = resolveThreadCopyPath({ worktreePath: thread.worktreePath });545+ if (path === null) {546+ Alert.alert("Could not copy path", "This thread does not have a workspace path.");547+ return;548+ }549+ copyTextWithHaptic(path, { target: "thread path", feedback: "selection" });550+ }, [thread.worktreePath]);551+ const handleCopyBranch = useCallback(() => {552+ if (thread.branch === null) return;553+ copyTextWithHaptic(thread.branch, { target: "thread branch", feedback: "selection" });554+ }, [thread.branch]);555+ const handleCopyThreadId = useCallback(() => {556+ copyTextWithHaptic(thread.id, { target: "thread ID", feedback: "selection" });@@ -0,0 +1,19 @@1+/**2+ * Strip terminal escape sequences from captured CLI stdout.3+ *4+ * OpenCode's CLI (and potentially other provider CLIs) can emit OSC title5+ * sequences (`ESC ]0;<title> BEL` / `ESC \`) and ANSI CSI color codes directly6+ * to stdout, even when stdout is a pipe. When T3 Code captures that output7+ * via `ChildProcessSpawner`, those bytes pollute structured parsing — e.g.8+ * `opencode agent list` becomes `\x1b]0;t3code: ready\x07build (primary)`9+ * instead of `build (primary)`, causing the agent inventory to store a10+ * polluted id that later fails with `Agent not found`.11+ *12+ * This is defensive for any provider CLI; the regexes are intentionally13+ * permissive and also handle Ghostty/Zsh title integrations that can leak14+ * through `shell: true` spawns.15+ */16+const OSC_RE = /\x1b\].*?(?:\x07|\x1b\\)/g;17+const CSI_RE = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;18+const CHARSET_RE = /\x1b[()][A-Za-z0-9]/g;19+const SINGLE_ESC_RE = /\x1b[@-Z\\-_]/g;
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed