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

Remove unused OpenTelemetry tracing and fix overlapping highlights (#1738)

Co-authored-by: opencode <[email protected]>
Dax 6 месяцев назад
Родитель
Сommit
85eaa5b58b

+ 1 - 1
.opencode/agent/docs.md

@@ -1,5 +1,5 @@
 ---
-description: You MUST use this agent when writing documentation
+description: ALWAYS use this when writing docs
 ---
 
 You are an expert technical documentation writer

+ 0 - 7
packages/opencode/package.json

@@ -38,13 +38,6 @@
     "@openauthjs/openauth": "0.4.3",
     "@opencode-ai/plugin": "workspace:*",
     "@opencode-ai/sdk": "workspace:*",
-    "@opentelemetry/auto-instrumentations-node": "0.62.0",
-    "@opentelemetry/exporter-jaeger": "2.0.1",
-    "@opentelemetry/exporter-otlp-http": "0.26.0",
-    "@opentelemetry/exporter-trace-otlp-http": "0.203.0",
-    "@opentelemetry/instrumentation-fetch": "0.203.0",
-    "@opentelemetry/sdk-node": "0.203.0",
-    "@opentelemetry/sdk-trace-node": "2.0.1",
     "@standard-schema/spec": "1.0.0",
     "@zip.js/zip.js": "2.7.62",
     "ai": "catalog:",

+ 0 - 2
packages/opencode/src/index.ts

@@ -1,6 +1,4 @@
 import "zod-openapi/extend"
-import { Trace } from "./trace"
-Trace.init()
 import yargs from "yargs"
 import { hideBin } from "yargs/helpers"
 import { RunCommand } from "./cli/cmd/run"

+ 0 - 17
packages/opencode/src/trace/index.ts

@@ -1,17 +0,0 @@
-import { NodeSDK } from "@opentelemetry/sdk-node"
-import { FetchInstrumentation } from "@opentelemetry/instrumentation-fetch"
-import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"
-
-export namespace Trace {
-  export function init() {
-    const sdk = new NodeSDK({
-      serviceName: "opencode",
-      instrumentations: [new FetchInstrumentation()],
-      traceExporter: new OTLPTraceExporter({
-        url: "http://localhost:4318/v1/traces", // or your OTLP endpoint
-      }),
-    })
-
-    sdk.start()
-  }
-}

+ 19 - 0
packages/tui/internal/components/chat/message.go

@@ -268,7 +268,26 @@ func renderText(
 			return 0
 		})
 
+		// Merge overlapping highlights to prevent duplication
+		merged := make([]highlightPart, 0)
 		for _, part := range highlights {
+			if len(merged) == 0 {
+				merged = append(merged, part)
+				continue
+			}
+
+			last := &merged[len(merged)-1]
+			// If current part overlaps with the last one, merge them
+			if part.start <= last.end {
+				if part.end > last.end {
+					last.end = part.end
+				}
+			} else {
+				merged = append(merged, part)
+			}
+		}
+
+		for _, part := range merged {
 			highlight := base.Foreground(part.color)
 			start, end := part.start, part.end