Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
// Two concurrent root fetches race: the stale one gets invalidated and
// its reveal fails with "Cannot resolve". The other succeeds.
const
=
[
.
,
.
]
.
filter
(
(
)
:
is
=>
!
!
)
;
.
strictEqual
(
.
,
1
,
'Exactly one reveal should fail from the stale fetch'
)
;
.
ok
(
/Cannot resolve tree item/
.
test
(
[
0
]
.
)
,
`Expected "Cannot resolve" error but got: ${errors[0].message}`
)
;
}
)
;
test
(
'TreeView - element already registered after rapid root refresh'
,
async
function
(
)
{
this
.
timeout
(
60_000
)
;
// This test reproduces a race condition where rapid concurrent getChildren calls
// return different element object instances that have the same ID in their TreeItem,
// causing "Element with id ... is already registered" error.
//
// The bug: When _addChildrenToClear(undefined) is called, it clears _childrenFetchTokens.
// If two fetches are pending, both may reset the requestId counter to 1, so both think
// they are the current request. When both try to register elements with the same ID
// but different object instances, the error is thrown.
type
TreeElement
=
{
readonly
:
'leaf'
;
readonly
:
number
}
;
class
RapidRefreshTreeDataProvider
implements
vscode
.
<
>
{
private
readonly
=
new
vscode
.
EventEmitter<TreeElement |undefined>
(
)
;
private
readonly
=
new
vscode
.
EventEmitter<number>
(
)
;
private
readonly
:
<
[
]
>
[
]
=
[
]
;
// Return different element instance each time
private
:
=
{
:
'leaf'
,
:
1
}
;
private
:
=
{
:
'leaf'
,
:
2
}
;
readonly
=
this
.
.
;
getChildren
(
?
:
)
:
<
[
]
>
{
if
(
!
)
{
const
=
new
DeferredPromise<TreeElement[]>
(
)
;
this
.
.
push
(
)
;
this
.
.
fire
(
this
.
.
)
;
return
.
;
}
return
Promise
.
resolve
(
[
]
)
;
}
getTreeItem
(
)
:
.
{
// Both element instances return the same id
const
=
new
vscode
.
TreeItem
(
'test element'
,
.
.
)
;
.
=
'same-id-each-time'
;
return
;
}
getParent
(
)
:
|
undefined
{
return
undefined
;
}
getElement1
(
)
:
{
return
this
.
;
}
getElement2
(
)
:
{
return
this
.
;
}
async
waitForRequestCount
(
:
number
)
:
Promise
<
void
>
{
while
(
this
.
.
length< count){awaitasPromise(this.requestEmitter.event);}}resolveRequestWithElement(index:number, element: TreeElement):void{const request =this.pendingRequests[index];if(request){
request.complete([element]);}}dispose():void{this.changeEmitter.dispose();this.requestEmitter.dispose();while(this.pendingRequests.length){this.pendingRequests.shift()!.complete([]);}}}const provider =newRapidRefreshTreeDataProvider();
disposables.push(provider);const treeView = vscode.window.createTreeView('test.treeRapidRefresh',{ treeDataProvider: provider });
disposables.push(treeView);// Start two concurrent reveal operations - this should trigger two getChildren calls// Similar to the first testconst firstReveal =(treeView.reveal(provider.getElement1(),{ expand:true}).then(()=>
(
{
:
undefined
as
|
undefined
}
)
)
as
Promise
<
{
:
|
undefined
}
>
)
.
catch
(
=>
(
{
}
)
)
;
const
=
(
.
reveal
(
.
getElement2
(
)
,
{
:
true
}
)
.
then
(
(
)
=>
(
{
:
undefined
as
|
undefined
}
)
)
as
Promise
<
{
:
|
undefined
}
>
)
.
catch
(
=>
(
{
}
)
)
;
// Wait for both getChildren calls to be pending
await
.
waitForRequestCount
(
2
)
;
// Resolve requests returning DIFFERENT element instances with SAME id
// First request returns element1, second returns element2
// Both elements have the same id 'same-id-each-time' in getTreeItem
.
resolveRequestWithElement
(
0
,
.
getElement1
(
)
)
;
await
delay
(
0
)
;
.
resolveRequestWithElement
(
1
,
.
getElement2
(
)
)
;
const
[
,
]
=
await
Promise
.
all
(
[
,
]
)
;
const
=
[
.
,
.
]
.
filter
(
(
)
:
is
=>
!
!
)
;
.
strictEqual
(
.
,
1
,
'Exactly one reveal should fail from the stale fetch'
)
;
.
ok
(
/Cannot resolve tree item/
.
test
(
[
0
]
.
)
,
`Expected "Cannot resolve" error but got: ${errors[0].message}`
)
;
}
)
;
test
(
'TreeView - element already registered during switch and update'
,
async
function
(
)
{
this
.
timeout
(
60_000
)
;
// This test reproduces a race condition where the tree is being "switched to"
// (via reveal, which triggers getChildren) while simultaneously the tree data
// is being updated with a new element being added. Both operations trigger
// concurrent getChildren calls. The first resolves with the old set of elements,
// the second resolves with a new set that includes a new element. If both try
// to register elements with the same ID, the error is thrown.
type
TreeElement
=
{
readonly
:
'leaf'
;
readonly
:
number
}
;
class
SwitchAndUpdateTreeDataProvider
implements
vscode
.
<
>
{
private
readonly
=
new
vscode
.
EventEmitter<TreeElement |undefined>
(
)
;
private
readonly
=
new
vscode
.
EventEmitter<number>
(
)
;
private
readonly
:
<
[
]
>
[
]
=
[
]
;
private
readonly
:
=
{
:
'leaf'
,
:
1
}
;
private
readonly
:
=
{
:
'leaf'
,
:
2
}
;
private
readonly
:
=
{
:
'leaf'
,
:
3
}
;
readonly
=
this
.
.
;
getChildren
(
?
:
)
:
<
[
]
>
{
if
(
!
)
{
const
=
new
DeferredPromise<TreeElement[]>
(
)
;
this
.
.
push
(
)
;
this
.
.
fire
(
this
.
.
)
;
return
.
;
}
return
Promise
.
resolve
(
[
]
)
;
}
getTreeItem
(
:
)
:
.
{
if
(
===
this
.
)
{
const
=
new
vscode
.
TreeItem
(
'added'
,
.
.
)
;
.
=
'added-elem'
;
return
;
}
const
=
new
vscode
.
TreeItem
(
'existing'
,
.
.
)
;
.
=
'existing-elem'
;
return
;
}
getParent
(
)
:
|
undefined
{
return
undefined
;
}
async
waitForRequestCount
(
:
number
)
:
Promise
<
void
>
{
while
(
this
.
.
length< count){awaitasPromise(this.requestEmitter.event);}}resolveRequestAt(index:number, elements: TreeElement[]):void{const request =this.pendingRequests[index];if(request){
request.complete(elements);}}getExistingOld(): TreeElement {returnthis.existingOld;}getExistingNew(): TreeElement {returnthis.existingNew;}getAddedElement(): TreeElement {returnthis.addedElement;}dispose():void{this.changeEmitter.dispose();this.requestEmitter.dispose();while(this.pendingRequests.length){this.pendingRequests.shift()!.complete([]);}}}const provider =newSwitchAndUpdateTreeDataProvider();
disposables.push(provider);const treeView = vscode.window.createTreeView('test.treeSwitchUpdate',{ treeDataProvider: provider });
disposables.push(treeView);// Two concurrent reveals simulate the tree being "switched to" while also// being updated: both trigger getChildren calls on the ext host directly.const revealFirst =(treeView.reveal(provider.getExistingOld(),{ expand:true}).then(()=>
(
{
:
undefined
as
|
undefined
}
)
)
as
Promise
<
{
:
|
undefined
}
>
)
.
catch
(
=>
(
{
}
)
)
;
const
=
(
.
reveal
(
.
getExistingNew
(
)
,
{
:
true
}
)
.
then
(
(
)
=>
(
{
:
undefined
as
|
undefined
}
)
)
as
Promise
<
{
:
|
undefined
}
>
)
.
catch
(
=>
(
{
}
)
)
;
// Wait for both getChildren calls to be pending
await
.
waitForRequestCount
(
2
)
;
// Resolve first request with old data (just the existing element, old instance)
.
resolveRequestAt
(
0
,
[
.
getExistingOld
(
)
]
)
;
await
delay
(
0
)
;
// Resolve second request with new data: different instance of existing + added element
.
resolveRequestAt
(
1
,
[
.
getExistingNew
(
)
,
.
getAddedElement
(
)
]
)
;
const
[
,
]
=
await
Promise
.
all
(
[
,
]
)
;
const
=
[
.
,
.
]
.
filter
(
(
)
:
is
=>
!
!
)
;
.
strictEqual
(
.
,
1
,
'Exactly one reveal should fail from the stale fetch'
)
;
.
ok
(
/Cannot resolve tree item/
.
test
(
[
0
]
.
)
,
`Expected "Cannot resolve" error but got: ${errors[0].message}`
)
;
}
)
;
test
(
'TreeView - element already registered after refresh'