Skip to content

Commit f53add8

Browse files
CLI - Tasks History
CLI - Tasks History
2 parents c267e96 + 7998d7b commit f53add8

File tree

19 files changed

+1169
-15
lines changed

19 files changed

+1169
-15
lines changed

.changeset/spicy-kings-appear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@kilocode/cli": patch
3+
---
4+
5+
Tasks history support

cli/src/commands/__tests__/clear.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ describe("clearCommand", () => {
3232
balanceData: null,
3333
profileLoading: false,
3434
balanceLoading: false,
35+
refreshTerminal: vi.fn().mockResolvedValue(undefined),
36+
taskHistoryData: null,
37+
taskHistoryFilters: {
38+
workspace: "current",
39+
sort: "newest",
40+
favoritesOnly: false,
41+
},
42+
taskHistoryLoading: false,
43+
taskHistoryError: null,
44+
fetchTaskHistory: vi.fn().mockResolvedValue(undefined),
45+
updateTaskHistoryFilters: vi.fn().mockResolvedValue(null),
46+
changeTaskHistoryPage: vi.fn().mockResolvedValue(null),
47+
nextTaskHistoryPage: vi.fn().mockResolvedValue(null),
48+
previousTaskHistoryPage: vi.fn().mockResolvedValue(null),
49+
sendWebviewMessage: vi.fn().mockResolvedValue(undefined),
3550
}
3651
})
3752

cli/src/commands/__tests__/new.test.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,39 @@ describe("/new command", () => {
1616
input: "/new",
1717
args: [],
1818
options: {},
19-
sendMessage: vi.fn(),
19+
sendMessage: vi.fn().mockResolvedValue(undefined),
2020
addMessage: vi.fn(),
2121
clearMessages: vi.fn(),
2222
replaceMessages: vi.fn(),
23+
setMessageCutoffTimestamp: vi.fn(),
2324
clearTask: vi.fn().mockResolvedValue(undefined),
2425
setMode: vi.fn(),
2526
exit: vi.fn(),
2627
routerModels: null,
2728
currentProvider: null,
2829
kilocodeDefaultModel: "",
29-
updateProviderModel: vi.fn(),
30-
refreshRouterModels: vi.fn(),
30+
updateProviderModel: vi.fn().mockResolvedValue(undefined),
31+
refreshRouterModels: vi.fn().mockResolvedValue(undefined),
32+
updateProvider: vi.fn().mockResolvedValue(undefined),
33+
profileData: null,
34+
balanceData: null,
35+
profileLoading: false,
36+
balanceLoading: false,
37+
refreshTerminal: vi.fn().mockResolvedValue(undefined),
38+
taskHistoryData: null,
39+
taskHistoryFilters: {
40+
workspace: "current",
41+
sort: "newest",
42+
favoritesOnly: false,
43+
},
44+
taskHistoryLoading: false,
45+
taskHistoryError: null,
46+
fetchTaskHistory: vi.fn().mockResolvedValue(undefined),
47+
updateTaskHistoryFilters: vi.fn().mockResolvedValue(null),
48+
changeTaskHistoryPage: vi.fn().mockResolvedValue(null),
49+
nextTaskHistoryPage: vi.fn().mockResolvedValue(null),
50+
previousTaskHistoryPage: vi.fn().mockResolvedValue(null),
51+
sendWebviewMessage: vi.fn().mockResolvedValue(undefined),
3152
}
3253
})
3354

cli/src/commands/clear.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const clearCommand: Command = {
1313
category: "system",
1414
priority: 8,
1515
handler: async (context) => {
16-
const { setMessageCutoffTimestamp, addMessage } = context
16+
const { setMessageCutoffTimestamp, addMessage, refreshTerminal } = context
1717
const now = Date.now()
1818
setMessageCutoffTimestamp(now)
1919
// Add Spacer message
@@ -23,5 +23,7 @@ export const clearCommand: Command = {
2323
content: "",
2424
ts: now + 1,
2525
})
26+
// Refresh terminal to clear screen
27+
await refreshTerminal()
2628
},
2729
}

cli/src/commands/core/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import type { RouterModels } from "../../types/messages.js"
66
import type { ProviderConfig } from "../../config/types.js"
77
import type { ProfileData, BalanceData } from "../../state/atoms/profile.js"
8+
import type { TaskHistoryData, TaskHistoryFilters } from "../../state/atoms/taskHistory.js"
89

910
export interface Command {
1011
name: string
@@ -55,6 +56,18 @@ export interface CommandContext {
5556
balanceData: BalanceData | null
5657
profileLoading: boolean
5758
balanceLoading: boolean
59+
// Task history context
60+
taskHistoryData: TaskHistoryData | null
61+
taskHistoryFilters: TaskHistoryFilters
62+
taskHistoryLoading: boolean
63+
taskHistoryError: string | null
64+
fetchTaskHistory: () => Promise<void>
65+
updateTaskHistoryFilters: (filters: Partial<TaskHistoryFilters>) => Promise<TaskHistoryData>
66+
changeTaskHistoryPage: (pageIndex: number) => Promise<TaskHistoryData>
67+
nextTaskHistoryPage: () => Promise<TaskHistoryData>
68+
previousTaskHistoryPage: () => Promise<TaskHistoryData>
69+
sendWebviewMessage: (message: any) => Promise<void>
70+
refreshTerminal: () => Promise<void>
5871
}
5972

6073
export type CommandHandler = (context: CommandContext) => Promise<void> | void
@@ -115,6 +128,7 @@ export interface ArgumentProviderContext {
115128
profileLoading: boolean
116129
updateProviderModel: (modelId: string) => Promise<void>
117130
refreshRouterModels: () => Promise<void>
131+
taskHistoryData: TaskHistoryData | null
118132
}
119133
}
120134

cli/src/commands/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { modelCommand } from "./model.js"
1616
import { profileCommand } from "./profile.js"
1717
import { teamsCommand } from "./teams.js"
1818
import { configCommand } from "./config.js"
19+
import { tasksCommand } from "./tasks.js"
1920

2021
/**
2122
* Initialize all commands
@@ -31,4 +32,5 @@ export function initializeCommands(): void {
3132
commandRegistry.register(profileCommand)
3233
commandRegistry.register(teamsCommand)
3334
commandRegistry.register(configCommand)
35+
commandRegistry.register(tasksCommand)
3436
}

cli/src/commands/new.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const newCommand: Command = {
1414
category: "system",
1515
priority: 9,
1616
handler: async (context) => {
17-
const { clearTask, replaceMessages } = context
17+
const { clearTask, replaceMessages, refreshTerminal } = context
1818

1919
// Clear the extension task state (this also clears extension messages)
2020
await clearTask()
@@ -32,5 +32,8 @@ export const newCommand: Command = {
3232
],
3333
}),
3434
])
35+
36+
// Force terminal refresh to clear screen
37+
await refreshTerminal()
3538
},
3639
}

0 commit comments

Comments
 (0)