Merge pull request #164 from continuedev/tomasz/switch-orgs
Switching orgs
This commit is contained in:
commit
5235dbc31f
16 changed files with 830 additions and 337 deletions
271
package-lock.json
generated
271
package-lock.json
generated
|
|
@ -44,6 +44,7 @@
|
|||
"posthog-node": "^5.6.0",
|
||||
"react": "^19.1.0",
|
||||
"readline-sync": "^1.4.10",
|
||||
"swr": "^2.3.4",
|
||||
"turndown": "^7.2.0",
|
||||
"typescript": "^5.8.3",
|
||||
"uuid": "^9.0.1",
|
||||
|
|
@ -58,6 +59,7 @@
|
|||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/github": "^11.0.3",
|
||||
"@semantic-release/npm": "^12.0.2",
|
||||
"@testing-library/react": "^16.3.0",
|
||||
"@types/diff": "^7.0.2",
|
||||
"@types/express": "^5.0.3",
|
||||
"@types/glob": "^8.1.0",
|
||||
|
|
@ -80,6 +82,7 @@
|
|||
"express": "^5.1.0",
|
||||
"happy-dom": "^18.0.1",
|
||||
"ink-testing-library": "^4.0.0",
|
||||
"jsdom": "^26.1.0",
|
||||
"nock": "^14.0.5",
|
||||
"semantic-release": "^24.2.7",
|
||||
"supertest": "^7.1.3",
|
||||
|
|
@ -128,8 +131,6 @@
|
|||
"integrity": "sha512-K1A6z8tS3XsmCMM86xoWdn7Fkdn9m6RSVtocUrJYIwZnFVkng/PvkEoWtOWmP+Scc6saYWHWZYbndEEXxl24jw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@csstools/css-calc": "^2.1.3",
|
||||
"@csstools/css-color-parser": "^3.0.9",
|
||||
|
|
@ -143,9 +144,7 @@
|
|||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
|
||||
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/@aws-crypto/crc32": {
|
||||
"version": "5.2.0",
|
||||
|
|
@ -940,6 +939,16 @@
|
|||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/runtime": {
|
||||
"version": "7.28.2",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.2.tgz",
|
||||
"integrity": "sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@colors/colors": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
|
||||
|
|
@ -1063,8 +1072,6 @@
|
|||
}
|
||||
],
|
||||
"license": "MIT-0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
|
|
@ -1085,8 +1092,6 @@
|
|||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
|
|
@ -1111,8 +1116,6 @@
|
|||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@csstools/color-helpers": "^5.0.2",
|
||||
"@csstools/css-calc": "^2.1.4"
|
||||
|
|
@ -1141,8 +1144,6 @@
|
|||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
|
|
@ -1166,8 +1167,6 @@
|
|||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
|
|
@ -5456,6 +5455,55 @@
|
|||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@testing-library/dom": {
|
||||
"version": "10.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz",
|
||||
"integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.10.4",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@types/aria-query": "^5.0.1",
|
||||
"aria-query": "5.3.0",
|
||||
"dom-accessibility-api": "^0.5.9",
|
||||
"lz-string": "^1.5.0",
|
||||
"picocolors": "1.1.1",
|
||||
"pretty-format": "^27.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@testing-library/react": {
|
||||
"version": "16.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.3.0.tgz",
|
||||
"integrity": "sha512-kFSyxiEDwv1WLl2fgsq6pPBbw5aWKrsY2/noi1Id0TK0UParSF62oFQFGHXIyaG4pp2tEub/Zlel+fjjZILDsw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@testing-library/dom": "^10.0.0",
|
||||
"@types/react": "^18.0.0 || ^19.0.0",
|
||||
"@types/react-dom": "^18.0.0 || ^19.0.0",
|
||||
"react": "^18.0.0 || ^19.0.0",
|
||||
"react-dom": "^18.0.0 || ^19.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@tsconfig/node10": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
|
||||
|
|
@ -5504,6 +5552,14 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/aria-query": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz",
|
||||
"integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/@types/body-parser": {
|
||||
"version": "1.19.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz",
|
||||
|
|
@ -6794,6 +6850,17 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/aria-query": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
|
||||
"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"dequal": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/array-buffer-byte-length": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz",
|
||||
|
|
@ -7912,8 +7979,6 @@
|
|||
"integrity": "sha512-2z+rWdzbbSZv6/rhtvzvqeZQHrBaqgogqt85sqFNbabZOuFbCVFb8kPeEtZjiKkbrm395irpNKiYeFeLiQnFPg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@asamuzakjp/css-color": "^3.2.0",
|
||||
"rrweb-cssom": "^0.8.0"
|
||||
|
|
@ -7941,8 +8006,6 @@
|
|||
"integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"whatwg-mimetype": "^4.0.0",
|
||||
"whatwg-url": "^14.0.0"
|
||||
|
|
@ -7957,8 +8020,6 @@
|
|||
"integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"punycode": "^2.3.1"
|
||||
},
|
||||
|
|
@ -7972,8 +8033,6 @@
|
|||
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
|
|
@ -7984,8 +8043,6 @@
|
|||
"integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tr46": "^5.1.0",
|
||||
"webidl-conversions": "^7.0.0"
|
||||
|
|
@ -8070,9 +8127,7 @@
|
|||
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz",
|
||||
"integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/deep-eql": {
|
||||
"version": "5.0.2",
|
||||
|
|
@ -8270,6 +8325,14 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dom-accessibility-api": {
|
||||
"version": "0.5.16",
|
||||
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",
|
||||
"integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/dot-prop": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz",
|
||||
|
|
@ -8373,8 +8436,6 @@
|
|||
"integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
|
|
@ -10475,8 +10536,6 @@
|
|||
"integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"whatwg-encoding": "^3.1.1"
|
||||
},
|
||||
|
|
@ -11378,9 +11437,7 @@
|
|||
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
||||
"integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/is-promise": {
|
||||
"version": "4.0.0",
|
||||
|
|
@ -11662,8 +11719,6 @@
|
|||
"integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"cssstyle": "^4.2.1",
|
||||
"data-urls": "^5.0.0",
|
||||
|
|
@ -11704,8 +11759,6 @@
|
|||
"integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"entities": "^6.0.0"
|
||||
},
|
||||
|
|
@ -11719,8 +11772,6 @@
|
|||
"integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"punycode": "^2.3.1"
|
||||
},
|
||||
|
|
@ -11734,8 +11785,6 @@
|
|||
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
|
|
@ -11746,8 +11795,6 @@
|
|||
"integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tr46": "^5.1.0",
|
||||
"webidl-conversions": "^7.0.0"
|
||||
|
|
@ -12100,6 +12147,17 @@
|
|||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/lz-string": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
|
||||
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"bin": {
|
||||
"lz-string": "bin/bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "0.30.17",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz",
|
||||
|
|
@ -15269,9 +15327,7 @@
|
|||
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.21.tgz",
|
||||
"integrity": "sha512-o6nIY3qwiSXl7/LuOU0Dmuctd34Yay0yeuZRLFmDPrrdHpXKFndPj3hM+YEPVHYC5fx2otBx4Ilc/gyYSAUaIA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
|
@ -16089,6 +16145,36 @@
|
|||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pretty-format": {
|
||||
"version": "27.5.1",
|
||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz",
|
||||
"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"ansi-regex": "^5.0.1",
|
||||
"ansi-styles": "^5.0.0",
|
||||
"react-is": "^17.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pretty-format/node_modules/ansi-styles": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",
|
||||
"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/pretty-ms": {
|
||||
"version": "9.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-9.2.0.tgz",
|
||||
|
|
@ -16280,13 +16366,44 @@
|
|||
}
|
||||
},
|
||||
"node_modules/react": {
|
||||
"version": "19.1.0",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz",
|
||||
"integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==",
|
||||
"version": "19.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.1.1.tgz",
|
||||
"integrity": "sha512-w8nqGImo45dmMIfljjMwOGtbmC/mk4CMYhWIicdSflH91J9TyCyczcPFXJzrZ/ZXcgGRFeP6BU0BEJTw6tZdfQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-dom": {
|
||||
"version": "19.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.1.tgz",
|
||||
"integrity": "sha512-Dlq/5LAZgF0Gaz6yiqZCf6VCcZs1ghAJyrsu84Q/GT0gV+mCxbfmKNoGRKBYMJ8IEdGPqu49YWXD02GCknEDkw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"scheduler": "^0.26.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^19.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/react-dom/node_modules/scheduler": {
|
||||
"version": "0.26.0",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz",
|
||||
"integrity": "sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/react-is": {
|
||||
"version": "17.0.2",
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
|
||||
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/react-reconciler": {
|
||||
"version": "0.32.0",
|
||||
"resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.32.0.tgz",
|
||||
|
|
@ -16637,9 +16754,7 @@
|
|||
"resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.8.0.tgz",
|
||||
"integrity": "sha512-guoltQEx+9aMf2gDZ0s62EcV8lsXR+0w8915TC3ITdn2YueuNjdAYh/levpU9nFaoChh9RUS5ZdQMrKfVEN9tw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/run-applescript": {
|
||||
"version": "7.0.0",
|
||||
|
|
@ -16787,8 +16902,6 @@
|
|||
"integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"xmlchars": "^2.2.0"
|
||||
},
|
||||
|
|
@ -17838,14 +17951,25 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/swr": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/swr/-/swr-2.3.4.tgz",
|
||||
"integrity": "sha512-bYd2lrhc+VarcpkgWclcUi92wYCpOgMws9Sd1hG1ntAu0NEy+14CbotuFjshBU2kt9rYj9TSmDcybpxpeTU1fg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dequal": "^2.0.3",
|
||||
"use-sync-external-store": "^1.4.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/symbol-tree": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/temp-dir": {
|
||||
"version": "3.0.0",
|
||||
|
|
@ -18053,8 +18177,6 @@
|
|||
"integrity": "sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tldts-core": "^6.1.86"
|
||||
},
|
||||
|
|
@ -18067,9 +18189,7 @@
|
|||
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.86.tgz",
|
||||
"integrity": "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
|
|
@ -18109,8 +18229,6 @@
|
|||
"integrity": "sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"tldts": "^6.1.32"
|
||||
},
|
||||
|
|
@ -18537,6 +18655,15 @@
|
|||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/use-sync-external-store": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz",
|
||||
"integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
|
|
@ -18801,8 +18928,6 @@
|
|||
"integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"xml-name-validator": "^5.0.0"
|
||||
},
|
||||
|
|
@ -18843,8 +18968,6 @@
|
|||
"integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"iconv-lite": "0.6.3"
|
||||
},
|
||||
|
|
@ -18858,8 +18981,6 @@
|
|||
"integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
|
|
@ -19231,8 +19352,6 @@
|
|||
"integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
|
|
@ -19242,9 +19361,7 @@
|
|||
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
|
||||
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
"posthog-node": "^5.6.0",
|
||||
"react": "^19.1.0",
|
||||
"readline-sync": "^1.4.10",
|
||||
"swr": "^2.3.4",
|
||||
"turndown": "^7.2.0",
|
||||
"typescript": "^5.8.3",
|
||||
"uuid": "^9.0.1",
|
||||
|
|
@ -82,6 +83,7 @@
|
|||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/github": "^11.0.3",
|
||||
"@semantic-release/npm": "^12.0.2",
|
||||
"@testing-library/react": "^16.3.0",
|
||||
"@types/diff": "^7.0.2",
|
||||
"@types/express": "^5.0.3",
|
||||
"@types/glob": "^8.1.0",
|
||||
|
|
@ -104,6 +106,7 @@
|
|||
"express": "^5.1.0",
|
||||
"happy-dom": "^18.0.1",
|
||||
"ink-testing-library": "^4.0.0",
|
||||
"jsdom": "^26.1.0",
|
||||
"nock": "^14.0.5",
|
||||
"semantic-release": "^24.2.7",
|
||||
"supertest": "^7.1.3",
|
||||
|
|
|
|||
24
src/ui/AppRoot.tsx
Normal file
24
src/ui/AppRoot.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import React from "react";
|
||||
|
||||
import { NavigationProvider } from "./context/NavigationContext.js";
|
||||
import { TUIChat } from "./TUIChat.js";
|
||||
|
||||
interface AppRootProps {
|
||||
remoteUrl?: string;
|
||||
configPath?: string;
|
||||
initialPrompt?: string;
|
||||
resume?: boolean;
|
||||
additionalRules?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Root component that wraps TUIChat with all necessary providers
|
||||
* This is the main entry point for the UI application
|
||||
*/
|
||||
export const AppRoot: React.FC<AppRootProps> = (props) => {
|
||||
return (
|
||||
<NavigationProvider>
|
||||
<TUIChat {...props} />
|
||||
</NavigationProvider>
|
||||
);
|
||||
};
|
||||
|
|
@ -5,18 +5,19 @@ import * as path from "path";
|
|||
import { Box, Text, useInput } from "ink";
|
||||
import open from "open";
|
||||
import React, { useState } from "react";
|
||||
import useSWR from "swr";
|
||||
|
||||
import { listUserOrganizations } from "../auth/workos.js";
|
||||
import { env } from "../env.js";
|
||||
import { isValidAnthropicApiKey, getApiKeyValidationError } from "../util/apiKeyValidation.js";
|
||||
import { updateAnthropicModelInYaml } from "../util/yamlConfigUpdater.js";
|
||||
|
||||
import { useNavigation } from "./context/NavigationContext.js";
|
||||
|
||||
const CONFIG_PATH = path.join(os.homedir(), ".continue", "config.yaml");
|
||||
|
||||
interface FreeTrialTransitionUIProps {
|
||||
onComplete: () => void;
|
||||
onSwitchToLocalConfig?: () => void;
|
||||
onFullReload?: () => void;
|
||||
onShowConfigSelector?: () => void;
|
||||
onReload: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,11 +39,9 @@ async function createOrUpdateConfig(apiKey: string): Promise<void> {
|
|||
}
|
||||
|
||||
const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
|
||||
onComplete,
|
||||
onSwitchToLocalConfig,
|
||||
onFullReload,
|
||||
onShowConfigSelector,
|
||||
onReload,
|
||||
}) => {
|
||||
const { navigateTo, closeCurrentScreen } = useNavigation();
|
||||
const [currentStep, setCurrentStep] = useState<
|
||||
"choice" | "enterApiKey" | "processing" | "success" | "error"
|
||||
>("choice");
|
||||
|
|
@ -51,12 +50,25 @@ const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
|
|||
const [errorMessage, setErrorMessage] = useState("");
|
||||
const [successMessage, setSuccessMessage] = useState("");
|
||||
const [wasModelsSetup, setWasModelsSetup] = useState(false);
|
||||
|
||||
// Fetch organizations using SWR
|
||||
const { data: organizations } = useSWR(
|
||||
"organizations",
|
||||
listUserOrganizations,
|
||||
{
|
||||
revalidateOnFocus: false,
|
||||
revalidateOnReconnect: false,
|
||||
shouldRetryOnError: false,
|
||||
}
|
||||
);
|
||||
|
||||
const hasOrganizations = organizations && organizations.length > 0;
|
||||
|
||||
useInput((input, key) => {
|
||||
if (currentStep === "choice") {
|
||||
if (key.upArrow && selectedOption > 1) {
|
||||
setSelectedOption(selectedOption - 1);
|
||||
} else if (key.downArrow && selectedOption < 3) {
|
||||
} else if (key.downArrow && selectedOption < (hasOrganizations ? 4 : 3)) {
|
||||
setSelectedOption(selectedOption + 1);
|
||||
} else if (input === "1") {
|
||||
setSelectedOption(1);
|
||||
|
|
@ -64,6 +76,8 @@ const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
|
|||
setSelectedOption(2);
|
||||
} else if (input === "3") {
|
||||
setSelectedOption(3);
|
||||
} else if (input === "4" && hasOrganizations) {
|
||||
setSelectedOption(4);
|
||||
} else if (key.return) {
|
||||
handleOptionSelect();
|
||||
}
|
||||
|
|
@ -83,11 +97,10 @@ const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
|
|||
}
|
||||
} else if (currentStep === "success" || currentStep === "error") {
|
||||
if (key.return) {
|
||||
closeCurrentScreen();
|
||||
// If user went through models setup, do a full reload to register their purchase
|
||||
if (wasModelsSetup && onFullReload) {
|
||||
onFullReload();
|
||||
} else {
|
||||
onComplete();
|
||||
if (wasModelsSetup) {
|
||||
onReload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -118,11 +131,10 @@ const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
|
|||
setWasModelsSetup(false); // This is not models setup
|
||||
} else if (selectedOption === 3) {
|
||||
// Option 3: Switch to different configuration
|
||||
if (onShowConfigSelector) {
|
||||
onShowConfigSelector();
|
||||
} else {
|
||||
onComplete();
|
||||
}
|
||||
navigateTo('config');
|
||||
} else if (selectedOption === 4 && hasOrganizations) {
|
||||
// Option 4: Switch to organization
|
||||
navigateTo('organization');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -138,11 +150,8 @@ const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
|
|||
|
||||
// After a brief delay, switch to local configuration
|
||||
setTimeout(() => {
|
||||
if (onSwitchToLocalConfig) {
|
||||
onSwitchToLocalConfig();
|
||||
} else {
|
||||
onComplete();
|
||||
}
|
||||
closeCurrentScreen();
|
||||
onReload();
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
setErrorMessage(
|
||||
|
|
@ -175,9 +184,14 @@ const FreeTrialTransitionUI: React.FC<FreeTrialTransitionUIProps> = ({
|
|||
<Text color={selectedOption === 3 ? "cyan" : "white"}>
|
||||
{selectedOption === 3 ? "▶ " : " "}3. ⚙️ Switch to a different configuration
|
||||
</Text>
|
||||
{hasOrganizations && (
|
||||
<Text color={selectedOption === 4 ? "cyan" : "white"}>
|
||||
{selectedOption === 4 ? "▶ " : " "}4. 🏢 Switch to organization profile
|
||||
</Text>
|
||||
)}
|
||||
<Text></Text>
|
||||
<Text color="gray">
|
||||
Use ↑↓ arrows or 1/2/3 to select, Enter to confirm
|
||||
Use ↑↓ arrows or {hasOrganizations ? "1/2/3/4" : "1/2/3"} to select, Enter to confirm
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { getGitRemoteUrl, isGitRepo } from "../util/git.js";
|
|||
import { ModeIndicator } from "./components/ModeIndicator.js";
|
||||
import { ToolPermissionSelector } from "./components/ToolPermissionSelector.js";
|
||||
import { ConfigSelector } from "./ConfigSelector.js";
|
||||
import { useNavigation } from "./context/NavigationContext.js";
|
||||
import { startFileIndexing } from "./FileSearchUI.js";
|
||||
import { FreeTrialStatus } from "./FreeTrialStatus.js";
|
||||
import { FreeTrialTransitionUI } from "./FreeTrialTransitionUI.js";
|
||||
|
|
@ -88,15 +89,8 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
apiClient: ApiClientServiceState;
|
||||
}>(["auth", "config", "model", "mcp", "apiClient"]);
|
||||
|
||||
// State for login prompt handling
|
||||
const [loginPrompt, setLoginPrompt] = useState<{
|
||||
text: string;
|
||||
resolve: (value: string) => void;
|
||||
} | null>(null);
|
||||
|
||||
// State for free trial transition
|
||||
const [isShowingFreeTrialTransition, setIsShowingFreeTrialTransition] =
|
||||
useState(false);
|
||||
// Use navigation context
|
||||
const { state: navState, navigateTo, closeCurrentScreen, isScreenActive } = useNavigation();
|
||||
|
||||
// State for intro message display
|
||||
const [showIntroMessage, setShowIntroMessage] = useState(false);
|
||||
|
|
@ -152,15 +146,15 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
// Custom login prompt handler for TUI
|
||||
const handleLoginPrompt = (promptText: string): Promise<string> => {
|
||||
return new Promise((resolve) => {
|
||||
setLoginPrompt({ text: promptText, resolve });
|
||||
navigateTo('login', { text: promptText, resolve });
|
||||
});
|
||||
};
|
||||
|
||||
// Handle login token submission
|
||||
const handleLoginTokenSubmit = (token: string) => {
|
||||
if (loginPrompt) {
|
||||
loginPrompt.resolve(token);
|
||||
setLoginPrompt(null);
|
||||
if (navState.screenData?.resolve) {
|
||||
navState.screenData.resolve(token);
|
||||
closeCurrentScreen();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -192,9 +186,9 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
initialPrompt,
|
||||
resume,
|
||||
additionalRules,
|
||||
onShowOrgSelector: () => showOrganizationSelector(),
|
||||
onShowConfigSelector: () => showConfigSelectorUI(),
|
||||
onShowModelSelector: () => showModelSelectorUI(),
|
||||
onShowOrgSelector: () => navigateTo('organization'),
|
||||
onShowConfigSelector: () => navigateTo('config'),
|
||||
onShowModelSelector: () => navigateTo('model'),
|
||||
onLoginPrompt: handleLoginPrompt,
|
||||
onReload: handleReload,
|
||||
// Remote mode configuration
|
||||
|
|
@ -204,26 +198,14 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
|
||||
const { renderMessage } = useMessageRenderer();
|
||||
|
||||
const {
|
||||
showOrgSelector,
|
||||
handleOrganizationSelect,
|
||||
handleOrganizationCancel,
|
||||
showOrganizationSelector,
|
||||
} = useOrganizationSelector({
|
||||
configPath,
|
||||
onAssistantChange: () => {},
|
||||
const { handleOrganizationSelect } = useOrganizationSelector({
|
||||
onMessage: (message) => {
|
||||
setMessages((prev) => [...prev, message]);
|
||||
},
|
||||
onChatReset: resetChatHistory,
|
||||
});
|
||||
|
||||
const {
|
||||
showConfigSelector,
|
||||
handleConfigSelect,
|
||||
handleConfigCancel,
|
||||
showConfigSelectorUI,
|
||||
} = useConfigSelector({
|
||||
const { handleConfigSelect } = useConfigSelector({
|
||||
configPath,
|
||||
onMessage: (message) => {
|
||||
setMessages((prev) => [...prev, message]);
|
||||
|
|
@ -231,46 +213,17 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
onChatReset: resetChatHistory,
|
||||
});
|
||||
|
||||
const {
|
||||
showModelSelector,
|
||||
handleModelSelect,
|
||||
handleModelCancel,
|
||||
showModelSelectorUI,
|
||||
} = useModelSelector({
|
||||
const { handleModelSelect } = useModelSelector({
|
||||
onMessage: (message) => {
|
||||
setMessages((prev) => [...prev, message]);
|
||||
},
|
||||
});
|
||||
|
||||
// Handle free trial transition completion
|
||||
const handleFreeTrialTransitionComplete = () => {
|
||||
setIsShowingFreeTrialTransition(false);
|
||||
handleReload();
|
||||
};
|
||||
|
||||
const handleFreeTrialSwitchToLocal = () => {
|
||||
setIsShowingFreeTrialTransition(false);
|
||||
handleReload();
|
||||
};
|
||||
|
||||
const handleFreeTrialFullReload = () => {
|
||||
setIsShowingFreeTrialTransition(false);
|
||||
handleReload();
|
||||
};
|
||||
|
||||
const handleFreeTrialShowConfigSelector = () => {
|
||||
setIsShowingFreeTrialTransition(false);
|
||||
showConfigSelectorUI();
|
||||
};
|
||||
|
||||
// Determine if input should be disabled
|
||||
// Allow input even when services are loading, but disable for UI overlays
|
||||
const isInputDisabled =
|
||||
showOrgSelector ||
|
||||
showConfigSelector ||
|
||||
showModelSelector ||
|
||||
!!loginPrompt ||
|
||||
isShowingFreeTrialTransition ||
|
||||
navState.currentScreen !== 'chat' ||
|
||||
!!activePermissionRequest;
|
||||
|
||||
return (
|
||||
|
|
@ -317,7 +270,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
)}
|
||||
|
||||
{/* Login prompt - shows above input when active */}
|
||||
{loginPrompt && (
|
||||
{isScreenActive('login') && navState.screenData && (
|
||||
<Box
|
||||
paddingX={1}
|
||||
borderStyle="round"
|
||||
|
|
@ -328,7 +281,7 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
<Text color="yellow" bold>
|
||||
Login Required
|
||||
</Text>
|
||||
<Text>{loginPrompt.text}</Text>
|
||||
<Text>{navState.screenData.text}</Text>
|
||||
<UserInput
|
||||
onSubmit={handleLoginTokenSubmit}
|
||||
isWaitingForResponse={false}
|
||||
|
|
@ -342,41 +295,36 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
)}
|
||||
|
||||
{/* Organization selector - shows above input when active */}
|
||||
{showOrgSelector && (
|
||||
{isScreenActive('organization') && (
|
||||
<OrganizationSelector
|
||||
onSelect={handleOrganizationSelect}
|
||||
onCancel={handleOrganizationCancel}
|
||||
onCancel={closeCurrentScreen}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Config selector - shows above input when active */}
|
||||
{showConfigSelector && (
|
||||
{isScreenActive('config') && (
|
||||
<ConfigSelector
|
||||
onSelect={handleConfigSelect}
|
||||
onCancel={handleConfigCancel}
|
||||
onCancel={closeCurrentScreen}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Model selector - shows above input when active */}
|
||||
{showModelSelector && (
|
||||
{isScreenActive('model') && (
|
||||
<ModelSelector
|
||||
onSelect={handleModelSelect}
|
||||
onCancel={handleModelCancel}
|
||||
onCancel={closeCurrentScreen}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Free trial transition UI - replaces input when active */}
|
||||
{isShowingFreeTrialTransition && (
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={handleFreeTrialTransitionComplete}
|
||||
onSwitchToLocalConfig={handleFreeTrialSwitchToLocal}
|
||||
onFullReload={handleFreeTrialFullReload}
|
||||
onShowConfigSelector={handleFreeTrialShowConfigSelector}
|
||||
/>
|
||||
{isScreenActive('free-trial') && (
|
||||
<FreeTrialTransitionUI onReload={handleReload} />
|
||||
)}
|
||||
|
||||
{/* Input area - only show when not showing free trial transition */}
|
||||
{!isShowingFreeTrialTransition && (
|
||||
{/* Input area - only show when showing chat screen */}
|
||||
{isScreenActive('chat') && (
|
||||
<>
|
||||
{/* Show permission selector when there's an active permission request */}
|
||||
{activePermissionRequest ? (
|
||||
|
|
@ -425,7 +373,13 @@ const TUIChat: React.FC<TUIChatProps> = ({
|
|||
<FreeTrialStatus
|
||||
apiClient={services.apiClient?.apiClient || undefined}
|
||||
model={services.model.model}
|
||||
onTransitionStateChange={setIsShowingFreeTrialTransition}
|
||||
onTransitionStateChange={(shouldShow) => {
|
||||
if (shouldShow && navState.currentScreen === 'chat') {
|
||||
navigateTo('free-trial');
|
||||
} else if (!shouldShow && navState.currentScreen === 'free-trial') {
|
||||
closeCurrentScreen();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
|
|
|
|||
|
|
@ -9,11 +9,18 @@ vi.mock("open", () => ({
|
|||
default: vi.fn()
|
||||
}));
|
||||
|
||||
// Mock the NavigationContext
|
||||
vi.mock("../context/NavigationContext.js", () => ({
|
||||
useNavigation: () => ({
|
||||
navigateTo: vi.fn(),
|
||||
closeCurrentScreen: vi.fn(),
|
||||
isScreenActive: vi.fn(() => false),
|
||||
state: { currentScreen: 'free-trial', screenData: null }
|
||||
})
|
||||
}));
|
||||
|
||||
describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
||||
const mockOnComplete = vi.fn();
|
||||
const mockOnSwitchToLocalConfig = vi.fn();
|
||||
const mockOnFullReload = vi.fn();
|
||||
const mockOnShowConfigSelector = vi.fn();
|
||||
const mockOnReload = vi.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
|
@ -23,10 +30,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
it("displays all three options with proper formatting", () => {
|
||||
const { lastFrame } = render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onShowConfigSelector={mockOnShowConfigSelector}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
@ -41,10 +45,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
it("highlights first option by default", () => {
|
||||
const { lastFrame } = render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onShowConfigSelector={mockOnShowConfigSelector}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
@ -57,10 +58,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
it("renders without crashing when all props are provided", () => {
|
||||
const { lastFrame } = render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onShowConfigSelector={mockOnShowConfigSelector}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
@ -72,9 +70,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
it("renders without crashing when onShowConfigSelector is not provided", () => {
|
||||
const { lastFrame } = render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onReload={mockOnReload}
|
||||
// onShowConfigSelector not provided
|
||||
/>
|
||||
);
|
||||
|
|
@ -88,10 +84,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
it("includes proper user instructions", () => {
|
||||
const { lastFrame } = render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onShowConfigSelector={mockOnShowConfigSelector}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
@ -103,10 +96,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
it("shows all options with proper descriptions", () => {
|
||||
const { lastFrame } = render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onShowConfigSelector={mockOnShowConfigSelector}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
@ -123,10 +113,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
expect(() => {
|
||||
render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onShowConfigSelector={mockOnShowConfigSelector}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
}).not.toThrow();
|
||||
|
|
@ -137,9 +124,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
expect(() => {
|
||||
render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
}).not.toThrow();
|
||||
|
|
@ -150,10 +135,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
it("renders with proper border styling", () => {
|
||||
const { lastFrame } = render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onShowConfigSelector={mockOnShowConfigSelector}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
@ -165,10 +147,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
it("displays with proper spacing and formatting", () => {
|
||||
const { lastFrame } = render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onShowConfigSelector={mockOnShowConfigSelector}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
@ -180,10 +159,7 @@ describe("FreeTrialTransitionUI - Rendering and Props Tests", () => {
|
|||
it("shows selection indicator on first option by default", () => {
|
||||
const { lastFrame } = render(
|
||||
<FreeTrialTransitionUI
|
||||
onComplete={mockOnComplete}
|
||||
onSwitchToLocalConfig={mockOnSwitchToLocalConfig}
|
||||
onFullReload={mockOnFullReload}
|
||||
onShowConfigSelector={mockOnShowConfigSelector}
|
||||
onReload={mockOnReload}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { render } from "ink-testing-library";
|
|||
import React from "react";
|
||||
|
||||
import { createUITestContext } from "../../test-helpers/ui-test-context.js";
|
||||
import { TUIChat } from "../TUIChat.js";
|
||||
import { AppRoot } from "../AppRoot.js";
|
||||
|
||||
describe("TUIChat - Basic UI Tests", () => {
|
||||
let context: any;
|
||||
|
|
@ -20,7 +20,7 @@ describe("TUIChat - Basic UI Tests", () => {
|
|||
});
|
||||
|
||||
it("renders without crashing", () => {
|
||||
const { lastFrame } = render(React.createElement(TUIChat));
|
||||
const { lastFrame } = render(React.createElement(AppRoot));
|
||||
const frame = lastFrame();
|
||||
|
||||
expect(frame).toBeDefined();
|
||||
|
|
@ -38,7 +38,7 @@ describe("TUIChat - Basic UI Tests", () => {
|
|||
allReady: false,
|
||||
});
|
||||
|
||||
const { lastFrame } = render(React.createElement(TUIChat));
|
||||
const { lastFrame } = render(React.createElement(AppRoot));
|
||||
const frame = lastFrame();
|
||||
|
||||
expect(frame).toBeDefined();
|
||||
|
|
@ -50,7 +50,7 @@ describe("TUIChat - Basic UI Tests", () => {
|
|||
|
||||
it("handles remote URL prop", () => {
|
||||
const { lastFrame } = render(
|
||||
React.createElement(TUIChat, { remoteUrl: "http://localhost:3000" })
|
||||
React.createElement(AppRoot, { remoteUrl: "http://localhost:3000" })
|
||||
);
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { render } from "ink-testing-library";
|
|||
import React from "react";
|
||||
|
||||
import { createUITestContext } from "../../test-helpers/ui-test-context.js";
|
||||
import { TUIChat } from "../TUIChat.js";
|
||||
import { AppRoot } from "../AppRoot.js";
|
||||
|
||||
export type TestMode = 'local' | 'remote';
|
||||
|
||||
|
|
@ -68,8 +68,8 @@ export function testBothModes(
|
|||
export function renderInMode(mode: TestMode, props?: any) {
|
||||
return render(
|
||||
mode === 'remote'
|
||||
? React.createElement(TUIChat, { remoteUrl: "http://localhost:3000", ...props })
|
||||
: React.createElement(TUIChat, props)
|
||||
? React.createElement(AppRoot, { remoteUrl: "http://localhost:3000", ...props })
|
||||
: React.createElement(AppRoot, props)
|
||||
) as ReturnType<typeof render>; // Explicit type to avoid TypeScript issues
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { render } from "ink-testing-library";
|
|||
import React from "react";
|
||||
|
||||
import { createUITestContext } from "../../test-helpers/ui-test-context.js";
|
||||
import { TUIChat } from "../TUIChat.js";
|
||||
import { AppRoot } from "../AppRoot.js";
|
||||
|
||||
describe("TUIChat - Remote Server Tests", () => {
|
||||
let context: any;
|
||||
|
|
@ -20,7 +20,7 @@ describe("TUIChat - Remote Server Tests", () => {
|
|||
|
||||
it("renders in remote mode with remote URL", () => {
|
||||
const { lastFrame } = render(
|
||||
<TUIChat remoteUrl="http://localhost:3000" />
|
||||
<AppRoot remoteUrl="http://localhost:3000" />
|
||||
);
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ describe("TUIChat - Remote Server Tests", () => {
|
|||
|
||||
it("shows remote mode indicator", () => {
|
||||
const { lastFrame } = render(
|
||||
<TUIChat remoteUrl="http://localhost:3000" />
|
||||
<AppRoot remoteUrl="http://localhost:3000" />
|
||||
);
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ describe("TUIChat - Remote Server Tests", () => {
|
|||
|
||||
it("does not show service loading in remote mode", () => {
|
||||
const { lastFrame } = render(
|
||||
<TUIChat remoteUrl="http://localhost:3000" />
|
||||
<AppRoot remoteUrl="http://localhost:3000" />
|
||||
);
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ describe("TUIChat - Remote Server Tests", () => {
|
|||
|
||||
it("handles different remote URLs", () => {
|
||||
const { lastFrame } = render(
|
||||
<TUIChat remoteUrl="https://api.example.com:8080" />
|
||||
<AppRoot remoteUrl="https://api.example.com:8080" />
|
||||
);
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ describe("TUIChat - Remote Server Tests", () => {
|
|||
|
||||
it("shows slash commands in remote mode", async () => {
|
||||
const { lastFrame, stdin } = render(
|
||||
<TUIChat remoteUrl="http://localhost:3000" />
|
||||
<AppRoot remoteUrl="http://localhost:3000" />
|
||||
);
|
||||
|
||||
// Wait for initial render
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { render } from "ink-testing-library";
|
|||
import React from "react";
|
||||
|
||||
import { createUITestContext } from "../../test-helpers/ui-test-context.js";
|
||||
import { TUIChat } from "../TUIChat.js";
|
||||
import { AppRoot } from "../AppRoot.js";
|
||||
|
||||
describe("TUIChat - Tool Display Tests", () => {
|
||||
let context: any;
|
||||
|
|
@ -20,7 +20,7 @@ describe("TUIChat - Tool Display Tests", () => {
|
|||
|
||||
it("renders without crashing when tools are available", () => {
|
||||
const { lastFrame } = render(
|
||||
<TUIChat remoteUrl="http://localhost:3000" />
|
||||
<AppRoot remoteUrl="http://localhost:3000" />
|
||||
);
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ describe("TUIChat - Tool Display Tests", () => {
|
|||
|
||||
it("handles UI with no tools configured", () => {
|
||||
const { lastFrame } = render(
|
||||
<TUIChat remoteUrl="http://localhost:3000" />
|
||||
<AppRoot remoteUrl="http://localhost:3000" />
|
||||
);
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ describe("TUIChat - Tool Display Tests", () => {
|
|||
|
||||
it("maintains UI stability during tool operations", async () => {
|
||||
const { lastFrame, stdin } = render(
|
||||
<TUIChat remoteUrl="http://localhost:3000" />
|
||||
<AppRoot remoteUrl="http://localhost:3000" />
|
||||
);
|
||||
|
||||
// Type a message that might trigger tool use
|
||||
|
|
@ -60,7 +60,7 @@ describe("TUIChat - Tool Display Tests", () => {
|
|||
|
||||
it("shows tool-related slash commands", async () => {
|
||||
const { lastFrame, stdin } = render(
|
||||
<TUIChat remoteUrl="http://localhost:3000" />
|
||||
<AppRoot remoteUrl="http://localhost:3000" />
|
||||
);
|
||||
|
||||
// Wait for initial render
|
||||
|
|
|
|||
106
src/ui/context/NavigationContext.tsx
Normal file
106
src/ui/context/NavigationContext.tsx
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import React, { createContext, useContext, useReducer, useCallback, ReactNode } from 'react';
|
||||
|
||||
/**
|
||||
* Navigation screens for the UI
|
||||
* Only one screen can be active at a time
|
||||
*/
|
||||
export type NavigationScreen =
|
||||
| 'chat' // Normal chat interface
|
||||
| 'organization' // Organization selector
|
||||
| 'config' // Config selector
|
||||
| 'model' // Model selector
|
||||
| 'free-trial' // Free trial transition UI
|
||||
| 'login'; // Login prompt
|
||||
|
||||
interface NavigationState {
|
||||
currentScreen: NavigationScreen;
|
||||
// Screen-specific data (e.g., login prompt details)
|
||||
screenData?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigation actions
|
||||
*/
|
||||
type NavigationAction =
|
||||
| { type: 'NAVIGATE_TO'; screen: NavigationScreen; data?: any }
|
||||
| { type: 'CLOSE_SCREEN' };
|
||||
|
||||
/**
|
||||
* Navigation reducer - handles all state transitions deterministically
|
||||
*/
|
||||
function navigationReducer(state: NavigationState, action: NavigationAction): NavigationState {
|
||||
switch (action.type) {
|
||||
case 'NAVIGATE_TO':
|
||||
return {
|
||||
currentScreen: action.screen,
|
||||
screenData: action.data ?? null,
|
||||
};
|
||||
|
||||
case 'CLOSE_SCREEN':
|
||||
return {
|
||||
currentScreen: 'chat',
|
||||
screenData: null,
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
interface NavigationContextValue {
|
||||
// Current navigation state
|
||||
state: NavigationState;
|
||||
|
||||
// Navigation methods
|
||||
navigateTo: (screen: NavigationScreen, data?: any) => void;
|
||||
closeCurrentScreen: () => void;
|
||||
|
||||
// Check if a specific screen is active
|
||||
isScreenActive: (screen: NavigationScreen) => boolean;
|
||||
}
|
||||
|
||||
const NavigationContext = createContext<NavigationContextValue | undefined>(undefined);
|
||||
|
||||
export function useNavigation() {
|
||||
const context = useContext(NavigationContext);
|
||||
if (!context) {
|
||||
throw new Error('useNavigation must be used within NavigationProvider');
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
interface NavigationProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function NavigationProvider({ children }: NavigationProviderProps) {
|
||||
const [state, dispatch] = useReducer(navigationReducer, {
|
||||
currentScreen: 'chat',
|
||||
screenData: null,
|
||||
});
|
||||
|
||||
const navigateTo = useCallback((screen: NavigationScreen, data?: any) => {
|
||||
dispatch({ type: 'NAVIGATE_TO', screen, data });
|
||||
}, []);
|
||||
|
||||
const closeCurrentScreen = useCallback(() => {
|
||||
dispatch({ type: 'CLOSE_SCREEN' });
|
||||
}, []);
|
||||
|
||||
const isScreenActive = useCallback((screen: NavigationScreen): boolean => {
|
||||
return state.currentScreen === screen;
|
||||
}, [state.currentScreen]);
|
||||
|
||||
const value: NavigationContextValue = {
|
||||
state,
|
||||
navigateTo,
|
||||
closeCurrentScreen,
|
||||
isScreenActive,
|
||||
};
|
||||
|
||||
return (
|
||||
<NavigationContext.Provider value={value}>
|
||||
{children}
|
||||
</NavigationContext.Provider>
|
||||
);
|
||||
}
|
||||
347
src/ui/context/__tests__/NavigationContext.test.tsx
Normal file
347
src/ui/context/__tests__/NavigationContext.test.tsx
Normal file
|
|
@ -0,0 +1,347 @@
|
|||
/**
|
||||
* @vitest-environment jsdom
|
||||
*/
|
||||
import { renderHook, act } from "@testing-library/react";
|
||||
import React from "react";
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
|
||||
import { NavigationProvider, useNavigation, NavigationScreen } from "../NavigationContext.js";
|
||||
|
||||
describe("NavigationContext", () => {
|
||||
// Helper to create wrapper
|
||||
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
||||
<NavigationProvider>{children}</NavigationProvider>
|
||||
);
|
||||
|
||||
describe("NavigationProvider", () => {
|
||||
it("provides navigation context to children", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
expect(result.current).toBeDefined();
|
||||
expect(result.current.state).toBeDefined();
|
||||
expect(result.current.navigateTo).toBeDefined();
|
||||
expect(result.current.closeCurrentScreen).toBeDefined();
|
||||
expect(result.current.isScreenActive).toBeDefined();
|
||||
});
|
||||
|
||||
it("initializes with chat as the current screen", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
expect(result.current.state.currentScreen).toBe("chat");
|
||||
expect(result.current.state.screenData).toBeNull();
|
||||
});
|
||||
|
||||
it("throws error when useNavigation is used outside provider", () => {
|
||||
// Suppress console.error for this test
|
||||
const originalError = console.error;
|
||||
console.error = vi.fn();
|
||||
|
||||
expect(() => {
|
||||
renderHook(() => useNavigation());
|
||||
}).toThrow("useNavigation must be used within NavigationProvider");
|
||||
|
||||
console.error = originalError;
|
||||
});
|
||||
});
|
||||
|
||||
describe("Navigation Actions", () => {
|
||||
describe("navigateTo", () => {
|
||||
it("navigates to a new screen", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("organization");
|
||||
});
|
||||
|
||||
expect(result.current.state.currentScreen).toBe("organization");
|
||||
});
|
||||
|
||||
it("navigates to a new screen with data", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const testData = { text: "Login required", resolve: vi.fn() };
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", testData);
|
||||
});
|
||||
|
||||
expect(result.current.state.currentScreen).toBe("login");
|
||||
expect(result.current.state.screenData).toEqual(testData);
|
||||
});
|
||||
|
||||
it("can navigate to all valid screens", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const screens: NavigationScreen[] = [
|
||||
"chat",
|
||||
"organization",
|
||||
"config",
|
||||
"model",
|
||||
"free-trial",
|
||||
"login",
|
||||
];
|
||||
|
||||
screens.forEach((screen) => {
|
||||
act(() => {
|
||||
result.current.navigateTo(screen);
|
||||
});
|
||||
expect(result.current.state.currentScreen).toBe(screen);
|
||||
});
|
||||
});
|
||||
|
||||
it("replaces screen data when navigating to the same screen", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const firstData = { value: 1 };
|
||||
const secondData = { value: 2 };
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", firstData);
|
||||
});
|
||||
expect(result.current.state.screenData).toEqual(firstData);
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", secondData);
|
||||
});
|
||||
expect(result.current.state.screenData).toEqual(secondData);
|
||||
});
|
||||
|
||||
it("clears screen data when navigating without data", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const testData = { value: "test" };
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", testData);
|
||||
});
|
||||
expect(result.current.state.screenData).toEqual(testData);
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("organization");
|
||||
});
|
||||
expect(result.current.state.screenData).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("closeCurrentScreen", () => {
|
||||
it("returns to chat screen when closing other screens", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("organization");
|
||||
});
|
||||
expect(result.current.state.currentScreen).toBe("organization");
|
||||
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
expect(result.current.state.currentScreen).toBe("chat");
|
||||
});
|
||||
|
||||
it("clears screen data when closing", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const testData = { text: "Test data" };
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", testData);
|
||||
});
|
||||
expect(result.current.state.screenData).toEqual(testData);
|
||||
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
expect(result.current.state.screenData).toBeNull();
|
||||
});
|
||||
|
||||
it("stays on chat screen when closing from chat", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
expect(result.current.state.currentScreen).toBe("chat");
|
||||
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
|
||||
expect(result.current.state.currentScreen).toBe("chat");
|
||||
});
|
||||
|
||||
it("closes from any screen back to chat", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const screens: Array<"organization" | "config" | "model" | "free-trial" | "login"> = [
|
||||
"organization",
|
||||
"config",
|
||||
"model",
|
||||
"free-trial",
|
||||
"login",
|
||||
];
|
||||
|
||||
screens.forEach((screen) => {
|
||||
act(() => {
|
||||
result.current.navigateTo(screen);
|
||||
});
|
||||
expect(result.current.state.currentScreen).toBe(screen);
|
||||
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
expect(result.current.state.currentScreen).toBe("chat");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("isScreenActive", () => {
|
||||
it("returns true for active screen", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
expect(result.current.isScreenActive("chat")).toBe(true);
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("organization");
|
||||
});
|
||||
|
||||
expect(result.current.isScreenActive("organization")).toBe(true);
|
||||
expect(result.current.isScreenActive("chat")).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for inactive screens", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
expect(result.current.isScreenActive("organization")).toBe(false);
|
||||
expect(result.current.isScreenActive("config")).toBe(false);
|
||||
expect(result.current.isScreenActive("model")).toBe(false);
|
||||
expect(result.current.isScreenActive("free-trial")).toBe(false);
|
||||
expect(result.current.isScreenActive("login")).toBe(false);
|
||||
});
|
||||
|
||||
it("updates correctly when navigating", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("free-trial");
|
||||
});
|
||||
expect(result.current.isScreenActive("free-trial")).toBe(true);
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("model");
|
||||
});
|
||||
expect(result.current.isScreenActive("free-trial")).toBe(false);
|
||||
expect(result.current.isScreenActive("model")).toBe(true);
|
||||
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
expect(result.current.isScreenActive("model")).toBe(false);
|
||||
expect(result.current.isScreenActive("chat")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("State Management", () => {
|
||||
it("maintains immutable state updates", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const initialState = result.current.state;
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("organization");
|
||||
});
|
||||
|
||||
expect(result.current.state).not.toBe(initialState);
|
||||
expect(result.current.state.currentScreen).toBe("organization");
|
||||
});
|
||||
|
||||
it("preserves unrelated state when updating", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", { custom: "data" });
|
||||
});
|
||||
|
||||
const stateWithData = result.current.state;
|
||||
|
||||
act(() => {
|
||||
result.current.navigateTo("login", { different: "data" });
|
||||
});
|
||||
|
||||
expect(result.current.state.currentScreen).toBe(stateWithData.currentScreen);
|
||||
expect(result.current.state.screenData).not.toBe(stateWithData.screenData);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Integration Scenarios", () => {
|
||||
it("handles login flow correctly", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
const mockResolve = vi.fn();
|
||||
|
||||
// Navigate to login with resolve callback
|
||||
act(() => {
|
||||
result.current.navigateTo("login", {
|
||||
text: "Please log in",
|
||||
resolve: mockResolve
|
||||
});
|
||||
});
|
||||
|
||||
expect(result.current.state.currentScreen).toBe("login");
|
||||
expect(result.current.state.screenData?.text).toBe("Please log in");
|
||||
expect(result.current.state.screenData?.resolve).toBe(mockResolve);
|
||||
|
||||
// Close login screen (simulating successful login)
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
|
||||
expect(result.current.state.currentScreen).toBe("chat");
|
||||
expect(result.current.state.screenData).toBeNull();
|
||||
});
|
||||
|
||||
it("handles organization selection flow", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
// Navigate to organization selector
|
||||
act(() => {
|
||||
result.current.navigateTo("organization");
|
||||
});
|
||||
expect(result.current.isScreenActive("organization")).toBe(true);
|
||||
|
||||
// Close after selection
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
expect(result.current.isScreenActive("chat")).toBe(true);
|
||||
});
|
||||
|
||||
it("handles free trial transition flow", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
// Show free trial screen
|
||||
act(() => {
|
||||
result.current.navigateTo("free-trial");
|
||||
});
|
||||
expect(result.current.isScreenActive("free-trial")).toBe(true);
|
||||
|
||||
// User might navigate to config from free trial
|
||||
act(() => {
|
||||
result.current.navigateTo("config");
|
||||
});
|
||||
expect(result.current.isScreenActive("config")).toBe(true);
|
||||
expect(result.current.isScreenActive("free-trial")).toBe(false);
|
||||
|
||||
// Return to chat
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
expect(result.current.isScreenActive("chat")).toBe(true);
|
||||
});
|
||||
|
||||
it("handles model switching flow", () => {
|
||||
const { result } = renderHook(() => useNavigation(), { wrapper });
|
||||
|
||||
// Navigate to model selector
|
||||
act(() => {
|
||||
result.current.navigateTo("model");
|
||||
});
|
||||
expect(result.current.state.currentScreen).toBe("model");
|
||||
|
||||
// Close after selection
|
||||
act(() => {
|
||||
result.current.closeCurrentScreen();
|
||||
});
|
||||
expect(result.current.state.currentScreen).toBe("chat");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -2,9 +2,8 @@ import { exec } from "child_process";
|
|||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { services } from "../../services/index.js";
|
||||
import { useNavigation } from "../context/NavigationContext.js";
|
||||
|
||||
interface ConfigOption {
|
||||
id: string;
|
||||
|
|
@ -29,10 +28,10 @@ export function useConfigSelector({
|
|||
onMessage,
|
||||
onChatReset,
|
||||
}: UseConfigSelectorProps) {
|
||||
const [showConfigSelector, setShowConfigSelector] = useState(false);
|
||||
const { closeCurrentScreen } = useNavigation();
|
||||
|
||||
const handleConfigSelect = async (config: ConfigOption) => {
|
||||
setShowConfigSelector(false);
|
||||
closeCurrentScreen();
|
||||
|
||||
if (config.type === "create") {
|
||||
// Open the web browser to create new assistant
|
||||
|
|
@ -112,18 +111,7 @@ export function useConfigSelector({
|
|||
}
|
||||
};
|
||||
|
||||
const handleConfigCancel = () => {
|
||||
setShowConfigSelector(false);
|
||||
};
|
||||
|
||||
const showConfigSelectorUI = () => {
|
||||
setShowConfigSelector(true);
|
||||
};
|
||||
|
||||
return {
|
||||
showConfigSelector,
|
||||
handleConfigSelect,
|
||||
handleConfigCancel,
|
||||
showConfigSelectorUI,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { useState } from "react";
|
||||
|
||||
import { updateModelName } from "../../auth/workos.js";
|
||||
import { services, serviceContainer, SERVICE_NAMES } from "../../services/index.js";
|
||||
import { ModelServiceState } from "../../services/types.js";
|
||||
import { useNavigation } from "../context/NavigationContext.js";
|
||||
|
||||
interface ModelOption {
|
||||
id: string;
|
||||
|
|
@ -24,10 +23,10 @@ export function useModelSelector({
|
|||
onMessage,
|
||||
onModelSwitch,
|
||||
}: UseModelSelectorProps) {
|
||||
const [showModelSelector, setShowModelSelector] = useState(false);
|
||||
const { closeCurrentScreen } = useNavigation();
|
||||
|
||||
const handleModelSelect = async (model: ModelOption) => {
|
||||
setShowModelSelector(false);
|
||||
closeCurrentScreen();
|
||||
|
||||
try {
|
||||
await services.model.switchModel(model.index);
|
||||
|
|
@ -61,18 +60,7 @@ export function useModelSelector({
|
|||
}
|
||||
};
|
||||
|
||||
const handleModelCancel = () => {
|
||||
setShowModelSelector(false);
|
||||
};
|
||||
|
||||
const showModelSelectorUI = () => {
|
||||
setShowModelSelector(true);
|
||||
};
|
||||
|
||||
return {
|
||||
showModelSelector,
|
||||
handleModelSelect,
|
||||
handleModelCancel,
|
||||
showModelSelectorUI,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,23 +1,11 @@
|
|||
import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml";
|
||||
import { BaseLlmApi } from "@continuedev/openai-adapters";
|
||||
import { useState } from "react";
|
||||
|
||||
import {
|
||||
isAuthenticatedConfig,
|
||||
loadAuthConfig,
|
||||
saveAuthConfig,
|
||||
} from "../../auth/workos.js";
|
||||
import { initialize } from "../../config.js";
|
||||
import { MCPService } from "../../mcp.js";
|
||||
import { services, reloadService } from "../../services/index.js";
|
||||
import { SERVICE_NAMES } from "../../services/types.js";
|
||||
import { useNavigation } from "../context/NavigationContext.js";
|
||||
|
||||
interface UseOrganizationSelectorProps {
|
||||
configPath?: string;
|
||||
onAssistantChange: (
|
||||
assistant: AssistantUnrolled,
|
||||
model: ModelConfig,
|
||||
llmApi: BaseLlmApi,
|
||||
mcpService: MCPService
|
||||
) => void;
|
||||
onMessage: (message: {
|
||||
role: string;
|
||||
content: string;
|
||||
|
|
@ -27,40 +15,38 @@ interface UseOrganizationSelectorProps {
|
|||
}
|
||||
|
||||
export function useOrganizationSelector({
|
||||
configPath,
|
||||
onAssistantChange,
|
||||
onMessage,
|
||||
onChatReset,
|
||||
}: UseOrganizationSelectorProps) {
|
||||
const [showOrgSelector, setShowOrgSelector] = useState(false);
|
||||
const { closeCurrentScreen } = useNavigation();
|
||||
|
||||
const handleOrganizationSelect = async (
|
||||
organizationId: string | null,
|
||||
organizationName: string
|
||||
) => {
|
||||
setShowOrgSelector(false);
|
||||
|
||||
// Update auth config
|
||||
const authConfig = loadAuthConfig();
|
||||
|
||||
// Only allow organization switching for authenticated users
|
||||
if (!isAuthenticatedConfig(authConfig)) {
|
||||
onMessage({
|
||||
role: "system",
|
||||
content:
|
||||
"Organization switching not available for environment variable auth",
|
||||
messageType: "system" as const,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const updatedConfig = {
|
||||
...authConfig,
|
||||
organizationId,
|
||||
};
|
||||
saveAuthConfig(updatedConfig);
|
||||
|
||||
try {
|
||||
// Check if user is authenticated
|
||||
const authState = services.auth.getState();
|
||||
if (!authState.isAuthenticated || !authState.authConfig) {
|
||||
onMessage({
|
||||
role: "system",
|
||||
content:
|
||||
"Organization switching not available - not authenticated",
|
||||
messageType: "system" as const,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isAuthenticatedConfig(authState.authConfig)) {
|
||||
onMessage({
|
||||
role: "system",
|
||||
content:
|
||||
"Organization switching not available for environment variable auth",
|
||||
messageType: "system" as const,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Show loading message
|
||||
onMessage({
|
||||
role: "system",
|
||||
|
|
@ -68,16 +54,11 @@ export function useOrganizationSelector({
|
|||
messageType: "system" as const,
|
||||
});
|
||||
|
||||
// Reinitialize assistant with new organization
|
||||
const {
|
||||
config,
|
||||
llmApi: newLlmApi,
|
||||
model: newModel,
|
||||
mcpService: newMcpService,
|
||||
} = await initialize(updatedConfig, configPath);
|
||||
// Switch organization through the auth service
|
||||
await services.auth.switchOrganization(organizationId);
|
||||
|
||||
// Update assistant configuration
|
||||
onAssistantChange(config, newModel, newLlmApi, newMcpService);
|
||||
// Reload all dependent services (API_CLIENT -> CONFIG -> MODEL/MCP)
|
||||
await reloadService(SERVICE_NAMES.AUTH);
|
||||
|
||||
// Reset chat history
|
||||
onChatReset();
|
||||
|
|
@ -91,6 +72,9 @@ export function useOrganizationSelector({
|
|||
content: `Successfully switched to organization: ${organizationName}`,
|
||||
messageType: "system" as const,
|
||||
});
|
||||
|
||||
// Close the organization selector
|
||||
closeCurrentScreen();
|
||||
} catch (error: any) {
|
||||
// Show error message
|
||||
onMessage({
|
||||
|
|
@ -98,21 +82,13 @@ export function useOrganizationSelector({
|
|||
content: `Failed to switch organization: ${error.message}`,
|
||||
messageType: "system" as const,
|
||||
});
|
||||
|
||||
// Close selector even on error
|
||||
closeCurrentScreen();
|
||||
}
|
||||
};
|
||||
|
||||
const handleOrganizationCancel = () => {
|
||||
setShowOrgSelector(false);
|
||||
};
|
||||
|
||||
const showOrganizationSelector = () => {
|
||||
setShowOrgSelector(true);
|
||||
};
|
||||
|
||||
return {
|
||||
showOrgSelector,
|
||||
handleOrganizationSelect,
|
||||
handleOrganizationCancel,
|
||||
showOrganizationSelector,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { PermissionMode } from "../permissions/types.js";
|
|||
import { initializeServices } from "../services/index.js";
|
||||
import { ServiceContainerProvider } from "../services/ServiceContainerContext.js";
|
||||
|
||||
import { TUIChat } from "./TUIChat.js";
|
||||
import { AppRoot } from "./AppRoot.js";
|
||||
|
||||
export { MarkdownRenderer } from "./MarkdownRenderer.js";
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ export async function startTUIChat(
|
|||
// Start the TUI immediately - it will handle loading states
|
||||
const { unmount } = render(
|
||||
React.createElement(ServiceContainerProvider, {
|
||||
children: React.createElement(TUIChat, {
|
||||
children: React.createElement(AppRoot, {
|
||||
configPath,
|
||||
initialPrompt,
|
||||
resume,
|
||||
|
|
@ -62,7 +62,7 @@ export async function startRemoteTUIChat(
|
|||
// Start the TUI in remote mode - no services needed
|
||||
const { unmount } = render(
|
||||
React.createElement(ServiceContainerProvider, {
|
||||
children: React.createElement(TUIChat, {
|
||||
children: React.createElement(AppRoot, {
|
||||
remoteUrl,
|
||||
initialPrompt,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue