Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.
TypeScript agent-teamagentic-aiai-agentsai-assistantclaude-codecodexcursorelectrongrokgrok-bot-alternativelinuxlocal-firstmacosmcpmulti-agentopenclaw-alternativeopencodewindows
Copy button on message code blocks; don't bold mentions inside code (#15)
Gian Moraes98c2516ac223
diff --git a/src/core/context.ts b/src/core/context.tsindex 43b343a..5be132b 100644--- a/src/core/context.ts+++ b/src/core/context.ts@@ -2,7 +2,7 @@// and a prompt with the conversation transcript. The CLI keeps no session// between turns, so everything the agent knows comes from here.import { L, lang, locale } from '../shared/lang'-import { describeSchedule, PROJECTS_DIR, type Agent, type Conversation, type Memory, type Message, type Routine, type Settings, type Skill } from '../shared/types'+import { CODE_SPANS, describeSchedule, PROJECTS_DIR, type Agent, type Conversation, type Memory, type Message, type Routine, type Settings, type Skill } from '../shared/types'import { osOf, shellCommand, systemName } from './platform'export const HISTORY_LIMIT = 30@@ -268,11 +268,8 @@ export function transcriptBlocks(opts: TranscriptOpts): { blocks: string[]; blocreturn { blocks, blockOf }}-// @handles in the text that belong to the given agents, in order of appearance.-// Handles inside code (fenced or inline) are quoted content, not a call — e.g. a prompt shown in a fenced block.-// A fence closes on the same run of backticks or tildes it opened with, so a ```` block can show a ``` one.-const CODE_SPANS = /(`{3,}|~{3,})[\s\S]*?(?:\1|$)|`[^`\n]*`/g-+// @handles in the text that belong to the given agents, in order of appearance. Handles inside+// code are quoted content, not a call (CODE_SPANS): a prompt shown in a fenced block, say.export function mentioned(text: string, agents: Agent[]): Agent[] {const found: Agent[] = []for (const m of text.replace(CODE_SPANS, ' ').matchAll(/(^|[^\w@])@([a-z0-9][a-z0-9_-]{1,31})\b/gi)) {diff --git a/src/renderer/src/components/Conversation.tsx b/src/renderer/src/components/Conversation.tsxindex 8fbb812..bcb511f 100644--- a/src/renderer/src/components/Conversation.tsx+++ b/src/renderer/src/components/Conversation.tsx@@ -1,4 +1,5 @@import { L } from '../../../shared/lang'+import { CODE_SPANS } from '../../../shared/types'import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react'import Markdown from 'react-markdown'import remarkGfm from 'remark-gfm'@@ -227,7 +228,7 @@ function MessageRow({ message, grouped }: { message: Message; grouped: boolean }{message.run && <RunSteps message={message} />}{message.text ? (<div className="md">- <Markdown remarkPlugins={[remarkGfm]}>{highlightMentions(message.text)}</Markdown>+ <Markdown remarkPlugins={[remarkGfm]} components={{ pre: CodeBlock }}>{highlightMentions(message.text)}</Markdown></div>) : null}{attached.length > 0 && (@@ -303,13 +304,34 @@ function RoutineMessage({ message }: { message: Message }): ReactNode {</div>)}<div className="md">- <Markdown remarkPlugins={[remarkGfm]}>{highlightMentions(message.text)}</Markdown>+ <Markdown remarkPlugins={[remarkGfm]} components={{ pre: CodeBlock }}>{highlightMentions(message.text)}</Markdown></div></div></article>)}+// Fenced code block in a chat message, with a copy button on the top right.+function CodeBlock({ children }: { children?: ReactNode }): ReactNode {+ const ref = useRef<HTMLPreElement>(null)+ const [copied, setCopied] = useState(false)+ return (+ <div className="md-code">+ <pre ref={ref}>{children}</pre>+ <button+ className="icon-btn icon-btn--sm md-code__copy"+ title={L(copied ? 'Copiado' : 'Copiar', copied ? 'Copied' : 'Copy')}+ aria-label={L(copied ? 'Copiado' : 'Copiar código', copied ? 'Copied' : 'Copy code')}+ onClick={() =>+ void navigator.clipboard.writeText(ref.current?.textContent ?? '').then(() => (setCopied(true), setTimeout(() => setCopied(false), 1500)))+ }+ >+ <Icon name={copied ? 'check' : 'copy'} size={13} />+ </button>+ </div>+ )+}+function SummaryPanel({ conv, messages, onClose }: { conv: Conversation; messages: Message[]; onClose: () => void }): ReactNode {const [text, setText] = useState(conv.summary ?? '')const [asked, setAsked] = useState<number | null>(null)@@ -428,7 +450,17 @@ function QuestionCard({ question, answered }: { question: string; answered: bool)}-const highlightMentions = (text: string): string => text.replace(/(^|\s)@([a-z0-9_-]{2,32})/gi, '$1**@$2**')+// A @handle in code is not bolded (CODE_SPANS, the core's rule too): the box shows and copies the real text.+const boldMentions = (t: string): string => t.replace(/(^|\s)@([a-z0-9_-]{2,32})/gi, '$1**@$2**')+const highlightMentions = (text: string): string => {+ let out = ''+ let last = 0+ for (const m of text.matchAll(CODE_SPANS)) {+ out += boldMentions(text.slice(last, m.index)) + m[0]+ last = m.index! + m[0].length+ }+ return out + boldMentions(text.slice(last))+}// Now, every second while `on`: the clock of a reply at work.function useNow(on: boolean): number {diff --git a/src/renderer/src/components/ui.tsx b/src/renderer/src/components/ui.tsxindex c35915a..25ac803 100644--- a/src/renderer/src/components/ui.tsx+++ b/src/renderer/src/components/ui.tsx@@ -19,6 +19,12 @@ const PATHS: Record<string, ReactNode> = {</>),check: <path d="m5 12 5 5L20 7" />,+ copy: (+ <>+ <rect x="8" y="8" width="14" height="14" rx="2" />+ <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />+ </>+ ),x: <path d="M6 6l12 12M18 6 6 18" />,chevron: <path d="m9 6 6 6-6 6" />,shield: <path d="M12 3 4 6v6c0 5 3.5 8 8 9 4.5-1 8-4 8-9V6l-8-3Z" />,diff --git a/src/renderer/src/styles.css b/src/renderer/src/styles.cssindex 8b44319..7710de3 100644--- a/src/renderer/src/styles.css+++ b/src/renderer/src/styles.css@@ -824,6 +824,19 @@ h3 {background: none;padding: 0;}+.md-code {+ position: relative;+ margin: 1em 0;+}+.md-code pre {+ margin: 0;+}+.md-code__copy {+ position: absolute;+ top: 6px;+ right: 6px;+ background: var(--code-bg);+}.md table {border-collapse: collapse;margin: 6px 0 8px;diff --git a/src/shared/types.ts b/src/shared/types.tsindex c1d4a53..deb4ad8 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -431,6 +431,11 @@ export const SUMMARY_WINDOW = 30 // messages kept verbatim after a consolidationexport const SUMMARY_MAX_AFTER = 50 // more than this after the summary triggers oneexport const STALE_DAYS = 60+// Code in a message, a fenced block or inline code, is quoted content: a @handle there neither+// calls the agent (mentioned() in the core) nor is bolded on screen (the message view). A fence+// closes on the same run of backticks or tildes it opened with, so a ```` block can show a ``` one.+export const CODE_SPANS = /(`{3,}|~{3,})[\s\S]*?(?:\1|$)|`[^`\n]*`/g+// How much of each memory scope goes in every prompt, in characters. The most// recently confirmed fill it; the older ones past it aren't lost: agents search// them with buscar_memorias, offered only while some memory is past the budget.