Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: deprecate PouchDB and refine AI chat UX (#21287)

ecmadao3588fd2c4061
diff --git a/frontend/package.json b/frontend/package.json
index c587dd9268..83313a04bc 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -72,8 +72,6 @@
"normalize-wheel": "^1.0.1",
"pev2": "1.23.0",
"posthog-js": "^1.406.2",
- "pouchdb": "^9.0.0",
- "pouchdb-find": "^9.0.0",
"qrcode.react": "^4.2.0",
"qs": "6.15.3",
"react": "^19.2.6",
@@ -120,8 +118,6 @@
"@types/mdast": "^4.0.4",
"@types/node": "24.13.3",
"@types/normalize-wheel": "^1.0.4",
- "@types/pouchdb": "^6.4.2",
- "@types/pouchdb-find": "^7.3.3",
"@types/qs": "6.15.1",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index 79974758ce..0821ab3169 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -154,12 +154,6 @@ importers:
posthog-js:
specifier: ^1.406.2
version: 1.407.2
- pouchdb:
- specifier: ^9.0.0
- version: 9.0.0
- pouchdb-find:
- specifier: ^9.0.0
- version: 9.0.0
qrcode.react:
specifier: ^4.2.0
version: 4.2.0([email protected])
@@ -293,12 +287,6 @@ importers:
'@types/normalize-wheel':
specifier: ^1.0.4
version: 1.0.4
- '@types/pouchdb':
- specifier: ^6.4.2
- version: 6.4.2
- '@types/pouchdb-find':
- specifier: ^7.3.3
- version: 7.3.3
'@types/qs':
specifier: 6.15.1
version: 6.15.1
@@ -1961,57 +1949,6 @@ packages:
resolution: {integrity: sha512-iclKEmOclXH2LGVkMkdal0+ffJphB3kbazakec96z1hW/CfJYmsZNFYLAmkpzePxKoKewXp2HSlsN6G4SG0b0g==}
- '@types/[email protected]':
- resolution: {integrity: sha512-1MGjmAMux3OIyJ+iXfhJ5hNIzS+KjGJ05O3bF5Gen5TiJUFNK1bOp3VVV9SxXgz+hGwnBruBAWdAqhbB6ZHhSA==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-KaFB29hUI97eTtJI6pjv7EQcqhZ63qHWovKgyiE+HZF5fVmdrBbTmnIrbR87AJXcXKy47+oQFJ7rzxY8TalpLQ==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-DJur1mt07GJXwGb5K+MOILoCOSgoQpsi7hybcTzRLeR3IO8Y8eq7TnhTkftAJdx9VHJGOiOXFjO+8BYM69j5yA==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-KwjkJ4fTNz5wPXYu20bUoWud7ty0t7tgdo4oc0AJvG+fcURAH7mI7uFmpE4dZIT+hUq5G61xu96AVq9b2q4T3g==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-mqeTpA2Ni2U4FA5ISRESy4WwhfUahXViUa3jQpXGdSpruaeHlhTLzZJPyz7/mGlvdAfAFv9Vd5d6ys3ASmMujw==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-+HQBCpD80XkKJE64r7uLwzkNRgkvMnhDI5rIFLx3USxdrRph/R3awcEubRFndcgtxzcUaL9iYw9KetgFMUqPrg==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-QCCtW561XuwFACzP/4zYySzs/a4em0EeuQdszen0YOaGV1/fRqJE0dOlmzh8do4sNJomLO6+MFtEzguGljnkgA==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-yi68syUvHs4OM3mzKlh4zfpov64KITIAnxi387zgdby6SEfAJzWPC0dfH77iEVRDGCrKb3cKTNkl/UGHnphaow==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-9oNkP5ZCGMkQALO9KmtbHXlkBq8i2hoCEE6/gWzRicAvL1y+WIKjEQiIIEamMhj5u5tARvW3n2/r+JXwLCyYgw==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-f+HjxEjYFpgoYWXnMI9AQZZ+SIG8dBiBPrpfWWGsCl+48rumsP5BuBWHq/aXoB8SRKYO0XdP4TNvMBWM3UATCw==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-gq1Qbqn9nCaAKRRv6fRHZ4/ER+QYEwSXBZlDQcxwdbPrtZO8EhIn2Bct0AlguaSEdFcABfbaxxyQwFINkNQ9dQ==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-U7zXk67s9Ar+9Pwj5kSbuMnn8zif0AOOIPy4KRFeJ/S/Tk+mNS90soj+3OV21H8xyB7WTxjvS1JLablZC6C6ow==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-9jGCAl6DUsXIl1vjuPu8tzGykAr84549P4IS0zYdrOKq5eXzQRUb/tb2hEVTmmTcYKXu2P1N55ABsdDNZvzGGA==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-AgYVqCnaA5D7cWkWyzZVuk0137N4yZsmIQTD/i3DmuMxYYoFrtWUoQu0tbA52SpTRGdL8ubQ7JFQXzA13fA6IQ==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-hryc2eCtNB3GbLcHSwU8glLaY66gDMus1AYkcIYAAxufdnK2BAy1oxaRLmnwRn1A1vG41P/t0htFD161LUnfQw==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-slB4zOwri3SAVHioFx/FWC/KqOzzb7nDFtV+qzaKzxkf+U5zTwCbK3uRHaj0d/XQk0DwVeajf1ni3Wiyq3j2OA==}
-
- '@types/[email protected]':
- resolution: {integrity: sha512-YsI47rASdtzR+3V3JE2UKY58snhm0AglHBpyckQBkRYoCbTvGagXHtV0x5n8nzN04jQmvTG+Sm85cIzKT3KXBA==}
-
resolution: {integrity: sha512-GZHUBZR9hckSUhrxmp1nG6NwdpM9fCunJwyThLW1X3AyHgd9IlHb6VANpQQqDr2o/qQp6McZ3y/IA2rVzKzSbw==}
@@ -2253,21 +2190,6 @@ packages:
peerDependencies:
vue: ^3.5.0
- resolution: {integrity: sha512-BsLm5vFMRUrrLeCcRc+G0t2qOaTzpoJQLOubq2XM72eNpjF5UdU5o/5NvlNhx95XHcAvcl8OMXr4mlg/fRgUXQ==}
- engines: {node: '>=6'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-TU5nlYgta8YrBMNpc9FwQzRbiXsj49gsALsXadbGHt9CROPzX5fB0rWDR5mtdpOOKa5XqRFpbj1QroPAoPzVjQ==}
- engines: {node: '>=6'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-DnhQwcFEaYsvYDnACLZhMmCWd3rkOeEvglpa4q5i/5Jlm3UIsWaxVzuXvDLFCSCWRO3yy2/+V/G7FusFgejnfQ==}
- engines: {node: '>=10'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
resolution: {integrity: sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==}
engines: {node: '>=0.4.0'}
@@ -2342,9 +2264,6 @@ packages:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
- resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
-
resolution: {integrity: sha512-HYXq73DDpCtNzOmrFsm9eSwCvWCql0RzqjpDzXN9EadiLJ4DNat0nsZ/Bzmy+Ud12mb4/zKDY0cQ805ZzN+i0A==}
engines: {node: '>=6.0.0'}
@@ -2376,12 +2295,6 @@ packages:
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
- resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
-
- resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
-
resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
engines: {node: '>=8'}
@@ -2397,10 +2310,6 @@ packages:
resolution: {integrity: sha512-72Cuvd95zbSYPKq6Fhg8eDJRlzgWDf7/mtoZv6Qe/DYNCEBdNxoA3+rZAU2ZhGCpZlns3EssFavaZomckT5Uuw==}
- resolution: {integrity: sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w==}
- engines: {node: '>=6'}
-
resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}
@@ -2663,11 +2572,6 @@ packages:
resolution: {integrity: sha512-Wy+JTSbFThEOXQIR2L6mxJvEs+veIzpmqD7ynWxMXGpnk3smkHQOp6forLdHsKpAMW9iJpaBBIxz285t1n1C3w==}
- resolution: {integrity: sha512-a59VOT+oDy7vtAbLRCZwWgxu2BaCfd5Hk7wxJd48ei7I+nsg8Orlb9CLG0PMZienk9BSUKgeAqkO2+Lw+1+Ukw==}
- engines: {node: '>=6'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==}
engines: {node: '>=8'}
@@ -2716,9 +2620,6 @@ packages:
resolution: {integrity: sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==}
engines: {node: '>=12'}
- resolution: {integrity: sha512-+BNfZ+deCo8hMNpDqDnvT+c0XpJ5cUa6mqYq89bho2Ifze4URTqRkcwR399hWoTrTkbZ/XJYDgP6rc7pRgffEQ==}
-
resolution: {integrity: sha512-LN1gO7+u9xjU5oEScGFKvXhYf7Y/empUIIEAGBs1LzUq/rg5duiDrkuH5A2lQGd5jfMOb9X9usDa2oVXwJ0U/Q==}
@@ -2739,14 +2640,6 @@ packages:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
- resolution: {integrity: sha512-QKrV0iKR6MZVJV08QY0wp1e7vF6QbhnbQhb07bwpEyuz4uZiZgPlEGdkCROuFkUwdxlFaiPIhjyarH1ee/3vhw==}
- engines: {node: '>=6'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-Brl10T8kYnc75IepKizW6Y9liyW8ikz1B7n/xoHrJxoVSSjoqPn30sb7XVFfQERK4QfUMYRGs9dhWwtt2eu6uA==}
-
resolution: {integrity: sha512-PwKooW9JUzh5chmYfHM3IQl5OkK2u2Nm011MgeZrss3JmFraUx/fqrf78kk8GUMYoibx/14MdwTl/1WKkG7TpQ==}
engines: {node: '>=10.13.0'}
@@ -2763,10 +2656,6 @@ packages:
resolution: {integrity: sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==}
engines: {node: '>=20.19.0'}
- resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==}
- hasBin: true
-
resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==}
engines: {node: '>= 0.4'}
@@ -2831,9 +2720,6 @@ packages:
picomatch:
optional: true
- resolution: {integrity: sha512-h9AgfjURuCgA2+2ISl8GbavpUdR+WGAM2McW/ovn4tVccegp8ZqCKWSBR8uRdM8dDNlx5WdKRWxBYUwteLDCNQ==}
-
resolution: {integrity: sha512-zdxgIEddhfsyCaWpJ2SdXEP8ZMrKJ6+5jl4OupODcywU0IhRk6gdXuVGcPICyfx2H97hVK7xmJtRLPjkxAX8Vw==}
@@ -2952,15 +2838,9 @@ packages:
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
engines: {node: '>=0.10.0'}
- resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
-
resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==}
- resolution: {integrity: sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==}
-
resolution: {integrity: sha512-VrNANlmnWQnh5COXIIOQXM9oOJw7naGKlBT74ZOOR6lpVXc3gFEu9FJLDFcpCJ2j+NWr8TIwtWD//T6ZX6TKiQ==}
@@ -2994,10 +2874,6 @@ packages:
resolution: {integrity: sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==}
- resolution: {integrity: sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==}
- engines: {node: '>=4'}
-
resolution: {integrity: sha512-1BTwHrs0wHnNZTyMWM8MPpVEs8u4uvLnUA2QZGt6cFjqY82DZV3lKH6hBGHqu8eJxkAIYcelm1kBR8v8URS4yA==}
@@ -3031,9 +2907,6 @@ packages:
resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==}
engines: {node: '>=8'}
- resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==}
-
resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==}
@@ -3081,69 +2954,6 @@ packages:
resolution: {integrity: sha512-SeY4/242PZ6M2cUtZvwEatbmIAjSK2zBm5PFUHFgJsR+1Kw51SBcqUHYzd5yofVAiyt0L047Kya7DqxoP+0Ouw==}
- resolution: {integrity: sha512-UyIwNb1lJBChJnGfjmO0OR+ezh2iVu1Kas3nvBS/BzGnx79dv6g7unpKIDNPMhfdTEGoc7mC8uAu51XEtX+FHQ==}
- engines: {node: '>=6'}
- deprecated: Superseded by level-transcoder (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-OTKKOqeav2QWcERMJR7IS9CUo1sHnke2C0gkSmcR7QuEtFNLLzHQAvnMw8ykvEcv0Qtkg0p7FOwP1v9e5Smdcw==}
- engines: {node: '>=6'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-BWRCMHBxbIqPxJ8vHOvKUsaO0v1sLYZtjN3K2iZJsRBYtp+ONsY6Jfi6hy9K3+zolgQRryhIn2NRZjZnWJ9NmQ==}
- engines: {node: '>=10'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-UVprBJXite4gPS+3VznfgDSU8PTRuVX0NXwoWW50KLxd2yw4Y1t2JUR5In1itQnudZqRMT9DlAM3Q//9NCjCFw==}
- engines: {node: '>=6'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-ZSthfEqzGSOMWoUGhTXdX9jv26d32XJuHz/5YnuHZzH6wldfWMOVwI9TBtKcya4BKTyTt3XVA0A3cF3q5CY30Q==}
- engines: {node: '>=6'}
-
- resolution: {integrity: sha512-SnBIDo2pdO5VXh02ZmtAyPP6/+6YTJg2ibLtl9C34pWvmtMEmRTWpra+qO/hifkUtBTOtfx6S9vLDjBsBK4gRg==}
- deprecated: Superseded by browser-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-HMwMaQPlTC1IlcwT3+swhqf/NUO+ZhXVz6TY1zZIIZlIR0YSn8GtAAWmIvKjNY16ZkEg/JcpAuQskxsXqC0yOQ==}
- engines: {node: '>=6'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-rXM7GYnW8gsl1vedTJIbzOrRv85c/2uCMpiiCzO2fndd06U/kUXEEU9evYn4zFggBOg36IsBW8LzqIpETwwQzg==}
- engines: {node: '>=6'}
-
- resolution: {integrity: sha512-E486g1NCjW5cF78KGPrMDRBYzPuueMZ6VBXHT6gC7A8UYWGiM14fGgp+s/L1oFfDWSPV/+SFkYCmZ0SiESkRKA==}
- engines: {node: '>=10'}
-
- resolution: {integrity: sha512-bBNKOEOMl8msO+uIM9YX/gUO6ckokZ/4pCwTm/lwvs46x6Xs8Zy0sn3Vh37eDqse4mhy4fOMIb/JsSM2nyQFtw==}
-
- resolution: {integrity: sha512-psRSqJZCsC/irNhfHzrVZbmPYXDcEYhA5TVNwr+V92jF44rbf86hqGp8fiT702FyiArScYIlPSBTDUASCVNSpw==}
- engines: {node: '>=8.6.0'}
-
- resolution: {integrity: sha512-iB8O/7Db9lPaITU1aA2txU/cBEXAt4vWwKQRrrWuS6XDgbP4QZGj9BL2aNbwb002atoQ/lIotJkfyzz+ygQnUQ==}
- engines: {node: '>=8.6.0'}
- deprecated: Superseded by classic-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-88c+E+Eizn4CkQOBHwqlCJaTNEjGpaEIikn1S+cINc5E9HEvJ77bqY4JY/HxT5u0caWqsc3P3DcFIKBI1vHt+A==}
- engines: {node: '>=10.12.0'}
- deprecated: Superseded by classic-level (https://github.com/Level/community#faq)
-
- resolution: {integrity: sha512-94++VFO3qN95cM/d6eBXvd894oJE0w3cInq9USsyQzzoJxmiYzPAocNcuGCPGGjoXqDVJcr3C1jzt1TSjyaiLQ==}
- engines: {node: '>=6'}
- deprecated: Superseded by abstract-level (https://github.com/Level/community#faq)
-
resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==}
@@ -3250,9 +3060,6 @@ packages:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
- resolution: {integrity: sha512-AI2r85+4MquTw9ZYqabu4nMwy9Oftlfa/e/52t9IjtfG+mGBbTNdAoZ3RQKLHR6r0wQnwZnPIEh/Ya6XTWAKNA==}
-
resolution: {integrity: sha512-rJicGl/3Fly/E0rOH1YmPZ6e49JCnKknh1ox1vpHnkfjujAkKA6sqUZvH3MTAaXXjgexyUwgNwTJzTtYuAFYJw==}
peerDependencies:
@@ -3472,9 +3279,6 @@ packages:
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
- resolution: {integrity: sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg==}
-
resolution: {integrity: sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==}
hasBin: true
@@ -3482,23 +3286,6 @@ packages:
resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==}
- resolution: {integrity: sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==}
- engines: {node: 4.x || >=6.0.0}
- peerDependencies:
- encoding: ^0.1.0
- peerDependenciesMeta:
- encoding:
- optional: true
-
- resolution: {integrity: sha512-dSq1xmcPDKPZ2EED2S6zw/b9NKsqzXRE6dVr8TVQnI3FJOTteUMuqF3Qqs6LZg+mLGYJWqQzMbIjMtJqTv87nQ==}
- hasBin: true
-
- resolution: {integrity: sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==}
- hasBin: true
-
resolution: {integrity: sha512-20JqtutY6JPXTUnL0ij1uad7Qe1baT46lyolh2sSENDd4sTzKZ4nmAFkeAARDKwmlLjPx6XKRlwRUxwjOy+lUg==}
@@ -3573,39 +3360,6 @@ packages:
resolution: {integrity: sha512-5deTvXopn+NJWEmCUw8Ix/ms3cv2+60WJ73Vgbvu2wSkZY/FIj2uqAgCnq7IewGpGC+tH7CAbPYFzH6hw8eW1w==}
- resolution: {integrity: sha512-SnTtqwAEiAa3uxKbc1J7LfiBViwEkKe2xkK92zxyTXPqWBvMnh4UU3GXxx7GrXTM4L9llsQ3lSjpbH4CNqG1Mw==}
-
- resolution: {integrity: sha512-2OMtgDZi82vqs+zNDE0YiYjOaWkYCUcZJZKK3WkRr+XYRu+2B7umJrnygJFhUwoGedBbHSrlQBLhdNV3F1AX1A==}
-
- resolution: {integrity: sha512-TrnEDNZEmIIl+W3xKUO8h+geqVLQ90oZe5ujPkl8myUzpREULWXWQBnV5EzPXVEKDBpJlb8T3I6oy/zdWGQpdA==}
-
- resolution: {integrity: sha512-961PSMLhW0UqqdJ566g+CdLZ5pkBJRd6l4WWpCDdD0USvE4xYfYGzv43w7nZZBw1k3Xdy092yqPge7yX/tfnyw==}
-
- resolution: {integrity: sha512-TbE3cUcAJQrwb9kr44tDP0X+NAbcqgjsTvcL30L4xzBNJeCPTIRjukYX80s154SHJUXBxcWRiPsMmNqpXsjfCA==}
-
- resolution: {integrity: sha512-vvVhq4eEOmSkwSRwf2NBYtdhURB7ryJ7sUI4WDN00GuLUj2g8jAXBJuZIryVgdYt/5S5cfn70iRL6Eow+LFhpA==}
-
- resolution: {integrity: sha512-Bjh8W6QXqp1j7MKmHhYYp5cYlcQsm5drD8Jd/F+ZlfNt18uiD2SQXWzGM5797+tiW/LszFGb8ttw0uHWjxufCQ==}
-
- resolution: {integrity: sha512-58xUYBvW3/s+aH0j4uOhhN8yCk0LQ254cxBzI/gbKA9PrfwHpe4zrr0L/ia5ml3A30oH1f8aTnuVMwWDkFcuww==}
-
- resolution: {integrity: sha512-ZYHYsdoedwm8j5tYofz+3+uUSK8i+7tRCBb01T0OuqDQb17+w5mzjHF8Ppi160xdPUPaWCo1Un+nLWGJzkmA3g==}
-
- resolution: {integrity: sha512-xWZE5c+nAslgmLC8JBZbky8AYgdz7pKtv7KTSi6CD2tuQD0WyNKib0YnhZndeE84dksTeZlqlg56RQHsHoB2LQ==}
-
- resolution: {integrity: sha512-6wjFc/PzwaWz86rmMXoqdBlR/fBSkNoWO1mEJO7RZNS6n3xf+fhhXWAWtws741KpLKx84IkmmJ48tp+fhFzj4A==}
-
resolution: {integrity: sha512-DCHYrK/B10yUD3ZjLfhZ3WIE/9Vf9VFUODcRE2dRomTYDpJk6z6L9wecSfhfE6M9ZTHUdyQkoC46arIDhEV84Q==}
peerDependencies:
@@ -3627,12 +3381,6 @@ packages:
resolution: {integrity: sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ==}
- resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==}
-
- resolution: {integrity: sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==}
-
resolution: {integrity: sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==}
engines: {node: '>=6'}
@@ -3653,12 +3401,6 @@ packages:
resolution: {integrity: sha512-lT5yCqEBgfoMYpf3F2xQRK7zEr1rhIIZuceDK6+xRkJQ4NMbHTwXqk4NkwDwQMNqXgG9r9fyHnzwNVs6zV5KRw==}
- resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==}
-
- resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
-
resolution: {integrity: sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==}
@@ -3760,19 +3502,9 @@ packages:
resolution: {integrity: sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==}
engines: {node: '>=0.10.0'}
- resolution: {integrity: sha512-azrivNydKRYt7zwLV5wWUK7YzKTWs3q87xSmY6DlHapPrCvaT6ZrukvM5erV+yCSSPmZT8zkSdttOHQpWWm9zw==}
-
- resolution: {integrity: sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==}
-
resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==}
- resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==}
- engines: {node: '>= 6'}
-
resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==}
engines: {node: '>=8'}
@@ -3824,9 +3556,6 @@ packages:
resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}
engines: {node: '>=0.10.0'}
- resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==}
-
resolution: {integrity: sha512-AgZ3UOZm3YndfrJ4OYjgrT7bmCm/1iqkjvEfH/oYjzh6PD2qw4QuT3jjnXIrpdt4MTpMXclMT3lXbmRY+XRakw==}
@@ -3874,9 +3603,6 @@ packages:
resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==}
- resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
-
resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
@@ -3905,9 +3631,6 @@ packages:
engines: {node: '>=10'}
hasBin: true
- resolution: {integrity: sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==}
-
resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==}
@@ -3952,9 +3675,6 @@ packages:
resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==}
- resolution: {integrity: sha512-wcFzz9cDfbuqe0FZzfi2or1sgyIrsDwmPwfZC4hiNidPdPINjeUwNfv5kldczoEAcjl9Y1L3SM7Uz2PUEQzxQw==}
-
resolution: {integrity: sha512-K+WKxWdqtKShV33gPjQl769wHxB3glypTOReCvYu/AJd38J+abHlpiF8rK6uBNPMrgw5thHZCI5JkEwsAqa9XA==}
peerDependencies:
@@ -3974,15 +3694,9 @@ packages:
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
engines: {node: '>=8'}
- resolution: {integrity: sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==}
-
resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==}
- resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
-
resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==}
@@ -4032,9 +3746,6 @@ packages:
engines: {node: '>=10'}
hasBin: true
- resolution: {integrity: sha512-enaDQ4MUyP2W6ZyT6EsMzqBPZaM/avg8iuo+l2d3QCs0J+6RaqkHV/2/lOwDTueBHeJ/2LG9lrLW3d5rWPucuQ==}
-
resolution: {integrity: sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==}
@@ -4071,17 +3782,10 @@ packages:
resolution: {integrity: sha512-KAB2lrSS48y91MzFPFuDg4hLbvDiyTjOVgaK7Erw+5AmZXNq4sFRVn8r6yxSLuNs15PaokrDRpS61ERY9uZOug==}
engines: {node: '>=10'}
- resolution: {integrity: sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==}
- engines: {node: '>=6'}
-
resolution: {integrity: sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==}
engines: {node: '>=16'}
- resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
-
resolution: {integrity: sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==}
engines: {node: '>=20'}
@@ -4166,10 +3870,6 @@ packages:
resolution: {integrity: sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg==}
- resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==}
- engines: {node: '>= 4.0.0'}
-
resolution: {integrity: sha512-5uKD0nqiYVzlmCRs01Fhs2BdkEgBS3SAVP6ndrBsuK42iC2+JHyxM05Rm9G8+5mkmRtzMZGY8Ct5+mliZxU/Ww==}
engines: {node: '>=18.12.0'}
@@ -4180,9 +3880,6 @@ packages:
peerDependencies:
browserslist: '>= 4.21.0'
- resolution: {integrity: sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==}
-
resolution: {integrity: sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==}
peerDependencies:
@@ -4195,11 +3892,6 @@ packages:
resolution: {integrity: sha512-6ZxzVpzDXDa3bJWaHilVayA+BH/1zmxCJoVgvmqJnid/gPoKHxUrS/aC/T6LGQtNHT+XHG9fXPJB4d+IrU30Ew==}
hasBin: true
- resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
- deprecated: uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).
- hasBin: true
-
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
@@ -4342,9 +4034,6 @@ packages:
typescript:
optional: true
- resolution: {integrity: sha512-Tm7jR1xTzBbPW+6y1tknKiEhz04Wf/1iZkcTJjSFcpNko43+dFW6+OOeQe9taJIug3NdfUAjFKgUSyQrIKaDvQ==}
-
resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==}
engines: {node: '>=18'}
@@ -4352,9 +4041,6 @@ packages:
resolution: {integrity: sha512-q6LWsLatGYZp5VGBIOvbTj6JBV2nOmC8KvWztXBmwJcfFAzhwKwbOxhUH306XY3CcaZDUlSmSuNPBsCn0bFu+g==}
- resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==}
-
resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==}
engines: {node: '>=20'}
@@ -4370,9 +4056,6 @@ packages:
resolution: {integrity: sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==}
engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}
- resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==}
-
resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
engines: {node: '>=8'}
@@ -4382,9 +4065,6 @@ packages:
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
engines: {node: '>=10'}
- resolution: {integrity: sha512-IJrvkhbAnj89W/GAVdVgbnPiVw5Ntg/B4tc/MUCIEwj/g6JIww1DWJyB/yBMT3yw2/TkT6IUZ0+IYef3flEw8A==}
-
resolution: {integrity: sha512-+0NTnW77fFN/DjQi6k/Sq/Yvk4Sgajw7urW8V+asjXnRgDs9gyGkdb7EzgfhA4goXsRIZKE28fzIXBHEzhuiWw==}
engines: {node: '>=10.0.0'}
@@ -4404,10 +4084,6 @@ packages:
resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}
- resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}
- engines: {node: '>=0.4'}
-
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
engines: {node: '>=10'}
@@ -6027,101 +5703,6 @@ snapshots:
'@types/[email protected]': {}
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-adapter-websql': 6.1.7
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-adapter-http': 6.1.6
- '@types/pouchdb-adapter-idb': 6.1.7
- '@types/pouchdb-adapter-websql': 6.1.7
- '@types/pouchdb-core': 7.0.15
- '@types/pouchdb-mapreduce': 6.1.10
- '@types/pouchdb-replication': 6.4.7
-
- '@types/[email protected]':
- dependencies:
- '@types/debug': 4.1.12
- '@types/pouchdb-find': 7.3.3
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-adapter-http': 6.1.6
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-adapter-http': 6.1.6
- '@types/pouchdb-adapter-leveldb': 6.1.6
- '@types/pouchdb-core': 7.0.15
- '@types/pouchdb-mapreduce': 6.1.10
- '@types/pouchdb-replication': 6.4.7
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-core': 7.0.15
- '@types/pouchdb-find': 7.3.3
-
- '@types/[email protected]':
- dependencies:
- '@types/pouchdb-adapter-cordova-sqlite': 1.0.4
- '@types/pouchdb-adapter-fruitdown': 6.1.6
- '@types/pouchdb-adapter-http': 6.1.6
- '@types/pouchdb-adapter-idb': 6.1.7
- '@types/pouchdb-adapter-leveldb': 6.1.6
- '@types/pouchdb-adapter-localstorage': 6.1.6
- '@types/pouchdb-adapter-memory': 6.1.6
- '@types/pouchdb-adapter-node-websql': 6.1.5
- '@types/pouchdb-adapter-websql': 6.1.7
- '@types/pouchdb-browser': 6.1.5
- '@types/pouchdb-core': 7.0.15
- '@types/pouchdb-http': 6.1.5
- '@types/pouchdb-mapreduce': 6.1.10
- '@types/pouchdb-node': 6.1.7
- '@types/pouchdb-replication': 6.4.7
-
'@types/[email protected]': {}
@@ -6342,31 +5923,6 @@ snapshots:
dependencies:
vue: 3.5.40([email protected])
- dependencies:
- buffer: 5.7.1
- immediate: 3.3.0
- level-concat-iterator: 2.0.1
- level-supports: 1.0.1
- xtend: 4.0.2
-
- dependencies:
- buffer: 5.7.1
- immediate: 3.3.0
- level-concat-iterator: 2.0.1
- level-supports: 1.0.1
- xtend: 4.0.2
-
- dependencies:
- buffer: 6.0.3
- catering: 2.1.1
- is-buffer: 2.0.5
- level-concat-iterator: 3.1.0
- level-supports: 2.1.0
- queue-microtask: 1.2.3
-
dependencies:
acorn: 8.17.0
@@ -6440,8 +5996,6 @@ snapshots:
-
@@ -6471,16 +6025,6 @@ snapshots:
- dependencies:
- base64-js: 1.5.1
- ieee754: 1.2.1
-
- dependencies:
- base64-js: 1.5.1
- ieee754: 1.2.1
-
@@ -6495,8 +6039,6 @@ snapshots:
-
@@ -6778,11 +6320,6 @@ snapshots:
dependencies:
character-entities: 2.0.2
- dependencies:
- abstract-leveldown: 6.2.3
- inherits: 2.0.4
-
@@ -6821,8 +6358,6 @@ snapshots:
-
@@ -6839,17 +6374,6 @@ snapshots:
- dependencies:
- abstract-leveldown: 6.3.0
- inherits: 2.0.4
- level-codec: 9.0.2
- level-errors: 2.0.1
-
- dependencies:
- write-stream: 0.4.3
-
dependencies:
graceful-fs: 4.2.11
@@ -6861,10 +6385,6 @@ snapshots:
- dependencies:
- prr: 1.0.1
-
@@ -6930,11 +6450,6 @@ snapshots:
optionalDependencies:
picomatch: 4.0.5
- dependencies:
- set-cookie-parser: 2.7.2
- tough-cookie: 4.1.4
-
@@ -7050,12 +6565,8 @@ snapshots:
dependencies:
safer-buffer: 2.1.2
-
-
@@ -7086,8 +6597,6 @@ snapshots:
is-alphabetical: 2.0.1
is-decimal: 2.0.1
-
@@ -7110,8 +6619,6 @@ snapshots:
dependencies:
is-docker: 2.2.1
-
@@ -7170,74 +6677,6 @@ snapshots:
chalk: 4.1.2
dotenv: 16.6.1
- dependencies:
- buffer: 5.7.1
-
-
- dependencies:
- catering: 2.1.1
-
- dependencies:
- errno: 0.1.8
-
- dependencies:
- inherits: 2.0.4
- readable-stream: 3.6.2
- xtend: 4.0.2
-
- dependencies:
- abstract-leveldown: 6.2.3
- buffer: 5.7.1
- inherits: 2.0.4
- ltgt: 2.2.1
-
- dependencies:
- encoding-down: 6.3.0
- levelup: 4.4.0
-
- dependencies:
- xtend: 4.0.2
-
-
- dependencies:
- end-stream: 0.1.0
-
- dependencies:
- level-js: 5.0.2
- level-packager: 5.1.1
- leveldown: 5.6.0
-
- dependencies:
- abstract-leveldown: 6.2.3
- napi-macros: 2.0.0
- node-gyp-build: 4.1.1
-
- dependencies:
- abstract-leveldown: 7.2.0
- napi-macros: 2.0.0
- node-gyp-build: 4.8.4
-
- dependencies:
- deferred-leveldown: 5.3.0
- level-errors: 2.0.1
- level-iterator-stream: 4.0.2
- level-supports: 1.0.1
- xtend: 4.0.2
-
dependencies:
immediate: 3.0.6
@@ -7315,8 +6754,6 @@ snapshots:
dependencies:
yallist: 3.1.1
-
dependencies:
react: 19.2.8
@@ -7726,8 +7163,6 @@ snapshots:
-
dependencies:
commander: 2.20.3
@@ -7738,14 +7173,6 @@ snapshots:
optional: true
- dependencies:
- whatwg-url: 5.0.0
-
-
-
dependencies:
node-addon-api: 7.1.1
@@ -7856,82 +7283,6 @@ snapshots:
transitivePeerDependencies:
- preact-render-to-string
- dependencies:
- pouchdb-binary-utils: 9.0.0
- pouchdb-collate: 9.0.0
- pouchdb-errors: 9.0.0
- pouchdb-fetch: 9.0.0
- pouchdb-mapreduce-utils: 9.0.0
- pouchdb-md5: 9.0.0
- pouchdb-utils: 9.0.0
- transitivePeerDependencies:
- - encoding
-
-
-
-
- dependencies:
- fetch-cookie: 2.2.0
- node-fetch: 2.6.9
- transitivePeerDependencies:
- - encoding
-
- dependencies:
- pouchdb-abstract-mapreduce: 9.0.0
- pouchdb-collate: 9.0.0
- pouchdb-errors: 9.0.0
- pouchdb-fetch: 9.0.0
- pouchdb-md5: 9.0.0
- pouchdb-selector-core: 9.0.0
- pouchdb-utils: 9.0.0
- transitivePeerDependencies:
- - encoding
-
- dependencies:
- pouchdb-utils: 9.0.0
-
- dependencies:
- pouchdb-binary-utils: 9.0.0
- spark-md5: 3.0.2
-
- dependencies:
- pouchdb-collate: 9.0.0
- pouchdb-utils: 9.0.0
-
- dependencies:
- pouchdb-errors: 9.0.0
- pouchdb-md5: 9.0.0
- uuid: 8.3.2
-
- dependencies:
- double-ended-queue: 2.1.0-0
- fetch-cookie: 2.2.0
- level: 6.0.1
- level-codec: 9.0.2
- level-write-stream: 1.0.0
- leveldown: 6.1.1
- levelup: 4.4.0
- ltgt: 2.2.1
- node-fetch: 2.6.9
- readable-stream: 1.1.14
- spark-md5: 3.0.2
- through2: 3.0.2
- uuid: 8.3.2
- vuvuzela: 1.0.3
- transitivePeerDependencies:
- - encoding
-
@@ -7946,12 +7297,6 @@ snapshots:
-
- dependencies:
- punycode: 2.3.1
-
@@ -7967,10 +7312,6 @@ snapshots:
-
-
@@ -8075,15 +7416,6 @@ snapshots:
-
- dependencies:
- core-util-is: 1.0.3
- inherits: 2.0.4
- isarray: 0.0.1
- string_decoder: 0.10.31
-
dependencies:
core-util-is: 1.0.3
@@ -8094,12 +7426,6 @@ snapshots:
string_decoder: 1.1.1
util-deprecate: 1.0.2
- dependencies:
- inherits: 2.0.4
- string_decoder: 1.3.0
- util-deprecate: 1.0.2
-
dependencies:
indent-string: 4.0.0
@@ -8172,8 +7498,6 @@ snapshots:
-
@@ -8257,8 +7581,6 @@ snapshots:
-
@@ -8279,8 +7601,6 @@ snapshots:
-
@@ -8328,8 +7648,6 @@ snapshots:
-
dependencies:
vue: 3.5.40([email protected])
@@ -8349,16 +7667,10 @@ snapshots:
is-fullwidth-code-point: 3.0.0
strip-ansi: 6.0.1
-
dependencies:
safe-buffer: 5.1.2
- dependencies:
- safe-buffer: 5.2.1
-
dependencies:
character-entities-html4: 2.1.0
@@ -8405,11 +7717,6 @@ snapshots:
commander: 2.20.3
source-map-support: 0.5.21
- dependencies:
- inherits: 2.0.4
- readable-stream: 3.6.2
-
@@ -8437,19 +7744,10 @@ snapshots:
- dependencies:
- psl: 1.15.0
- punycode: 2.3.1
- universalify: 0.2.0
- url-parse: 1.5.10
-
dependencies:
tldts: 7.0.19
-
dependencies:
punycode: 2.3.1
@@ -8555,8 +7853,6 @@ snapshots:
unist-util-is: 6.0.0
unist-util-visit-parents: 6.0.1
-
dependencies:
'@jridgewell/remapping': 2.3.5
@@ -8570,11 +7866,6 @@ snapshots:
escalade: 3.2.0
picocolors: 1.1.1
- dependencies:
- querystringify: 2.2.0
- requires-port: 1.0.0
-
dependencies:
react: 19.2.8
@@ -8583,8 +7874,6 @@ snapshots:
-
@@ -8694,16 +7983,12 @@ snapshots:
optionalDependencies:
typescript: 7.0.2
-
dependencies:
xml-name-validator: 5.0.0
-
@@ -8718,11 +8003,6 @@ snapshots:
transitivePeerDependencies:
- '@noble/hashes'
- dependencies:
- tr46: 0.0.3
- webidl-conversions: 3.0.1
-
dependencies:
siginfo: 2.0.0
@@ -8734,18 +8014,12 @@ snapshots:
string-width: 4.2.3
strip-ansi: 6.0.1
- dependencies:
- readable-stream: 0.0.4
-
-
diff --git a/frontend/pnpm-workspace.yaml b/frontend/pnpm-workspace.yaml
index f99ad5e555..2fcbf68851 100644
--- a/frontend/pnpm-workspace.yaml
+++ b/frontend/pnpm-workspace.yaml
@@ -24,13 +24,5 @@ allowBuilds:
'@code-inspector/core': false
core-js: true
esbuild: true
- # `pouchdb` pulls leveldown in transitively ([email protected] via
- # [email protected], plus [email protected] directly) for Node-side use, but
- # the frontend only runs pouchdb in the browser via `level-js`/IndexedDB
- # — the native binding is never loaded at runtime. [email protected] is
- # deprecated and fails to build on Node 24 / Apple Silicon. Explicit
- # `false` opts out of the build without triggering pnpm 11's
- # ERR_PNPM_IGNORED_BUILDS error.
- leveldown: false
# See the @code-inspector/core comment above.
node-pty: false
diff --git a/frontend/scripts/ui-guideline-legacy-debt.json b/frontend/scripts/ui-guideline-legacy-debt.json
index 4ccb614f84..70be606335 100644
--- a/frontend/scripts/ui-guideline-legacy-debt.json
+++ b/frontend/scripts/ui-guideline-legacy-debt.json
@@ -1194,12 +1194,6 @@
"token": "text-gray-500",
"count": 1
},
- {
- "path": "src/modules/ai/components/HistoryPanel/ConversationList.tsx",
- "rule": "no-native-control",
- "token": "button",
- "count": 2
- },
{
"path": "src/modules/ai/components/HistoryPanel/ConversationList.tsx",
"rule": "no-off-scale-gap",
@@ -1212,36 +1206,6 @@
"token": "rounded-md",
"count": 1
},
- {
- "path": "src/modules/ai/components/HistoryPanel/ConversationList.tsx",
- "rule": "no-raw-color",
- "token": "bg-indigo-100",
- "count": 1
- },
- {
- "path": "src/modules/ai/components/HistoryPanel/ConversationList.tsx",
- "rule": "no-raw-color",
- "token": "border-indigo-400",
- "count": 1
- },
- {
- "path": "src/modules/ai/components/HistoryPanel/ConversationList.tsx",
- "rule": "no-raw-color",
- "token": "hover:bg-indigo-50",
- "count": 3
- },
- {
- "path": "src/modules/ai/components/HistoryPanel/ConversationList.tsx",
- "rule": "no-raw-color",
- "token": "hover:border-indigo-400",
- "count": 1
- },
- {
- "path": "src/modules/ai/components/HistoryPanel/ConversationList.tsx",
- "rule": "no-raw-color",
- "token": "text-gray-500",
- "count": 3
- },
{
"path": "src/modules/ai/components/PromptInput.tsx",
"rule": "no-button-dimension-override",
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 22e9a684ef..74bc6663c4 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1815,7 +1815,7 @@
"actions": {
"explain-code": "Explain code",
"find-problems": "Find problems",
- "insert-at-caret": "Insert at caret",
+ "insert-at-caret": "Insert at cursor",
"new-chat-using-selection": "New chat using selection"
},
"ai-assistant": "AI Assistant",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 0320e3000a..16c8084490 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1815,7 +1815,7 @@
"actions": {
"explain-code": "コードの説明",
"find-problems": "問題を見つける",
- "insert-at-caret": "キャレットに挿入",
+ "insert-at-caret": "カーソル位置に挿入",
"new-chat-using-selection": "選択範囲を使用して新しいチャットを開始"
},
"ai-assistant": "AI アシスタント",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 6e08084d6d..c1a81e428d 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1815,7 +1815,7 @@
"actions": {
"explain-code": "Giải thích mã",
"find-problems": "Tìm vấn đề",
- "insert-at-caret": "Chèn vào con trỏ",
+ "insert-at-caret": "Chèn tại con trỏ",
"new-chat-using-selection": "Cuộc trò chuyện mới bằng nội dung đã chọn"
},
"ai-assistant": "Trợ lý AI",
diff --git a/frontend/src/modules/ai/components/ChatPanel.test.tsx b/frontend/src/modules/ai/components/ChatPanel.test.tsx
index c974530c37..cbe647b6fd 100644
--- a/frontend/src/modules/ai/components/ChatPanel.test.tsx
+++ b/frontend/src/modules/ai/components/ChatPanel.test.tsx
@@ -143,6 +143,53 @@ describe("ChatPanel", () => {
content: "schema context\nshow me the tables",
}),
]);
+ expect(mocks.createMessage).toHaveBeenNthCalledWith(
+ 1,
+ expect.objectContaining({ content: "show me the tables" })
+ );
+ expect(mocks.createMessage.mock.calls[0]?.[0]).not.toHaveProperty("prompt");
+ });
+
+ test("rebuilds schema context for a conversation restored from storage", async () => {
+ const conversation = emptyConversation();
+ const firstUser: Message = {
+ id: "message-1",
+ created_ts: 1,
+ author: "USER",
+ content: "first question",
+ status: "DONE",
+ error: "",
+ conversation,
+ };
+ const firstAnswer: Message = {
+ id: "message-2",
+ created_ts: 2,
+ author: "AI",
+ content: "first answer",
+ status: "DONE",
+ error: "",
+ conversation,
+ };
+ conversation.messageList = [firstUser, firstAnswer];
+ mocks.currentConversation = conversation;
+ mocks.context = {
+ ...mocks.context,
+ chat: {
+ ...(mocks.context?.chat as object),
+ list: [conversation],
+ selected: conversation,
+ },
+ };
+
+ render(<ChatPanel />);
+ fireEvent.click(screen.getByRole("button", { name: "send" }));
+
+ await waitFor(() => expect(mocks.chat).toHaveBeenCalledTimes(1));
+ expect(mocks.chat.mock.calls[0]?.[0].messages).toEqual([
+ expect.objectContaining({ content: "schema context\nfirst question" }),
+ expect.objectContaining({ content: "first answer" }),
+ expect.objectContaining({ content: "show me the tables" }),
+ ]);
});
test("logs the original Connect error when the chat request fails", async () => {
diff --git a/frontend/src/modules/ai/components/ChatPanel.tsx b/frontend/src/modules/ai/components/ChatPanel.tsx
index 85c68410c4..1cdaa2ccba 100644
--- a/frontend/src/modules/ai/components/ChatPanel.tsx
+++ b/frontend/src/modules/ai/components/ChatPanel.tsx
@@ -86,46 +86,48 @@ export function ChatPanel() {
if (!tab) return;
const { messageList } = conversation;
- let prompt = query;
- if (messageList.length === 0) {
- const engine = context.engine;
- const databaseMetadata = context.databaseMetadata;
- const schema = context.schema;
- prompt = [
- promptUtils.declaration(databaseMetadata, engine, schema),
- query,
- ].join("\n");
- }
+ const declaration = promptUtils.declaration(
+ context.databaseMetadata,
+ context.engine,
+ context.schema
+ );
const userMessage = await store.createMessage({
conversation_id: conversation.id,
content: query,
- prompt,
author: "USER",
error: "",
status: "DONE",
});
if (messageList.length === 0) {
- console.debug("[AI Assistant] init chat:", prompt);
+ console.debug(
+ "[AI Assistant] init chat:",
+ [declaration, query].join("\n")
+ );
}
const answer = await store.createMessage({
author: "AI",
- prompt: "",
content: "",
error: "",
conversation_id: conversation.id,
status: "LOADING",
});
+ let declarationAttached = false;
const messages: AIChatMessage[] =
- userMessage.conversation.messageList.map((message) =>
- createProto(AIChatMessageSchema, {
+ userMessage.conversation.messageList.map((message) => {
+ let content = message.content;
+ if (message.author === "USER" && !declarationAttached) {
+ content = [declaration, content].join("\n");
+ declarationAttached = true;
+ }
+ return createProto(AIChatMessageSchema, {
role:
message.author === "USER"
? AIChatMessageRole.AI_CHAT_MESSAGE_ROLE_USER
: AIChatMessageRole.AI_CHAT_MESSAGE_ROLE_ASSISTANT,
- content: message.prompt,
- })
- );
+ content,
+ });
+ });
setLoading(true);
try {
const response = await aiServiceClientConnect.chat({ messages });
@@ -133,7 +135,6 @@ export function ChatPanel() {
console.debug("[AI Assistant] answer:", text);
if (text) {
answer.content = text;
- answer.prompt = text;
}
answer.status = "DONE";
} catch (err) {
diff --git a/frontend/src/modules/ai/components/ChatView/ChatView.tsx b/frontend/src/modules/ai/components/ChatView/ChatView.tsx
index c8c520bc9d..901328f17d 100644
--- a/frontend/src/modules/ai/components/ChatView/ChatView.tsx
+++ b/frontend/src/modules/ai/components/ChatView/ChatView.tsx
@@ -73,7 +73,7 @@ export function ChatView({ mode = "CHAT", conversation }: Props) {
) : (
<div
ref={containerRef}
- className="flex min-w-0 max-w-full flex-col justify-end px-2 gap-y-4"
+ className="flex min-w-0 max-w-full flex-col justify-end gap-y-4 px-2 pt-2"
>
{conversation.messageList.map((message) => (
<div
diff --git a/frontend/src/modules/ai/components/ChatView/MessageWrapping.test.tsx b/frontend/src/modules/ai/components/ChatView/MessageWrapping.test.tsx
index 3fe5d9f80c..af0651901d 100644
--- a/frontend/src/modules/ai/components/ChatView/MessageWrapping.test.tsx
+++ b/frontend/src/modules/ai/components/ChatView/MessageWrapping.test.tsx
@@ -2,12 +2,21 @@ import { render } from "@testing-library/react";
import { describe, expect, test, vi } from "vitest";
import type { Conversation, Message } from "../../types";
import { AIMessageView } from "./AIMessageView";
+import { ChatView } from "./ChatView";
import { UserMessageView } from "./UserMessageView";
vi.mock("./Markdown/CodeBlock", () => ({
CodeBlock: () => <div data-testid="code-block" />,
}));
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+vi.mock("../context", () => ({
+ useAIContext: () => ({ events: { emit: vi.fn() } }),
+}));
+
const longContent =
"https://example.com/" + "unbroken-path-segment".repeat(20);
@@ -29,7 +38,6 @@ function createMessage(
created_ts: 1,
author,
content: longContent,
- prompt: longContent,
status,
error: "",
conversation,
@@ -40,6 +48,20 @@ function createMessage(
}
describe("AI chat message wrapping", () => {
+ test("keeps the first message separated from the panel header", () => {
+ const message = createMessage("AI", "LOADING");
+ const scrollTo = vi.fn();
+ HTMLElement.prototype.scrollTo = scrollTo;
+
+ const { container } = render(
+ <ChatView conversation={message.conversation} />
+ );
+
+ expect(container.querySelector(".message")?.parentElement).toHaveClass(
+ "pt-2"
+ );
+ });
+
test.each([
["AI", AIMessageView],
["USER", UserMessageView],
diff --git a/frontend/src/modules/ai/components/HistoryPanel/ConversationList.test.tsx b/frontend/src/modules/ai/components/HistoryPanel/ConversationList.test.tsx
new file mode 100644
index 0000000000..cce7f0966f
--- /dev/null
+++ b/frontend/src/modules/ai/components/HistoryPanel/ConversationList.test.tsx
@@ -0,0 +1,255 @@
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+import { Sheet, SheetContent, SheetTitle } from "@/components/ui/sheet";
+import type { Conversation } from "../../types";
+import { ConversationList } from "./ConversationList";
+
+const mocks = vi.hoisted(() => ({
+ deleteConversation: vi.fn(),
+ emit: vi.fn(),
+ setSelected: vi.fn(),
+ updateConversation: vi.fn(),
+}));
+
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+vi.mock("scroll-into-view-if-needed", () => ({
+ default: vi.fn(),
+}));
+
+vi.mock("@/modules/sql-editor/store/tab", () => ({
+ useCurrentSQLEditorTab: () => ({
+ connection: {
+ database: "instances/test/databases/test",
+ instance: "instances/test",
+ },
+ }),
+}));
+
+vi.mock("../../store", () => ({
+ useConversationStore: () => ({
+ deleteConversation: mocks.deleteConversation,
+ updateConversation: mocks.updateConversation,
+ }),
+}));
+
+const conversation: Conversation = {
+ id: "conversation-1",
+ created_ts: 1,
+ name: "Original title",
+ instance: "instances/test",
+ database: "instances/test/databases/test",
+ messageList: [],
+};
+
+vi.mock("../context", () => ({
+ useAIContext: () => ({
+ events: { emit: mocks.emit },
+ chat: {
+ list: [conversation],
+ ready: true,
+ selected: conversation,
+ setSelected: mocks.setSelected,
+ },
+ }),
+}));
+
+describe("ConversationList", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ conversation.name = "Original title";
+ mocks.updateConversation.mockResolvedValue(undefined);
+ });
+
+ test("renames a conversation in place", async () => {
+ render(<ConversationList />);
+
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: "plugin.ai.conversation.rename",
+ })
+ );
+
+ const input = screen.getByRole("textbox", {
+ name: "plugin.ai.conversation.rename",
+ }) as HTMLTextAreaElement;
+ await waitFor(() => expect(input).toHaveFocus());
+ expect(input).toHaveValue("Original title");
+ expect(input.selectionStart).toBe(0);
+ expect(input.selectionEnd).toBe("Original title".length);
+
+ fireEvent.change(input, { target: { value: "Updated title" } });
+ fireEvent.keyDown(input, { key: "Enter" });
+
+ await waitFor(() => {
+ expect(mocks.updateConversation).toHaveBeenCalledWith({
+ ...conversation,
+ name: "Updated title",
+ });
+ });
+ expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
+ });
+
+ test("uses an auto-height textarea for wrapped titles", () => {
+ conversation.name =
+ "Which users have created the most query history entries, saved queries, issues, and task runs?";
+ render(<ConversationList />);
+
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: "plugin.ai.conversation.rename",
+ })
+ );
+
+ const textarea = screen.getByRole("textbox", {
+ name: "plugin.ai.conversation.rename",
+ }) as HTMLTextAreaElement;
+ expect(textarea.tagName).toBe("TEXTAREA");
+ expect(textarea).toHaveAttribute("rows", "1");
+ expect(textarea).toHaveClass("resize-none", "overflow-hidden");
+
+ Object.defineProperty(textarea, "scrollHeight", {
+ configurable: true,
+ value: 72,
+ });
+ fireEvent.change(textarea, {
+ target: { value: `${conversation.name} More details.` },
+ });
+ expect(textarea.style.height).toBe("72px");
+ });
+
+ test("keeps the inline rename open inside the history sheet", async () => {
+ render(
+ <Sheet open>
+ <SheetContent>
+ <SheetTitle>History</SheetTitle>
+ <ConversationList />
+ </SheetContent>
+ </Sheet>
+ );
+
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: "plugin.ai.conversation.rename",
+ })
+ );
+
+ await waitFor(() => {
+ expect(
+ screen.getByRole("textbox", {
+ name: "plugin.ai.conversation.rename",
+ })
+ ).toBeVisible();
+ });
+ });
+
+ test("opens the inline rename on primary pointer down", () => {
+ render(<ConversationList />);
+
+ fireEvent.pointerDown(
+ screen.getByRole("button", {
+ name: "plugin.ai.conversation.rename",
+ }),
+ { button: 0 }
+ );
+
+ expect(
+ screen.getByRole("textbox", {
+ name: "plugin.ai.conversation.rename",
+ })
+ ).toBeVisible();
+ });
+
+ test("cancels an inline rename with Escape", async () => {
+ render(<ConversationList />);
+
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: "plugin.ai.conversation.rename",
+ })
+ );
+ const input = screen.getByRole("textbox", {
+ name: "plugin.ai.conversation.rename",
+ });
+ fireEvent.change(input, { target: { value: "Discarded title" } });
+ fireEvent.keyDown(input, { key: "Escape" });
+
+ await waitFor(() => {
+ expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
+ });
+ expect(mocks.updateConversation).not.toHaveBeenCalled();
+ expect(screen.getByText("Original title")).toBeInTheDocument();
+ });
+
+ test("saves an inline rename on blur", async () => {
+ render(<ConversationList />);
+
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: "plugin.ai.conversation.rename",
+ })
+ );
+ const input = screen.getByRole("textbox", {
+ name: "plugin.ai.conversation.rename",
+ });
+ fireEvent.change(input, { target: { value: "Blurred title" } });
+ fireEvent.blur(input);
+
+ await waitFor(() => {
+ expect(mocks.updateConversation).toHaveBeenCalledWith({
+ ...conversation,
+ name: "Blurred title",
+ });
+ });
+ });
+
+ test("keeps an untitled conversation as a placeholder until it is edited", () => {
+ conversation.name = "";
+ render(<ConversationList />);
+
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: "plugin.ai.conversation.rename",
+ })
+ );
+ const input = screen.getByRole("textbox", {
+ name: "plugin.ai.conversation.rename",
+ });
+ expect(input).toHaveValue("");
+ expect(input).toHaveAttribute(
+ "placeholder",
+ "plugin.ai.conversation.untitled"
+ );
+
+ fireEvent.blur(input);
+ expect(mocks.updateConversation).not.toHaveBeenCalled();
+ });
+
+ test("confirms deletion in an anchored popover", async () => {
+ render(<ConversationList />);
+
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: "plugin.ai.conversation.delete",
+ })
+ );
+
+ expect(screen.queryByRole("alertdialog")).not.toBeInTheDocument();
+ const confirmation = screen.getByText(
+ "bbkit.confirm-button.sure-to-delete"
+ );
+ expect(confirmation.closest("[data-open]")).not.toBeNull();
+
+ fireEvent.click(screen.getByText("common.delete"));
+
+ await waitFor(() => {
+ expect(mocks.deleteConversation).toHaveBeenCalledWith(conversation.id);
+ });
+ expect(mocks.setSelected).toHaveBeenCalledWith(undefined);
+ expect(
+ screen.queryByText("bbkit.confirm-button.sure-to-delete")
+ ).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/modules/ai/components/HistoryPanel/ConversationList.tsx b/frontend/src/modules/ai/components/HistoryPanel/ConversationList.tsx
index c9f78697a1..a3e7d40739 100644
--- a/frontend/src/modules/ai/components/HistoryPanel/ConversationList.tsx
+++ b/frontend/src/modules/ai/components/HistoryPanel/ConversationList.tsx
@@ -1,23 +1,25 @@
import { head } from "lodash-es";
import { Loader2, PencilIcon, PlusIcon, TrashIcon } from "lucide-react";
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import scrollIntoView from "scroll-into-view-if-needed";
-import {
- AlertDialog,
- AlertDialogClose,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogTitle,
-} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
+import { Textarea } from "@/components/ui/textarea";
import { cn } from "@/lib/utils";
import { useCurrentSQLEditorTab } from "@/modules/sql-editor/store/tab";
import { useConversationStore } from "../../store";
import type { Conversation } from "../../types";
import { useAIContext } from "../context";
-import { ConversationRenameDialog } from "./ConversationRenameDialog";
+
+const resizeTextarea = (textarea: HTMLTextAreaElement) => {
+ textarea.style.height = "0px";
+ textarea.style.height = `${textarea.scrollHeight}px`;
+};
/**
* React port of `plugins/ai/components/HistoryPanel/ConversationList.vue`.
@@ -26,7 +28,7 @@ import { ConversationRenameDialog } from "./ConversationRenameDialog";
* actions and a sticky "New conversation" footer.
*
* Behavioural pitfalls preserved from the Vue source:
- * - On tab switch (`(instance, database)` change) the rename dialog is
+ * - On tab switch (`(instance, database)` change) the inline rename is
* dismissed — a half-completed rename for a previous tab's
* conversation shouldn't survive a context change.
* - When the selected conversation changes the row scrolls into view
@@ -44,13 +46,16 @@ export function ConversationList() {
const { events, chat } = useAIContext();
const { list, ready, selected, setSelected } = chat;
- const [rename, setRename] = useState<Conversation | undefined>(undefined);
+ const [rename, setRename] = useState<
+ { conversation: Conversation; name: string } | undefined
+ >(undefined);
const [deleteCandidate, setDeleteCandidate] = useState<
Conversation | undefined
>(undefined);
+ const renameTextareaRef = useRef<HTMLTextAreaElement>(null);
- // Dismiss the rename dialog whenever the active tab's connection
- // changes — a stale dialog tied to a different tab's conversation
+ // Dismiss the inline rename whenever the active tab's connection
+ // changes — a stale edit tied to a different tab's conversation
// would mutate the wrong record on Save.
const connectionKey = currentTab
? `${currentTab.connection.instance}|${currentTab.connection.database}`
@@ -60,6 +65,18 @@ export function ConversationList() {
setDeleteCandidate(undefined);
}, [connectionKey]);
+ useEffect(() => {
+ if (!rename) return;
+ const raf = requestAnimationFrame(() => {
+ const textarea = renameTextareaRef.current;
+ if (!textarea) return;
+ resizeTextarea(textarea);
+ textarea.focus();
+ textarea.select();
+ });
+ return () => cancelAnimationFrame(raf);
+ }, [rename?.conversation.id]);
+
// Scroll the selected row into view when it changes.
useEffect(() => {
if (!selected?.id || list.length === 0) return;
@@ -74,10 +91,25 @@ export function ConversationList() {
const handleConfirmDelete = async () => {
if (!deleteCandidate) return;
- const index = list.findIndex((c) => c.id === selected?.id);
+ const index = list.findIndex((c) => c.id === deleteCandidate.id);
+ const remaining = list.filter((c) => c.id !== deleteCandidate.id);
await store.deleteConversation(deleteCandidate.id);
setDeleteCandidate(undefined);
- setSelected(list[index] ?? undefined);
+ if (selected?.id === deleteCandidate.id) {
+ setSelected(remaining[index] ?? remaining[index - 1]);
+ }
+ };
+
+ const handleRename = async (conversation: Conversation) => {
+ if (rename?.conversation.id !== conversation.id) return;
+ const name = rename.name;
+ setRename(undefined);
+ if (name === conversation.name) return;
+ await store.updateConversation({ ...conversation, name });
+ };
+
+ const startRename = (conversation: Conversation) => {
+ setRename({ conversation, name: conversation.name });
};
return (
@@ -87,6 +119,7 @@ export function ConversationList() {
<>
{list.map((conversation) => {
const isActive = selected?.id === conversation.id;
+ const isRenaming = rename?.conversation.id === conversation.id;
const previewTitle =
head(conversation.messageList)?.content ||
t("plugin.ai.conversation.untitled");
@@ -95,44 +128,127 @@ export function ConversationList() {
key={conversation.id}
data-conversation-id={conversation.id}
className={cn(
- "flex items-start gap-x-0.5 border rounded-md py-2 pl-2 pr-0.5 hover:bg-indigo-50 hover:border-indigo-400 cursor-pointer",
- isActive && "bg-indigo-100 border-indigo-400"
+ "flex items-start gap-x-0.5 border rounded-md py-2 pl-2 pr-0.5 hover:bg-control-bg hover:border-accent cursor-pointer",
+ isActive && "bg-accent/10 border-accent",
+ isRenaming && "cursor-default"
)}
onClick={() => setSelected(conversation)}
>
- {conversation.name ? (
- <div className="text-sm flex-1 whitespace-pre-wrap wrap-break-word break-all">
+ {isRenaming ? (
+ <Textarea
+ ref={renameTextareaRef}
+ size="md"
+ rows={1}
+ value={rename.name}
+ placeholder={previewTitle}
+ aria-label={t("plugin.ai.conversation.rename")}
+ className="min-h-6 min-w-0 flex-1 resize-none overflow-hidden text-sm leading-5 placeholder:italic"
+ style={{ padding: "2px 4px" }}
+ onClick={(event) => event.stopPropagation()}
+ onChange={(event) => {
+ resizeTextarea(event.currentTarget);
+ setRename({
+ conversation,
+ name: event.target.value,
+ });
+ }}
+ onBlur={() => void handleRename(conversation)}
+ onKeyDown={(event) => {
+ event.stopPropagation();
+ if (event.nativeEvent.isComposing) return;
+ if (event.key === "Enter") {
+ event.preventDefault();
+ event.currentTarget.blur();
+ } else if (event.key === "Escape") {
+ event.preventDefault();
+ setRename(undefined);
+ }
+ }}
+ />
+ ) : conversation.name ? (
+ <div className="min-w-0 flex-1 whitespace-pre-wrap wrap-break-word break-all text-sm">
{conversation.name}
</div>
) : (
- <div className="text-sm flex-1 truncate text-gray-500 italic">
+ <div className="min-w-0 flex-1 truncate text-sm text-control-light italic">
{previewTitle}
</div>
)}
- <div className="flex items-center gap-x-px">
- <button
- type="button"
- className="flex items-center p-0.5 border border-transparent rounded-sm text-gray-500 hover:text-accent hover:bg-indigo-50 hover:border-accent cursor-pointer"
- onClick={(e) => {
- e.stopPropagation();
- setRename(conversation);
- }}
- aria-label={t("plugin.ai.conversation.rename")}
- >
- <PencilIcon className="size-3" />
- </button>
- <button
- type="button"
- className="flex items-center p-0.5 border border-transparent rounded-sm text-gray-500 hover:text-accent hover:bg-indigo-50 hover:border-accent cursor-pointer"
- onClick={(e) => {
- e.stopPropagation();
- setDeleteCandidate(conversation);
- }}
- aria-label={t("plugin.ai.conversation.delete")}
- >
- <TrashIcon className="size-3" />
- </button>
- </div>
+ {!isRenaming && (
+ <div className="flex items-center gap-x-px">
+ <Button
+ type="button"
+ appearance="secondary"
+ size="xs"
+ className="shrink-0 text-control-light hover:text-accent"
+ onPointerDown={(event) => {
+ if (event.button !== 0) return;
+ event.preventDefault();
+ event.stopPropagation();
+ startRename(conversation);
+ }}
+ onClick={(e) => {
+ e.stopPropagation();
+ startRename(conversation);
+ }}
+ aria-label={t("plugin.ai.conversation.rename")}
+ >
+ <PencilIcon className="size-3.5" />
+ </Button>
+ <Popover
+ open={deleteCandidate?.id === conversation.id}
+ onOpenChange={(open) =>
+ setDeleteCandidate(open ? conversation : undefined)
+ }
+ >
+ <PopoverTrigger
+ render={
+ <Button
+ type="button"
+ appearance="secondary"
+ size="xs"
+ className="shrink-0 text-control-light hover:text-error"
+ onClick={(event) => {
+ event.stopPropagation();
+ setDeleteCandidate(conversation);
+ }}
+ aria-label={t("plugin.ai.conversation.delete")}
+ />
+ }
+ >
+ <TrashIcon className="size-3.5" />
+ </PopoverTrigger>
+ <PopoverContent
+ side="bottom"
+ align="end"
+ className="w-64"
+ >
+ <div className="font-medium">
+ {t("plugin.ai.conversation.delete")}
+ </div>
+ <div className="mt-1 text-control-light">
+ {t("bbkit.confirm-button.sure-to-delete")}
+ </div>
+ <div className="mt-3 flex justify-end gap-x-2">
+ <Button
+ appearance="outline"
+ size="sm"
+ onClick={() => setDeleteCandidate(undefined)}
+ >
+ {t("common.cancel")}
+ </Button>
+ <Button
+ variant="destructive"
+ size="sm"
+ onClick={() => void handleConfirmDelete()}
+ >
+ {t("common.delete")}
+ </Button>
+ </div>
+ </PopoverContent>
+ </Popover>
+ </div>
+ )}
</div>
);
})}
@@ -153,41 +269,6 @@ export function ConversationList() {
<Loader2 className="self-center mt-8 size-5 animate-spin" />
)}
</div>
-
- {rename && (
- <ConversationRenameDialog
- conversation={rename}
- onCancel={() => setRename(undefined)}
- onUpdated={() => setRename(undefined)}
- />
- )}
-
- <AlertDialog
- open={!!deleteCandidate}
- onOpenChange={(open) => !open && setDeleteCandidate(undefined)}
- >
- <AlertDialogContent>
- <AlertDialogTitle>
- {t("plugin.ai.conversation.delete")}
- </AlertDialogTitle>
- <AlertDialogDescription>
- {t("bbkit.confirm-button.sure-to-delete")}
- </AlertDialogDescription>
- <AlertDialogFooter>
- <AlertDialogClose
- render={
- <Button appearance="outline">{t("common.cancel")}</Button>
- }
- />
- <Button
- variant="destructive"
- onClick={() => void handleConfirmDelete()}
- >
- {t("common.delete")}
- </Button>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
</div>
);
}
diff --git a/frontend/src/modules/ai/components/HistoryPanel/ConversationRenameDialog.tsx b/frontend/src/modules/ai/components/HistoryPanel/ConversationRenameDialog.tsx
deleted file mode 100644
index 6928be32e2..0000000000
--- a/frontend/src/modules/ai/components/HistoryPanel/ConversationRenameDialog.tsx
+++ /dev/null
@@ -1,96 +0,0 @@
-import { head } from "lodash-es";
-import { Loader2 } from "lucide-react";
-import { useEffect, useRef, useState } from "react";
-import { useTranslation } from "react-i18next";
-import { Button } from "@/components/ui/button";
-import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
-import { Input } from "@/components/ui/input";
-import { useConversationStore } from "../../store";
-import type { Conversation } from "../../types";
-
-type Props = {
- readonly conversation: Conversation;
- readonly onCancel: () => void;
- readonly onUpdated: () => void;
-};
-
-/**
- * React port of `plugins/ai/components/HistoryPanel/ConversationRenameDialog.vue`.
- *
- * Single-field rename modal. The name initializes to:
- * 1. The current conversation name, or
- * 2. The first message's content (often the user's seed prompt), or
- * 3. The localized "Untitled conversation" placeholder.
- *
- * Mirrors the Vue version exactly. Auto-focuses the input on mount via
- * a ref + rAF so the input is interactive immediately when the dialog
- * portal mounts.
- */
-export function ConversationRenameDialog({
- conversation,
- onCancel,
- onUpdated,
-}: Props) {
- const { t } = useTranslation();
- const store = useConversationStore();
-
- const [name, setName] = useState(
- conversation.name ||
- head(conversation.messageList)?.content ||
- t("plugin.ai.conversation.untitled")
- );
- const [loading, setLoading] = useState(false);
-
- const inputRef = useRef<HTMLInputElement | null>(null);
- useEffect(() => {
- const raf = requestAnimationFrame(() => {
- inputRef.current?.focus();
- });
- return () => cancelAnimationFrame(raf);
- }, []);
-
- const handleRename = async () => {
- setLoading(true);
- conversation.name = name;
- await store.updateConversation(conversation);
- onUpdated();
- };
-
- return (
- <Dialog open onOpenChange={(open) => !open && onCancel()}>
- <DialogContent className="w-[18rem] p-6">
- <DialogTitle>{t("plugin.ai.conversation.rename")}</DialogTitle>
- <div className="relative flex flex-col items-start gap-y-2 mt-3">
- <div className="text-sm text-control">{t("common.name")}</div>
- <div className="w-full">
- <Input
- ref={inputRef}
- value={name}
- onChange={(e) => setName(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- e.preventDefault();
- void handleRename();
- }
- }}
- className="w-full"
- />
- </div>
- <div className="w-full flex items-center justify-end gap-x-2 mt-4 pt-2 border-t">
- <Button appearance="outline" onClick={onCancel}>
- {t("common.cancel")}
- </Button>
- <Button onClick={() => void handleRename()} disabled={loading}>
- {t("common.update")}
- </Button>
- </div>
- {loading && (
- <div className="absolute inset-0 bg-background/50 flex items-center justify-center rounded-sm">
- <Loader2 className="size-5 animate-spin" />
- </div>
- )}
- </div>
- </DialogContent>
- </Dialog>
- );
-}
diff --git a/frontend/src/modules/ai/store/conversation.test.ts b/frontend/src/modules/ai/store/conversation.test.ts
index 9b67b78b46..225c76cb66 100644
--- a/frontend/src/modules/ai/store/conversation.test.ts
+++ b/frontend/src/modules/ai/store/conversation.test.ts
@@ -1,99 +1,84 @@
import { beforeEach, describe, expect, test, vi } from "vitest";
-
-type StoredDocument = Record<string, unknown> & {
- _id: string;
- _rev?: string;
-};
-
-const pouch = vi.hoisted(() => ({
- databases: new Map<string, Map<string, StoredDocument>>(),
-}));
-
-vi.mock("pouchdb", () => {
- class MockPouchDB {
- static plugin() {}
-
- constructor(private readonly name: string) {
- if (!pouch.databases.has(name)) {
- pouch.databases.set(name, new Map());
- }
- }
-
- private get documents() {
- return pouch.databases.get(this.name)!;
- }
-
- async createIndex() {}
-
- async find({ selector }: { selector: Record<string, unknown> }) {
- const docs = [...this.documents.values()].filter((document) =>
- Object.entries(selector).every(([field, condition]) => {
- const value = document[field];
- const matcher = condition as { $eq?: unknown; $in?: unknown[] };
- if ("$eq" in matcher) return value === matcher.$eq;
- if ("$in" in matcher) return matcher.$in?.includes(value) ?? false;
- return value === condition;
- })
- );
- return { docs };
- }
-
- async get(id: string) {
- const document = this.documents.get(id);
- if (!document) throw new Error("missing");
- return { ...document };
- }
-
- async put(document: StoredDocument) {
- const existing = this.documents.get(document._id);
- if (existing && document._rev !== existing._rev) {
- const error = new Error("Document update conflict") as Error & {
- status: number;
- };
- error.status = 409;
- throw error;
- }
- const generation = existing
- ? Number(existing._rev?.split("-")[0]) + 1
- : 1;
- const rev = `${generation}-test`;
- this.documents.set(document._id, { ...document, _rev: rev });
- return { id: document._id, ok: true, rev };
- }
-
- async bulkDocs(documents: StoredDocument[]) {
- return Promise.all(documents.map((document) => this.put(document)));
- }
-
- async destroy() {
- this.documents.clear();
- }
- }
-
- return { default: MockPouchDB };
-});
-
-vi.mock("pouchdb-find", () => ({ default: {} }));
-
+import { useAppStore } from "@/stores/app";
import { useConversationStore } from "./conversation";
+import { saveConversationHistory } from "./conversationStorage";
const connection = {
instance: "instances/test",
database: "instances/test/databases/demo",
};
+const storageKey = "bb.ai.conversations.workspaces/[email protected]";
+
+const storedConversation = (id: string) => {
+ const conversation = {
+ id,
+ created_ts: 1,
+ name: id,
+ ...connection,
+ messageList: [],
+ } as ReturnType<
+ typeof useConversationStore.getState
+ >["conversationsById"][string];
+ conversation.messageList = [
+ {
+ id: `${id}-message`,
+ created_ts: 1,
+ author: "USER",
+ content: id,
+ status: "DONE",
+ error: "",
+ conversation,
+ },
+ ];
+ return conversation;
+};
+
beforeEach(() => {
- for (const documents of pouch.databases.values()) {
- documents.clear();
- }
+ localStorage.clear();
+ vi.restoreAllMocks();
+ useAppStore.setState({
+ currentUser: {
+ email: "[email protected]",
+ workspace: "workspaces/test",
+ } as never,
+ serverInfo: { saas: true } as never,
+ });
useConversationStore.setState({
conversationsById: {},
readyByConnection: {},
+ storageKey: undefined,
});
});
describe("AI conversation persistence", () => {
- test("removing an empty conversation during reload does not conflict", async () => {
+ test("restores a conversation after the in-memory store is reset", async () => {
+ const conversation = await useConversationStore
+ .getState()
+ .createConversation({ ...connection, name: "saved" });
+ await useConversationStore.getState().createMessage({
+ author: "USER",
+ content: "visible question",
+ error: "",
+ status: "DONE",
+ conversation_id: conversation.id,
+ });
+ useConversationStore.setState({
+ conversationsById: {},
+ readyByConnection: {},
+ storageKey: undefined,
+ });
+
+ const conversations = await useConversationStore
+ .getState()
+ .fetchConversationListByConnection(connection as never);
+
+ expect(conversations).toHaveLength(1);
+ expect(conversations[0]?.messageList[0]?.content).toBe("visible question");
+ expect(localStorage.getItem(storageKey)).toContain("visible question");
+ });
+
+ test("removing an empty conversation during reload persists the deletion", async () => {
await useConversationStore.getState().createConversation({
...connection,
name: "",
@@ -101,6 +86,7 @@ describe("AI conversation persistence", () => {
useConversationStore.setState({
conversationsById: {},
readyByConnection: {},
+ storageKey: undefined,
});
const conversations = await useConversationStore
@@ -109,6 +95,7 @@ describe("AI conversation persistence", () => {
expect(conversations).toEqual([]);
expect(useConversationStore.getState().conversationsById).toEqual({});
+ expect(localStorage.getItem(storageKey)).not.toContain(connection.database);
});
test("reload marks an interrupted response as failed", async () => {
@@ -118,7 +105,6 @@ describe("AI conversation persistence", () => {
await useConversationStore.getState().createMessage({
author: "AI",
content: "",
- prompt: "",
error: "",
status: "LOADING",
conversation_id: conversation.id,
@@ -126,6 +112,7 @@ describe("AI conversation persistence", () => {
useConversationStore.setState({
conversationsById: {},
readyByConnection: {},
+ storageKey: undefined,
});
const conversations = await useConversationStore
@@ -136,9 +123,177 @@ describe("AI conversation persistence", () => {
status: "FAILED",
error: "Request timeout",
});
+ });
+
+ test("keeps chat usable when local storage writes fail", async () => {
+ vi.spyOn(Storage.prototype, "setItem").mockImplementation(() => {
+ throw new DOMException("Storage quota exceeded", "QuotaExceededError");
+ });
+
+ const conversation = await useConversationStore
+ .getState()
+ .createConversation({ ...connection, name: "memory only" });
+ const message = await useConversationStore.getState().createMessage({
+ author: "USER",
+ content: "SELECT 1",
+ error: "",
+ status: "DONE",
+ conversation_id: conversation.id,
+ });
+
+ expect(message.content).toBe("SELECT 1");
expect(
useConversationStore.getState().conversationsById[conversation.id]
- ?.messageList[0]
- ).toMatchObject({ status: "FAILED", error: "Request timeout" });
+ ?.messageList
+ ).toHaveLength(1);
+ });
+
+ test("does not write stale conversations into a different user key", async () => {
+ const conversation = await useConversationStore
+ .getState()
+ .createConversation({ ...connection, name: "user A" });
+ const message = await useConversationStore.getState().createMessage({
+ author: "USER",
+ content: "user A question",
+ error: "",
+ status: "DONE",
+ conversation_id: conversation.id,
+ });
+ const userBKey = "bb.ai.conversations.workspaces/[email protected]";
+ saveConversationHistory(userBKey, [storedConversation("user-b-history")]);
+ const userBHistory = localStorage.getItem(userBKey);
+ useAppStore.setState({
+ currentUser: {
+ email: "[email protected]",
+ workspace: "workspaces/test",
+ } as never,
+ });
+
+ message.content = "late user A response";
+ await useConversationStore.getState().updateMessage(message);
+
+ expect(localStorage.getItem(userBKey)).toBe(userBHistory);
+ });
+
+ test("hydrates the new identity before creating a conversation", async () => {
+ const userA = await useConversationStore
+ .getState()
+ .createConversation({ ...connection, name: "user A" });
+ await useConversationStore.getState().createMessage({
+ author: "USER",
+ content: "user A question",
+ error: "",
+ status: "DONE",
+ conversation_id: userA.id,
+ });
+ const userBKey = "bb.ai.conversations.workspaces/[email protected]";
+ saveConversationHistory(userBKey, [storedConversation("user-b-history")]);
+ useAppStore.setState({
+ currentUser: {
+ email: "[email protected]",
+ workspace: "workspaces/test",
+ } as never,
+ });
+
+ await useConversationStore
+ .getState()
+ .createConversation({ ...connection, name: "new conversation" });
+
+ const userBHistory = localStorage.getItem(userBKey) ?? "";
+ expect(userBHistory).toContain("user-b-history");
+ expect(userBHistory).not.toContain("user A question");
+ });
+
+ test("rebases writes from a stale browser tab on persisted history", async () => {
+ saveConversationHistory(storageKey, [storedConversation("existing")]);
+ await useConversationStore
+ .getState()
+ .fetchConversationListByConnection(connection as never);
+ const staleTabState = useConversationStore.getState().conversationsById;
+
+ const tabAConversation = await useConversationStore
+ .getState()
+ .createConversation({ ...connection, name: "tab A" });
+ await useConversationStore.getState().createMessage({
+ author: "USER",
+ content: "question from tab A",
+ error: "",
+ status: "DONE",
+ conversation_id: tabAConversation.id,
+ });
+
+ useConversationStore.setState({ conversationsById: staleTabState });
+ const tabBConversation = await useConversationStore
+ .getState()
+ .createConversation({ ...connection, name: "tab B" });
+ await useConversationStore.getState().createMessage({
+ author: "USER",
+ content: "question from tab B",
+ error: "",
+ status: "DONE",
+ conversation_id: tabBConversation.id,
+ });
+
+ expect(localStorage.getItem(storageKey)).toContain("question from tab A");
+ expect(localStorage.getItem(storageKey)).toContain("question from tab B");
+ });
+
+ test("merges messages written to the same conversation from stale tabs", async () => {
+ saveConversationHistory(storageKey, [storedConversation("shared")]);
+ await useConversationStore
+ .getState()
+ .fetchConversationListByConnection(connection as never);
+ const staleTabState = useConversationStore.getState().conversationsById;
+
+ await useConversationStore.getState().createMessage({
+ author: "USER",
+ content: "message from tab A",
+ error: "",
+ status: "DONE",
+ conversation_id: "shared",
+ });
+
+ useConversationStore.setState({ conversationsById: staleTabState });
+ await useConversationStore.getState().createMessage({
+ author: "USER",
+ content: "message from tab B",
+ error: "",
+ status: "DONE",
+ conversation_id: "shared",
+ });
+
+ const history = localStorage.getItem(storageKey) ?? "";
+ expect(history).toContain("message from tab A");
+ expect(history).toContain("message from tab B");
+ });
+
+ test("always includes the workspace in self-host storage keys", async () => {
+ useAppStore.setState({
+ currentUser: {
+ email: "[email protected]",
+ workspace: "workspaces/self-host",
+ } as never,
+ serverInfo: { saas: false, workspace: "workspaces/self-host" } as never,
+ });
+
+ const conversation = await useConversationStore
+ .getState()
+ .createConversation({ ...connection, name: "self-host" });
+ await useConversationStore.getState().createMessage({
+ author: "USER",
+ content: "self-host question",
+ error: "",
+ status: "DONE",
+ conversation_id: conversation.id,
+ });
+
+ expect(
+ localStorage.getItem(
+ "bb.ai.conversations.workspaces/[email protected]"
+ )
+ ).toContain("self-host question");
+ expect(
+ localStorage.getItem("[email protected]")
+ ).toBeNull();
});
});
diff --git a/frontend/src/modules/ai/store/conversation.ts b/frontend/src/modules/ai/store/conversation.ts
index e00be86d9f..1a858b6234 100644
--- a/frontend/src/modules/ai/store/conversation.ts
+++ b/frontend/src/modules/ai/store/conversation.ts
@@ -1,317 +1,284 @@
-import { groupBy, omit } from "lodash-es";
-import PouchDB from "pouchdb";
-import PouchDBFind from "pouchdb-find";
import { v1 as uuidv1 } from "uuid";
import { create } from "zustand";
+import { useAppStore } from "@/stores/app";
import type { SQLEditorConnection } from "@/types";
+import { storageKeyAiConversations } from "@/utils/storage-keys";
import type { Conversation, Message } from "../types";
-
-type RowStatus = "NORMAL" | "ARCHIVED";
-
-type Entity<T, O extends keyof T, E = unknown> = Omit<T, "id" | O> & {
- _id: string;
- _rev?: string;
- row_status: RowStatus;
-} & E;
-
-type ConversationEntity = Entity<Conversation, "messageList">;
-type MessageEntity = Entity<
- Message,
- "conversation",
- {
- conversation_id: string;
- }
+import {
+ loadConversationHistory,
+ mutateConversationHistory,
+} from "./conversationStorage";
+
+type ConversationCreate = Omit<
+ Conversation,
+ "id" | "created_ts" | "messageList"
>;
-
-type EntityCreate<T> = Omit<T, "_id" | "created_ts" | "row_status">;
-
-PouchDB.plugin(PouchDBFind);
-
-const convertConversationToEntity = (
- conversation: Conversation
-): ConversationEntity => ({
- ...omit(conversation, "id", "messageList"),
- _id: conversation.id,
- row_status: "NORMAL",
-});
-
-const convertMessageToEntity = (message: Message): MessageEntity => ({
- ...omit(message, "id", "conversation"),
- _id: message.id,
- row_status: "NORMAL",
- conversation_id: message.conversation.id,
-});
-
-const FK_MESSAGE_CONVERSATION_ID = "fk_message_conversation_id";
-
-const conversations = new PouchDB<ConversationEntity>(
- "bb.plugin.ai.conversations"
-);
-const messages = new PouchDB<MessageEntity>("bb.plugin.ai.messages");
-
-const putExisting = async <T extends { _id: string }>(
- database: PouchDB.Database<T>,
- entity: T
-) => {
- const current = await database.get(entity._id);
- return database.put({ ...entity, _rev: current._rev });
+type MessageCreate = Omit<Message, "id" | "created_ts" | "conversation"> & {
+ conversation_id: string;
};
-const ready: Promise<unknown>[] = [];
-ready.push(
- messages.createIndex({
- index: { name: FK_MESSAGE_CONVERSATION_ID, fields: ["conversation_id"] },
- })
-);
-
const connectionKey = (conn: { instance: string; database: string }) =>
`${conn.instance}/${conn.database}`;
+const currentStorageKey = () => {
+ const state = useAppStore.getState();
+ const email = state.currentUser?.email;
+ const workspace =
+ state.currentUser?.workspace || state.serverInfo?.workspace || "";
+ if (!email || !workspace) return undefined;
+ return storageKeyAiConversations(workspace, email);
+};
+
+const withMessageBackReferences = (
+ conversation: Omit<Conversation, "messageList">,
+ messages: Message[]
+): Conversation => {
+ const next: Conversation = { ...conversation, messageList: [] };
+ next.messageList = messages.map((message) => ({
+ ...message,
+ conversation: next,
+ }));
+ return next;
+};
+
type ConversationState = {
conversationsById: Record<string, Conversation>;
readyByConnection: Record<string, boolean>;
+ storageKey?: string;
fetchConversationListByConnection: (
conn: SQLEditorConnection
) => Promise<Conversation[]>;
createConversation: (
- conversationCreate: EntityCreate<ConversationEntity>
+ conversationCreate: ConversationCreate
) => Promise<Conversation>;
updateConversation: (conversation: Conversation) => Promise<Conversation>;
deleteConversation: (id: string) => Promise<void>;
- createMessage: (
- messageCreate: EntityCreate<MessageEntity>
- ) => Promise<Message>;
+ createMessage: (messageCreate: MessageCreate) => Promise<Message>;
updateMessage: (message: Message) => Promise<Message>;
reset: () => Promise<void>;
};
-// Build a plain Conversation (with its message back-refs) from entities.
-const buildConversation = (
- c: ConversationEntity,
- messageEntities: MessageEntity[]
-): Conversation => {
- const conversation: Conversation = {
- ...omit(c, "_id", "_rev", "row_status"),
- id: c._id,
- messageList: [],
- } as Conversation;
- conversation.messageList = messageEntities
- .map<Message>(
- (m) =>
- ({
- ...omit(m, "_id", "_rev", "row_status", "conversation_id"),
- id: m._id,
- conversation,
- }) as Message
- )
- .sort((a, b) => a.created_ts - b.created_ts);
- return conversation;
-};
-
-// Immutably replace a conversation in the map.
-const withConversation = (
- byId: Record<string, Conversation>,
- conversation: Conversation
-): Record<string, Conversation> => ({
- ...byId,
- [conversation.id]: conversation,
-});
+let persistenceWarningShown = false;
export const useConversationStore = create<ConversationState>((set, get) => {
- const deleteConversation = async (id: string): Promise<void> => {
- const conversation = get().conversationsById[id];
- if (!conversation) return;
- if (conversation.messageList.length > 0) {
- await Promise.all(
- conversation.messageList.map((message) =>
- putExisting(messages, {
- ...convertMessageToEntity(message),
- row_status: "ARCHIVED" as const,
- })
- )
- );
- }
- await putExisting(conversations, {
- ...convertConversationToEntity(conversation),
- row_status: "ARCHIVED",
+ const persist = async (
+ key: string | undefined,
+ mutate: (conversations: Conversation[]) => Conversation[]
+ ) => {
+ if (!key || get().storageKey !== key || currentStorageKey() !== key) return;
+ const saved = await mutateConversationHistory(key, (conversations) => {
+ if (get().storageKey !== key || currentStorageKey() !== key) return;
+ return mutate(conversations);
});
- set((state) => {
- const next = { ...state.conversationsById };
- delete next[id];
- return { conversationsById: next };
- });
- };
-
- const updateMessage = async (message: Message): Promise<Message> => {
- await putExisting(messages, convertMessageToEntity(message));
- const conversation = get().conversationsById[message.conversation.id];
- if (conversation) {
- const nextConversation: Conversation = {
- ...conversation,
- messageList: conversation.messageList.map((m) =>
- m.id === message.id ? message : m
- ),
- };
- set((state) => ({
- conversationsById: withConversation(
- state.conversationsById,
- nextConversation
- ),
- }));
+ if (!saved && !persistenceWarningShown) {
+ persistenceWarningShown = true;
+ console.warn("[AI Assistant] Unable to persist conversation history");
}
- return message;
- };
-
- const fixAbnormalMessages = async (messageList: Message[]) => {
- const requests = messageList
- .filter((message) => message.status === "LOADING")
- .map((message) => {
- message.status = "FAILED";
- message.error = "Request timeout";
- return updateMessage(message);
- });
- await Promise.all(requests);
};
const fetchConversationListByConnection = async (
conn: SQLEditorConnection
): Promise<Conversation[]> => {
- const conversationEntityList = (
- await conversations.find({
- selector: {
- row_status: { $eq: "NORMAL" },
- instance: { $eq: conn.instance },
- database: { $eq: conn.database },
- },
- })
- ).docs;
- const flattenMessageList = (
- await messages.find({
- selector: {
- row_status: { $eq: "NORMAL" },
- conversation_id: { $in: conversationEntityList.map((c) => c._id) },
- },
- })
- ).docs;
-
- const groupByConversationId = groupBy(
- flattenMessageList,
- (m) => m.conversation_id
- );
- conversationEntityList.sort((a, b) => a.created_ts - b.created_ts);
- const rawConversationList = conversationEntityList.map<Conversation>((c) =>
- buildConversation(c, groupByConversationId[c._id] ?? [])
- );
-
- await fixAbnormalMessages(
- rawConversationList.flatMap((c) => c.messageList)
+ const key = currentStorageKey();
+ const existing = get();
+ const allConversations =
+ existing.storageKey === key
+ ? Object.values(existing.conversationsById)
+ : key
+ ? loadConversationHistory(key)
+ : [];
+ const conversationsById = Object.fromEntries(
+ allConversations
+ .filter((conversation) => conversation.messageList.length > 0)
+ .map((conversation) => [conversation.id, conversation])
);
-
- const emptyConversationList = rawConversationList.filter(
- (c) => c.messageList.length === 0
- );
-
- set((state) => {
- const next = { ...state.conversationsById };
- for (const c of rawConversationList) next[c.id] = c;
- return {
- conversationsById: next,
- readyByConnection: {
- ...state.readyByConnection,
- [connectionKey(conn)]: true,
- },
- };
+ set({
+ conversationsById,
+ storageKey: key,
+ readyByConnection: {
+ ...(existing.storageKey === key ? existing.readyByConnection : {}),
+ [connectionKey(conn)]: true,
+ },
});
-
- await Promise.all(
- emptyConversationList.map((c) => deleteConversation(c.id))
- );
-
- return rawConversationList.filter((c) => c.messageList.length > 0);
+ return Object.values(conversationsById)
+ .filter(
+ (conversation) =>
+ conversation.instance === conn.instance &&
+ conversation.database === conn.database
+ )
+ .sort((a, b) => a.created_ts - b.created_ts);
};
const createConversation = async (
- conversationCreate: EntityCreate<ConversationEntity>
+ conversationCreate: ConversationCreate
): Promise<Conversation> => {
- const c: ConversationEntity = {
- _id: uuidv1(),
+ const key = currentStorageKey();
+ const conversation: Conversation = {
+ id: uuidv1(),
created_ts: Date.now(),
- row_status: "NORMAL",
+ messageList: [],
...conversationCreate,
};
- const response = await conversations.put(c);
- c._rev = response.rev;
- const conversation = buildConversation(c, []);
set((state) => ({
- conversationsById: withConversation(
- state.conversationsById,
- conversation
- ),
+ conversationsById: {
+ ...(state.storageKey === key
+ ? state.conversationsById
+ : Object.fromEntries(
+ (key ? loadConversationHistory(key) : []).map((stored) => [
+ stored.id,
+ stored,
+ ])
+ )),
+ [conversation.id]: conversation,
+ },
+ readyByConnection:
+ state.storageKey === key ? state.readyByConnection : {},
+ storageKey: key,
}));
+ await persist(key, (conversations) => [
+ ...conversations.filter(({ id }) => id !== conversation.id),
+ conversation,
+ ]);
return conversation;
};
const updateConversation = async (
conversation: Conversation
): Promise<Conversation> => {
- await putExisting(conversations, convertConversationToEntity(conversation));
+ const key = currentStorageKey();
const existing = get().conversationsById[conversation.id];
- const next: Conversation = {
- ...conversation,
- messageList: existing?.messageList ?? conversation.messageList,
- };
+ const next = withMessageBackReferences(
+ conversation,
+ existing?.messageList ?? conversation.messageList
+ );
set((state) => ({
- conversationsById: withConversation(state.conversationsById, next),
+ conversationsById: {
+ ...state.conversationsById,
+ [next.id]: next,
+ },
}));
+ await persist(key, (conversations) =>
+ conversations.map((stored) =>
+ stored.id === next.id
+ ? withMessageBackReferences(
+ {
+ ...stored,
+ name: next.name,
+ instance: next.instance,
+ database: next.database,
+ },
+ stored.messageList
+ )
+ : stored
+ )
+ );
return next;
};
+ const deleteConversation = async (id: string): Promise<void> => {
+ const key = currentStorageKey();
+ set((state) => {
+ const conversationsById = { ...state.conversationsById };
+ delete conversationsById[id];
+ return { conversationsById };
+ });
+ await persist(key, (conversations) =>
+ conversations.filter((conversation) => conversation.id !== id)
+ );
+ };
+
const createMessage = async (
- messageCreate: EntityCreate<MessageEntity>
+ messageCreate: MessageCreate
): Promise<Message> => {
- const m: MessageEntity = {
- _id: uuidv1(),
+ const key = currentStorageKey();
+ const conversation = get().conversationsById[messageCreate.conversation_id];
+ if (!conversation) {
+ throw new Error(
+ `Conversation not found: ${messageCreate.conversation_id}`
+ );
+ }
+ const message = {
+ id: uuidv1(),
created_ts: Date.now(),
- row_status: "NORMAL",
- ...messageCreate,
- };
- const response = await messages.put(m);
- m._rev = response.rev;
- const conversation = get().conversationsById[m.conversation_id];
- const message: Message = {
- ...omit(m, "_id", "_rev", "row_status", "conversation_id"),
- id: m._id,
+ author: messageCreate.author,
+ content: messageCreate.content,
+ status: messageCreate.status,
+ error: messageCreate.error,
conversation,
- } as Message;
- if (conversation) {
- const nextConversation: Conversation = {
- ...conversation,
- messageList: [...conversation.messageList, message],
- };
- message.conversation = nextConversation;
- set((state) => ({
- conversationsById: withConversation(
- state.conversationsById,
- nextConversation
- ),
- }));
- }
- return message;
+ } satisfies Message;
+ const next = withMessageBackReferences(conversation, [
+ ...conversation.messageList,
+ message,
+ ]);
+ set((state) => ({
+ conversationsById: {
+ ...state.conversationsById,
+ [next.id]: next,
+ },
+ }));
+ await persist(key, (conversations) => {
+ const stored = conversations.find(({ id }) => id === next.id);
+ if (!stored) return [...conversations, next];
+ const messages = stored.messageList.some(({ id }) => id === message.id)
+ ? stored.messageList
+ : [...stored.messageList, message].sort(
+ (a, b) => a.created_ts - b.created_ts
+ );
+ const merged = withMessageBackReferences(stored, messages);
+ return conversations.map((conversation) =>
+ conversation.id === merged.id ? merged : conversation
+ );
+ });
+ return next.messageList.at(-1)!;
+ };
+
+ const updateMessage = async (message: Message): Promise<Message> => {
+ const key = currentStorageKey();
+ const conversation = get().conversationsById[message.conversation.id];
+ if (!conversation) return message;
+ const next = withMessageBackReferences(
+ conversation,
+ conversation.messageList.map((current) =>
+ current.id === message.id ? message : current
+ )
+ );
+ set((state) => ({
+ conversationsById: {
+ ...state.conversationsById,
+ [next.id]: next,
+ },
+ }));
+ await persist(key, (conversations) => {
+ const stored = conversations.find(({ id }) => id === next.id);
+ if (!stored) return conversations;
+ const exists = stored.messageList.some(({ id }) => id === message.id);
+ const messages = exists
+ ? stored.messageList.map((current) =>
+ current.id === message.id ? message : current
+ )
+ : [...stored.messageList, message].sort(
+ (a, b) => a.created_ts - b.created_ts
+ );
+ const merged = withMessageBackReferences(stored, messages);
+ return conversations.map((conversation) =>
+ conversation.id === merged.id ? merged : conversation
+ );
+ });
+ return next.messageList.find(({ id }) => id === message.id) ?? message;
};
const reset = async () => {
- try {
- await Promise.all(ready);
- await Promise.all([conversations.destroy(), messages.destroy()]);
- } catch {
- // nothing to do
- }
- set({ conversationsById: {}, readyByConnection: {} });
+ set({
+ conversationsById: {},
+ readyByConnection: {},
+ storageKey: undefined,
+ });
};
return {
conversationsById: {},
readyByConnection: {},
+ storageKey: undefined,
fetchConversationListByConnection,
createConversation,
updateConversation,
@@ -322,8 +289,6 @@ export const useConversationStore = create<ConversationState>((set, get) => {
};
});
-// Conversations for a given connection, sorted by creation time (mirrors the
-// Vue store's filtered `conversationList`).
export const conversationListByConnection = (
state: ConversationState,
conn: { instance: string; database: string }
diff --git a/frontend/src/modules/ai/store/conversationStorage.test.ts b/frontend/src/modules/ai/store/conversationStorage.test.ts
new file mode 100644
index 0000000000..06b8180e07
--- /dev/null
+++ b/frontend/src/modules/ai/store/conversationStorage.test.ts
@@ -0,0 +1,209 @@
+import { beforeEach, describe, expect, test, vi } from "vitest";
+import type { Conversation, Message } from "../types";
+import {
+ loadConversationHistory,
+ MAX_CONVERSATION_HISTORY_BYTES,
+ mutateConversationHistory,
+ saveConversationHistory,
+} from "./conversationStorage";
+
+const STORAGE_KEY = "[email protected]";
+
+const conversation = (
+ id: string,
+ createdTs: number,
+ contents: string[] = ["SELECT 1"]
+): Conversation => {
+ const result: Conversation = {
+ id,
+ created_ts: createdTs,
+ name: id,
+ instance: "instances/test",
+ database: "instances/test/databases/demo",
+ messageList: [],
+ };
+ result.messageList = contents.map<Message>((content, index) => ({
+ id: `${id}-message-${index}`,
+ created_ts: createdTs + index,
+ author: index % 2 === 0 ? "USER" : "AI",
+ content,
+ status: "DONE",
+ error: "",
+ conversation: result,
+ }));
+ return result;
+};
+
+beforeEach(() => {
+ localStorage.clear();
+ vi.restoreAllMocks();
+ Object.defineProperty(navigator, "locks", {
+ configurable: true,
+ value: undefined,
+ });
+});
+
+describe("AI conversation local storage", () => {
+ test("restores visible history with message back-references", () => {
+ const original = conversation("conversation-1", 1, ["visible question"]);
+
+ expect(saveConversationHistory(STORAGE_KEY, [original])).toBe(true);
+ const [restored] = loadConversationHistory(STORAGE_KEY);
+ expect(restored).toMatchObject({
+ id: "conversation-1",
+ messageList: [
+ expect.objectContaining({
+ content: "visible question",
+ }),
+ ],
+ });
+ expect(restored?.messageList[0]?.conversation).toBe(restored);
+ });
+
+ test("turns an interrupted response into a failed message on reload", () => {
+ const original = conversation("conversation-1", 1);
+ original.messageList[0]!.author = "AI";
+ original.messageList[0]!.status = "LOADING";
+ original.messageList[0]!.content = "";
+
+ saveConversationHistory(STORAGE_KEY, [original]);
+
+ expect(
+ loadConversationHistory(STORAGE_KEY)[0]?.messageList[0]
+ ).toMatchObject({
+ status: "FAILED",
+ error: "Request timeout",
+ });
+ });
+
+ test("keeps only the 20 most recent conversations", () => {
+ const conversations = Array.from({ length: 25 }, (_, index) =>
+ conversation(`conversation-${index}`, index)
+ );
+
+ saveConversationHistory(STORAGE_KEY, conversations);
+
+ const restored = loadConversationHistory(STORAGE_KEY);
+ expect(restored).toHaveLength(20);
+ expect(restored[0]?.id).toBe("conversation-5");
+ expect(restored.at(-1)?.id).toBe("conversation-24");
+ });
+
+ test("does not let an empty draft evict saved conversations", () => {
+ const conversations = Array.from({ length: 20 }, (_, index) =>
+ conversation(`conversation-${index}`, index)
+ );
+ conversations.push(conversation("empty-draft", 21, []));
+
+ saveConversationHistory(STORAGE_KEY, conversations);
+
+ const restored = loadConversationHistory(STORAGE_KEY);
+ expect(restored).toHaveLength(20);
+ expect(restored.some(({ id }) => id === "empty-draft")).toBe(false);
+ expect(restored[0]?.id).toBe("conversation-0");
+ });
+
+ test("keeps serialized history within one MiB", () => {
+ const original = conversation("conversation-1", 1, [
+ "old".repeat(MAX_CONVERSATION_HISTORY_BYTES),
+ "answer",
+ "recent question",
+ ]);
+
+ saveConversationHistory(STORAGE_KEY, [original]);
+
+ const raw = localStorage.getItem(STORAGE_KEY) ?? "";
+ expect(new TextEncoder().encode(raw).byteLength).toBeLessThanOrEqual(
+ MAX_CONVERSATION_HISTORY_BYTES
+ );
+ expect(loadConversationHistory(STORAGE_KEY)[0]?.messageList).toEqual([
+ expect.objectContaining({ content: "recent question" }),
+ ]);
+ });
+
+ test("drops a conversation whose metadata alone exceeds the byte cap", () => {
+ const original = conversation("conversation-1", 1, []);
+ original.name = "x".repeat(MAX_CONVERSATION_HISTORY_BYTES + 1);
+
+ saveConversationHistory(STORAGE_KEY, [original]);
+
+ const raw = localStorage.getItem(STORAGE_KEY) ?? "";
+ expect(new TextEncoder().encode(raw).byteLength).toBeLessThanOrEqual(
+ MAX_CONVERSATION_HISTORY_BYTES
+ );
+ expect(loadConversationHistory(STORAGE_KEY)).toEqual([]);
+ });
+
+ test("physically removes conversations omitted by the next write", () => {
+ saveConversationHistory(STORAGE_KEY, [
+ conversation("deleted", 1),
+ conversation("kept", 2),
+ ]);
+
+ saveConversationHistory(STORAGE_KEY, [conversation("kept", 2)]);
+
+ expect(loadConversationHistory(STORAGE_KEY).map(({ id }) => id)).toEqual([
+ "kept",
+ ]);
+ expect(localStorage.getItem(STORAGE_KEY)).not.toContain("deleted");
+ });
+
+ test("ignores malformed stored history", () => {
+ localStorage.setItem(STORAGE_KEY, '{"version":1,"conversations":"bad"}');
+
+ expect(loadConversationHistory(STORAGE_KEY)).toEqual([]);
+ });
+
+ test("prunes and retries once after a storage write failure", () => {
+ const setItem = vi
+ .spyOn(Storage.prototype, "setItem")
+ .mockImplementationOnce(() => {
+ throw new DOMException("Storage quota exceeded", "QuotaExceededError");
+ })
+ .mockImplementationOnce(() => undefined);
+
+ const saved = saveConversationHistory(
+ STORAGE_KEY,
+ Array.from({ length: 4 }, (_, index) =>
+ conversation(`conversation-${index}`, index, ["x".repeat(100)])
+ )
+ );
+
+ expect(saved).toBe(true);
+ expect(setItem).toHaveBeenCalledTimes(2);
+ expect(String(setItem.mock.calls[1]?.[1]).length).toBeLessThan(
+ String(setItem.mock.calls[0]?.[1]).length
+ );
+ });
+
+ test("does not throw when both storage write attempts fail", () => {
+ vi.spyOn(Storage.prototype, "setItem").mockImplementation(() => {
+ throw new DOMException("Storage quota exceeded", "QuotaExceededError");
+ });
+
+ expect(
+ saveConversationHistory(STORAGE_KEY, [conversation("conversation-1", 1)])
+ ).toBe(false);
+ });
+
+ test("coordinates history mutations with a cross-tab lock", async () => {
+ const request = vi.fn(async (_name: string, callback: () => boolean) =>
+ callback()
+ );
+ Object.defineProperty(navigator, "locks", {
+ configurable: true,
+ value: { request },
+ });
+
+ await mutateConversationHistory(STORAGE_KEY, (conversations) => [
+ ...conversations,
+ conversation("conversation-1", 1),
+ ]);
+
+ expect(request).toHaveBeenCalledWith(
+ `${STORAGE_KEY}.write`,
+ expect.any(Function)
+ );
+ expect(loadConversationHistory(STORAGE_KEY)).toHaveLength(1);
+ });
+});
diff --git a/frontend/src/modules/ai/store/conversationStorage.ts b/frontend/src/modules/ai/store/conversationStorage.ts
new file mode 100644
index 0000000000..dfa27f10ec
--- /dev/null
+++ b/frontend/src/modules/ai/store/conversationStorage.ts
@@ -0,0 +1,224 @@
+import type {
+ Conversation,
+ Message,
+ MessageAuthor,
+ MessageStatus,
+} from "../types";
+
+const STORAGE_VERSION = 1;
+const MAX_CONVERSATIONS = 20;
+export const MAX_CONVERSATION_HISTORY_BYTES = 1024 * 1024;
+
+type StoredMessage = {
+ id: string;
+ created_ts: number;
+ author: MessageAuthor;
+ content: string;
+ status: MessageStatus;
+ error: string;
+};
+
+type StoredConversation = Omit<Conversation, "messageList"> & {
+ messageList: StoredMessage[];
+};
+
+type StoredConversationHistory = {
+ version: typeof STORAGE_VERSION;
+ conversations: StoredConversation[];
+};
+
+type ConversationHistoryMutation = (
+ conversations: Conversation[]
+) => Conversation[] | undefined;
+
+const serializedSize = (value: string) =>
+ new TextEncoder().encode(value).byteLength;
+
+const serialize = (conversations: StoredConversation[]) =>
+ JSON.stringify({
+ version: STORAGE_VERSION,
+ conversations,
+ } satisfies StoredConversationHistory);
+
+const removeOldestMessages = (conversation: StoredConversation) => {
+ conversation.messageList.shift();
+ while (
+ conversation.messageList.length > 0 &&
+ conversation.messageList[0]?.author !== "USER"
+ ) {
+ conversation.messageList.shift();
+ }
+};
+
+const fitToLimit = (conversations: StoredConversation[]) => {
+ const bounded = conversations
+ .sort((a, b) => a.created_ts - b.created_ts)
+ .slice(-MAX_CONVERSATIONS);
+ let serialized = serialize(bounded);
+ while (serializedSize(serialized) > MAX_CONVERSATION_HISTORY_BYTES) {
+ if (bounded.length > 1) {
+ bounded.shift();
+ } else if (bounded[0]?.messageList.length) {
+ removeOldestMessages(bounded[0]);
+ } else if (bounded.length === 1) {
+ bounded.shift();
+ } else {
+ break;
+ }
+ serialized = serialize(bounded);
+ }
+ return { conversations: bounded, serialized };
+};
+
+const forRetry = (conversations: StoredConversation[]) => {
+ if (conversations.length > 1) {
+ return conversations.slice(Math.floor(conversations.length / 2));
+ }
+ const [conversation] = conversations;
+ if (!conversation || conversation.messageList.length === 0) {
+ return conversations;
+ }
+ const retryConversation = {
+ ...conversation,
+ messageList: conversation.messageList.slice(
+ Math.ceil(conversation.messageList.length / 2)
+ ),
+ };
+ while (
+ retryConversation.messageList.length > 0 &&
+ retryConversation.messageList[0]?.author !== "USER"
+ ) {
+ retryConversation.messageList.shift();
+ }
+ return [retryConversation];
+};
+
+const toStoredConversation = (
+ conversation: Conversation
+): StoredConversation => ({
+ id: conversation.id,
+ created_ts: conversation.created_ts,
+ name: conversation.name,
+ instance: conversation.instance,
+ database: conversation.database,
+ messageList: conversation.messageList.map(
+ ({ id, created_ts, author, content, status, error }) => ({
+ id,
+ created_ts,
+ author,
+ content,
+ status,
+ error,
+ })
+ ),
+});
+
+const isStoredMessage = (value: unknown): value is StoredMessage => {
+ if (!value || typeof value !== "object") return false;
+ const message = value as Partial<StoredMessage>;
+ return (
+ typeof message.id === "string" &&
+ typeof message.created_ts === "number" &&
+ (message.author === "USER" || message.author === "AI") &&
+ typeof message.content === "string" &&
+ ["LOADING", "DONE", "FAILED"].includes(message.status ?? "") &&
+ typeof message.error === "string"
+ );
+};
+
+const isStoredConversation = (value: unknown): value is StoredConversation => {
+ if (!value || typeof value !== "object") return false;
+ const conversation = value as Partial<StoredConversation>;
+ return (
+ typeof conversation.id === "string" &&
+ typeof conversation.created_ts === "number" &&
+ typeof conversation.name === "string" &&
+ typeof conversation.instance === "string" &&
+ typeof conversation.database === "string" &&
+ Array.isArray(conversation.messageList) &&
+ conversation.messageList.every(isStoredMessage)
+ );
+};
+
+const readConversationHistory = (
+ key: string,
+ recoverInterruptedMessages: boolean
+): Conversation[] => {
+ try {
+ const raw = localStorage.getItem(key);
+ if (!raw) return [];
+ const parsed = JSON.parse(raw) as Partial<StoredConversationHistory>;
+ if (
+ parsed.version !== STORAGE_VERSION ||
+ !Array.isArray(parsed.conversations) ||
+ !parsed.conversations.every(isStoredConversation)
+ ) {
+ localStorage.removeItem(key);
+ return [];
+ }
+ return parsed.conversations.map((stored) => {
+ const conversation: Conversation = {
+ id: stored.id,
+ created_ts: stored.created_ts,
+ name: stored.name,
+ instance: stored.instance,
+ database: stored.database,
+ messageList: [],
+ };
+ conversation.messageList = stored.messageList.map<Message>((message) => ({
+ ...message,
+ status:
+ recoverInterruptedMessages && message.status === "LOADING"
+ ? "FAILED"
+ : message.status,
+ error:
+ recoverInterruptedMessages && message.status === "LOADING"
+ ? "Request timeout"
+ : message.error,
+ conversation,
+ }));
+ return conversation;
+ });
+ } catch {
+ return [];
+ }
+};
+
+export const loadConversationHistory = (key: string): Conversation[] =>
+ readConversationHistory(key, true);
+
+export const saveConversationHistory = (
+ key: string,
+ conversations: Conversation[]
+): boolean => {
+ const stored = conversations
+ .filter((conversation) => conversation.messageList.length > 0)
+ .map(toStoredConversation);
+ const bounded = fitToLimit(stored);
+ try {
+ localStorage.setItem(key, bounded.serialized);
+ return true;
+ } catch {
+ try {
+ const retry = fitToLimit(forRetry(bounded.conversations));
+ localStorage.setItem(key, retry.serialized);
+ return true;
+ } catch {
+ return false;
+ }
+ }
+};
+
+export const mutateConversationHistory = async (
+ key: string,
+ mutate: ConversationHistoryMutation
+): Promise<boolean> => {
+ const write = () => {
+ const conversations = mutate(readConversationHistory(key, false));
+ if (!conversations) return true;
+ return saveConversationHistory(key, conversations);
+ };
+ const locks = globalThis.navigator?.locks;
+ if (!locks) return write();
+ return locks.request(`${key}.write`, write);
+};
diff --git a/frontend/src/modules/ai/types/conversation.ts b/frontend/src/modules/ai/types/conversation.ts
index 499ec443ea..ef79a76ae9 100644
--- a/frontend/src/modules/ai/types/conversation.ts
+++ b/frontend/src/modules/ai/types/conversation.ts
@@ -7,7 +7,6 @@ export type Message = {
created_ts: number; // ms
author: MessageAuthor;
content: string; // Content to display
- prompt: string; // Prompt to send to AI
status: MessageStatus; // Always "DONE" when `author`="USER"
error: string;
conversation: Conversation;
diff --git a/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.test.tsx b/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.test.tsx
index b1a3860aa4..ec8f8722ac 100644
--- a/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.test.tsx
+++ b/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.test.tsx
@@ -189,7 +189,7 @@ vi.mock("@/modules/sql-editor/store/tab", () => ({
}));
vi.mock("@/modules/sql-editor/legacy/migration", () => ({
- migrateLegacyCache: vi.fn(async () => undefined),
+ cleanupLegacyPouchDatabases: vi.fn(async () => undefined),
}));
vi.mock("./SQLEditorHomePage", () => ({
diff --git a/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.tsx b/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.tsx
index 79c05c52e8..b2445c8f46 100644
--- a/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.tsx
+++ b/frontend/src/modules/sql-editor/components/SQLEditorRouteShell.tsx
@@ -19,7 +19,7 @@ import {
import { useAppProject } from "@/hooks/useAppProject";
import { extractSavedQueryConnection } from "@/lib/sqlEditorConnection";
import { useClampResultRowsLimitToPolicy } from "@/modules/sql-editor/hooks/useSQLEditorState";
-import { migrateLegacyCache } from "@/modules/sql-editor/legacy/migration";
+import { cleanupLegacyPouchDatabases } from "@/modules/sql-editor/legacy/migration";
import { sqlEditorEvents } from "@/modules/sql-editor/model/events";
import type { AsidePanelTab } from "@/modules/sql-editor/store";
import { useSQLEditorStore } from "@/modules/sql-editor/store";
@@ -152,7 +152,7 @@ export function SQLEditorRouteShell() {
void (async () => {
getSQLEditorEditorState().setProjectContextReady(false);
const project = await initializeProject();
- await migrateLegacyCache();
+ await cleanupLegacyPouchDatabases();
await getSQLEditorTabsState().initProject(project);
await initializeConnectionFromQuery();
setBootstrapDone(true);
diff --git a/frontend/src/modules/sql-editor/components/StandardPanel/SQLEditor.tsx b/frontend/src/modules/sql-editor/components/StandardPanel/SQLEditor.tsx
index c3c6734b7b..babaa46026 100644
--- a/frontend/src/modules/sql-editor/components/StandardPanel/SQLEditor.tsx
+++ b/frontend/src/modules/sql-editor/components/StandardPanel/SQLEditor.tsx
@@ -35,6 +35,7 @@ import { useAIActions } from "../Panels/common/useAIActions";
import { monacoThemeName } from "../theme/derive";
import { useActiveSQLEditorTheme } from "../theme/useActiveSQLEditorTheme";
import { computeAppendedSelection } from "./appendSelection";
+import { prepareSnippetInsertion } from "./prepareSnippetInsertion";
import { activeSQLEditorRef, activeStatementRef } from "./state";
import { UploadFileButton } from "./UploadFileButton";
@@ -317,16 +318,35 @@ export function SQLEditor({ onExecute }: SQLEditorProps) {
setPendingInsertAtCaret(undefined);
requestAnimationFrame(() => {
+ const model = editor.getModel();
+ if (!model) return;
const selection = editor.getSelection();
- const maxLineNumber = editor.getModel()?.getLineCount() ?? 0;
- const range =
- selection ??
- new monaco.Range(maxLineNumber + 1, 1, maxLineNumber + 1, 1);
+ const endPosition = model.getPositionAt(model.getValueLength());
+ const range = selection ?? monaco.Range.fromPositions(endPosition);
+ const startOffset = model.getOffsetAt({
+ lineNumber: range.startLineNumber,
+ column: range.startColumn,
+ });
+ const endOffset = model.getOffsetAt({
+ lineNumber: range.endLineNumber,
+ column: range.endColumn,
+ });
+ const value = model.getValue();
+ const insertion = prepareSnippetInsertion(
+ text,
+ value.slice(0, startOffset),
+ value.slice(endOffset),
+ model.getEOL()
+ );
editor.executeEdits("bb.event.insert-at-caret", [
- { forceMoveMarkers: true, text, range },
+ { forceMoveMarkers: true, text: insertion.text, range },
]);
+ const cursorPosition = model.getPositionAt(
+ startOffset + insertion.cursorOffset
+ );
+ editor.setPosition(cursorPosition);
editor.focus();
- editor.revealLine(range.startLineNumber);
+ editor.revealLine(cursorPosition.lineNumber);
});
}, [pendingInsertAtCaret, setPendingInsertAtCaret]);
diff --git a/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.test.ts b/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.test.ts
new file mode 100644
index 0000000000..8b3088439f
--- /dev/null
+++ b/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.test.ts
@@ -0,0 +1,49 @@
+import { describe, expect, test } from "vitest";
+import { prepareSnippetInsertion } from "./prepareSnippetInsertion";
+
+describe("prepareSnippetInsertion", () => {
+ test("separates a snippet from SQL following the cursor", () => {
+ expect(prepareSnippetInsertion("SELECT 2;", "", "SELECT 1;", "\n")).toEqual(
+ {
+ text: "SELECT 2;\n",
+ cursorOffset: "SELECT 2;\n".length,
+ }
+ );
+ });
+
+ test("places a snippet on its own lines when inserted mid-line", () => {
+ expect(prepareSnippetInsertion("SELECT 2;", "SELECT ", "1;", "\n")).toEqual(
+ {
+ text: "\nSELECT 2;\n",
+ cursorOffset: "\nSELECT 2;\n".length,
+ }
+ );
+ });
+
+ test("uses an existing following newline without creating a blank line", () => {
+ expect(
+ prepareSnippetInsertion("SELECT 2;", "SELECT 1;\n", "\nSELECT 3;", "\n")
+ ).toEqual({
+ text: "SELECT 2;",
+ cursorOffset: "SELECT 2;".length + 1,
+ });
+ });
+
+ test("leaves the cursor on a new line when inserting at end of file", () => {
+ expect(prepareSnippetInsertion("SELECT 2;", "SELECT 1;", "", "\n")).toEqual(
+ {
+ text: "\nSELECT 2;\n",
+ cursorOffset: "\nSELECT 2;\n".length,
+ }
+ );
+ });
+
+ test("normalizes snippet boundaries and respects the model line ending", () => {
+ expect(
+ prepareSnippetInsertion("\nSELECT 2;\r\n", "", "SELECT 1;", "\r\n")
+ ).toEqual({
+ text: "SELECT 2;\r\n",
+ cursorOffset: "SELECT 2;\r\n".length,
+ });
+ });
+});
diff --git a/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.ts b/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.ts
new file mode 100644
index 0000000000..65c0c569de
--- /dev/null
+++ b/frontend/src/modules/sql-editor/components/StandardPanel/prepareSnippetInsertion.ts
@@ -0,0 +1,35 @@
+type PreparedSnippetInsertion = {
+ text: string;
+ /** Cursor offset relative to the start of the replaced range. */
+ cursorOffset: number;
+};
+
+const followingLineBreakLength = (text: string): number => {
+ if (text.startsWith("\r\n")) return 2;
+ if (text.startsWith("\n") || text.startsWith("\r")) return 1;
+ return 0;
+};
+
+export const prepareSnippetInsertion = (
+ content: string,
+ before: string,
+ after: string,
+ eol: string
+): PreparedSnippetInsertion => {
+ const snippet = content
+ .replace(/\r\n?/g, "\n")
+ .replace(/^\n+|\n+$/g, "")
+ .replaceAll("\n", eol);
+ const needsLeadingLineBreak =
+ before.length > 0 && !before.endsWith("\n") && !before.endsWith("\r");
+ const followingLineBreak = followingLineBreakLength(after);
+ const needsTrailingLineBreak = followingLineBreak === 0;
+ const text = `${needsLeadingLineBreak ? eol : ""}${snippet}${
+ needsTrailingLineBreak ? eol : ""
+ }`;
+
+ return {
+ text,
+ cursorOffset: text.length + followingLineBreak,
+ };
+};
diff --git a/frontend/src/modules/sql-editor/legacy/extendedTab.ts b/frontend/src/modules/sql-editor/legacy/extendedTab.ts
deleted file mode 100644
index 82503321bc..0000000000
--- a/frontend/src/modules/sql-editor/legacy/extendedTab.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import { pick } from "lodash-es";
-import PouchDB from "pouchdb";
-import PouchDBFind from "pouchdb-find";
-import type { SQLEditorTab } from "@/types";
-
-interface PouchDBError extends Error {
- status?: number;
-}
-
-export const EXTENDED_TAB_FIELDS = [
- "statement",
- "batchQueryContext",
- "treeState",
-] as const;
-type ExtendedTab = Pick<SQLEditorTab, (typeof EXTENDED_TAB_FIELDS)[number]>;
-type ExtendedTabEntity = ExtendedTab & {
- _id: string;
- _rev?: string;
- project: string; // for tracing
- user: string; // for tracing
-};
-
-PouchDB.plugin(PouchDBFind);
-
-// Pinia-free: a stateless wrapper over a PouchDB instance used only by the
-// one-time legacy SQL-editor cache migration (`./migration`). The PouchDB
-// instance is created lazily on first use (the former `useExtendedTabStore`
-// Pinia store deferred creation to first access the same way) so importing
-// this module does not eagerly touch IndexedDB.
-let db: PouchDB.Database<ExtendedTabEntity> | null = null;
-let ready: Promise<unknown> | null = null;
-
-const getDB = () => {
- if (!db) {
- db = new PouchDB<ExtendedTabEntity>("bb.sql-editor.extended-tab", {
- // Remove unused and old data automatically.
- auto_compaction: true,
- // Do not save and track old revisions, this is for saving storage usage.
- revs_limit: 1,
- });
- ready = Promise.all([
- db.createIndex({ index: { name: "idx_tab_user", fields: ["user"] } }),
- db.createIndex({
- index: { name: "idx_tab_project", fields: ["project"] },
- }),
- ]);
- }
- return { db, ready: ready as Promise<unknown> };
-};
-
-export const fetchExtendedTab = async (
- tab: SQLEditorTab,
- fallback?: () => void
-) => {
- try {
- const { db, ready } = getDB();
- await ready;
- const doc = await db.get(tab.id);
- Object.assign(tab, {
- _rev: doc._rev,
- _user: doc.user,
- _project: doc.project,
- ...pick(doc, EXTENDED_TAB_FIELDS),
- });
- } catch (err) {
- if (fallback) {
- fallback();
- }
-
- if ((err as PouchDBError)?.status === 404) return;
- console.debug("[SQLEditorExtendedTab] fetchExtendedTab", err);
- }
-};
-
-export const deleteExtendedTab = async (id: string) => {
- try {
- const { db, ready } = getDB();
- await ready;
- const doc = await db.get(id);
- await db.remove(doc);
- } catch (err) {
- console.warn("[SQLEditorExtendedTab] deleteExtendedTab", err);
- }
-};
diff --git a/frontend/src/modules/sql-editor/legacy/migration.test.ts b/frontend/src/modules/sql-editor/legacy/migration.test.ts
new file mode 100644
index 0000000000..eaeb604e86
--- /dev/null
+++ b/frontend/src/modules/sql-editor/legacy/migration.test.ts
@@ -0,0 +1,23 @@
+import { afterEach, describe, expect, test, vi } from "vitest";
+import { cleanupLegacyPouchDatabases } from "./migration";
+
+afterEach(() => {
+ vi.unstubAllGlobals();
+});
+
+describe("legacy PouchDB cleanup", () => {
+ test("continues when deleting a database throws synchronously", async () => {
+ const deleteDatabase = vi.fn((name: string) => {
+ if (name === "_pouch_bb.plugin.ai.messages") {
+ throw new DOMException("IndexedDB unavailable", "InvalidStateError");
+ }
+ const request = {} as IDBOpenDBRequest;
+ queueMicrotask(() => request.onsuccess?.(new Event("success")));
+ return request;
+ });
+ vi.stubGlobal("indexedDB", { deleteDatabase });
+
+ await expect(cleanupLegacyPouchDatabases()).resolves.toBeUndefined();
+ expect(deleteDatabase).toHaveBeenCalledTimes(4);
+ });
+});
diff --git a/frontend/src/modules/sql-editor/legacy/migration.ts b/frontend/src/modules/sql-editor/legacy/migration.ts
index 861f520b2d..83575e42df 100644
--- a/frontend/src/modules/sql-editor/legacy/migration.ts
+++ b/frontend/src/modules/sql-editor/legacy/migration.ts
@@ -1,22 +1,12 @@
import { create } from "@bufbuild/protobuf";
-import { isUndefined, omit, omitBy } from "lodash-es";
+import { isUndefined, omitBy } from "lodash-es";
import { extractSavedQueryConnection } from "@/lib/sqlEditorConnection";
import { useAppStore } from "@/stores/app";
import { getCurrentUserV1 } from "@/stores/modules/migration-helpers";
import { extractUserEmail } from "@/stores/modules/v1";
import type { EditorPanelViewState, SQLEditorTab } from "@/types";
-import { DEFAULT_SQL_EDITOR_TAB_MODE } from "@/types";
import { SavedQuerySchema } from "@/types/proto-es/v1/saved_query_service_pb";
-import {
- canCreateSavedQueryInProject,
- defaultSQLEditorTab,
- WebStorageHelper,
-} from "@/utils";
-import {
- deleteExtendedTab,
- EXTENDED_TAB_FIELDS,
- fetchExtendedTab,
-} from "./extendedTab";
+import { canCreateSavedQueryInProject, defaultSQLEditorTab } from "@/utils";
const LOCAL_STORAGE_KEY_PREFIX = "bb.sql-editor-tab";
@@ -61,89 +51,32 @@ type PersistentTab = Pick<
"id" | "title" | "connection" | "mode" | "status"
> & { worksheet?: string };
-type LegacyStoredTab = PersistentTab & { statement?: string };
-
-export const migrateLegacyCache = async () => {
- const userUID = extractUserEmail(getCurrentUserV1().name);
-
- const keyNamespace = `${LOCAL_STORAGE_KEY_PREFIX}.${userUID}`;
- const tabIdListKey = `${keyNamespace}.tab-id-list`;
- const tabIdListMapByProject = readLegacyStorage<Record<string, string[]>>(
- tabIdListKey,
- {}
+const LEGACY_POUCH_DATABASES = [
+ "_pouch_bb.plugin.ai.conversations",
+ "_pouch_bb.plugin.ai.messages",
+ "_pouch_bb.sql-editor.extended-tab",
+ "_pouch_bb.storage",
+];
+
+export const cleanupLegacyPouchDatabases = async () => {
+ if (!globalThis.indexedDB) return;
+ await Promise.all(
+ LEGACY_POUCH_DATABASES.map(
+ (name) =>
+ new Promise<void>((resolve) => {
+ let request: IDBOpenDBRequest;
+ try {
+ request = indexedDB.deleteDatabase(name);
+ } catch {
+ resolve();
+ return;
+ }
+ request.onsuccess = () => resolve();
+ request.onerror = () => resolve();
+ request.onblocked = () => resolve();
+ })
+ )
);
-
- const getStorage = () => {
- return new WebStorageHelper(keyNamespace);
- };
-
- const keyForTab = (id: string) => {
- return `tab.${id}`;
- };
-
- const loadStoredTab = async (id: string) => {
- const stored = getStorage().load<PersistentTab | undefined>(
- keyForTab(id),
- undefined
- );
- if (!stored) {
- return undefined;
- }
- const tab: SQLEditorTab = {
- ...defaultSQLEditorTab(),
- // Ignore extended fields stored in localStorage since they are migrated
- // to extendedTabStore.
- ...omit(stored, [...EXTENDED_TAB_FIELDS, "worksheet"]),
- // Legacy tabs stored the link under `worksheet` in the old name format.
- savedQuery: (stored.worksheet ?? "").replace(
- "/worksheets/",
- "/savedQueries/"
- ),
- id,
- };
- if (tab.mode !== DEFAULT_SQL_EDITOR_TAB_MODE) {
- // Do not enter ADMIN mode initially
- tab.mode = DEFAULT_SQL_EDITOR_TAB_MODE;
- }
-
- await fetchExtendedTab(tab, () => {
- // When the first time of migration, the extended doc in IndexedDB is not
- // found.
- // Fallback to the original PersistentTab in LocalStorage if possible.
- // This might happen only once to each user, since the second time when a
- // tab is saved, extended fields will be migrated, and won't be saved to
- // LocalStorage, so the fallback routine won't be hit.
- const { statement } = stored as LegacyStoredTab;
- if (statement) {
- tab.statement = statement;
- }
- });
-
- return tab;
- };
-
- const entries = [...Object.entries(tabIdListMapByProject)];
- for (const [project, tabIds] of entries) {
- const draftTabListKey = `${LOCAL_STORAGE_KEY_PREFIX}.${project}.${userUID}.draft-tab-list`;
- const draftTabList = readLegacyStorage<SQLEditorTab[]>(draftTabListKey, []);
-
- for (const tabId of tabIds) {
- const exist = draftTabList.find((draft) => draft.id === tabId);
- if (exist) {
- continue;
- }
- const tab = await loadStoredTab(tabId);
- await deleteExtendedTab(tabId);
- if (!tab) {
- continue;
- }
- draftTabList.push(tab);
- }
- writeLegacyStorage(draftTabListKey, draftTabList);
-
- delete tabIdListMapByProject[project];
- writeLegacyStorage(tabIdListKey, tabIdListMapByProject);
- }
};
export const migrateDraftsFromCache = async (project: string) => {
diff --git a/frontend/src/utils/storage-keys.ts b/frontend/src/utils/storage-keys.ts
index 65d3c618fe..5aedb8fa0c 100644
--- a/frontend/src/utils/storage-keys.ts
+++ b/frontend/src/utils/storage-keys.ts
@@ -117,6 +117,8 @@ export const storageKeySqlEditorAiSuggestion = (email: string) =>
`bb.sql-editor.ai-suggestion.${email}`;
// --- AI ---
+export const storageKeyAiConversations = (scope: string, email: string) =>
+ withScope("bb.ai.conversations", scope, email);
export const storageKeyAiSuggestions = (hash: string) =>
`bb.ai.suggestions.${hash}`;
diff --git a/frontend/vitest.setup.ts b/frontend/vitest.setup.ts
index a284c833fe..7ff2b98d92 100644
--- a/frontend/vitest.setup.ts
+++ b/frontend/vitest.setup.ts
@@ -63,21 +63,3 @@ if (typeof globalThis.ResizeObserver === "undefined") {
}
}
}
-
-vi.mock("pouchdb", () => {
- class MockPouchDB {
- static plugin = vi.fn();
-
- get = vi.fn(async () => undefined);
- put = vi.fn(async () => undefined);
- remove = vi.fn(async () => undefined);
- }
-
- return {
- default: MockPouchDB,
- };
-});
-
-vi.mock("pouchdb-find", () => ({
- default: {},
-}));