diff --git a/CLAUDE.md b/CLAUDE.md index c317064255..47dc3e3d86 120000 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1 +1 @@ -AGENTS.md +AGENTS.md \ No newline at end of file diff --git a/apps/desktop/src/appBranding.ts b/apps/desktop/src/appBranding.ts index fe1d13186b..49cbcc6780 100644 --- a/apps/desktop/src/appBranding.ts +++ b/apps/desktop/src/appBranding.ts @@ -1,7 +1,8 @@ import type { DesktopAppBranding, DesktopAppStageLabel } from "@t3tools/contracts"; +import { isNightlyDesktopVersion } from "./updateChannels"; + const APP_BASE_NAME = "T3 Code"; -const NIGHTLY_VERSION_PATTERN = /-nightly\.\d{8}\.\d+$/; export function resolveDesktopAppStageLabel(input: { readonly isDevelopment: boolean; @@ -11,7 +12,7 @@ export function resolveDesktopAppStageLabel(input: { return "Dev"; } - return NIGHTLY_VERSION_PATTERN.test(input.appVersion) ? "Nightly" : "Alpha"; + return isNightlyDesktopVersion(input.appVersion) ? "Nightly" : "Alpha"; } export function resolveDesktopAppBranding(input: { diff --git a/apps/desktop/src/desktopSettings.test.ts b/apps/desktop/src/desktopSettings.test.ts index 7efdc88e73..7c8be53f82 100644 --- a/apps/desktop/src/desktopSettings.test.ts +++ b/apps/desktop/src/desktopSettings.test.ts @@ -7,6 +7,7 @@ import { afterEach, describe, expect, it } from "vitest"; import { DEFAULT_DESKTOP_SETTINGS, readDesktopSettings, + resolveDefaultDesktopSettings, setDesktopServerExposurePreference, setDesktopUpdateChannelPreference, writeDesktopSettings, @@ -28,7 +29,15 @@ function makeSettingsPath() { describe("desktopSettings", () => { it("returns defaults when no settings file exists", () => { - expect(readDesktopSettings(makeSettingsPath())).toEqual(DEFAULT_DESKTOP_SETTINGS); + expect(readDesktopSettings(makeSettingsPath(), "0.0.17")).toEqual(DEFAULT_DESKTOP_SETTINGS); + }); + + it("defaults packaged nightly builds to the nightly update channel", () => { + expect(resolveDefaultDesktopSettings("0.0.17-nightly.20260415.1")).toEqual({ + serverExposureMode: "local-only", + updateChannel: "nightly", + updateChannelConfiguredByUser: false, + }); }); it("persists and reloads the configured server exposure mode", () => { @@ -37,11 +46,13 @@ describe("desktopSettings", () => { writeDesktopSettings(settingsPath, { serverExposureMode: "network-accessible", updateChannel: "latest", + updateChannelConfiguredByUser: true, }); - expect(readDesktopSettings(settingsPath)).toEqual({ + expect(readDesktopSettings(settingsPath, "0.0.17")).toEqual({ serverExposureMode: "network-accessible", updateChannel: "latest", + updateChannelConfiguredByUser: true, }); }); @@ -51,12 +62,14 @@ describe("desktopSettings", () => { { serverExposureMode: "local-only", updateChannel: "latest", + updateChannelConfiguredByUser: false, }, "network-accessible", ), ).toEqual({ serverExposureMode: "network-accessible", updateChannel: "latest", + updateChannelConfiguredByUser: false, }); }); @@ -66,12 +79,14 @@ describe("desktopSettings", () => { { serverExposureMode: "local-only", updateChannel: "latest", + updateChannelConfiguredByUser: false, }, "nightly", ), ).toEqual({ serverExposureMode: "local-only", updateChannel: "nightly", + updateChannelConfiguredByUser: true, }); }); @@ -79,6 +94,54 @@ describe("desktopSettings", () => { const settingsPath = makeSettingsPath(); fs.writeFileSync(settingsPath, "{not-json", "utf8"); - expect(readDesktopSettings(settingsPath)).toEqual(DEFAULT_DESKTOP_SETTINGS); + expect(readDesktopSettings(settingsPath, "0.0.17")).toEqual(DEFAULT_DESKTOP_SETTINGS); + }); + + it("falls back to the nightly channel for legacy nightly settings without an update track", () => { + const settingsPath = makeSettingsPath(); + fs.writeFileSync(settingsPath, JSON.stringify({ serverExposureMode: "local-only" }), "utf8"); + + expect(readDesktopSettings(settingsPath, "0.0.17-nightly.20260415.1")).toEqual({ + serverExposureMode: "local-only", + updateChannel: "nightly", + updateChannelConfiguredByUser: false, + }); + }); + + it("migrates legacy implicit stable settings to nightly when running a nightly build", () => { + const settingsPath = makeSettingsPath(); + fs.writeFileSync( + settingsPath, + JSON.stringify({ + serverExposureMode: "local-only", + updateChannel: "latest", + }), + "utf8", + ); + + expect(readDesktopSettings(settingsPath, "0.0.17-nightly.20260415.1")).toEqual({ + serverExposureMode: "local-only", + updateChannel: "nightly", + updateChannelConfiguredByUser: false, + }); + }); + + it("preserves an explicit stable choice on nightly builds", () => { + const settingsPath = makeSettingsPath(); + fs.writeFileSync( + settingsPath, + JSON.stringify({ + serverExposureMode: "local-only", + updateChannel: "latest", + updateChannelConfiguredByUser: true, + }), + "utf8", + ); + + expect(readDesktopSettings(settingsPath, "0.0.17-nightly.20260415.1")).toEqual({ + serverExposureMode: "local-only", + updateChannel: "latest", + updateChannelConfiguredByUser: true, + }); }); }); diff --git a/apps/desktop/src/desktopSettings.ts b/apps/desktop/src/desktopSettings.ts index 7fc0ddd786..cb0829a8b6 100644 --- a/apps/desktop/src/desktopSettings.ts +++ b/apps/desktop/src/desktopSettings.ts @@ -2,16 +2,27 @@ import * as FS from "node:fs"; import * as Path from "node:path"; import type { DesktopServerExposureMode, DesktopUpdateChannel } from "@t3tools/contracts"; +import { resolveDefaultDesktopUpdateChannel } from "./updateChannels"; + export interface DesktopSettings { readonly serverExposureMode: DesktopServerExposureMode; readonly updateChannel: DesktopUpdateChannel; + readonly updateChannelConfiguredByUser: boolean; } export const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = { serverExposureMode: "local-only", updateChannel: "latest", + updateChannelConfiguredByUser: false, }; +export function resolveDefaultDesktopSettings(appVersion: string): DesktopSettings { + return { + ...DEFAULT_DESKTOP_SETTINGS, + updateChannel: resolveDefaultDesktopUpdateChannel(appVersion), + }; +} + export function setDesktopServerExposurePreference( settings: DesktopSettings, requestedMode: DesktopServerExposureMode, @@ -28,33 +39,47 @@ export function setDesktopUpdateChannelPreference( settings: DesktopSettings, requestedChannel: DesktopUpdateChannel, ): DesktopSettings { - return settings.updateChannel === requestedChannel - ? settings - : { - ...settings, - updateChannel: requestedChannel, - }; + return { + ...settings, + updateChannel: requestedChannel, + updateChannelConfiguredByUser: true, + }; } -export function readDesktopSettings(settingsPath: string): DesktopSettings { +export function readDesktopSettings(settingsPath: string, appVersion: string): DesktopSettings { + const defaultSettings = resolveDefaultDesktopSettings(appVersion); + try { if (!FS.existsSync(settingsPath)) { - return DEFAULT_DESKTOP_SETTINGS; + return defaultSettings; } const raw = FS.readFileSync(settingsPath, "utf8"); const parsed = JSON.parse(raw) as { readonly serverExposureMode?: unknown; readonly updateChannel?: unknown; + readonly updateChannelConfiguredByUser?: unknown; }; + const parsedUpdateChannel = + parsed.updateChannel === "nightly" || parsed.updateChannel === "latest" + ? parsed.updateChannel + : null; + const isLegacySettings = parsed.updateChannelConfiguredByUser === undefined; + const updateChannelConfiguredByUser = + parsed.updateChannelConfiguredByUser === true || + (isLegacySettings && parsedUpdateChannel === "nightly"); return { serverExposureMode: parsed.serverExposureMode === "network-accessible" ? "network-accessible" : "local-only", - updateChannel: parsed.updateChannel === "nightly" ? "nightly" : "latest", + updateChannel: + updateChannelConfiguredByUser && parsedUpdateChannel !== null + ? parsedUpdateChannel + : defaultSettings.updateChannel, + updateChannelConfiguredByUser, }; } catch { - return DEFAULT_DESKTOP_SETTINGS; + return defaultSettings; } } diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts index 987cad3408..4386c340f9 100644 --- a/apps/desktop/src/main.ts +++ b/apps/desktop/src/main.ts @@ -58,6 +58,7 @@ import { showDesktopConfirmDialog } from "./confirmDialog"; import { resolveDesktopServerExposure } from "./serverExposure"; import { syncShellEnvironment } from "./syncShellEnvironment"; import { getAutoUpdateDisabledReason, shouldBroadcastDownloadProgress } from "./updateState"; +import { doesVersionMatchDesktopUpdateChannel } from "./updateChannels"; import { ServerListeningDetector } from "./serverListeningDetector"; import { createInitialDesktopUpdateState, @@ -190,7 +191,7 @@ let desktopLogSink: RotatingFileSink | null = null; let backendLogSink: RotatingFileSink | null = null; let restoreStdIoCapture: (() => void) | null = null; let backendObservabilitySettings = readPersistedBackendObservabilitySettings(); -let desktopSettings = readDesktopSettings(DESKTOP_SETTINGS_PATH); +let desktopSettings = readDesktopSettings(DESKTOP_SETTINGS_PATH, app.getVersion()); let desktopServerExposureMode: DesktopServerExposureMode = desktopSettings.serverExposureMode; let destructiveMenuIconCache: Electron.NativeImage | null | undefined; @@ -1140,7 +1141,7 @@ function applyAutoUpdaterChannel(channel: DesktopUpdateChannel): void { autoUpdater.allowPrerelease = channel === "nightly"; autoUpdater.allowDowngrade = channel === "nightly"; console.info( - `[desktop-updater] Using update channel '${channel}' (allowPrerelease=${channel === "nightly"}).`, + `[desktop-updater] Using update channel '${channel}' (allowPrerelease=${channel === "nightly"}, allowDowngrade=${channel === "nightly"}).`, ); } @@ -1285,6 +1286,15 @@ function configureAutoUpdater(): void { console.info("[desktop-updater] Looking for updates..."); }); autoUpdater.on("update-available", (info) => { + if (!doesVersionMatchDesktopUpdateChannel(info.version, updateState.channel)) { + console.info( + `[desktop-updater] Ignoring ${info.version} because it does not match the selected '${updateState.channel}' channel.`, + ); + setUpdateState(reduceDesktopUpdateStateOnNoUpdate(updateState, new Date().toISOString())); + lastLoggedDownloadMilestone = -1; + return; + } + setUpdateState( reduceDesktopUpdateStateOnUpdateAvailable( updateState, @@ -1792,13 +1802,14 @@ function registerIpcHandlers(): void { } const nextChannel = rawChannel as DesktopUpdateChannel; - if (nextChannel === desktopSettings.updateChannel) { - return updateState; - } desktopSettings = setDesktopUpdateChannelPreference(desktopSettings, nextChannel); writeDesktopSettings(DESKTOP_SETTINGS_PATH, desktopSettings); + if (nextChannel === updateState.channel) { + return updateState; + } + const enabled = shouldEnableAutoUpdates(); setUpdateState(createBaseUpdateState(nextChannel, enabled)); diff --git a/apps/desktop/src/updateChannels.test.ts b/apps/desktop/src/updateChannels.test.ts new file mode 100644 index 0000000000..bd1dcc0c73 --- /dev/null +++ b/apps/desktop/src/updateChannels.test.ts @@ -0,0 +1,41 @@ +import { describe, expect, it } from "vitest"; + +import { + doesVersionMatchDesktopUpdateChannel, + isNightlyDesktopVersion, + resolveDefaultDesktopUpdateChannel, +} from "./updateChannels"; + +describe("isNightlyDesktopVersion", () => { + it("detects packaged nightly versions", () => { + expect(isNightlyDesktopVersion("0.0.17-nightly.20260415.1")).toBe(true); + }); + + it("does not flag stable versions as nightly", () => { + expect(isNightlyDesktopVersion("0.0.17")).toBe(false); + }); +}); + +describe("resolveDefaultDesktopUpdateChannel", () => { + it("defaults stable builds to latest", () => { + expect(resolveDefaultDesktopUpdateChannel("0.0.17")).toBe("latest"); + }); + + it("defaults nightly builds to nightly", () => { + expect(resolveDefaultDesktopUpdateChannel("0.0.17-nightly.20260415.1")).toBe("nightly"); + }); +}); + +describe("doesVersionMatchDesktopUpdateChannel", () => { + it("accepts nightly releases on the nightly channel", () => { + expect(doesVersionMatchDesktopUpdateChannel("0.0.17-nightly.20260416.1", "nightly")).toBe(true); + }); + + it("rejects stable releases on the nightly channel", () => { + expect(doesVersionMatchDesktopUpdateChannel("0.0.17", "nightly")).toBe(false); + }); + + it("rejects nightly releases on the stable channel", () => { + expect(doesVersionMatchDesktopUpdateChannel("0.0.17-nightly.20260416.1", "latest")).toBe(false); + }); +}); diff --git a/apps/desktop/src/updateChannels.ts b/apps/desktop/src/updateChannels.ts new file mode 100644 index 0000000000..615b8e6db6 --- /dev/null +++ b/apps/desktop/src/updateChannels.ts @@ -0,0 +1,18 @@ +import type { DesktopUpdateChannel } from "@t3tools/contracts"; + +const NIGHTLY_VERSION_PATTERN = /-nightly\.\d{8}\.\d+$/; + +export function isNightlyDesktopVersion(version: string): boolean { + return NIGHTLY_VERSION_PATTERN.test(version); +} + +export function resolveDefaultDesktopUpdateChannel(appVersion: string): DesktopUpdateChannel { + return isNightlyDesktopVersion(appVersion) ? "nightly" : "latest"; +} + +export function doesVersionMatchDesktopUpdateChannel( + version: string, + channel: DesktopUpdateChannel, +): boolean { + return resolveDefaultDesktopUpdateChannel(version) === channel; +} diff --git a/apps/server/src/orchestration/Layers/ProjectionPipeline.ts b/apps/server/src/orchestration/Layers/ProjectionPipeline.ts index 833b9b02f1..cb9d424323 100644 --- a/apps/server/src/orchestration/Layers/ProjectionPipeline.ts +++ b/apps/server/src/orchestration/Layers/ProjectionPipeline.ts @@ -1283,6 +1283,14 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti } return; } + // Only approval-requested activities should create pending-approval + // rows. Other activity kinds that happen to carry a requestId + // (e.g. user-input.requested / user-input.resolved) must not + // pollute this projection — they have their own accounting via + // derivePendingUserInputCountFromActivities. + if (event.payload.activity.kind !== "approval.requested") { + return; + } if (Option.isSome(existingRow) && existingRow.value.status === "resolved") { return; } diff --git a/apps/server/src/provider/Layers/ClaudeAdapter.ts b/apps/server/src/provider/Layers/ClaudeAdapter.ts index 38fa6cb457..b8e10d0814 100644 --- a/apps/server/src/provider/Layers/ClaudeAdapter.ts +++ b/apps/server/src/provider/Layers/ClaudeAdapter.ts @@ -19,6 +19,7 @@ import { type SDKUserMessage, ModelUsage, } from "@anthropic-ai/claude-agent-sdk"; +import { parseCliArgs } from "@t3tools/shared/cliArgs"; import { ApprovalRequestId, type CanonicalItemType, @@ -2741,6 +2742,7 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( ), ); const claudeBinaryPath = claudeSettings.binaryPath; + const extraArgs = parseCliArgs(claudeSettings.launchArgs).flags; const modelSelection = input.modelSelection?.provider === "claudeAgent" ? input.modelSelection : undefined; const caps = getClaudeModelCapabilities(modelSelection?.model); @@ -2780,6 +2782,7 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( canUseTool, env: process.env, ...(input.cwd ? { additionalDirectories: [input.cwd] } : {}), + ...(Object.keys(extraArgs).length > 0 ? { extraArgs } : {}), }; const queryRuntime = yield* Effect.try({ diff --git a/apps/server/src/serverSettings.test.ts b/apps/server/src/serverSettings.test.ts index dcf3fa189e..d8a992f0ec 100644 --- a/apps/server/src/serverSettings.test.ts +++ b/apps/server/src/serverSettings.test.ts @@ -92,6 +92,7 @@ it.layer(NodeServices.layer)("server settings", (it) => { enabled: true, binaryPath: "/usr/local/bin/claude", customModels: ["claude-custom"], + launchArgs: "", }); assert.deepEqual(next.textGenerationModelSelection, { provider: "codex", @@ -167,6 +168,7 @@ it.layer(NodeServices.layer)("server settings", (it) => { enabled: true, binaryPath: "/opt/homebrew/bin/claude", customModels: [], + launchArgs: "", }); }).pipe(Effect.provide(makeServerSettingsLayer())), ); diff --git a/apps/web/src/components/ChatMarkdown.browser.tsx b/apps/web/src/components/ChatMarkdown.browser.tsx index 48f345bd2f..a397d52a37 100644 --- a/apps/web/src/components/ChatMarkdown.browser.tsx +++ b/apps/web/src/components/ChatMarkdown.browser.tsx @@ -63,7 +63,7 @@ describe("ChatMarkdown", () => { ); try { - const link = page.getByRole("link", { name: "PermissionRule.ts:1" }); + const link = page.getByRole("link", { name: "PermissionRule.ts · L1" }); await expect.element(link).toBeInTheDocument(); await expect.element(link).toHaveAttribute("href", `${filePath}#L1`); @@ -76,4 +76,66 @@ describe("ChatMarkdown", () => { await screen.unmount(); } }); + + it("shows column information inline when present", async () => { + const filePath = + "/Users/yashsingh/p/sco/claude-code-extract/src/utils/permissions/PermissionRule.ts"; + const screen = await render( + , + ); + + try { + const link = page.getByRole("link", { name: "PermissionRule.ts · L1:C7" }); + await expect.element(link).toBeInTheDocument(); + await expect.element(link).toHaveAttribute("href", `${filePath}#L1C7`); + + await link.click(); + + await vi.waitFor(() => { + expect(openInPreferredEditorMock).toHaveBeenCalledWith( + expect.anything(), + `${filePath}:1:7`, + ); + }); + } finally { + await screen.unmount(); + } + }); + + it("disambiguates duplicate file basenames inline", async () => { + const firstPath = "/Users/yashsingh/p/t3code/apps/web/src/components/chat/MessagesTimeline.tsx"; + const secondPath = "/Users/yashsingh/p/t3code/apps/web/src/components/MessagesTimeline.tsx"; + const screen = await render( + , + ); + + try { + await expect + .element(page.getByRole("link", { name: "MessagesTimeline.tsx · components/chat" })) + .toBeInTheDocument(); + await expect + .element(page.getByRole("link", { name: "MessagesTimeline.tsx · src/components" })) + .toBeInTheDocument(); + } finally { + await screen.unmount(); + } + }); + + it("keeps normal web links unchanged", async () => { + const screen = await render( + , + ); + + try { + const link = page.getByRole("link", { name: "OpenAI" }); + await expect.element(link).toBeInTheDocument(); + await expect.element(link).toHaveAttribute("href", "https://openai.com/docs"); + await expect.element(link).toHaveAttribute("target", "_blank"); + } finally { + await screen.unmount(); + } + }); }); diff --git a/apps/web/src/components/ChatMarkdown.tsx b/apps/web/src/components/ChatMarkdown.tsx index 366f923157..ba1c944cc8 100644 --- a/apps/web/src/components/ChatMarkdown.tsx +++ b/apps/web/src/components/ChatMarkdown.tsx @@ -3,6 +3,7 @@ import { CheckIcon, CopyIcon } from "lucide-react"; import React, { Children, Suspense, + type MouseEvent as ReactMouseEvent, isValidElement, use, useCallback, @@ -17,13 +18,17 @@ import type { Components } from "react-markdown"; import ReactMarkdown from "react-markdown"; import { defaultUrlTransform } from "react-markdown"; import remarkGfm from "remark-gfm"; +import { VscodeEntryIcon } from "./chat/VscodeEntryIcon"; +import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; +import { toastManager } from "./ui/toast"; import { openInPreferredEditor } from "../editorPreferences"; import { resolveDiffThemeName, type DiffThemeName } from "../lib/diffRendering"; import { fnv1a32 } from "../lib/diffRendering"; import { LRUCache } from "../lib/lruCache"; import { useTheme } from "../hooks/useTheme"; -import { resolveMarkdownFileLinkTarget, rewriteMarkdownFileUriHref } from "../markdown-links"; +import { resolveMarkdownFileLinkMeta, rewriteMarkdownFileUriHref } from "../markdown-links"; import { readLocalApi } from "../localApi"; +import { cn } from "../lib/utils"; class CodeHighlightErrorBoundary extends React.Component< { fallback: ReactNode; children: ReactNode }, @@ -236,34 +241,289 @@ function SuspenseShikiCodeBlock({ ); } +interface MarkdownFileLinkProps { + href: string; + targetPath: string; + displayPath: string; + filePath: string; + label: string; + theme: "light" | "dark"; + className?: string | undefined; +} + +const MARKDOWN_LINK_HREF_PATTERN = /\[[^\]]*]\(([^)\s]+)(?:\s+["'][^"']*["'])?\)/g; +const MARKDOWN_FILE_LINK_CLASS_NAME = + "chat-markdown-file-link relative top-[2px] max-w-full no-underline"; +const MARKDOWN_FILE_LINK_ICON_CLASS_NAME = "chat-markdown-file-link-icon size-3.5 shrink-0"; +const MARKDOWN_FILE_LINK_LABEL_CLASS_NAME = "chat-markdown-file-link-label truncate"; + +function pathParentSegments(path: string): string[] { + const normalized = path.replaceAll("\\", "/"); + const segments = normalized.split("/").filter((segment) => segment.length > 0); + return segments.slice(0, -1); +} + +function buildFileLinkParentSuffixByPath(filePaths: ReadonlyArray): Map { + const groups = new Map>(); + for (const filePath of filePaths) { + const pathSegments = filePath + .replaceAll("\\", "/") + .split("/") + .filter((segment) => segment.length > 0); + const basename = pathSegments[pathSegments.length - 1]; + if (!basename) continue; + const group = groups.get(basename) ?? new Set(); + group.add(filePath); + groups.set(basename, group); + } + + const suffixByPath = new Map(); + for (const group of groups.values()) { + const uniquePaths = [...group]; + if (uniquePaths.length < 2) continue; + + const parentSegmentsByPath = new Map( + uniquePaths.map((filePath) => [filePath, pathParentSegments(filePath)]), + ); + const minUniqueDepthByPath = new Map(); + + for (const filePath of uniquePaths) { + const segments = parentSegmentsByPath.get(filePath) ?? []; + let resolvedDepth = segments.length; + for (let depth = 1; depth <= segments.length; depth += 1) { + const candidate = segments.slice(-depth).join("/"); + const collision = uniquePaths.some((otherPath) => { + if (otherPath === filePath) return false; + const otherSegments = parentSegmentsByPath.get(otherPath) ?? []; + return otherSegments.slice(-depth).join("/") === candidate; + }); + if (!collision) { + resolvedDepth = depth; + break; + } + } + minUniqueDepthByPath.set(filePath, resolvedDepth); + } + + for (const filePath of uniquePaths) { + const segments = parentSegmentsByPath.get(filePath) ?? []; + if (segments.length === 0) continue; + const minUniqueDepth = minUniqueDepthByPath.get(filePath) ?? 1; + const suffixDepth = Math.min(segments.length, Math.max(minUniqueDepth, 2)); + suffixByPath.set(filePath, segments.slice(-suffixDepth).join("/")); + } + } + + return suffixByPath; +} + +function extractMarkdownLinkHrefs(text: string): string[] { + const hrefs: string[] = []; + for (const match of text.matchAll(MARKDOWN_LINK_HREF_PATTERN)) { + const href = match[1]?.trim(); + if (!href) continue; + hrefs.push(href); + } + return hrefs; +} + +function normalizeMarkdownLinkHrefKey(href: string): string { + return rewriteMarkdownFileUriHref(href.trim()) ?? href.trim(); +} + +const MarkdownFileLink = memo(function MarkdownFileLink({ + href, + targetPath, + displayPath, + filePath, + label, + theme, + className, +}: MarkdownFileLinkProps) { + const handleOpen = useCallback(() => { + const api = readLocalApi(); + if (!api) { + toastManager.add({ + type: "error", + title: "Open in editor is unavailable", + }); + return; + } + + void openInPreferredEditor(api, targetPath).catch((error) => { + toastManager.add({ + type: "error", + title: "Unable to open file", + description: error instanceof Error ? error.message : "An error occurred.", + }); + }); + }, [targetPath]); + + const handleCopy = useCallback((value: string, title: string) => { + if (typeof window === "undefined" || !navigator.clipboard?.writeText) { + toastManager.add({ + type: "error", + title: `Failed to copy ${title.toLowerCase()}`, + description: "Clipboard API unavailable.", + }); + return; + } + + void navigator.clipboard.writeText(value).then( + () => { + toastManager.add({ + type: "success", + title: `${title} copied`, + description: value, + }); + }, + (error) => { + toastManager.add({ + type: "error", + title: `Failed to copy ${title.toLowerCase()}`, + description: error instanceof Error ? error.message : "An error occurred.", + }); + }, + ); + }, []); + + const handleContextMenu = useCallback( + async (event: ReactMouseEvent) => { + event.preventDefault(); + event.stopPropagation(); + + const api = readLocalApi(); + if (!api) return; + + const clicked = await api.contextMenu.show( + [ + { id: "open", label: "Open in editor" }, + { id: "copy-relative", label: "Copy relative path" }, + { id: "copy-full", label: "Copy full path" }, + ] as const, + { x: event.clientX, y: event.clientY }, + ); + + if (clicked === "open") { + handleOpen(); + return; + } + if (clicked === "copy-relative") { + handleCopy(displayPath, "Relative path"); + return; + } + if (clicked === "copy-full") { + handleCopy(targetPath, "Full path"); + } + }, + [displayPath, handleCopy, handleOpen, targetPath], + ); + + return ( + + { + event.preventDefault(); + event.stopPropagation(); + handleOpen(); + }} + onContextMenu={handleContextMenu} + > + + {label} + + } + /> + +
+ {displayPath} +
+
+
+ ); +}, areMarkdownFileLinkPropsEqual); + +function areMarkdownFileLinkPropsEqual( + previous: Readonly, + next: Readonly, +): boolean { + return ( + previous.href === next.href && + previous.targetPath === next.targetPath && + previous.displayPath === next.displayPath && + previous.filePath === next.filePath && + previous.label === next.label && + previous.theme === next.theme && + previous.className === next.className + ); +} + function ChatMarkdown({ text, cwd, isStreaming = false }: ChatMarkdownProps) { const { resolvedTheme } = useTheme(); const diffThemeName = resolveDiffThemeName(resolvedTheme); + const markdownFileLinkMetaByHref = useMemo(() => { + const metaByHref = new Map< + string, + NonNullable> + >(); + for (const href of extractMarkdownLinkHrefs(text)) { + const normalizedHref = normalizeMarkdownLinkHrefKey(href); + if (metaByHref.has(normalizedHref)) continue; + const meta = resolveMarkdownFileLinkMeta(normalizedHref, cwd); + if (meta) { + metaByHref.set(normalizedHref, meta); + } + } + return metaByHref; + }, [cwd, text]); + const fileLinkParentSuffixByPath = useMemo(() => { + const filePaths = [...markdownFileLinkMetaByHref.values()].map((meta) => meta.filePath); + return buildFileLinkParentSuffixByPath(filePaths); + }, [markdownFileLinkMetaByHref]); const markdownUrlTransform = useCallback((href: string) => { return rewriteMarkdownFileUriHref(href) ?? defaultUrlTransform(href); }, []); const markdownComponents = useMemo( () => ({ a({ node: _node, href, ...props }) { - const targetPath = resolveMarkdownFileLinkTarget(href, cwd); - if (!targetPath) { + const normalizedHref = href ? normalizeMarkdownLinkHrefKey(href) : ""; + const fileLinkMeta = normalizedHref ? markdownFileLinkMetaByHref.get(normalizedHref) : null; + if (!fileLinkMeta) { return ; } + const parentSuffix = fileLinkParentSuffixByPath.get(fileLinkMeta.filePath); + const labelParts = [fileLinkMeta.basename]; + if (typeof parentSuffix === "string" && parentSuffix.length > 0) { + labelParts.push(parentSuffix); + } + if (fileLinkMeta.line) { + labelParts.push( + `L${fileLinkMeta.line}${fileLinkMeta.column ? `:C${fileLinkMeta.column}` : ""}`, + ); + } + return ( - { - event.preventDefault(); - event.stopPropagation(); - const api = readLocalApi(); - if (api) { - void openInPreferredEditor(api, targetPath); - } else { - console.warn("Native API not found. Unable to open file in editor."); - } - }} + ); }, @@ -289,7 +549,13 @@ function ChatMarkdown({ text, cwd, isStreaming = false }: ChatMarkdownProps) { ); }, }), - [cwd, diffThemeName, isStreaming], + [ + diffThemeName, + fileLinkParentSuffixByPath, + isStreaming, + markdownFileLinkMetaByHref, + resolvedTheme, + ], ); return ( diff --git a/apps/web/src/components/ComposerPromptEditor.tsx b/apps/web/src/components/ComposerPromptEditor.tsx index 95157d787f..8113099638 100644 --- a/apps/web/src/components/ComposerPromptEditor.tsx +++ b/apps/web/src/components/ComposerPromptEditor.tsx @@ -32,11 +32,8 @@ import { type ElementNode, type LexicalNode, type SerializedLexicalNode, - TextNode, - type EditorConfig, type EditorState, type NodeKey, - type SerializedTextNode, type Spread, } from "lexical"; import { @@ -103,7 +100,7 @@ type SerializedComposerMentionNode = Spread< type: "composer-mention"; version: 1; }, - SerializedTextNode + SerializedLexicalNode >; type SerializedComposerSkillNode = Spread< @@ -132,7 +129,40 @@ const ComposerTerminalContextActionsContext = createContext<{ onRemoveTerminalContext: () => {}, }); -class ComposerMentionNode extends TextNode { +function ComposerMentionDecorator(props: { path: string }) { + const theme = resolvedThemeFromDocument(); + const chip = ( + + + {basenameOfPath(props.path)} + + ); + + return ( + + + + {props.path} + + + ); +} + +class ComposerMentionNode extends DecoratorNode { __path: string; static override getType(): string { @@ -144,12 +174,12 @@ class ComposerMentionNode extends TextNode { } static override importJSON(serializedNode: SerializedComposerMentionNode): ComposerMentionNode { - return $createComposerMentionNode(serializedNode.path); + return $createComposerMentionNode(serializedNode.path).updateFromJSON(serializedNode); } constructor(path: string, key?: NodeKey) { + super(key); const normalizedPath = path.startsWith("@") ? path.slice(1) : path; - super(`@${normalizedPath}`, key); this.__path = normalizedPath; } @@ -162,41 +192,26 @@ class ComposerMentionNode extends TextNode { }; } - override createDOM(_config: EditorConfig): HTMLElement { + override createDOM(): HTMLElement { const dom = document.createElement("span"); - dom.className = COMPOSER_INLINE_CHIP_CLASS_NAME; - dom.contentEditable = "false"; - dom.setAttribute("spellcheck", "false"); - renderMentionChipDom(dom, this.__path); + dom.className = "inline-flex align-middle leading-none"; return dom; } - override updateDOM( - prevNode: ComposerMentionNode, - dom: HTMLElement, - _config: EditorConfig, - ): boolean { - dom.contentEditable = "false"; - if (prevNode.__text !== this.__text || prevNode.__path !== this.__path) { - renderMentionChipDom(dom, this.__path); - } + override updateDOM(): false { return false; } - override canInsertTextBefore(): false { - return false; + override getTextContent(): string { + return `@${this.__path}`; } - override canInsertTextAfter(): false { - return false; - } - - override isTextEntity(): true { + override isInline(): true { return true; } - override isToken(): true { - return true; + override decorate(): ReactElement { + return ; } } @@ -434,26 +449,6 @@ function resolvedThemeFromDocument(): "light" | "dark" { return document.documentElement.classList.contains("dark") ? "dark" : "light"; } -function renderMentionChipDom(container: HTMLElement, pathValue: string): void { - container.textContent = ""; - container.style.setProperty("user-select", "none"); - container.style.setProperty("-webkit-user-select", "none"); - - const theme = resolvedThemeFromDocument(); - const icon = document.createElement("img"); - icon.alt = ""; - icon.ariaHidden = "true"; - icon.className = COMPOSER_INLINE_CHIP_ICON_CLASS_NAME; - icon.loading = "lazy"; - icon.src = getVscodeIconUrlForEntry(pathValue, inferEntryKindFromPath(pathValue), theme); - - const label = document.createElement("span"); - label.className = COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME; - label.textContent = basenameOfPath(pathValue); - - container.append(icon, label); -} - function terminalContextSignature(contexts: ReadonlyArray): string { return contexts .map((context) => @@ -595,12 +590,9 @@ function getAbsoluteOffsetForPoint(node: LexicalNode, pointOffset: number): numb } if ($isTextNode(node)) { - if (node instanceof ComposerMentionNode) { - return getAbsoluteOffsetForInlineTokenPoint(node, offset, pointOffset); - } return offset + Math.min(pointOffset, node.getTextContentSize()); } - if (node instanceof ComposerSkillNode || node instanceof ComposerTerminalContextNode) { + if (isComposerInlineTokenNode(node)) { return getAbsoluteOffsetForInlineTokenPoint(node, offset, pointOffset); } @@ -642,12 +634,9 @@ function getExpandedAbsoluteOffsetForPoint(node: LexicalNode, pointOffset: numbe } if ($isTextNode(node)) { - if (node instanceof ComposerMentionNode) { - return getExpandedAbsoluteOffsetForInlineTokenPoint(node, offset, pointOffset); - } return offset + Math.min(pointOffset, node.getTextContentSize()); } - if (node instanceof ComposerSkillNode || node instanceof ComposerTerminalContextNode) { + if (isComposerInlineTokenNode(node)) { return getExpandedAbsoluteOffsetForInlineTokenPoint(node, offset, pointOffset); } @@ -673,10 +662,7 @@ function findSelectionPointAtOffset( node: LexicalNode, remainingRef: { value: number }, ): { key: string; offset: number; type: "text" | "element" } | null { - if (node instanceof ComposerMentionNode || node instanceof ComposerSkillNode) { - return findSelectionPointForInlineToken(node, remainingRef); - } - if (node instanceof ComposerTerminalContextNode) { + if (isComposerInlineTokenNode(node)) { return findSelectionPointForInlineToken(node, remainingRef); } diff --git a/apps/web/src/components/KeybindingsToast.browser.tsx b/apps/web/src/components/KeybindingsToast.browser.tsx index 92ba61aa5f..6449a71587 100644 --- a/apps/web/src/components/KeybindingsToast.browser.tsx +++ b/apps/web/src/components/KeybindingsToast.browser.tsx @@ -98,7 +98,7 @@ function createBaseServerConfig(): ServerConfig { textGenerationModelSelection: { provider: "codex" as const, model: "gpt-5.4-mini" }, providers: { codex: { enabled: true, binaryPath: "", homePath: "", customModels: [] }, - claudeAgent: { enabled: true, binaryPath: "", customModels: [] }, + claudeAgent: { enabled: true, binaryPath: "", customModels: [], launchArgs: "" }, }, }, }; diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsx new file mode 100644 index 0000000000..a8a53831a2 --- /dev/null +++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx @@ -0,0 +1,189 @@ +import { EnvironmentId, MessageId } from "@t3tools/contracts"; +import { createRef } from "react"; +import { renderToStaticMarkup } from "react-dom/server"; +import { beforeAll, describe, expect, it, vi } from "vitest"; +import type { LegendListRef } from "@legendapp/list/react"; + +vi.mock("@legendapp/list/react", async () => { + const React = await import("react"); + + const LegendList = React.forwardRef(function MockLegendList( + props: { + data: Array<{ id: string }>; + keyExtractor: (item: { id: string }) => string; + renderItem: (args: { item: { id: string } }) => React.ReactNode; + ListHeaderComponent?: React.ReactNode; + ListFooterComponent?: React.ReactNode; + }, + _ref: React.ForwardedRef, + ) { + return ( +
+ {props.ListHeaderComponent} + {props.data.map((item) => ( +
{props.renderItem({ item })}
+ ))} + {props.ListFooterComponent} +
+ ); + }); + + return { LegendList }; +}); + +function matchMedia() { + return { + matches: false, + addEventListener: () => {}, + removeEventListener: () => {}, + }; +} + +beforeAll(() => { + const classList = { + add: () => {}, + remove: () => {}, + toggle: () => {}, + contains: () => false, + }; + + vi.stubGlobal("localStorage", { + getItem: () => null, + setItem: () => {}, + removeItem: () => {}, + clear: () => {}, + }); + vi.stubGlobal("window", { + matchMedia, + addEventListener: () => {}, + removeEventListener: () => {}, + requestAnimationFrame: (callback: FrameRequestCallback) => { + callback(0); + return 0; + }, + cancelAnimationFrame: () => {}, + desktopBridge: undefined, + }); + vi.stubGlobal("document", { + documentElement: { + classList, + offsetHeight: 0, + }, + }); +}); + +const ACTIVE_THREAD_ENVIRONMENT_ID = EnvironmentId.make("environment-local"); + +function buildProps() { + return { + isWorking: false, + activeTurnInProgress: false, + activeTurnId: null, + activeTurnStartedAt: null, + listRef: createRef(), + completionDividerBeforeEntryId: null, + completionSummary: null, + turnDiffSummaryByAssistantMessageId: new Map(), + routeThreadKey: "environment-local:thread-1", + onOpenTurnDiff: () => {}, + revertTurnCountByUserMessageId: new Map(), + onRevertUserMessage: () => {}, + isRevertingCheckpoint: false, + onImageExpand: () => {}, + activeThreadEnvironmentId: ACTIVE_THREAD_ENVIRONMENT_ID, + markdownCwd: undefined, + resolvedTheme: "light" as const, + timestampFormat: "locale" as const, + workspaceRoot: undefined, + onIsAtEndChange: () => {}, + }; +} + +describe("MessagesTimeline", () => { + it("renders inline terminal labels with the composer chip UI", async () => { + const { MessagesTimeline } = await import("./MessagesTimeline"); + const markup = renderToStaticMarkup( + ", + "- Terminal 1 lines 1-5:", + " 1 | julius@mac effect-http-ws-cli % bun i", + " 2 | bun install v1.3.9 (cf6cdbbb)", + "", + ].join("\n"), + createdAt: "2026-03-17T19:12:28.000Z", + streaming: false, + }, + }, + ]} + />, + ); + + expect(markup).toContain("Terminal 1 lines 1-5"); + expect(markup).toContain("lucide-terminal"); + expect(markup).toContain("yoo what's "); + }, 20_000); + + it("renders context compaction entries in the normal work log", async () => { + const { MessagesTimeline } = await import("./MessagesTimeline"); + const markup = renderToStaticMarkup( + , + ); + + expect(markup).toContain("Context compacted"); + expect(markup).toContain("Work log"); + }); + + it("formats changed file paths from the workspace root", async () => { + const { MessagesTimeline } = await import("./MessagesTimeline"); + const markup = renderToStaticMarkup( + , + ); + + expect(markup).toContain("t3code/apps/web/src/session-logic.ts"); + expect(markup).not.toContain("C:/Users/mike/dev-stuff/t3code/apps/web/src/session-logic.ts"); + }); +}); diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx index 183dcde4f8..8fac10eb98 100644 --- a/apps/web/src/components/chat/MessagesTimeline.tsx +++ b/apps/web/src/components/chat/MessagesTimeline.tsx @@ -60,6 +60,7 @@ import { formatInlineTerminalContextLabel, textContainsInlineTerminalContextLabels, } from "./userMessageTerminalContexts"; +import { formatWorkspaceRelativePath } from "../../filePathDisplay"; // --------------------------------------------------------------------------- // Context — shared state consumed by every row component via useContext. @@ -528,6 +529,7 @@ const WorkGroupSection = memo(function WorkGroupSection({ }: { groupedEntries: Extract["groupedEntries"]; }) { + const { workspaceRoot } = use(TimelineRowCtx); const [isExpanded, setIsExpanded] = useState(false); const hasOverflow = groupedEntries.length > MAX_VISIBLE_WORK_LOG_ENTRIES; const visibleEntries = @@ -559,7 +561,11 @@ const WorkGroupSection = memo(function WorkGroupSection({ )}
{visibleEntries.map((workEntry) => ( - + ))}
@@ -861,15 +867,17 @@ function workToneClass(tone: "thinking" | "tool" | "info" | "error"): string { function workEntryPreview( workEntry: Pick, + workspaceRoot: string | undefined, ) { if (workEntry.command) return workEntry.command; if (workEntry.detail) return workEntry.detail; if ((workEntry.changedFiles?.length ?? 0) === 0) return null; const [firstPath] = workEntry.changedFiles ?? []; if (!firstPath) return null; + const displayPath = formatWorkspaceRelativePath(firstPath, workspaceRoot); return workEntry.changedFiles!.length === 1 - ? firstPath - : `${firstPath} +${workEntry.changedFiles!.length - 1} more`; + ? displayPath + : `${displayPath} +${workEntry.changedFiles!.length - 1} more`; } function workEntryRawCommand( @@ -924,12 +932,13 @@ function toolWorkEntryHeading(workEntry: TimelineWorkEntry): string { const SimpleWorkEntryRow = memo(function SimpleWorkEntryRow(props: { workEntry: TimelineWorkEntry; + workspaceRoot: string | undefined; }) { - const { workEntry } = props; + const { workEntry, workspaceRoot } = props; const iconConfig = workToneIcon(workEntry.tone); const EntryIcon = workEntryIcon(workEntry); const heading = toolWorkEntryHeading(workEntry); - const preview = workEntryPreview(workEntry); + const preview = workEntryPreview(workEntry, workspaceRoot); const rawCommand = workEntryRawCommand(workEntry); const displayText = preview ? `${heading} - ${preview}` : heading; const hasChangedFiles = (workEntry.changedFiles?.length ?? 0) > 0; @@ -988,15 +997,18 @@ const SimpleWorkEntryRow = memo(function SimpleWorkEntryRow(props: { {hasChangedFiles && !previewIsChangedFiles && (
- {workEntry.changedFiles?.slice(0, 4).map((filePath) => ( - - {filePath} - - ))} + {workEntry.changedFiles?.slice(0, 4).map((filePath) => { + const displayPath = formatWorkspaceRelativePath(filePath, workspaceRoot); + return ( + + {displayPath} + + ); + })} {(workEntry.changedFiles?.length ?? 0) > 4 && ( +{(workEntry.changedFiles?.length ?? 0) - 4} diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx index 1d297add3c..f76c69581d 100644 --- a/apps/web/src/components/settings/SettingsPanels.tsx +++ b/apps/web/src/components/settings/SettingsPanels.tsx @@ -511,7 +511,8 @@ export function GeneralSettingsPanel() { claudeAgent: Boolean( settings.providers.claudeAgent.binaryPath !== DEFAULT_UNIFIED_SETTINGS.providers.claudeAgent.binaryPath || - settings.providers.claudeAgent.customModels.length > 0, + settings.providers.claudeAgent.customModels.length > 0 || + settings.providers.claudeAgent.launchArgs !== "", ), }); const [customModelInputByProvider, setCustomModelInputByProvider] = useState< @@ -1278,6 +1279,37 @@ export function GeneralSettingsPanel() {
) : null} + {providerCard.provider === "claudeAgent" ? ( +
+ +
+ ) : null} +
Models
diff --git a/apps/web/src/filePathDisplay.test.ts b/apps/web/src/filePathDisplay.test.ts new file mode 100644 index 0000000000..c196b5677b --- /dev/null +++ b/apps/web/src/filePathDisplay.test.ts @@ -0,0 +1,41 @@ +import { describe, expect, it } from "vitest"; + +import { formatWorkspaceRelativePath } from "./filePathDisplay"; + +describe("formatWorkspaceRelativePath", () => { + it("formats absolute workspace paths from the workspace root", () => { + expect( + formatWorkspaceRelativePath( + "C:/Users/mike/dev-stuff/t3code/apps/web/src/session-logic.ts:501", + "C:/Users/mike/dev-stuff/t3code", + ), + ).toBe("t3code/apps/web/src/session-logic.ts:501"); + }); + + it("prefixes relative paths with the workspace root label", () => { + expect( + formatWorkspaceRelativePath( + "apps/web/src/session-logic.ts:501", + "C:/Users/mike/dev-stuff/t3code", + ), + ).toBe("t3code/apps/web/src/session-logic.ts:501"); + }); + + it("keeps paths already rooted at the workspace label stable", () => { + expect( + formatWorkspaceRelativePath( + "t3code/apps/web/src/session-logic.ts:501", + "C:/Users/mike/dev-stuff/t3code", + ), + ).toBe("t3code/apps/web/src/session-logic.ts:501"); + }); + + it("preserves columns when present", () => { + expect( + formatWorkspaceRelativePath( + "/C:/Users/mike/dev-stuff/t3code/apps/web/src/session-logic.ts:501:9", + "C:/Users/mike/dev-stuff/t3code", + ), + ).toBe("t3code/apps/web/src/session-logic.ts:501:9"); + }); +}); diff --git a/apps/web/src/filePathDisplay.ts b/apps/web/src/filePathDisplay.ts new file mode 100644 index 0000000000..5a6e2a02e1 --- /dev/null +++ b/apps/web/src/filePathDisplay.ts @@ -0,0 +1,57 @@ +import { splitPathAndPosition } from "./terminal-links"; + +function normalizePathSeparators(path: string): string { + return path.replaceAll("\\", "/"); +} + +function canonicalizeWindowsDrivePath(path: string): string { + return /^\/[A-Za-z]:\//.test(path) ? path.slice(1) : path; +} + +function trimTrailingPathSeparators(path: string): string { + return path.replace(/[\\/]+$/, ""); +} + +function basenameOfPath(path: string): string { + const separatorIndex = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\")); + return separatorIndex >= 0 ? path.slice(separatorIndex + 1) : path; +} + +function stripRelativePrefixes(path: string): string { + return path.replace(/^\.\/+/, "").replace(/^\/+/, ""); +} + +export function formatWorkspaceRelativePath( + pathWithPosition: string, + workspaceRoot: string | undefined, +): string { + const { path, line, column } = splitPathAndPosition(pathWithPosition); + const normalizedPath = canonicalizeWindowsDrivePath(normalizePathSeparators(path)); + + let displayPath = normalizedPath; + if (workspaceRoot) { + const normalizedWorkspaceRoot = canonicalizeWindowsDrivePath( + normalizePathSeparators(trimTrailingPathSeparators(workspaceRoot)), + ); + const workspaceLabel = basenameOfPath(normalizedWorkspaceRoot); + const pathForCompare = normalizedPath.toLowerCase(); + const workspaceForCompare = normalizedWorkspaceRoot.toLowerCase(); + const workspaceWithSeparator = `${workspaceForCompare}/`; + const workspaceLabelWithSeparator = `${workspaceLabel.toLowerCase()}/`; + + if (pathForCompare === workspaceForCompare) { + displayPath = workspaceLabel; + } else if (pathForCompare.startsWith(workspaceWithSeparator)) { + const relativeSuffix = normalizedPath.slice(normalizedWorkspaceRoot.length + 1); + displayPath = `${workspaceLabel}/${relativeSuffix}`; + } else if (!normalizedPath.startsWith("/")) { + const relativePath = stripRelativePrefixes(normalizedPath); + displayPath = pathForCompare.startsWith(workspaceLabelWithSeparator) + ? normalizedPath + : `${workspaceLabel}/${relativePath}`; + } + } + + if (!line) return displayPath; + return `${displayPath}:${line}${column ? `:${column}` : ""}`; +} diff --git a/apps/web/src/index.css b/apps/web/src/index.css index 833fb1d8d6..6a4db39855 100644 --- a/apps/web/src/index.css +++ b/apps/web/src/index.css @@ -324,6 +324,47 @@ label:has(> select#reasoning-effort) select { font-size: 0.75rem; } +.chat-markdown-file-link { + display: inline-flex; + align-items: center; + gap: 0.28rem; + border: 1px solid color-mix(in srgb, var(--border) 92%, transparent); + border-radius: 0.375rem; + background: color-mix(in srgb, var(--muted) 88%, var(--background)); + padding: 0.08rem 0.34rem; + color: var(--foreground); + font-family: var(--font-mono, ui-monospace, monospace); + font-size: 0.75rem; + line-height: 1.15; + vertical-align: text-bottom; + transition: + background-color 120ms ease, + border-color 120ms ease, + color 120ms ease, + opacity 120ms ease; +} + +.chat-markdown-file-link:hover { + opacity: 1; + color: var(--foreground); + border-color: color-mix(in srgb, var(--border) 65%, var(--foreground)); + background: color-mix(in srgb, var(--muted) 72%, var(--background)); +} + +.chat-markdown-file-link:focus-visible { + outline: none; + box-shadow: 0 0 0 1px color-mix(in srgb, var(--ring) 70%, transparent); +} + +.chat-markdown-file-link-icon { + opacity: 0.72; +} + +.chat-markdown-file-link-label { + color: color-mix(in srgb, var(--foreground) 88%, transparent); + line-height: 1.1; +} + .chat-markdown pre { max-width: 100%; overflow-x: auto; @@ -340,6 +381,24 @@ label:has(> select#reasoning-effort) select { font-size: 0.75rem; } +.markdown-file-link-tooltip-scroll { + scrollbar-width: thin; + scrollbar-color: color-mix(in srgb, var(--border) 78%, transparent) transparent; +} + +.markdown-file-link-tooltip-scroll::-webkit-scrollbar { + height: 6px; +} + +.markdown-file-link-tooltip-scroll::-webkit-scrollbar-track { + background: transparent; +} + +.markdown-file-link-tooltip-scroll::-webkit-scrollbar-thumb { + border-radius: 999px; + background: color-mix(in srgb, var(--border) 78%, transparent); +} + .chat-markdown .chat-markdown-codeblock { --chat-markdown-codeblock-copy-button-space: 1.5rem; position: relative; diff --git a/apps/web/src/markdown-links.test.ts b/apps/web/src/markdown-links.test.ts index d3ca8bc99a..a49512d8ec 100644 --- a/apps/web/src/markdown-links.test.ts +++ b/apps/web/src/markdown-links.test.ts @@ -1,6 +1,10 @@ import { describe, expect, it } from "vitest"; -import { resolveMarkdownFileLinkTarget, rewriteMarkdownFileUriHref } from "./markdown-links"; +import { + resolveMarkdownFileLinkMeta, + resolveMarkdownFileLinkTarget, + rewriteMarkdownFileUriHref, +} from "./markdown-links"; describe("rewriteMarkdownFileUriHref", () => { it("rewrites file uri hrefs into direct path hrefs", () => { @@ -57,6 +61,29 @@ describe("resolveMarkdownFileLinkTarget", () => { ); }); + it("formats tooltip display paths relative to the cwd when possible", () => { + expect( + resolveMarkdownFileLinkMeta( + "file:///C:/Users/mike/dev-stuff/t3code/apps/web/src/session-logic.ts#L501", + "C:/Users/mike/dev-stuff/t3code", + ), + ).toMatchObject({ + displayPath: "t3code/apps/web/src/session-logic.ts:501", + }); + }); + + it("formats tooltip display paths relative to the cwd for slash-prefixed windows paths", () => { + expect( + resolveMarkdownFileLinkMeta( + "/C:/Users/mike/dev-stuff/t3code/apps/web/src/components/chat/MessagesTimeline.virtualization.browser.tsx", + "C:/Users/mike/dev-stuff/t3code", + ), + ).toMatchObject({ + displayPath: + "t3code/apps/web/src/components/chat/MessagesTimeline.virtualization.browser.tsx", + }); + }); + it("does not treat app routes as file links", () => { expect(resolveMarkdownFileLinkTarget("/chat/settings")).toBeNull(); }); diff --git a/apps/web/src/markdown-links.ts b/apps/web/src/markdown-links.ts index b5dcab0100..003fb0409d 100644 --- a/apps/web/src/markdown-links.ts +++ b/apps/web/src/markdown-links.ts @@ -1,4 +1,5 @@ -import { resolvePathLinkTarget } from "./terminal-links"; +import { formatWorkspaceRelativePath } from "./filePathDisplay"; +import { resolvePathLinkTarget, splitPathAndPosition } from "./terminal-links"; const WINDOWS_DRIVE_PATH_PATTERN = /^[A-Za-z]:[\\/]/; const WINDOWS_UNC_PATH_PATTERN = /^\\\\/; @@ -21,6 +22,15 @@ const POSIX_FILE_ROOT_PREFIXES = [ "/root/", ] as const; +export interface MarkdownFileLinkMeta { + filePath: string; + targetPath: string; + displayPath: string; + basename: string; + line?: number; + column?: number; +} + function safeDecode(value: string): string { try { return decodeURIComponent(value); @@ -143,3 +153,31 @@ export function resolveMarkdownFileLinkTarget( if (!cwd) return null; return resolvePathLinkTarget(pathWithPosition, cwd); } + +function basenameOfPath(path: string): string { + const separatorIndex = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\")); + return separatorIndex >= 0 ? path.slice(separatorIndex + 1) : path; +} + +export function resolveMarkdownFileLinkMeta( + href: string | undefined, + cwd?: string, +): MarkdownFileLinkMeta | null { + const targetPath = resolveMarkdownFileLinkTarget(href, cwd); + if (!targetPath) return null; + + const { path, line, column } = splitPathAndPosition(targetPath); + const parsedLine = line ? Number.parseInt(line, 10) : Number.NaN; + const parsedColumn = column ? Number.parseInt(column, 10) : Number.NaN; + const lineNumber = Number.isFinite(parsedLine) ? parsedLine : undefined; + const columnNumber = Number.isFinite(parsedColumn) ? parsedColumn : undefined; + + return { + filePath: path, + targetPath, + displayPath: formatWorkspaceRelativePath(targetPath, cwd), + basename: basenameOfPath(path), + ...(lineNumber !== undefined ? { line: lineNumber } : {}), + ...(columnNumber !== undefined ? { column: columnNumber } : {}), + }; +} diff --git a/apps/web/src/terminal-links.ts b/apps/web/src/terminal-links.ts index 0d40a90e41..a4eeda4279 100644 --- a/apps/web/src/terminal-links.ts +++ b/apps/web/src/terminal-links.ts @@ -137,7 +137,7 @@ function inferHomeFromCwd(cwd: string): string | undefined { return undefined; } -function splitPathAndPosition(value: string): { +export function splitPathAndPosition(value: string): { path: string; line: string | undefined; column: string | undefined; diff --git a/docs/release.md b/docs/release.md index 7486dc6960..fc17d3e39d 100644 --- a/docs/release.md +++ b/docs/release.md @@ -37,7 +37,7 @@ This document covers the unified release workflow for stable and nightly desktop - tag format: `nightly-vX.Y.Z-nightly.YYYYMMDD.` - release name includes the short commit SHA - `make_latest` is always `false` -- Uses the current `apps/desktop/package.json` semver core (`X.Y.Z`) as the nightly base, then appends a nightly prerelease suffix. +- Uses the next stable patch version as the nightly base. For example, `0.0.17` produces nightlies on `0.0.18-nightly.*`. - Publishes Electron auto-update metadata to the dedicated `nightly` updater channel, so desktop users can opt into that track independently from stable. - Publishes the CLI package (`apps/server`, npm package `t3`) to the `nightly` npm dist-tag using the same nightly version. - Does not commit version bumps back to `main`. diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index fe432e098b..375f4ed27e 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -70,6 +70,7 @@ export const ClaudeSettings = Schema.Struct({ enabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))), binaryPath: makeBinaryPathSetting("claude"), customModels: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(Effect.succeed([]))), + launchArgs: Schema.String.pipe(Schema.withDecodingDefault(Effect.succeed(""))), }); export type ClaudeSettings = typeof ClaudeSettings.Type; @@ -164,6 +165,7 @@ const ClaudeSettingsPatch = Schema.Struct({ enabled: Schema.optionalKey(Schema.Boolean), binaryPath: Schema.optionalKey(Schema.String), customModels: Schema.optionalKey(Schema.Array(Schema.String)), + launchArgs: Schema.optionalKey(Schema.String), }); export const ServerSettingsPatch = Schema.Struct({ diff --git a/packages/shared/package.json b/packages/shared/package.json index d695b4d45d..a16ebc36a9 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -68,6 +68,10 @@ "types": "./src/qrCode.ts", "import": "./src/qrCode.ts" }, + "./cliArgs": { + "types": "./src/cliArgs.ts", + "import": "./src/cliArgs.ts" + }, "./path": { "types": "./src/path.ts", "import": "./src/path.ts" diff --git a/packages/shared/src/cliArgs.test.ts b/packages/shared/src/cliArgs.test.ts new file mode 100644 index 0000000000..02c0b48805 --- /dev/null +++ b/packages/shared/src/cliArgs.test.ts @@ -0,0 +1,134 @@ +import { describe, expect, it } from "vitest"; + +import { parseCliArgs } from "./cliArgs"; + +describe("parseCliArgs", () => { + it("returns empty result for empty string", () => { + expect(parseCliArgs("")).toEqual({ flags: {}, positionals: [] }); + }); + + it("returns empty result for whitespace-only string", () => { + expect(parseCliArgs(" ")).toEqual({ flags: {}, positionals: [] }); + }); + + it("returns empty result for empty array", () => { + expect(parseCliArgs([])).toEqual({ flags: {}, positionals: [] }); + }); + + it("parses --chrome boolean flag", () => { + expect(parseCliArgs("--chrome")).toEqual({ + flags: { chrome: null }, + positionals: [], + }); + }); + + it("parses --chrome with --verbose", () => { + expect(parseCliArgs("--chrome --verbose")).toEqual({ + flags: { chrome: null, verbose: null }, + positionals: [], + }); + }); + + it("parses --effort with a value", () => { + expect(parseCliArgs("--effort high")).toEqual({ + flags: { effort: "high" }, + positionals: [], + }); + }); + + it("parses --chrome --effort high --debug", () => { + expect(parseCliArgs("--chrome --effort high --debug")).toEqual({ + flags: { chrome: null, effort: "high", debug: null }, + positionals: [], + }); + }); + + it("parses --model with full model name", () => { + expect(parseCliArgs("--model claude-sonnet-4-6")).toEqual({ + flags: { model: "claude-sonnet-4-6" }, + positionals: [], + }); + }); + + it("parses --append-system-prompt with value and --chrome", () => { + expect(parseCliArgs("--append-system-prompt always-think-step-by-step --chrome")).toEqual({ + flags: { "append-system-prompt": "always-think-step-by-step", chrome: null }, + positionals: [], + }); + }); + + it("parses --max-budget-usd with numeric value", () => { + expect(parseCliArgs("--chrome --max-budget-usd 5.00")).toEqual({ + flags: { chrome: null, "max-budget-usd": "5.00" }, + positionals: [], + }); + }); + + it("parses --effort=high syntax", () => { + expect(parseCliArgs("--effort=high")).toEqual({ + flags: { effort: "high" }, + positionals: [], + }); + }); + + it("parses --key=value mixed with boolean flags", () => { + expect(parseCliArgs("--chrome --model=claude-sonnet-4-6 --debug")).toEqual({ + flags: { chrome: null, model: "claude-sonnet-4-6", debug: null }, + positionals: [], + }); + }); + + it("collects positional arguments", () => { + expect(parseCliArgs("1.2.3")).toEqual({ + flags: {}, + positionals: ["1.2.3"], + }); + }); + + it("collects positionals mixed with flags (argv array)", () => { + expect(parseCliArgs(["1.2.3", "--root", "/path", "--github-output"])).toEqual({ + flags: { root: "/path", "github-output": null }, + positionals: ["1.2.3"], + }); + }); + + it("handles extra whitespace between tokens", () => { + expect(parseCliArgs(" --chrome --verbose ")).toEqual({ + flags: { chrome: null, verbose: null }, + positionals: [], + }); + }); + + it("ignores bare -- with no flag name", () => { + expect(parseCliArgs("--")).toEqual({ flags: {}, positionals: [] }); + }); + + it("boolean flag does not consume next token as value", () => { + expect(parseCliArgs(["--github-output", "1.2.3"], { booleanFlags: ["github-output"] })).toEqual( + { + flags: { "github-output": null }, + positionals: ["1.2.3"], + }, + ); + }); + + it("non-boolean flag still consumes next token", () => { + expect(parseCliArgs(["--root", "/path", "1.2.3"], { booleanFlags: ["github-output"] })).toEqual( + { + flags: { root: "/path" }, + positionals: ["1.2.3"], + }, + ); + }); + + it("mixes boolean and value flags with positionals", () => { + expect( + parseCliArgs(["--github-output", "--root", "/path", "1.2.3"], { + booleanFlags: ["github-output"], + }), + ).toEqual({ + flags: { "github-output": null, root: "/path" }, + positionals: ["1.2.3"], + }); + }); +}); diff --git a/packages/shared/src/cliArgs.ts b/packages/shared/src/cliArgs.ts new file mode 100644 index 0000000000..2092009330 --- /dev/null +++ b/packages/shared/src/cliArgs.ts @@ -0,0 +1,76 @@ +export interface ParsedCliArgs { + readonly flags: Record; + readonly positionals: string[]; +} + +export interface ParseCliArgsOptions { + readonly booleanFlags?: readonly string[]; +} + +/** + * Parse CLI-style arguments into flags and positionals. + * + * Accepts a string (split by whitespace) or a pre-split argv array. + * Supports `--key value`, `--key=value`, and `--flag` (boolean) syntax. + * + * parseCliArgs("") + * → { flags: {}, positionals: [] } + * + * parseCliArgs("--chrome") + * → { flags: { chrome: null }, positionals: [] } + * + * parseCliArgs("--chrome --effort high") + * → { flags: { chrome: null, effort: "high" }, positionals: [] } + * + * parseCliArgs("--effort=high") + * → { flags: { effort: "high" }, positionals: [] } + * + * parseCliArgs(["1.2.3", "--root", "/path", "--github-output"], { booleanFlags: ["github-output"] }) + * → { flags: { root: "/path", "github-output": null }, positionals: ["1.2.3"] } + */ +export function parseCliArgs( + args: string | readonly string[], + options?: ParseCliArgsOptions, +): ParsedCliArgs { + const tokens = + typeof args === "string" ? args.trim().split(/\s+/).filter(Boolean) : Array.from(args); + const booleanSet = options?.booleanFlags ? new Set(options.booleanFlags) : undefined; + + const flags: Record = {}; + const positionals: string[] = []; + + for (let i = 0; i < tokens.length; i++) { + const token = tokens[i]!; + + if (token.startsWith("--")) { + const rest = token.slice(2); + if (!rest) continue; + + // Handle --key=value syntax + const eqIndex = rest.indexOf("="); + if (eqIndex !== -1) { + flags[rest.slice(0, eqIndex)] = rest.slice(eqIndex + 1); + continue; + } + + // Known boolean flag — never consumes next token + if (booleanSet?.has(rest)) { + flags[rest] = null; + continue; + } + + // Handle --key value or --flag (boolean) + const next = tokens[i + 1]; + if (next !== undefined && !next.startsWith("--")) { + flags[rest] = next; + i++; + } else { + flags[rest] = null; + } + } else { + positionals.push(token); + } + } + + return { flags, positionals }; +} diff --git a/scripts/release-smoke.ts b/scripts/release-smoke.ts index 3ca283c11a..960730a354 100644 --- a/scripts/release-smoke.ts +++ b/scripts/release-smoke.ts @@ -127,17 +127,17 @@ try { ); assertContains( nightlyReleaseMetadata, - "version=9.9.9-nightly.20260413.321", + "version=9.9.10-nightly.20260413.321", "Expected nightly metadata to contain the derived nightly version.", ); assertContains( nightlyReleaseMetadata, - "tag=nightly-v9.9.9-nightly.20260413.321", + "tag=nightly-v9.9.10-nightly.20260413.321", "Expected nightly metadata to contain the derived nightly tag.", ); assertContains( nightlyReleaseMetadata, - "name=T3 Code Nightly 9.9.9-nightly.20260413.321 (abcdef123456)", + "name=T3 Code Nightly 9.9.10-nightly.20260413.321 (abcdef123456)", "Expected nightly metadata to include the short commit SHA in the release name.", ); diff --git a/scripts/resolve-nightly-release.test.ts b/scripts/resolve-nightly-release.test.ts index 8a38143445..56358d6c14 100644 --- a/scripts/resolve-nightly-release.test.ts +++ b/scripts/resolve-nightly-release.test.ts @@ -3,6 +3,7 @@ import { assert, it } from "@effect/vitest"; import { resolveNightlyBaseVersion, resolveNightlyReleaseMetadata, + resolveNightlyTargetVersion, } from "./resolve-nightly-release.ts"; it("strips prerelease and build metadata when deriving the nightly base version", () => { @@ -11,14 +12,20 @@ it("strips prerelease and build metadata when deriving the nightly base version" assert.equal(resolveNightlyBaseVersion("1.2.3-beta.4+build.9"), "1.2.3"); }); +it("bumps the patch version before deriving nightly prerelease versions", () => { + assert.equal(resolveNightlyTargetVersion("0.0.17"), "0.0.18"); + assert.equal(resolveNightlyTargetVersion("9.9.9-smoke.0"), "9.9.10"); + assert.equal(resolveNightlyTargetVersion("1.2.3-beta.4+build.9"), "1.2.4"); +}); + it("derives nightly metadata including the short commit sha in the release name", () => { assert.deepStrictEqual( - resolveNightlyReleaseMetadata("9.9.9", "20260413", 321, "abcdef1234567890"), + resolveNightlyReleaseMetadata("9.9.10", "20260413", 321, "abcdef1234567890"), { - baseVersion: "9.9.9", - version: "9.9.9-nightly.20260413.321", - tag: "nightly-v9.9.9-nightly.20260413.321", - name: "T3 Code Nightly 9.9.9-nightly.20260413.321 (abcdef123456)", + baseVersion: "9.9.10", + version: "9.9.10-nightly.20260413.321", + tag: "nightly-v9.9.10-nightly.20260413.321", + name: "T3 Code Nightly 9.9.10-nightly.20260413.321 (abcdef123456)", shortSha: "abcdef123456", }, ); diff --git a/scripts/resolve-nightly-release.ts b/scripts/resolve-nightly-release.ts index 571baec8f4..4a92ef63ae 100644 --- a/scripts/resolve-nightly-release.ts +++ b/scripts/resolve-nightly-release.ts @@ -32,6 +32,17 @@ const decodeDesktopPackageJson = Schema.decodeUnknownEffect( export const resolveNightlyBaseVersion = (version: string) => version.replace(/[-+].*$/, ""); +export const resolveNightlyTargetVersion = (version: string) => { + const stableCore = resolveNightlyBaseVersion(version); + const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(stableCore); + if (!match) { + throw new Error(`Invalid desktop package version '${version}'.`); + } + + const [, major, minor, patch] = match; + return `${major}.${minor}.${Number(patch) + 1}`; +}; + export const resolveNightlyReleaseMetadata = ( baseVersion: string, date: string, @@ -59,7 +70,7 @@ const readDesktopBaseVersion = Effect.fn("readDesktopBaseVersion")(function* ( const packageJson = yield* fs .readFileString(packageJsonPath) .pipe(Effect.flatMap(decodeDesktopPackageJson)); - return resolveNightlyBaseVersion(packageJson.version); + return resolveNightlyTargetVersion(packageJson.version); }); const writeOutput = Effect.fn("writeOutput")(function* ( diff --git a/scripts/update-release-package-versions.test.ts b/scripts/update-release-package-versions.test.ts new file mode 100644 index 0000000000..9e31c7675b --- /dev/null +++ b/scripts/update-release-package-versions.test.ts @@ -0,0 +1,71 @@ +import { describe, expect, it } from "vitest"; + +import { parseArgs } from "./update-release-package-versions.ts"; + +describe("parseArgs", () => { + it("parses version only", () => { + expect(parseArgs(["1.2.3"])).toEqual({ + version: "1.2.3", + rootDir: undefined, + writeGithubOutput: false, + }); + }); + + it("parses version with --root", () => { + expect(parseArgs(["1.2.3", "--root", "/path"])).toEqual({ + version: "1.2.3", + rootDir: "/path", + writeGithubOutput: false, + }); + }); + + it("parses version with --github-output", () => { + expect(parseArgs(["1.2.3", "--github-output"])).toEqual({ + version: "1.2.3", + rootDir: undefined, + writeGithubOutput: true, + }); + }); + + it("parses version with --root and --github-output", () => { + expect(parseArgs(["1.2.3", "--root", "/path", "--github-output"])).toEqual({ + version: "1.2.3", + rootDir: "/path", + writeGithubOutput: true, + }); + }); + + it("accepts flags before the version positional", () => { + expect(parseArgs(["--github-output", "--root", "/path", "1.2.3"])).toEqual({ + version: "1.2.3", + rootDir: "/path", + writeGithubOutput: true, + }); + }); + + it("throws on missing version", () => { + expect(() => parseArgs([])).toThrow("Usage:"); + }); + + it("throws on duplicate version", () => { + expect(() => parseArgs(["1.2.3", "2.0.0"])).toThrow( + "Only one release version can be provided.", + ); + }); + + it("throws on unknown flag", () => { + expect(() => parseArgs(["1.2.3", "--unknown"])).toThrow("Unknown argument: --unknown"); + }); + + it("throws on --root without value", () => { + expect(() => parseArgs(["1.2.3", "--root"])).toThrow("Missing value for --root."); + }); + + it("does not consume version as --github-output value", () => { + expect(parseArgs(["--github-output", "1.2.3"])).toEqual({ + version: "1.2.3", + rootDir: undefined, + writeGithubOutput: true, + }); + }); +}); diff --git a/scripts/update-release-package-versions.ts b/scripts/update-release-package-versions.ts index b860b85e8e..cefeef33ea 100644 --- a/scripts/update-release-package-versions.ts +++ b/scripts/update-release-package-versions.ts @@ -2,6 +2,8 @@ import { appendFileSync, readFileSync, writeFileSync } from "node:fs"; import { resolve } from "node:path"; import { fileURLToPath } from "node:url"; +import { parseCliArgs } from "@t3tools/shared/cliArgs"; + export const releasePackageFiles = [ "apps/server/package.json", "apps/desktop/package.json", @@ -40,52 +42,37 @@ export function updateReleasePackageVersions( return { changed }; } -function parseArgs(argv: ReadonlyArray): { +export function parseArgs(argv: ReadonlyArray): { version: string; rootDir: string | undefined; writeGithubOutput: boolean; } { - let version: string | undefined; - let rootDir: string | undefined; - let writeGithubOutput = false; + const { flags, positionals } = parseCliArgs(argv, { booleanFlags: ["github-output"] }); - for (let index = 0; index < argv.length; index += 1) { - const argument = argv[index]; - if (argument === undefined) { - continue; - } - - if (argument === "--github-output") { - writeGithubOutput = true; - continue; - } - - if (argument === "--root") { - rootDir = argv[index + 1]; - if (!rootDir) { - throw new Error("Missing value for --root."); - } - index += 1; - continue; - } - - if (argument.startsWith("--")) { - throw new Error(`Unknown argument: ${argument}`); - } - - if (version !== undefined) { - throw new Error("Only one release version can be provided."); - } - version = argument; + const unknownFlags = Object.keys(flags).filter((k) => k !== "github-output" && k !== "root"); + if (unknownFlags.length > 0) { + throw new Error(`Unknown argument: --${unknownFlags[0]}`); } - if (!version) { + if ("root" in flags && flags.root === null) { + throw new Error("Missing value for --root."); + } + + if (positionals.length > 1) { + throw new Error("Only one release version can be provided."); + } + + if (positionals.length !== 1 || !positionals[0]) { throw new Error( "Usage: node scripts/update-release-package-versions.ts [--root ] [--github-output]", ); } - return { version, rootDir, writeGithubOutput }; + return { + version: positionals[0], + rootDir: flags.root ?? undefined, + writeGithubOutput: "github-output" in flags, + }; } const isMain =