Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ const ReadyTerminalSurface = memo(function ReadyTerminalSurface({
if (NativeTerminalSurfaceView) {
return (
<View style={props.style}>
{/* oxlint-disable-next-line react/static-components -- The resolver returns a cached native component with stable identity. */}
<NativeTerminalSurfaceView
ref={nativeRef}
appearanceScheme={themeAppearance}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ function setup() {
// Mirrors the draft screen applying its route project on mount, before the provider's effects run.
useEffect(() => {
if (props.pickOnMount) value.setProject(props.pickOnMount);
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- picks once on mount; setProject changes every render
}, []);
return null;
}
Expand Down
10 changes: 3 additions & 7 deletions apps/mobile/src/features/threads/thread-work-log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import { useAtomCommand } from "../../state/use-atom-command";
import { toolActivityFaviconUrl } from "@t3tools/shared/favicon";
import { isJavaScriptReplTool } from "@t3tools/shared/toolActivity";
import { useMarkdownCodeHighlight } from "./markdownCodeHighlightState";
import { highlightCommand, type HighlightedLines } from "../../lib/highlights";
import { highlightCommand, type HighlightedLines, withTokenStarts } from "../../lib/highlights";
import {
commandHighlightLanguage,
withVisibleControlCharacters,
Expand Down Expand Up @@ -851,15 +851,11 @@ function HighlightedCodeText({
readonly code: string;
readonly lines: HighlightedLines | null;
}) {
let offset = 0;
const highlighted = lines?.flatMap((line, lineIndex) => {
const highlighted = (lines ? withTokenStarts(lines) : undefined)?.flatMap((line, lineIndex) => {
const separator = lineIndex > 0 ? "\n" : "";
offset += separator.length;
return [
separator,
...line.map((token) => {
const start = offset;
offset += token.content.length;
...line.map(({ token, start }) => {
// Plain RN Text inherits the mono font; AppText would reset it to sans.
return (
<RNText key={start} style={token.color ? { color: token.color } : undefined}>
Expand Down
33 changes: 16 additions & 17 deletions apps/mobile/src/features/threads/thread-workflow-opening.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useMarkdownCodeHighlight } from "./markdownCodeHighlightState";
import { SubagentRow } from "./SubagentRow";
import { WorkLogBlock } from "./work-log-layout";
import { useOpenLinkedThread } from "./useOpenLinkedThread";
import { withTokenStarts } from "../../lib/highlights";

const FOLDED_SCRIPT_LINES = 10;

Expand Down Expand Up @@ -169,23 +170,21 @@ function WorkflowScript(props: { readonly script: string }) {
const lineCount = script.split("\n").length;
const canFold = lineCount > FOLDED_SCRIPT_LINES;
const shownLines = canFold && !expanded ? FOLDED_SCRIPT_LINES : lineCount;
let offset = 0;
const highlighted = lines?.slice(0, shownLines).flatMap((line, lineIndex) => {
const separator = lineIndex > 0 ? "\n" : "";
offset += separator.length;
return [
separator,
...line.map((token) => {
const start = offset;
offset += token.content.length;
return (
<Text key={start} style={token.color ? { color: token.color } : undefined}>
{token.content}
</Text>
);
}),
];
});
const highlighted = (lines ? withTokenStarts(lines) : undefined)
?.slice(0, shownLines)
.flatMap((line, lineIndex) => {
const separator = lineIndex > 0 ? "\n" : "";
return [
separator,
...line.map(({ token, start }) => {
return (
<Text key={start} style={token.color ? { color: token.color } : undefined}>
{token.content}
</Text>
);
}),
];
});
return (
<View className="gap-1">
<View className="rounded-lg bg-subtle px-3 py-2.5">
Expand Down
15 changes: 15 additions & 0 deletions apps/mobile/src/lib/highlights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,21 @@ function withOffsets(code: string, lines: HighlightedLines): SyntaxToken[][] {
});
}

/** Pairs each token with its start in the lines joined by "\n", a stable React key. */
export function withTokenStarts(
lines: HighlightedLines,
): ReadonlyArray<ReadonlyArray<{ readonly token: HighlightedToken; readonly start: number }>> {
let offset = 0;
return lines.map((line, index) => {
if (index > 0) offset += 1;
return line.map((token) => {
const start = offset;
offset += token.content.length;
return { token, start };
});
});
}

/** LF and CRLF split lines; a trailing line break yields a final empty line. */
export function highlightCode(
code: string,
Expand Down
10 changes: 3 additions & 7 deletions apps/mobile/src/native/HighlightedCodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { MarkdownStyle } from "react-native-enriched-markdown";
import { Menu } from "../components/ui/Menu";
import { useMarkdownCodeHighlight } from "../features/threads/markdownCodeHighlightState";
import { copyTextWithHaptic } from "../lib/copyTextWithHaptic";
import type { HighlightScheme } from "../lib/highlights";
import { type HighlightScheme, withTokenStarts } from "../lib/highlights";
import { CodeBlockFrame, CodeBlockHeaderButton } from "./CodeBlockFrame";
import { fencedCodeMarkdown } from "./codeBlockMarkdown";
import type { NativeMarkdownTextStyle } from "./SelectableMarkdownText.types";
Expand Down Expand Up @@ -61,7 +61,6 @@ export function HighlightedCodeBlock(props: {
enabled: props.complete,
});
const fence = props.fence.toLowerCase();
let offset = 0;
const text = (
// Not selectable: as in the native block, a long-press opens the copy menu instead.
<Text
Expand All @@ -72,14 +71,11 @@ export function HighlightedCodeBlock(props: {
lineHeight: codeStyle.lineHeight,
}}
>
{lines?.flatMap((line, lineIndex) => {
{(lines ? withTokenStarts(lines) : undefined)?.flatMap((line, lineIndex) => {
const separator = lineIndex > 0 ? "\n" : "";
offset += separator.length;
return [
separator,
...line.map((token) => {
const start = offset;
offset += token.content.length;
...line.map(({ token, start }) => {
return (
<Text key={start} style={token.color ? { color: token.color } : undefined}>
{token.content}
Expand Down
10 changes: 5 additions & 5 deletions apps/server/src/issue/IssueService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,11 +880,11 @@ const make = Effect.gen(function* () {
}
return yield* (
failure ??
new IssueOperationError({
operation: "resolveUrl",
reason: "not-found",
detail: "This issue URL does not belong to the connected workspace.",
})
new IssueOperationError({
operation: "resolveUrl",
reason: "not-found",
detail: "This issue URL does not belong to the connected workspace.",
})
);
},
);
Expand Down
10 changes: 6 additions & 4 deletions apps/server/src/orchestration-v2/Orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13212,10 +13212,12 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
if (Option.isNone(session) || session.value.hasPendingBackgroundWorkForThread === undefined) {
return false;
}
return yield* session.value
.hasPendingBackgroundWorkForThread(providerThread)
// A failed probe cannot confirm that the work ended.
.pipe(Effect.catchCause(() => Effect.succeed(true)));
return yield* (
session.value
.hasPendingBackgroundWorkForThread(providerThread)
// A failed probe cannot confirm that the work ended.
.pipe(Effect.catchCause(() => Effect.succeed(true)))
);
});
for (const item of pendingBackgroundTurnItems({
turnItems: input.projection.turnItems,
Expand Down
9 changes: 4 additions & 5 deletions apps/server/src/orchestration-v2/PullRequestWatchReactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,11 +985,10 @@ export const make = Effect.gen(function* () {
yield* forkParked(
Stream.runForEach(engine.streamDomainEvents, (event) => {
if (event.type !== "thread.pull-request-synced") return Effect.void;
const unread = visibleThreadPullRequests(event.payload.pullRequests ?? []).flatMap(
(link) =>
link.watch === undefined || lives.has(lifeKeyOf(event.threadId, link, link.watch))
? []
: [threadPullRequestKeyOf(link)],
const unread = visibleThreadPullRequests(event.payload.pullRequests ?? []).flatMap((link) =>
link.watch === undefined || lives.has(lifeKeyOf(event.threadId, link, link.watch))
? []
: [threadPullRequestKeyOf(link)],
);
return Effect.forEach(new Set(unread), readOnChange, { discard: true });
}).pipe(Effect.catchCause(logFailure("pull request watch event stream failed", {}))),
Expand Down
12 changes: 6 additions & 6 deletions apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,12 +654,12 @@ const makeHarness = Effect.fn("makeThreadSettlementHarness")(function* (options:
]);
return yield* (
options.pullRequestSummary?.(input, readOptions) ??
Effect.succeed(
makePullRequestSummary({
...input,
state: "open",
}),
)
Effect.succeed(
makePullRequestSummary({
...input,
state: "open",
}),
)
);
});

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/project/ProjectCloneTracker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe("ProjectCloneTracker", () => {
Effect.gen(function* () {
yield* (
options?.onProgress?.({ stage: "receiving", percent: 40, detail: "1 MiB" }) ??
Effect.void
Effect.void
);
yield* Deferred.await(release);
return { cwd: input.destinationPath, remoteUrl: input.remoteUrl ?? "", repository: null };
Expand Down
29 changes: 14 additions & 15 deletions apps/server/src/pullRequest/PullRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2859,21 +2859,20 @@ export const make = Effect.gen(function* () {
);
}
return viewerPermissionsOf(project, input, "labelCandidates").pipe(
Effect.flatMap(
(viewer): Effect.Effect<PullRequestLabelCandidateList, PullRequestError> =>
viewer.labels === false
? Effect.fail(
new PullRequestOperationError({
operation: "labelCandidates",
detail: LABEL_CHANGE_REFUSAL,
}),
)
: list({
cwd: project.project.workspaceRoot,
repository: project.repository,
host: project.host,
number: input.number,
}).pipe(Effect.mapError(toPullRequestError("labelCandidates"))),
Effect.flatMap((viewer): Effect.Effect<PullRequestLabelCandidateList, PullRequestError> =>
viewer.labels === false
? Effect.fail(
new PullRequestOperationError({
operation: "labelCandidates",
detail: LABEL_CHANGE_REFUSAL,
}),
)
: list({
cwd: project.project.workspaceRoot,
repository: project.repository,
host: project.host,
number: input.number,
}).pipe(Effect.mapError(toPullRequestError("labelCandidates"))),
),
);
}),
Expand Down
8 changes: 4 additions & 4 deletions apps/server/src/terminal/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2790,10 +2790,10 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
if (!candidate) {
return yield* (
lastError ??
new PtyAdapter.PtySpawnError({
adapter: "terminal-manager",
attemptedShells: [],
})
new PtyAdapter.PtySpawnError({
adapter: "terminal-manager",
attemptedShells: [],
})
);
}

Expand Down
18 changes: 10 additions & 8 deletions apps/server/src/workspace/TaskFolders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,16 @@ const make = Effect.gen(function* () {
return refuse(
`and ${managedPolicyDeniedMessage(layoutCommandsOffBy, "project worktree layout commands")}`,
);
const approved = yield* approvals
.isApproved({ projectId: project.projectId, kind, command: text })
// An approval that cannot be read is not one.
.pipe(
Effect.catch((cause) =>
Effect.logWarning(cause.detail, { cause }).pipe(Effect.as(false)),
),
);
const approved = yield* (
approvals
.isApproved({ projectId: project.projectId, kind, command: text })
// An approval that cannot be read is not one.
.pipe(
Effect.catch((cause) =>
Effect.logWarning(cause.detail, { cause }).pipe(Effect.as(false)),
),
)
);
if (!approved)
return refuse(
"which nobody has approved as it is written now. Review and approve it in the web or desktop app, under Worktree layout in the project's settings or when starting a worktree thread there.",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"@types/use-sync-external-store": "^0.0.6",
"@vercel/config": "^0.3.0",
"@vitejs/plugin-react": "^6.1.2",
"@vitest/browser-playwright": "5.0.5",
"@vitest/browser-playwright": "5.1.1",
"compression": "^1.8.2",
"gt": "2.27.0",
"oxc-transform-react": "~0.152.0",
Expand Down
2 changes: 0 additions & 2 deletions apps/web/src/components/CommandPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,6 @@ function OpenCommandPaletteDialog(props: {
),
)
: null;
// oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
const now = new Date().toISOString();
const openableThreads = threads.filter(
(thread) => thread.settledOverride !== "settled" && !effectiveSnoozed(thread, { now }),
Expand Down Expand Up @@ -2350,7 +2349,6 @@ function OpenCommandPaletteDialog(props: {
input: {
projectId: newProjectId(),
title: inferProjectTitleFromPath(destinationPath),
// oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
createdAt: new Date().toISOString(),
remoteUrl: addProjectCloneFlow.remoteUrl,
destinationPath,
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/components/CommandPaletteThreadItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ export function useCommandPaletteThreadItems(input: {
const isOpen =
activeThread?.environmentId === thread.environmentId && activeThread.id === thread.id;
if (threadSearchQuery.trim().length > 0 && !threadSearchQuery.startsWith(">") && !isOpen) {
// oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
claimThreadOpen(thread.environmentId, thread.id, Date.now());
}
if (
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/chat/ChatHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const ChatHeader = memo(function ChatHeader({
stopObserving();
};
}, [
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- Title, font and rename changes resize the breadcrumb text without resizing the list, so it re-measures.
// Title, font and rename changes resize the breadcrumb text without resizing the list, so it re-measures.
activeProjectName,
activeThreadTitle,
parentThreadLink,
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/components/chat/ComposerImageThumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const ComposerImageThumbnail = memo(function ComposerImageThumbnail({
const cached = readComposerImageThumbnail(file);
if (file.size <= MAX_COMPRESSIBLE_SOURCE_BYTES && !isHeicImageFile(file) && !cached) {
localUrl = URL.createObjectURL(file);
// oxlint-disable-next-line react/set-state-in-effect -- the blob URL is created and revoked by this effect
setPreview({ file, src: localUrl });
}
if (cached === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/chat/ModelPickerSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const ModelPickerSidebar = memo(function ModelPickerSidebar(props: {
}
setSelectedIndicatorTop(selectedItem.offsetTop + selectedItem.offsetHeight / 2 - 10);
}, [
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- Adding, removing or reordering providers moves the selected item, so the indicator re-measures.
// Adding, removing or reordering providers moves the selected item, so the indicator re-measures.
props.instanceEntries,
props.selectedInstanceId,
showFavorites,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type PullRequestDetailView,
} from "@t3tools/contracts";
import { expect, it, vi } from "vite-plus/test";
import { page, userEvent } from "vite-plus/test/browser";
import { page } from "vite-plus/test/browser";
import appCss from "~/index.css?inline";
import { DraftId, useComposerDraftStore } from "~/composerDraftStore";
import { act, fakeTimers, render } from "../../../test/render";
Expand Down Expand Up @@ -248,7 +248,8 @@ it("reads the first diff page once the pointer rests on the Code tab", async ()
const code = screen.getByRole("button", { name: "Code", exact: true });
await expect.element(code).toBeVisible();

await userEvent.hover(code);
// userEvent advances fake timers while it runs (vitest#11242), blurring the 150 ms boundary.
await act(() => code.element().dispatchEvent(new PointerEvent("pointerover", { bubbles: true })));
await act(() => vi.advanceTimersByTime(149));
expect(reads.diff).toEqual([]);
await act(() => vi.advanceTimersByTime(1));
Expand Down
2 changes: 0 additions & 2 deletions apps/web/src/hooks/useThreadActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,6 @@ export function useThreadActions() {
);
}
const resolved = resolveThreadTarget(target);
// oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
const nowIso = new Date().toISOString();
const wokeAt = resolved ? threadWokeAt(resolved.thread, { now: nowIso }) : null;
const undoPlan = ThreadUndo.planThreadUndo("settle", resolved?.thread);
Expand Down Expand Up @@ -971,7 +970,6 @@ export function useThreadActions() {
);
}
const resolved = resolveThreadTarget(target);
// oxlint-disable-next-line react/purity -- runs in an event handler (oxc#27309)
if (resolved && !canSnooze(resolved.thread, { now: new Date().toISOString() })) {
return AsyncResult.failure(
Cause.fail(
Expand Down
Loading
Loading