Skip to content

Commit ffa1fc1

Browse files
committed
chore: address comments
1 parent bf8700f commit ffa1fc1

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

packages/core/src/amazonq/util/files.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
} from '../../shared/utilities/workspaceUtils'
1414

1515
import { ContentLengthError, PrepareRepoFailedError } from '../../amazonqFeatureDev/errors'
16-
import { ContentLengthError as DocContentLengthError } from '../../amazonqDoc/errors'
1716
import { getLogger } from '../../shared/logger/logger'
1817
import { maxFileSizeBytes } from '../../amazonqFeatureDev/limits'
1918
import { CurrentWsFolders, DeletedFileInfo, NewFileInfo, NewFileZipContents } from '../../amazonqDoc/types'
@@ -49,7 +48,6 @@ export type PrepareRepoDataOptions = {
4948
telemetry?: TelemetryHelper
5049
zip?: ZipStream
5150
isIncludeInfraDiagram?: boolean
52-
featureName?: 'featureDev' | 'docGeneration'
5351
}
5452

5553
/**
@@ -188,9 +186,6 @@ export async function prepareRepoData(
188186
} catch (error) {
189187
getLogger().debug(`featureDev: Failed to prepare repo: ${error}`)
190188
if (error instanceof ToolkitError && error.code === 'ContentLengthError') {
191-
if (options?.featureName === 'docGeneration') {
192-
throw new DocContentLengthError()
193-
}
194189
throw new ContentLengthError()
195190
}
196191
throw new PrepareRepoFailedError()

packages/core/src/amazonqDoc/session/session.ts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import fs from '../../shared/fs/fs'
3030
import globals from '../../shared/extensionGlobals'
3131
import { extensionVersion } from '../../shared/vscode/env'
3232
import { getLogger } from '../../shared/logger/logger'
33+
import { ContentLengthError } from '../errors'
34+
import { ContentLengthError as FeatureDevContentLengthError } from '../../amazonqFeatureDev/errors'
3335

3436
export class Session {
3537
private _state?: SessionState | Omit<SessionState, 'uploadId'>
@@ -126,28 +128,35 @@ export class Session {
126128
return this.nextInteraction(msg, mode, folderPath)
127129
}
128130
private async nextInteraction(msg: string, mode: Mode, folderPath?: string) {
129-
const resp = await this.state.interact({
130-
task: this.task,
131-
msg,
132-
fs: this.config.fs,
133-
mode: mode,
134-
folderPath: folderPath,
135-
messenger: this.messenger,
136-
telemetry: this.telemetry,
137-
tokenSource: this.state.tokenSource,
138-
uploadHistory: this.state.uploadHistory,
139-
})
131+
try {
132+
const resp = await this.state.interact({
133+
task: this.task,
134+
msg,
135+
fs: this.config.fs,
136+
mode: mode,
137+
folderPath: folderPath,
138+
messenger: this.messenger,
139+
telemetry: this.telemetry,
140+
tokenSource: this.state.tokenSource,
141+
uploadHistory: this.state.uploadHistory,
142+
})
143+
144+
if (resp.nextState) {
145+
if (!this.state?.tokenSource?.token.isCancellationRequested) {
146+
this.state?.tokenSource?.cancel()
147+
}
140148

141-
if (resp.nextState) {
142-
if (!this.state?.tokenSource?.token.isCancellationRequested) {
143-
this.state?.tokenSource?.cancel()
149+
// Move to the next state
150+
this._state = resp.nextState
144151
}
145152

146-
// Move to the next state
147-
this._state = resp.nextState
153+
return resp.interaction
154+
} catch (e) {
155+
if (e instanceof FeatureDevContentLengthError) {
156+
throw new ContentLengthError()
157+
}
158+
throw e
148159
}
149-
150-
return resp.interaction
151160
}
152161

153162
public async updateFilesPaths(

packages/core/src/amazonqDoc/session/sessionState.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ export class DocPrepareCodeGenState extends BasePrepareCodeGenState {
144144
return await prepareRepoData(workspaceRoots, workspaceFolders, span, {
145145
...options,
146146
isIncludeInfraDiagram: true,
147-
featureName: 'docGeneration',
148147
})
149148
}
150149
}

0 commit comments

Comments
 (0)