Skip to content

Commit d5a40e1

Browse files
authored
feat: Error fixing and performance optimization (#387)
* feat(ui): enable auto approve settings display in chat * refactor(core): optimize workspace event handling and request management * feat(zgsm): enhance codebase index handling and confirmation dialog * refactor(settings): optimize zgsm codebase settings component * build: update dependencies and improve file monitoring performance * test(workspace-event-monitor): fix event buffer size assertion * feat(core): enhance process detection and health check * test: enhance workspace event monitor tests with comprehensive coverage * chore: version from 1.6.3-dev to 1.6.2
1 parent 7ec0b3a commit d5a40e1

19 files changed

+1712
-782
lines changed

packages/types/src/global-settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export const EVALS_SETTINGS: RooCodeSettings = {
257257
pinnedApiConfigs: {},
258258

259259
autoApprovalEnabled: true,
260-
showAutoApproveSettingsAtChat: false,
260+
showAutoApproveSettingsAtChat: true,
261261
alwaysAllowReadOnly: true,
262262
alwaysAllowReadOnlyOutsideWorkspace: false,
263263
alwaysAllowWrite: true,

pnpm-lock.yaml

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

src/core/costrict/activate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export async function deactivate() {
206206
disconnectIPC()
207207
stopIPCServer()
208208
// Clean up workspace event monitoring
209-
await workspaceEventMonitor.handleVSCodeClose()
209+
workspaceEventMonitor.handleVSCodeClose()
210210

211211
// Currently no specific cleanup needed
212212
loggerDeactivate()

src/core/costrict/codebase-index/client.ts

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class CodebaseIndexClient {
5050
port: number
5151
[key: string]: any
5252
} = {} as any
53-
53+
lastHeaders = {} as any
5454
private clientId: string = getClientId()
5555

5656
get processName() {
@@ -139,25 +139,18 @@ export class CodebaseIndexClient {
139139
private async makeRequest<T>(url: string, options: RequestInit = {}, token?: string): Promise<ApiResponse<T>> {
140140
const headers = await this.getHeaders(token)
141141

142-
const defaultOptions: RequestInit = {
143-
headers: {
144-
...headers,
145-
"Content-Type": "application/json",
146-
},
147-
}
148-
149142
const finalOptions: RequestInit = {
150-
...defaultOptions,
151143
...options,
152144
headers: {
153-
...defaultOptions.headers,
145+
"Content-Type": "application/json",
146+
...headers,
154147
...options.headers,
155148
},
156149
}
157150

158151
const maxRetries = 2
159152
let lastError: Error = new Error("Unknown error")
160-
153+
this.lastHeaders = finalOptions.headers
161154
for (let attempt = 0; attempt <= maxRetries; attempt++) {
162155
try {
163156
const response = await fetch(url, finalOptions)
@@ -326,8 +319,6 @@ export class CodebaseIndexClient {
326319

327320
async isRunning(processName = this.processName) {
328321
const pids = await processIsRunning(processName, this.logger)
329-
if (pids.length > 0) {
330-
}
331322
return [pids.length > 0, pids] as [boolean, number[]]
332323
}
333324

@@ -376,8 +367,8 @@ export class CodebaseIndexClient {
376367
if (!codebaseIndexerServiceConfig) {
377368
throw new Error("Failed to find codebase-indexer service in well-known.json")
378369
}
379-
380-
if (codebaseIndexerServiceConfig.status !== "running") {
370+
const [isRun] = await this.isRunning(this.serverName)
371+
if (codebaseIndexerServiceConfig.status !== "running" && !isRun) {
381372
throw new Error("codebase-indexer service not running!")
382373
}
383374

@@ -442,6 +433,41 @@ export class CodebaseIndexClient {
442433
return this.makeRequest<number>(url, options, token)
443434
}
444435

436+
publishSyncWorkspaceEvents<T>(request: WorkspaceEventRequest) {
437+
const url = `${this.getCodebaseIndexerServerHost(this.serverHost)}/codebase-indexer/api/v1/events`
438+
439+
const headers = {
440+
...this.lastHeaders,
441+
"X-Request-ID": uuidv7(),
442+
"Content-Type": "application/json",
443+
} as {
444+
[key: string]: string
445+
}
446+
447+
const httpModule = url.startsWith("https://") ? require("https") : require("http")
448+
const urlObj = new URL(url)
449+
450+
const options = {
451+
hostname: urlObj.hostname,
452+
port: urlObj.port,
453+
path: urlObj.pathname + urlObj.search,
454+
method: "POST",
455+
headers: headers,
456+
timeout: 3000,
457+
}
458+
459+
try {
460+
const req = httpModule.request(options)
461+
req.on("error", (error: Error) => {
462+
console.error("Failed to send workspace close event:", error.message)
463+
})
464+
req.write(JSON.stringify(request))
465+
req.end()
466+
} catch (error: any) {
467+
console.error("Failed to create HTTP request for workspace close event:", error.message)
468+
}
469+
}
470+
445471
/**
446472
* Manually trigger index build
447473
* @param request Index build request
@@ -483,7 +509,7 @@ export class CodebaseIndexClient {
483509
* @returns Promise<ApiResponse<number>> Returns response data
484510
*/
485511
async healthCheck(
486-
path: string,
512+
url: string,
487513
token?: string,
488514
): Promise<{
489515
message: string
@@ -496,7 +522,7 @@ export class CodebaseIndexClient {
496522
method: "GET",
497523
}
498524

499-
return this.makeRequest(path, options, token) as unknown as {
525+
return this.makeRequest(url, options, token) as unknown as {
500526
message: string
501527
status: string
502528
[key: string]: any

0 commit comments

Comments
 (0)