Skip to content

Commit a8aea14

Browse files
authored
chore: bump version to v1.53.0 (#7171)
1 parent d941cee commit a8aea14

File tree

4 files changed

+101
-4
lines changed

4 files changed

+101
-4
lines changed

packages/types/npm/package.metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@roo-code/types",
3-
"version": "1.52.0",
3+
"version": "1.53.0",
44
"description": "TypeScript type definitions for Roo Code.",
55
"publishConfig": {
66
"access": "public",

packages/types/src/task.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export interface TaskLike {
9292
approveAsk(options?: { text?: string; images?: string[] }): void
9393
denyAsk(options?: { text?: string; images?: string[] }): void
9494
submitUserMessage(text: string, images?: string[]): void
95+
abortTask(): void
9596
}
9697

9798
export type TaskEvents = {

src/core/task/Task.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ import {
2121
type ClineMessage,
2222
type ClineSay,
2323
type ClineAsk,
24-
type IdleAsk,
25-
type ResumableAsk,
26-
type InteractiveAsk,
2724
type ToolProgressStatus,
2825
type HistoryItem,
2926
RooCodeEventName,

src/core/task/__tests__/Task.spec.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,4 +1614,103 @@ describe("Cline", () => {
16141614
})
16151615
})
16161616
})
1617+
1618+
describe("abortTask", () => {
1619+
it("should set abort flag and emit TaskAborted event", async () => {
1620+
const task = new Task({
1621+
provider: mockProvider,
1622+
apiConfiguration: mockApiConfig,
1623+
task: "test task",
1624+
startTask: false,
1625+
})
1626+
1627+
// Spy on emit method
1628+
const emitSpy = vi.spyOn(task, "emit")
1629+
1630+
// Mock the dispose method to avoid actual cleanup
1631+
vi.spyOn(task, "dispose").mockImplementation(() => {})
1632+
1633+
// Call abortTask
1634+
await task.abortTask()
1635+
1636+
// Verify abort flag is set
1637+
expect(task.abort).toBe(true)
1638+
1639+
// Verify TaskAborted event was emitted
1640+
expect(emitSpy).toHaveBeenCalledWith("taskAborted")
1641+
})
1642+
1643+
it("should be equivalent to clicking Cancel button functionality", async () => {
1644+
const task = new Task({
1645+
provider: mockProvider,
1646+
apiConfiguration: mockApiConfig,
1647+
task: "test task",
1648+
startTask: false,
1649+
})
1650+
1651+
// Mock the dispose method to track cleanup
1652+
const disposeSpy = vi.spyOn(task, "dispose").mockImplementation(() => {})
1653+
1654+
// Call abortTask
1655+
await task.abortTask()
1656+
1657+
// Verify the same behavior as Cancel button
1658+
expect(task.abort).toBe(true)
1659+
expect(disposeSpy).toHaveBeenCalled()
1660+
})
1661+
1662+
it("should work with TaskLike interface", async () => {
1663+
const task = new Task({
1664+
provider: mockProvider,
1665+
apiConfiguration: mockApiConfig,
1666+
task: "test task",
1667+
startTask: false,
1668+
})
1669+
1670+
// Cast to TaskLike to ensure interface compliance
1671+
const taskLike = task as any // TaskLike interface from types package
1672+
1673+
// Verify abortTask method exists and is callable
1674+
expect(typeof taskLike.abortTask).toBe("function")
1675+
1676+
// Mock the dispose method to avoid actual cleanup
1677+
vi.spyOn(task, "dispose").mockImplementation(() => {})
1678+
1679+
// Call abortTask through interface
1680+
await taskLike.abortTask()
1681+
1682+
// Verify it works
1683+
expect(task.abort).toBe(true)
1684+
})
1685+
1686+
it("should handle errors during disposal gracefully", async () => {
1687+
const task = new Task({
1688+
provider: mockProvider,
1689+
apiConfiguration: mockApiConfig,
1690+
task: "test task",
1691+
startTask: false,
1692+
})
1693+
1694+
// Mock dispose to throw an error
1695+
const mockError = new Error("Disposal failed")
1696+
vi.spyOn(task, "dispose").mockImplementation(() => {
1697+
throw mockError
1698+
})
1699+
1700+
// Spy on console.error to verify error is logged
1701+
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => {})
1702+
1703+
// abortTask should not throw even if dispose fails
1704+
await expect(task.abortTask()).resolves.not.toThrow()
1705+
1706+
// Verify error was logged
1707+
expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining("Error during task"), mockError)
1708+
1709+
// Verify abort flag is still set
1710+
expect(task.abort).toBe(true)
1711+
1712+
// Restore console.error
1713+
consoleErrorSpy.mockRestore()
1714+
})
1715+
})
16171716
})

0 commit comments

Comments
 (0)