Skip to content

Commit 44086e4

Browse files
authored
Add support for task page event population (#7117)
1 parent 0d0bba2 commit 44086e4

18 files changed

+276
-167
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.48.0",
3+
"version": "1.49.0",
44
"description": "TypeScript type definitions for Roo Code.",
55
"publishConfig": {
66
"access": "public",

packages/types/src/task.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { z } from "zod"
33
import { RooCodeEventName } from "./events.js"
44
import { type ClineMessage, type BlockingAsk, type TokenUsage } from "./message.js"
55
import { type ToolUsage, type ToolName } from "./tool.js"
6+
import type { StaticAppProperties, GitProperties, TelemetryProperties } from "./telemetry.js"
67

78
/**
89
* TaskProviderLike
@@ -14,19 +15,23 @@ export interface TaskProviderState {
1415

1516
export interface TaskProviderLike {
1617
readonly cwd: string
18+
readonly appProperties: StaticAppProperties
19+
readonly gitProperties: GitProperties | undefined
1720

18-
getCurrentCline(): TaskLike | undefined
21+
getCurrentTask(): TaskLike | undefined
1922
getCurrentTaskStack(): string[]
23+
getRecentTasks(): string[]
2024

21-
initClineWithTask(text?: string, images?: string[], parentTask?: TaskLike): Promise<TaskLike>
25+
createTask(text?: string, images?: string[], parentTask?: TaskLike): Promise<TaskLike>
2226
cancelTask(): Promise<void>
2327
clearTask(): Promise<void>
24-
postStateToWebview(): Promise<void>
2528

2629
getState(): Promise<TaskProviderState>
27-
30+
postStateToWebview(): Promise<void>
2831
postMessageToWebview(message: unknown): Promise<void>
2932

33+
getTelemetryProperties(): Promise<TelemetryProperties>
34+
3035
on<K extends keyof TaskProviderEvents>(
3136
event: K,
3237
listener: (...args: TaskProviderEvents[K]) => void | Promise<void>,
@@ -36,14 +41,6 @@ export interface TaskProviderLike {
3641
event: K,
3742
listener: (...args: TaskProviderEvents[K]) => void | Promise<void>,
3843
): this
39-
40-
context: {
41-
extension?: {
42-
packageJSON?: {
43-
version?: string
44-
}
45-
}
46-
}
4744
}
4845

4946
export type TaskProviderEvents = {

packages/types/src/telemetry.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,37 @@ export enum TelemetryEventName {
7272
* TelemetryProperties
7373
*/
7474

75-
export const appPropertiesSchema = z.object({
75+
export const staticAppPropertiesSchema = z.object({
7676
appName: z.string(),
7777
appVersion: z.string(),
7878
vscodeVersion: z.string(),
7979
platform: z.string(),
8080
editorName: z.string(),
81+
})
82+
83+
export type StaticAppProperties = z.infer<typeof staticAppPropertiesSchema>
84+
85+
export const dynamicAppPropertiesSchema = z.object({
8186
language: z.string(),
8287
mode: z.string(),
88+
})
89+
90+
export type DynamicAppProperties = z.infer<typeof dynamicAppPropertiesSchema>
91+
92+
export const cloudAppPropertiesSchema = z.object({
8393
cloudIsAuthenticated: z.boolean().optional(),
8494
})
8595

96+
export type CloudAppProperties = z.infer<typeof cloudAppPropertiesSchema>
97+
98+
export const appPropertiesSchema = z.object({
99+
...staticAppPropertiesSchema.shape,
100+
...dynamicAppPropertiesSchema.shape,
101+
...cloudAppPropertiesSchema.shape,
102+
})
103+
104+
export type AppProperties = z.infer<typeof appPropertiesSchema>
105+
86106
export const taskPropertiesSchema = z.object({
87107
taskId: z.string().optional(),
88108
apiProvider: z.enum(providerNames).optional(),
@@ -99,20 +119,23 @@ export const taskPropertiesSchema = z.object({
99119
.optional(),
100120
})
101121

122+
export type TaskProperties = z.infer<typeof taskPropertiesSchema>
123+
102124
export const gitPropertiesSchema = z.object({
103125
repositoryUrl: z.string().optional(),
104126
repositoryName: z.string().optional(),
105127
defaultBranch: z.string().optional(),
106128
})
107129

130+
export type GitProperties = z.infer<typeof gitPropertiesSchema>
131+
108132
export const telemetryPropertiesSchema = z.object({
109133
...appPropertiesSchema.shape,
110134
...taskPropertiesSchema.shape,
111135
...gitPropertiesSchema.shape,
112136
})
113137

114138
export type TelemetryProperties = z.infer<typeof telemetryPropertiesSchema>
115-
export type GitProperties = z.infer<typeof gitPropertiesSchema>
116139

117140
/**
118141
* TelemetryEvent

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/link-packages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function startWatch(pkg: PackageConfig): WatcherResult {
212212
throw new Error(`Invalid watch command for ${pkg.name}`)
213213
}
214214

215-
console.log(`Watching for changes to ${pkg.sourcePath} with ${cmd} ${args.join(" ")}`)
215+
console.log(`👀 Watching for changes to ${pkg.sourcePath} with ${cmd} ${args.join(" ")}`)
216216

217217
const child = spawn(cmd, args, {
218218
cwd: path.resolve(__dirname, "..", pkg.sourcePath),
@@ -251,7 +251,7 @@ function startWatch(pkg: PackageConfig): WatcherResult {
251251
debounceTimer = setTimeout(() => {
252252
linkPackage(pkg)
253253

254-
console.log(`📋 Copied ${pkg.name} to ${pkg.targetPaths.length} paths\n`)
254+
console.log(`♻️ Copied ${pkg.name} to ${pkg.targetPaths.length} paths\n`)
255255

256256
debounceTimer = null
257257
}, DEBOUNCE_DELAY)

src/core/task/Task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
19511951
const history = await provider?.getTaskWithId(this.taskId)
19521952

19531953
if (history) {
1954-
await provider?.initClineWithHistoryItem(history.historyItem)
1954+
await provider?.createTaskWithHistoryItem(history.historyItem)
19551955
}
19561956
}
19571957
} finally {

src/core/tools/__tests__/newTaskTool.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const mockAskApproval = vi.fn<AskApproval>()
2222
const mockHandleError = vi.fn<HandleError>()
2323
const mockPushToolResult = vi.fn()
2424
const mockRemoveClosingTag = vi.fn((_name: string, value: string | undefined) => value ?? "")
25-
const mockInitClineWithTask = vi.fn<() => Promise<MockClineInstance>>().mockResolvedValue({ taskId: "mock-subtask-id" })
25+
const mockCreateTask = vi.fn<() => Promise<MockClineInstance>>().mockResolvedValue({ taskId: "mock-subtask-id" })
2626
const mockEmit = vi.fn()
2727
const mockRecordToolError = vi.fn()
2828
const mockSayAndCreateMissingParamError = vi.fn()
@@ -40,7 +40,7 @@ const mockCline = {
4040
deref: vi.fn(() => ({
4141
getState: vi.fn(() => ({ customModes: [], mode: "ask" })),
4242
handleModeSwitch: vi.fn(),
43-
initClineWithTask: mockInitClineWithTask,
43+
createTask: mockCreateTask,
4444
})),
4545
},
4646
}
@@ -88,8 +88,8 @@ describe("newTaskTool", () => {
8888
// Verify askApproval was called
8989
expect(mockAskApproval).toHaveBeenCalled()
9090

91-
// Verify the message passed to initClineWithTask reflects the code's behavior in unit tests
92-
expect(mockInitClineWithTask).toHaveBeenCalledWith(
91+
// Verify the message passed to createTask reflects the code's behavior in unit tests
92+
expect(mockCreateTask).toHaveBeenCalledWith(
9393
"Review this: \\@file1.txt and also \\\\\\@file2.txt", // Unit Test Expectation: \\@ -> \@, \\\\@ -> \\\\@
9494
undefined,
9595
mockCline,
@@ -122,7 +122,7 @@ describe("newTaskTool", () => {
122122
mockRemoveClosingTag,
123123
)
124124

125-
expect(mockInitClineWithTask).toHaveBeenCalledWith(
125+
expect(mockCreateTask).toHaveBeenCalledWith(
126126
"This is already unescaped: \\@file1.txt", // Expected: \@ remains \@
127127
undefined,
128128
mockCline,
@@ -149,7 +149,7 @@ describe("newTaskTool", () => {
149149
mockRemoveClosingTag,
150150
)
151151

152-
expect(mockInitClineWithTask).toHaveBeenCalledWith(
152+
expect(mockCreateTask).toHaveBeenCalledWith(
153153
"A normal mention @file1.txt", // Expected: @ remains @
154154
undefined,
155155
mockCline,
@@ -176,7 +176,7 @@ describe("newTaskTool", () => {
176176
mockRemoveClosingTag,
177177
)
178178

179-
expect(mockInitClineWithTask).toHaveBeenCalledWith(
179+
expect(mockCreateTask).toHaveBeenCalledWith(
180180
"Mix: @file0.txt, \\@file1.txt, \\@file2.txt, \\\\\\@file3.txt", // Unit Test Expectation: @->@, \@->\@, \\@->\@, \\\\@->\\\\@
181181
undefined,
182182
mockCline,

src/core/tools/newTaskTool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export async function newTaskTool(
8383
cline.pausedModeSlug = (await provider.getState()).mode ?? defaultModeSlug
8484

8585
// Create new task instance first (this preserves parent's current mode in its history)
86-
const newCline = await provider.initClineWithTask(unescapedMessage, undefined, cline)
86+
const newCline = await provider.createTask(unescapedMessage, undefined, cline)
87+
8788
if (!newCline) {
8889
pushToolResult(t("tools:newTask.errors.policy_restriction"))
8990
return

0 commit comments

Comments
 (0)