Skip to content

Commit

Permalink
chore: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinDing1 committed Feb 24, 2025
1 parent bf8700f commit ffa1fc1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
5 changes: 0 additions & 5 deletions packages/core/src/amazonq/util/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from '../../shared/utilities/workspaceUtils'

import { ContentLengthError, PrepareRepoFailedError } from '../../amazonqFeatureDev/errors'
import { ContentLengthError as DocContentLengthError } from '../../amazonqDoc/errors'
import { getLogger } from '../../shared/logger/logger'
import { maxFileSizeBytes } from '../../amazonqFeatureDev/limits'
import { CurrentWsFolders, DeletedFileInfo, NewFileInfo, NewFileZipContents } from '../../amazonqDoc/types'
Expand Down Expand Up @@ -49,7 +48,6 @@ export type PrepareRepoDataOptions = {
telemetry?: TelemetryHelper
zip?: ZipStream
isIncludeInfraDiagram?: boolean
featureName?: 'featureDev' | 'docGeneration'
}

/**
Expand Down Expand Up @@ -188,9 +186,6 @@ export async function prepareRepoData(
} catch (error) {
getLogger().debug(`featureDev: Failed to prepare repo: ${error}`)
if (error instanceof ToolkitError && error.code === 'ContentLengthError') {
if (options?.featureName === 'docGeneration') {
throw new DocContentLengthError()
}
throw new ContentLengthError()
}
throw new PrepareRepoFailedError()
Expand Down
45 changes: 27 additions & 18 deletions packages/core/src/amazonqDoc/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import fs from '../../shared/fs/fs'
import globals from '../../shared/extensionGlobals'
import { extensionVersion } from '../../shared/vscode/env'
import { getLogger } from '../../shared/logger/logger'
import { ContentLengthError } from '../errors'
import { ContentLengthError as FeatureDevContentLengthError } from '../../amazonqFeatureDev/errors'

export class Session {
private _state?: SessionState | Omit<SessionState, 'uploadId'>
Expand Down Expand Up @@ -126,28 +128,35 @@ export class Session {
return this.nextInteraction(msg, mode, folderPath)
}
private async nextInteraction(msg: string, mode: Mode, folderPath?: string) {
const resp = await this.state.interact({
task: this.task,
msg,
fs: this.config.fs,
mode: mode,
folderPath: folderPath,
messenger: this.messenger,
telemetry: this.telemetry,
tokenSource: this.state.tokenSource,
uploadHistory: this.state.uploadHistory,
})
try {
const resp = await this.state.interact({
task: this.task,
msg,
fs: this.config.fs,
mode: mode,
folderPath: folderPath,
messenger: this.messenger,
telemetry: this.telemetry,
tokenSource: this.state.tokenSource,
uploadHistory: this.state.uploadHistory,
})

if (resp.nextState) {
if (!this.state?.tokenSource?.token.isCancellationRequested) {
this.state?.tokenSource?.cancel()
}

if (resp.nextState) {
if (!this.state?.tokenSource?.token.isCancellationRequested) {
this.state?.tokenSource?.cancel()
// Move to the next state
this._state = resp.nextState
}

// Move to the next state
this._state = resp.nextState
return resp.interaction
} catch (e) {
if (e instanceof FeatureDevContentLengthError) {
throw new ContentLengthError()
}
throw e
}

return resp.interaction
}

public async updateFilesPaths(
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/amazonqDoc/session/sessionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export class DocPrepareCodeGenState extends BasePrepareCodeGenState {
return await prepareRepoData(workspaceRoots, workspaceFolders, span, {
...options,
isIncludeInfraDiagram: true,
featureName: 'docGeneration',
})
}
}

0 comments on commit ffa1fc1

Please sign in to comment.