Skip to content

Commit e41ebe0

Browse files
author
easonLiangWorldedtech
committed
style: apply prettier to the files this PR touches
The compile job's "Check formatting" step (pnpm format:check -> prettier --check .) is red on 53ed5b3. It is a formatting gate, not a test or type failure: Lint and Check types were skipped. The step only became reachable because the PR merge ref now carries a main that declares the format:check script and a root .prettierignore; neither exists on this branch's own base, which is why the same files were never checked before. Attribution, so the nature of this commit is on the record: the debt is not from the last round. An LF worktree at 53ed5b3 and at its parent e1c304f produce an identical prettier offender list, including all six files the job names, so the previous commit added zero offenders. This unit simply carried files that the gate had never run against. Only files inside this PR's diff are formatted - six, and the six are exactly the offenders the merge ref reports; nothing outside the diff was touched. Formatting is whitespace only: the discardFileTab() region is byte-for-byte identical, its statement sequence and the two hoisted calls above the tab loop are unchanged, which is what #1932 depends on. Verified after merging org main 09e7326: prettier --check . reports 0 offenders; core/tools 669, integrations/editor 92 and core/task 829 tests pass; eslint . --ext=ts --max-warnings=0 exits 0 with no suppression count increase; tsc --noEmit reports 0 errors.
1 parent 30023a9 commit e41ebe0

6 files changed

Lines changed: 21 additions & 43 deletions

File tree

‎src/core/tools/BaseTool.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ export abstract class BaseTool<TName extends ToolName> {
112112
* reported exactly once. Per-task only: a global teardown would clobber another task
113113
* that is still streaming through this singleton.
114114
*/
115-
protected async releaseStreamStateOnParseFailure(
116-
_task: Task,
117-
_callbacks: ToolCallbacks,
118-
): Promise<boolean> {
115+
protected async releaseStreamStateOnParseFailure(_task: Task, _callbacks: ToolCallbacks): Promise<boolean> {
119116
return false
120117
}
121118

‎src/core/tools/WriteToFileTool.ts‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,7 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> {
185185
* and true is returned to suppress the incidental parse error - the failure surfaces
186186
* exactly once.
187187
*/
188-
protected override async releaseStreamStateOnParseFailure(
189-
task: Task,
190-
callbacks: ToolCallbacks,
191-
): Promise<boolean> {
188+
protected override async releaseStreamStateOnParseFailure(task: Task, callbacks: ToolCallbacks): Promise<boolean> {
192189
const state = this.taskPartialStreamState.get(this.getPartialStreamFailureKey(task))
193190
if (!state) {
194191
return false
@@ -488,7 +485,7 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> {
488485

489486
try {
490487
// Everything from here up to the diff view is setup that can fail before
491-
// execute() ever runs; the catch below owns the teardown for that window.
488+
// execute() ever runs; the catch below owns the teardown for that window.
492489
const provider = task.providerRef.deref()
493490
const state = await provider?.getState()
494491
// First await since the state was registered: a cancellation during getState() would
@@ -540,8 +537,7 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> {
540537
}
541538

542539
partialMessage = JSON.stringify(sharedMessageProps)
543-
await task.ask("tool", partialMessage, block.partial).catch(() => {})
544-
540+
await task.ask("tool", partialMessage, block.partial).catch(() => {})
545541
} catch (error) {
546542
// Unexpected failure in the pre-streaming setup (provider state, the filesystem probe,
547543
// policy checks, message construction): this delta never reaches the diff view or

‎src/core/tools/__tests__/writeToFileTool-partial-state-cleanup.spec.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,18 @@ describe("WriteToFileTool per-task partial-state cleanup", () => {
5959
// The registration side of the pairing, asserted BEFORE the cleanup runs: the off()
6060
// assertion below only proves the right listener was deregistered if this one pins which
6161
// listener was registered in the first place.
62-
expect((task as unknown as CleanupTask).once).toHaveBeenCalledWith(RooCodeEventName.TaskAborted, state.abortCleanup)
62+
expect((task as unknown as CleanupTask).once).toHaveBeenCalledWith(
63+
RooCodeEventName.TaskAborted,
64+
state.abortCleanup,
65+
)
6366

6467
writeToFileTool.clearTaskState(task)
6568

6669
expect(writeToFileTool["taskPartialStreamState"].size).toBe(0)
67-
expect((task as unknown as CleanupTask).off).toHaveBeenCalledWith(RooCodeEventName.TaskAborted, state.abortCleanup)
70+
expect((task as unknown as CleanupTask).off).toHaveBeenCalledWith(
71+
RooCodeEventName.TaskAborted,
72+
state.abortCleanup,
73+
)
6874
})
6975

7076
it("is a no-op for a task that never streamed", async () => {
@@ -242,4 +248,4 @@ describe("WriteToFileTool partial-delta cancellation", () => {
242248
expect(task.diffViewProvider.update).not.toHaveBeenCalled()
243249
expect(writeToFileTool["taskPartialStreamState"].size).toBe(0)
244250
})
245-
})
251+
})

‎src/core/tools/__tests__/writeToFileTool.spec.ts‎

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,6 @@ describe("writeToFileTool", () => {
544544
}
545545
})
546546

547-
548-
549547
it("releases the per-task stream state when provider state rejects during a partial delta", async () => {
550548
// handlePartial() registers the entry and the TaskAborted listener, then awaits
551549
// provider.getState(). A rejection there never reaches the diff view or execute(), so
@@ -636,7 +634,6 @@ describe("writeToFileTool", () => {
636634
await executeWriteFileTool({}, { isPartial: true })
637635
expect(mockCline.ask).toHaveBeenCalledTimes(1)
638636
})
639-
640637
})
641638

642639
describe("parse-failure reporting and early-return cleanup", () => {
@@ -705,7 +702,7 @@ describe("writeToFileTool", () => {
705702
expect(writeToFileTool["taskPartialStreamState"].size).toBe(0)
706703
const abortListener = mockCline.once.mock.calls.find(
707704
([event]: unknown[]) => event === RooCodeEventName.TaskAborted,
708-
)?.[1]
705+
)?.[1]
709706
expect(abortListener).toBeInstanceOf(Function)
710707
expect(mockCline.off).toHaveBeenCalledWith(RooCodeEventName.TaskAborted, abortListener)
711708
// The ask threw, so the denial result was never pushed: the release cannot depend on it.
@@ -867,7 +864,9 @@ describe("writeToFileTool", () => {
867864
expect(mockHandleError).toHaveBeenCalledWith("parsing write_to_file args", expect.any(Error))
868865
// Otherwise the retained streamFailed suppresses the diff preview of every
869866
// later write_to_file in this task.
870-
expect(writeToFileTool["taskPartialStreamState"].has(`${mockCline.taskId}.${mockCline.instanceId}`)).toBe(false)
867+
expect(writeToFileTool["taskPartialStreamState"].has(`${mockCline.taskId}.${mockCline.instanceId}`)).toBe(
868+
false,
869+
)
871870
// ...and the cleanup must stay scoped: the other task is still streaming.
872871
expect(writeToFileTool["taskPartialStreamState"].get("task-2.instance-2")?.streamFailed).toBe(true)
873872
})
@@ -978,7 +977,6 @@ describe("writeToFileTool", () => {
978977
expect(mockHandleError).toHaveBeenCalledWith("writing file", expect.any(Error))
979978
expect(writeToFileTool["taskPartialStreamState"].size).toBe(0)
980979
})
981-
982980
})
983981

984982
describe("user interaction", () => {
@@ -1020,8 +1018,6 @@ describe("writeToFileTool", () => {
10201018
expect(mockCline.diffViewProvider.reset).toHaveBeenCalled()
10211019
})
10221020

1023-
1024-
10251021
it("swallows partial streaming errors instead of surfacing a duplicate error bubble", async () => {
10261022
// The same filesystem operation is retried in execute() once the block completes,
10271023
// and that authoritative non-partial path reports the error to the user. Surfacing
@@ -1292,14 +1288,6 @@ describe("writeToFileTool", () => {
12921288
expect(mockCline.diffViewProvider.open).toHaveBeenCalledTimes(1)
12931289
})
12941290

1295-
1296-
1297-
1298-
1299-
1300-
1301-
1302-
13031291
it("keeps partial stream failures isolated per task", async () => {
13041292
mockCline.diffViewProvider.open.mockRejectedValueOnce(
13051293
Object.assign(new Error("EROFS: read-only file system, mkdir '/task-a'"), { code: "EROFS" }),
@@ -1324,8 +1312,6 @@ describe("writeToFileTool", () => {
13241312
expect(mockCline.diffViewProvider.open).toHaveBeenCalledTimes(2)
13251313
})
13261314

1327-
1328-
13291315
it("EROFS in handlePartial does not stall agent loop -- createDirectoriesForFile is not called", async () => {
13301316
// Regression test: before the fix, createDirectoriesForFile was called in handlePartial
13311317
// with no .catch() guard. An EROFS throw escaped to BaseTool.handle(), which called
@@ -1346,9 +1332,5 @@ describe("writeToFileTool", () => {
13461332
expect(mockedCreateDirectoriesForFile).not.toHaveBeenCalled()
13471333
expect(mockHandleError).not.toHaveBeenCalled()
13481334
})
1349-
1350-
1351-
1352-
13531335
})
13541336
})

‎src/integrations/editor/DiffViewProvider.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ export class DiffViewProvider {
592592
for (let i = this.createdDirs.length - 1; i >= 0; i--) {
593593
await this.removeCreatedDir(this.createdDirs[i])
594594
}
595-
596595
} else {
597596
// Only reachable after a successful open(), so the editor exists.
598597
const updatedDocument = this.activeDiffEditor?.document
@@ -976,10 +975,7 @@ export class DiffViewProvider {
976975
return
977976
}
978977
const edit = new vscode.WorkspaceEdit()
979-
const range = new vscode.Range(
980-
document.positionAt(0),
981-
document.positionAt(document.getText().length),
982-
)
978+
const range = new vscode.Range(document.positionAt(0), document.positionAt(document.getText().length))
983979
edit.replace(document.uri, range, this.originalContent ?? "")
984980
const restored = await vscode.workspace.applyEdit(edit)
985981
if (!restored) {

‎src/integrations/editor/__tests__/DiffViewProvider.spec.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,9 @@ describe("DiffViewProvider", () => {
13121312
editType: "create",
13131313
createdDirs: [],
13141314
})
1315-
vi.mocked(fs.unlink).mockRejectedValueOnce(Object.assign(new Error("EACCES: permission denied"), { code: "EACCES" }))
1315+
vi.mocked(fs.unlink).mockRejectedValueOnce(
1316+
Object.assign(new Error("EACCES: permission denied"), { code: "EACCES" }),
1317+
)
13161318

13171319
await expect(diffViewProvider.revertChanges()).rejects.toThrow("EACCES: permission denied")
13181320
})
@@ -1608,7 +1610,6 @@ describe("DiffViewProvider", () => {
16081610
expect(vscode.window.tabGroups.close).not.toHaveBeenCalled()
16091611
expect(fs.unlink).not.toHaveBeenCalled()
16101612
})
1611-
16121613
})
16131614

16141615
describe("userTouchedDiffEditor keep/close behavior", () => {

0 commit comments

Comments
 (0)