Skip to content

Commit ee5546f

Browse files
committed
fix(roo-import): address import state persistence and cleanup
1 parent d6c54f7 commit ee5546f

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

apps/vscode-e2e/src/suite/roo-import.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,23 @@ suite("Roo Import", function () {
3636
setDefaultSuiteTimeout(this)
3737

3838
let tmpDir: string
39+
const importedTaskIds: string[] = []
3940

4041
suiteSetup(async () => {
4142
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "zoo-e2e-roo-import-"))
4243
})
4344

4445
suiteTeardown(async () => {
4546
await fs.rm(tmpDir, { recursive: true, force: true })
47+
48+
const storagePath = globalThis.api?.storagePath
49+
if (storagePath) {
50+
await Promise.all(
51+
importedTaskIds.map((id) =>
52+
fs.rm(path.join(storagePath, "tasks", id), { recursive: true, force: true }),
53+
),
54+
)
55+
}
4656
})
4757

4858
test("importRooHandoff command is registered", async () => {
@@ -61,6 +71,7 @@ suite("Roo Import", function () {
6171
const handoffDir = path.join(tmpDir, "handoff")
6272
const tasksSource = path.join(handoffDir, "data", "tasks")
6373
const taskId = `e2e-test-task-${Date.now()}`
74+
importedTaskIds.push(taskId)
6475
await fs.mkdir(path.join(tasksSource, taskId), { recursive: true })
6576
await fs.writeFile(path.join(tasksSource, taskId, "history_item.json"), JSON.stringify({ id: taskId }))
6677

@@ -83,7 +94,7 @@ suite("Roo Import", function () {
8394
assert.strictEqual(contents.id, taskId, "Task file content should match what was exported")
8495
})
8596

86-
test("skips import when handoff was already imported", async () => {
97+
test("re-runs import with an explicit path without throwing", async () => {
8798
const handoffPath = path.join(tmpDir, "handoff-duplicate.json")
8899
const createdAt = new Date().toISOString()
89100
await fs.writeFile(handoffPath, JSON.stringify(makeHandoff({ createdAt })))

src/activate/__tests__/registerCommands.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ describe("handleImportRooHandoff", () => {
127127
expect(mockProvider.postStateToWebview).not.toHaveBeenCalled()
128128
})
129129

130+
it("does not call postStateToWebview when import fails", async () => {
131+
vi.mocked(RooImport.promptAndImportRooHandoff).mockResolvedValue({ success: false, error: "invalid handoff" })
132+
133+
await handleImportRooHandoff(undefined, mockContext, mockOutputChannel)
134+
135+
expect(mockProvider.postStateToWebview).not.toHaveBeenCalled()
136+
})
137+
130138
it("logs and returns undefined when the import throws", async () => {
131139
vi.mocked(RooImport.importRooHandoffFromPath).mockRejectedValue(new Error("disk full"))
132140

src/activate/registerCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export async function handleImportRooHandoff(
8585
? await importRooHandoffFromPath(handoffPath, importOptions)
8686
: await promptAndImportRooHandoff(importOptions)
8787

88-
if (result) {
88+
if (result?.success) {
8989
await visibleProvider.postStateToWebview()
9090
}
9191

src/services/roo-import/RooImport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ export async function importRooHandoffFromPath(
241241

242242
const currentProviderName = merged.currentApiConfigName
243243
const currentProvider = merged.apiConfigs[currentProviderName]
244-
contextProxy.setValue("currentApiConfigName", currentProviderName)
244+
await contextProxy.setValue("currentApiConfigName", currentProviderName)
245245
if (currentProvider) {
246246
await contextProxy.setProviderSettings(currentProvider)
247247
}
248-
contextProxy.setValue("listApiConfigMeta", await providerSettingsManager.listConfig())
248+
await contextProxy.setValue("listApiConfigMeta", await providerSettingsManager.listConfig())
249249

250250
log("Imported provider profiles")
251251
} else {

0 commit comments

Comments
 (0)