Просмотр исходного кода

fix(app): omit shell prompts when copying commands (#42958)

Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com>
opencode-agent[bot] 18 часов назад
Родитель
Сommit
c5e58b38a8

+ 4 - 0
packages/session-ui/src/components/message-part.css

@@ -418,6 +418,10 @@
     white-space: pre-wrap;
     overflow-wrap: anywhere;
   }
+
+  [data-slot="bash-prompt"] {
+    user-select: none;
+  }
 }
 
 [data-component="edit-trigger"],

+ 9 - 4
packages/session-ui/src/components/message-part.tsx

@@ -2111,15 +2111,15 @@ ToolRegistry.register({
     const pending = () =>
       props.status === "pending" || props.status === "running" || props.metadata.status === "running"
     const sawPending = pending()
+    const command = () => props.input.command ?? props.metadata.command ?? ""
     const text = createMemo(() => {
-      const cmd = props.input.command ?? props.metadata.command ?? ""
       const out = stripAnsi(props.output || props.metadata.output || "").replace(/\r\n?/g, "\n")
-      return `$ ${cmd}${out ? "\n\n" + out : ""}`
+      return `${command()}${out ? "\n\n" + out : ""}`
     })
     const [copied, setCopied] = createSignal(false)
 
     const handleCopy = async () => {
-      const content = text()
+      const content = command()
       if (!content) return
       if (await writeClipboard(content)) {
         setCopied(true)
@@ -2166,7 +2166,12 @@ ToolRegistry.register({
             aria-label={i18n.t("ui.scrollView.ariaLabel")}
           >
             <pre data-slot="bash-pre">
-              <code>{text()}</code>
+              <code>
+                <span data-slot="bash-prompt" aria-hidden="true">
+                  {"$ "}
+                </span>
+                {text()}
+              </code>
             </pre>
           </div>
         </div>