Skip to content

Commit cc57b57

Browse files
authored
Fix prepare hooks for Effect language service patch (#113)
Replace package prepare hooks with a shared patch script Clean up related TypeScript and sorting usage across server and web
1 parent f513a5f commit cc57b57

46 files changed

Lines changed: 303 additions & 339 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/commands/rec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ argument-hint: <option>
55
Respond with ONLY the exact text for the matching option below. No extra commentary.
66

77
Options:
8+
89
- `lgtm` → "LGTM — approved."
910
- `ack` → "Acknowledged."
1011
- `done` → "Done."

apps/desktop/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ function registerIpcHandlers(): void {
11711171
});
11721172

11731173
ipcMain.removeHandler(SET_SIDEBAR_OPACITY_CHANNEL);
1174-
ipcMain.handle(SET_SIDEBAR_OPACITY_CHANNEL, async (_event, rawOpacity: unknown) => {
1174+
ipcMain.handle(SET_SIDEBAR_OPACITY_CHANNEL, async (_event, _rawOpacity: unknown) => {
11751175
// Sidebar opacity is handled purely on the renderer side via CSS.
11761176
// This channel exists so the bridge contract is satisfied; the renderer
11771177
// applies the value through a CSS custom-property.

apps/desktop/src/previewController.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,6 @@ interface TabEntry {
2626
state: PreviewTabState;
2727
}
2828

29-
function createClosedTabState(tabId: PreviewTabId): PreviewTabState {
30-
return {
31-
tabId,
32-
status: "closed",
33-
url: null,
34-
title: null,
35-
error: null,
36-
canGoBack: false,
37-
canGoForward: false,
38-
devToolsOpen: false,
39-
};
40-
}
41-
4229
export class DesktopPreviewController {
4330
private tabs: Map<PreviewTabId, TabEntry> = new Map();
4431
private activeTabId: PreviewTabId | null = null;
@@ -67,16 +54,6 @@ export class DesktopPreviewController {
6754
if (!validatedUrl.ok) {
6855
// Still create the tab but in error state
6956
const tabId = randomUUID();
70-
const tabState: PreviewTabState = {
71-
tabId,
72-
status: "error",
73-
url: null,
74-
title: null,
75-
error: validatedUrl.error,
76-
canGoBack: false,
77-
canGoForward: false,
78-
devToolsOpen: false,
79-
};
8057
// Don't actually create a view for invalid URLs
8158
return { tabId, state: this.buildTabsState() };
8259
}

apps/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"dev": "bun run src/index.ts",
1919
"build": "node scripts/cli.ts build",
2020
"start": "node dist/index.mjs",
21-
"prepare": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || effect-language-service patch",
21+
"prepare": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || node ../../scripts/patch-effect-language-service.ts",
2222
"typecheck": "tsc --noEmit",
2323
"test": "vitest run"
2424
},

apps/server/src/git/Layers/CodexTextGeneration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Effect, FileSystem, Layer, Option, Path, Schema, Stream } from "effect"
44
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
55

66
import { DEFAULT_GIT_TEXT_GENERATION_MODEL } from "@okcode/contracts";
7-
import { mergeNodeProcessEnv } from "@okcode/shared/environment";
87
import { sanitizeBranchFragment, sanitizeFeatureBranchName } from "@okcode/shared/git";
98

109
import { resolveAttachmentPath } from "../../attachmentStore.ts";

apps/server/src/git/Layers/GitCore.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ import {
3333
} from "../Services/GitCore.ts";
3434
import { ServerConfig } from "../../config.ts";
3535
import { decodeJsonResult } from "@okcode/shared/schemaJson";
36-
import { ProjectionSnapshotQuery } from "../../orchestration/Services/ProjectionSnapshotQuery.ts";
37-
import { resolveRuntimeEnvironment } from "../../runtimeEnvironment.ts";
3836

3937
function safeRealpath(value: string): string {
4038
try {

apps/server/src/git/Layers/GitHubCli.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Effect, Layer, Schema } from "effect";
22
import { PositiveInt, TrimmedNonEmptyString } from "@okcode/contracts";
3-
import { mergeNodeProcessEnv } from "@okcode/shared/environment";
43

54
import { runProcess } from "../../processRunner";
65
import { GitHubCliError } from "../Errors.ts";
@@ -10,8 +9,6 @@ import {
109
type GitHubCliShape,
1110
type GitHubPullRequestSummary,
1211
} from "../Services/GitHubCli.ts";
13-
import { ProjectionSnapshotQuery } from "../../orchestration/Services/ProjectionSnapshotQuery.ts";
14-
import { resolveRuntimeEnvironment } from "../../runtimeEnvironment.ts";
1512

1613
const DEFAULT_TIMEOUT_MS = 30_000;
1714

apps/server/src/orchestration/decider.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,22 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
9393
}
9494

9595
const archiveEvents: Omit<OrchestrationEvent, "sequence">[] = projectsToArchive.map(
96-
(project) => ({
97-
...withEventBase({
98-
aggregateKind: "project" as const,
99-
aggregateId: project.id,
100-
occurredAt: command.createdAt,
101-
commandId: command.commandId,
102-
}),
103-
type: "project.deleted" as const,
104-
payload: {
105-
projectId: project.id,
106-
deletedAt: command.createdAt,
107-
},
108-
}),
96+
(project) =>
97+
Object.assign(
98+
withEventBase({
99+
aggregateKind: "project" as const,
100+
aggregateId: project.id,
101+
occurredAt: command.createdAt,
102+
commandId: command.commandId,
103+
}),
104+
{
105+
type: "project.deleted" as const,
106+
payload: {
107+
projectId: project.id,
108+
deletedAt: command.createdAt,
109+
},
110+
},
111+
),
109112
);
110113
return [...archiveEvents, projectCreatedEvent];
111114
}
@@ -198,20 +201,22 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
198201
return threadCreatedEvent;
199202
}
200203

201-
const archiveEvents: Omit<OrchestrationEvent, "sequence">[] = threadsToArchive.map(
202-
(thread) => ({
203-
...withEventBase({
204+
const archiveEvents: Omit<OrchestrationEvent, "sequence">[] = threadsToArchive.map((thread) =>
205+
Object.assign(
206+
withEventBase({
204207
aggregateKind: "thread" as const,
205208
aggregateId: thread.id,
206209
occurredAt: command.createdAt,
207210
commandId: command.commandId,
208211
}),
209-
type: "thread.deleted" as const,
210-
payload: {
211-
threadId: thread.id,
212-
deletedAt: command.createdAt,
212+
{
213+
type: "thread.deleted" as const,
214+
payload: {
215+
threadId: thread.id,
216+
deletedAt: command.createdAt,
217+
},
213218
},
214-
}),
219+
),
215220
);
216221
return [...archiveEvents, threadCreatedEvent];
217222
}

apps/server/src/persistence/Services/EnvironmentVariables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async function readOrCreateSecretKey(secretKeyPath: string): Promise<Buffer> {
182182
const existing = await fs.readFile(secretKeyPath, "utf8");
183183
const decoded = Buffer.from(existing.trim(), "base64");
184184
if (decoded.byteLength !== SECRET_KEY_BYTES) {
185-
throw new Error("Invalid vault key length.");
185+
throw new Error("Invalid vault key length.", { cause: writeError });
186186
}
187187
return decoded;
188188
}

apps/server/src/prReview/Layers/PrReview.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Effect, Layer } from "effect";
22
import type {
3-
GitHubUserPreview,
43
PrConflictAnalysis,
54
PrReviewAddThreadInput,
65
PrReviewComment,
@@ -9,17 +8,13 @@ import type {
98
PrReviewDashboardResult,
109
PrReviewFile,
1110
PrReviewPatchInput,
12-
PrReviewPatchResult,
1311
PrReviewParticipant,
1412
PrReviewReplyToThreadInput,
1513
PrReviewResolveThreadInput,
1614
PrReviewSearchUsersInput,
17-
PrReviewSearchUsersResult,
1815
PrReviewSummary,
1916
PrReviewUserPreviewInput,
2017
PrSubmitReviewInput,
21-
PrSubmitReviewResult,
22-
PrWorkflowStepResolution,
2318
PrWorkflowStepRunResult,
2419
} from "@okcode/contracts";
2520
import { GitHubCli } from "../../git/Services/GitHubCli.ts";
@@ -356,11 +351,7 @@ function normalizeDashboardResponse(
356351
startSide: asString(record.startDiffSide),
357352
isResolved: Boolean(record.isResolved),
358353
isOutdated: Boolean(record.isOutdated),
359-
state: Boolean(record.isResolved)
360-
? "resolved"
361-
: Boolean(record.isOutdated)
362-
? "outdated"
363-
: "open",
354+
state: record.isResolved ? "resolved" : record.isOutdated ? "outdated" : "open",
364355
comments,
365356
} as PrReviewDashboardResult["threads"][number];
366357
})
@@ -643,7 +634,7 @@ const makePrReview = Effect.gen(function* () {
643634
const dashboard = yield* refreshDashboard({ cwd: input.cwd, prNumber: input.prNumber });
644635
const thread = dashboard.threads.find((entry) => entry.id === input.threadId);
645636
const targetCommentId = [...(thread?.comments ?? [])]
646-
.reverse()
637+
.toReversed()
647638
.find((comment) => comment.databaseId !== null)?.databaseId;
648639
if (!thread || targetCommentId === undefined || targetCommentId === null) {
649640
return yield* new PrReviewError({

0 commit comments

Comments
 (0)