:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(signals): mark the priciest scout runs on the roster strip (#98553)
posthog[bot]d8bf33ef7017
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 6c25d2a89926..a85c4723fd7a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7777,9 +7777,9 @@ snapshots:scenes-app-inbox-scene--legacy-scouts--light:hash: v1.k794b7964.fbdba6b2b4d3fccde859fd2213b1580d43744013be41922b19fe371cc8c72e5b.MsUe8tUW9R4bOplWlproOR3eYuTgTKGTuYQoiarWC54scenes-app-inbox-scene--scouts--dark:- hash: v1.k794b7964.0eef9748c7485bd0e519ef32b6bd6890291c20ecc617e35ab1de72dbd5b1e9f9.-DfMfYg2UkOH6pOxLS7POXt4JyBB4-3QdUjKaKoyuCA+ hash: v1.k794b7964.7053803019f3c5c4d33bad380d4e4f8e8f066ef6d8e4936908cb73958143455a.0r-TdrrkSFVt7rRBizrLuOXauYQQbDJV_SfkCoavUeQscenes-app-inbox-scene--scouts--light:- hash: v1.k794b7964.4b634c388046989b7804835854ab8de1d955b4ce1dab3b03c2a2bc62fa0dc3f4.20y6mNcUODF37sZoiz0BysfMDp__nJiBGjyfudjG0kI+ hash: v1.k794b7964.4621afa320a2848672229b084310b41c6ae69de64879790b82da3a4821f80d71.QzcK4mYI1XCwSl9GR5aV3jdSz0MSkxAfFPicSHHxY5kscenes-app-inbox-scene--self-driving-onboarding--dark:hash: v1.k794b7964.6b7b2950c3a0df456074962aada4405283deea5158415e032f0b0f8f25e5dbc2.xg-B8FCyxFnbFGtI5vZxy2htjDbFs0Dms_9sTrA7MwYscenes-app-inbox-scene--self-driving-onboarding--light:@@ -7837,73 +7837,73 @@ snapshots:scenes-app-inbox-scoutowners--states--light:hash: v1.k794b7964.62cb1889d60cf91cae1d0337da5a9209f4a759a1ccfed6a67dd6d2b238e75f13.qvVHYAWE8wGdD83VE5OOHw6uveEUae2uieDQ6sExrrsscenes-app-inbox-scoutsroster--large-fleet--dark:- hash: v1.k794b7964.483de5b2263bf9a5a42e8931f19cb8305f9e6b6e9777564f6b560f135f04e624.7uDjOpdXd7rfxdCLYcs_6YHcoqtijp_vPmSL2WHs7Yk+ hash: v1.k794b7964.6a104e1f11d3d44a190714666d7db789d8479d6e3d0686089ead4138646f8b9d.yT7Pq0w9e_Hf2v8nuO41bjNvRA7nlyUgUKrpPs623VIscenes-app-inbox-scoutsroster--large-fleet--light:- hash: v1.k794b7964.1059bc4b2a13b58ecd34adb74be07f01f10c2b416ca754c4cdaf74bcc5738053.Cbvhxz1M94vF9sX4pytiOqTnr9QQ2UeX7GRgsvJiyKM+ hash: v1.k794b7964.c54727de9306e93a3c6a20bf0f41719bdcef495e0945134201c8ad05ac2f8204.eNDflDb_NZ8w9fauXrHe36z-8JHZ320f0l4AVIxPO9sscenes-app-inbox-scoutsroster--narrow--dark:hash: v1.k794b7964.67106f2ee332cdefdd195f9ac461c76dd294415e4f6df9dbb4863436048b1bbd.VX98iv4ZBxPp6mZ11iJxeesn7i41Dk0Kmdrziawc5Qgscenes-app-inbox-scoutsroster--narrow--light:- hash: v1.k794b7964.6eca8870ce3fb0ac6bed7b6c1a213d0ddf106eef85e752d278355c5834044bcd.5FMfKlBLR9--8H85MIUoZ8OkojTZJyFK-juVX23yBL8+ hash: v1.k794b7964.fcdccdc5587bd8c324e82fd7620713aa70d0fc11cc3fd60617cd8385960d34f0.BrMGAFw1-lBRxGrCK8c_Ga5SKdLaAzoSH1GJj6KwvPIscenes-app-inbox-scoutsroster--roster--dark:- hash: v1.k794b7964.39e26f30989851080429efb281b4448ffc9039fee9bb5402186ed7fd2912dc26.sPEQ59LyZ9b5pr6uHM5j20CsYVq_An5CinTV8_bbfD0+ hash: v1.k794b7964.cb947603948fda90cc6fda9efc2e78e240efb013149e44fee03b2a4cc03b0b41.sH5fGdFy2ImPKL1Rl4GF9TmxfCvLqMSXYFrF83PFw0Uscenes-app-inbox-scoutsroster--roster--light:- hash: v1.k794b7964.26bc674402f84674d7b39764006867e5fe0a658c1bf7fc02172bf2cf42b78e5f.I6BS8h0D6TLChcep2O0Vn2eT5LvntQiSa6Fi_eyzgRE+ hash: v1.k794b7964.b00bf7fe96c22218a5ad7fc62fba676d095899f0e9bc4a5f54cffe8cb212a799.xPUahRQgcuZMoUDEt8wbSdryvS7tj6VZSKMZLXDY7FQscenes-app-inbox-scoutsroster--roster-legacy--dark:hash: v1.k794b7964.5339804f4cc136f9700b3329b0121ab62f3008197dcb4ff7c91d714e1fbdbbb5.peuyX_VFezfUR5E8LAdqk4e3GZWeYZ8qhq1Xp6HNLncscenes-app-inbox-scoutsroster--roster-legacy--light:hash: v1.k794b7964.d0ee903a8da5dd314b8b60412ac603d71fe2780cf7f498895b6bd040fe62ea2b.HSpIhnqqTWXHITf3_Opkoex_umbGmYhw01fki4ZX2Dgscenes-app-inbox-scoutsuggestionsstrip--collapsed--dark:- hash: v1.k794b7964.67533cc95661181a45f9682312c2b88931d35d1e892fec93c95fdd421d05593b.rHrsQwyOBatb0OOLZ_Xg2gMPjxt2mIOUEw9XRsN7xIg+ hash: v1.k794b7964.cae1abb0a0c5c33fd391f83d4cf8d194603b65e8057a5a8df56c849537ed3990.fwW1NTVJXd3hBKpGVAXqqIj-OnJzTCSUQ4A19quJdvgscenes-app-inbox-scoutsuggestionsstrip--collapsed--light:- hash: v1.k794b7964.57813eded2b1c9a1180b98a843493c5353e4891e6d0bf978ee99ce1fc9f72e24.desKj6CGCcfrL7K-hjqNibtthv22gd-Lzx6WPf-epBM+ hash: v1.k794b7964.a5a7b9df70a529eb02b58a785c25b65de38243dd7461a30f403282e996a03991.MCU-mj3s6elQuZxnXdy_h86UmvffRdRr4nieSR1Tb88scenes-app-inbox-scoutsuggestionsstrip--empty-fleet--dark:hash: v1.k794b7964.a9e935349a3145375d09cc1a483fd4cf2a760256000855e6e15a4cfaf2548236.mRkmlsFFKTFT_U5FUUw4ltXiVW4u7ICa1YC424x5GJEscenes-app-inbox-scoutsuggestionsstrip--empty-fleet--light:hash: v1.k794b7964.90d7232a692b063940384aa89d05c70e2c1af66eeeca08fe49bcdd9938e456a0.a3KW1AmgQwcQV84WzmFAeCk_ars13rMcEHeBSkn8S-cscenes-app-inbox-scoutsuggestionsstrip--fresh--dark:- hash: v1.k794b7964.a48a81bcaba120274c582d0d6f0fac80bece4cb6b22fda987d24ed69b8767b66.jAr47iAQdn6jjaCZKOl_3RLxcLLwMI5IT99clZsq9zA+ hash: v1.k794b7964.e4a80aa15ae407bdc14f972169bef63c08d8b92df3c403939d974678cff6f683.5sFzHtegn1fpbuvGiZRd97Pgfctsk6ZwXxmU3q1LPxsscenes-app-inbox-scoutsuggestionsstrip--fresh--light:- hash: v1.k794b7964.974824a015d7b531be6f3544b35fc62335e7cdd38268851a858188fa7a0b8e94.DiX0pcHMec3rjRESiVcOD7Iofwcql4J-ejg4sm2SxTk+ hash: v1.k794b7964.76c8e317bfb396bf3319dd9608f6deaf5d908b4284218fca79bc4a1cf5d87327.enIP-yo5jHWRHUu4dsASWZdg0H_K_X1bQN_7VJ6taskscenes-app-inbox-scoutsuggestionsstrip--last-scan-failed--dark:- hash: v1.k794b7964.94b77a977fb5d4d404498c2668ef981afe39efc40bf68fa47839344edceb218d.x4n7VdD6uc-Ialdy_YbZEKJzIIARdh6bFyzW_NDNeZ8+ hash: v1.k794b7964.3a7cd9d82ba9869916d448765364a5a2a4e3ff13519e286e5cbf6427de0317b2.1R7779omARFpg1I_tEXoqr6xiA7w-5aSepSqkLlIt_sscenes-app-inbox-scoutsuggestionsstrip--last-scan-failed--light:- hash: v1.k794b7964.3857c0fee475d63aa48ef4fac4512f5ce109b8e00af9ca32e6595c513c89f5f6.OJ_uYDe4-XN4PpYTm2xY37h5uBgtVterbJViPfb19Fs+ hash: v1.k794b7964.8938e799fb00a4f81c08ec0447e3f4f60a8dd38ca45219432898eda1beeaee69.CzrkV8ue2mcji7euauznWfeSGY49QwtsydaZw3gtbvQscenes-app-inbox-scoutsuggestionsstrip--narrow--dark:- hash: v1.k794b7964.ed94855c9c9fc734e8bc824ab59dbe817d666a70a2e5b0020ae5dc66be4fe742.JFA0vFLxcbGkuVI5y2MkCKGe4zbPb4zptPs9n326UT0+ hash: v1.k794b7964.593dc157d1faaef24b3ed48173b4729801348099124f2b5b4c6c37a9d58b87d0.eTS1JOi30O4KIRdJsX_pPUxHX0YxZQzpJ4ibd0Gcrv4scenes-app-inbox-scoutsuggestionsstrip--narrow--light:- hash: v1.k794b7964.26eaddb08cb66f2429064b530005a00861751cd5deeb65e9a098a8811d475bfb.UhPMW_EiszFoNsOuepJVPQibd2vxG0bnZY3DQKksAZg+ hash: v1.k794b7964.35ed7ec1a9b8f6d64bd00f9c97d7cf40cd9d0515e2ae0e6b48d3f334b0f5053d.VuZe-To5pCdusgBbKyJj6gFQT5YKSwZn-0mzJHZV9qgscenes-app-inbox-scoutsuggestionsstrip--never-generated--dark:- hash: v1.k794b7964.39e26f30989851080429efb281b4448ffc9039fee9bb5402186ed7fd2912dc26.3tfbUaa3WQw-wVGxNFvovrADZf_3m2_FkxluNoimVdc+ hash: v1.k794b7964.cb947603948fda90cc6fda9efc2e78e240efb013149e44fee03b2a4cc03b0b41.aVY4wYoLySAgvPFkNBZ9dpjUO3PV7DBvb00XPrTHYkwscenes-app-inbox-scoutsuggestionsstrip--never-generated--light:- hash: v1.k794b7964.bda4b9761970b6db839d52bf095c11d998fb8ffa2f84d7d1238a6f9c163cf67a.lcKr8Ht7DMA4Bp8mxsEpQklK5iGtHrDEJrubiXQeTSk+ hash: v1.k794b7964.128d7bd98d5825f08df13efa9a573b3ca20bc4d3caa04d6a16f40a211c6204fa.opx1P80t_yJe2bLDe67f7MTLDIcCgM3bNV8mQllmPcEscenes-app-inbox-scoutsuggestionsstrip--nothing-left--dark:- hash: v1.k794b7964.669e760714fe3acda90a90713fd40015a8eda10ee6aae7c7628d6820a18a520f.05GoZkCOgwfyr5N54RAer1SGyJIYQKB8D-7g_Cb5PD8+ hash: v1.k794b7964.cb947603948fda90cc6fda9efc2e78e240efb013149e44fee03b2a4cc03b0b41.JaKUyZLXjjLcRrWBABTyco0UmwwTdI8ybIc4tMKPXwMscenes-app-inbox-scoutsuggestionsstrip--nothing-left--light:- hash: v1.k794b7964.6132d08f6269e363d43e27e6908ce8c719099c00bcbf2dadd41516a2c474c85b.fzuFZjcwuJfMmZybduYCmSKdSu8nGl_udgCPRZcZobw+ hash: v1.k794b7964.128d7bd98d5825f08df13efa9a573b3ca20bc4d3caa04d6a16f40a211c6204fa.2-20ggxaJkkZix940eTPRo-2OGdq57oCQI6HxKVz_cYscenes-app-inbox-scoutsuggestionsstrip--scanning--dark:- hash: v1.k794b7964.ea9137550bb6178ace0701c151ddbfb96995042a1fd2fee39b5e296f91aefff0.linffwBWJQGNxcbZoEEtTHjxBkAxvhRoZidzkx95dKQ+ hash: v1.k794b7964.5fbcc9252f49aeb183318dcca95c23e9d59a4404ac77c432b73f1b987e9ad08a.CB6fz41Ol6FjOmV3Hsoz0Qt6ZLuYe9SiNqeL1ZpQiTEscenes-app-inbox-scoutsuggestionsstrip--scanning--light:hash: v1.k794b7964.4e32d9c94dab7dea8dc230f4849626be9c02492cbadc388f9f5e63402d25685a.0TgQOB_KdOjZNo_lB1Jz4JKCrHPX5FO1npJvQ_fIEQ0scenes-app-inbox-scoutsuggestionsstrip--scanning-collapsed--dark:- hash: v1.k794b7964.2974c3ed95c84494b5c8747fbfcc7f715f81c6bce31911aa36315e3115fccf5b.602N2DaHAxZvPeNn7sTTYCu0GtWoNplWEMpbcuUcEMw+ hash: v1.k794b7964.cfcaab9ce0c8a5495a1083d9dc520ecb2c4ca8a0ac2fea7f61ba829235794d09.1nERXNatZa2u2DcXlSGnREIjyGQTDd0Md2YmM-Lufagscenes-app-inbox-scoutsuggestionsstrip--scanning-collapsed--light:- hash: v1.k794b7964.a139550b807301e4832067850ad4527f7f0a25fc721995632b691454d6beb284.cwrpk5fZ1AaNGVJ6KV_U6-1MH77Jl6mrpuSpSc4phpo+ hash: v1.k794b7964.e333bf9dced322d8bdcf542669d8d843dd2cdfcd2b12f535db5b95aafbbfd6b9.kYFG9VRcC3gONE3FQOoc50ywNxZv_Og30-J-I3nhOCcscenes-app-inbox-scoutsuggestionsstrip--scanning-with-nothing-to-show--dark:- hash: v1.k794b7964.872fb6320825913b751e41be16585d7419b56498a04879bb676feb2d45956da7.C4BUY7TTxtlW3k1U-GrjmXwy2jZfou6hg_5EMSFFfa0+ hash: v1.k794b7964.98ef56fe8a6d7dffa479868e4cf24d4156330c6a48bee1eca9155e4cb2110346.7GlpOQ3YdsEJYvAhWYrvb7WgvRE6UTp0pnxILEdvjFYscenes-app-inbox-scoutsuggestionsstrip--scanning-with-nothing-to-show--light:- hash: v1.k794b7964.37e820ce174fc9fd70e27ccf6fc9b8654716abe4013f9e043372555e0ba9829b.XTmTK65QEbkaOkZUc5_2il2RqDeICc_p98_3qdRDBSA+ hash: v1.k794b7964.078d542500d2f482ec93f60ce93929da3dac045f627d59218419061cb3230994.C_J1SBx3KB9EjEmzwMG4eYUw6R69CqnRwGcOppTLq1wscenes-app-inbox-scoutsuggestionsstrip--single-card--dark:- hash: v1.k794b7964.72c82855e6a294d35efdcb3651013f332876ca97d5669150a85ab591f5eed59a.aguVH00mJQ-54JxWvHdeMQle2S-qBC6CcpVy1bjyuBE+ hash: v1.k794b7964.6dd9b783dcb009774567203065cdd77ec36bacef2a08ef84502ea35c2c86cb72.t-v7fppkwj53c7X29aUFc1CePIbHfUFa_kMcz6Q80dcscenes-app-inbox-scoutsuggestionsstrip--single-card--light:- hash: v1.k794b7964.22d44af6322853ac4b62e93606134bf083ffaea4e4edea99c864670715bb8c8d.v-dR4iCxKFuOPrpdJ01v_JUouVxuQe8TM65ELSrFqTw+ hash: v1.k794b7964.583a7067bb09e415f53b1f8a13b76264e2b28a18f4d725a5162dc04182192c4f.PGN_3FMJwvukfMGbCLkWzXX9dDblmI3PWFlGySK4kLcscenes-app-inbox-scoutsuggestionsstrip--stale--dark:- hash: v1.k794b7964.f41b10ad25e74442dd46e735d605949a7f1c6a52099b864d5b32df18cb6c277e.N50quO-8rvUo-m3JJyPXlgoVZLWfTXoyyaT5TJAaKBw+ hash: v1.k794b7964.4356de4ce8daaac66ba9c822a32007d7400eefe9cec57d561c873a82371984bf.rqo1wVyiFOMzZh-Nk2W17ZPodPtTJJO5wtn_mMbNK7cscenes-app-inbox-scoutsuggestionsstrip--stale--light:- hash: v1.k794b7964.256235fc6e9c29b0487f5e02eb9f3aa35b337f784a16ae5ab89325aa04885155.7i88MK5QfCyP7hDVBvmpnddyr0yVxIexj_HoGn2nAgQ+ hash: v1.k794b7964.00796e0b71ec02937541060ec197e245b41b87579280b8341a8a967b5e6196bc.tDmT3J2mXWN-Etx4t4DJNaE5SenbjrPLLBItQUe2NQQscenes-app-inbox-scoutsuggestionsstrip--uneven-motivations--dark:- hash: v1.k794b7964.e110afa6c50a22f1bb3e58160b76950c73672d67f34b1d536846194ecd94ada2.jFU8QIkM0XH7vfaZYlImtR4g7xXplTpE6x8DNNm4KH4+ hash: v1.k794b7964.3fcfb882c7f56b5f301d2a43d18472e505d514c8e359de582b96675f961f93c2.nsNc83Vy-zwOgjTNzGBKm3-8JpyKB7aFliZXHHQFNw8scenes-app-inbox-scoutsuggestionsstrip--uneven-motivations--light:- hash: v1.k794b7964.cd8f04a2768f00a4a8010f1cea58794c2379d9933b2ab2141b605faf53d57836.U_uthHW3YdqOsezpDPlYnSuud_bm3XQ1o-NVFNGqsHQ+ hash: v1.k794b7964.c8b4394889278d90d9a4d657614c1753c95bee3bcc72279af006d8f18952d2ef.6FFOtF06QjkHZmrbYdkSXr0wyBxDEFhiMx80JWeKQCEscenes-app-inbox-scoutwriteaccesstag--compact--dark:hash: v1.k794b7964.449b1898c216f12c6a62f2c0a1544ce814cdc7e4d519c69287d686e8b9a90b79.yXNYamE5tvB24QXwyniqxYtd3IAlRpo-RoLspp9zOKQscenes-app-inbox-scoutwriteaccesstag--compact--light:diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsxindex c0046f795420..f26743142059 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutRosterCard.tsx@@ -36,7 +36,8 @@ function MetaSeparator(): JSX.Element {*/export function ScoutRosterCard({ row }: { row: ScoutRosterRow }): JSX.Element {const { config, group } = row- const { rollups, updatingScoutIds, scoutRunsLoadedOnce, scoutRunCosts } = useValues(scoutFleetLogic)+ const { rollups, updatingScoutIds, scoutRunsLoadedOnce, scoutRunCosts, expensiveRunCostThreshold } =+ useValues(scoutFleetLogic)const { updateScoutConfig } = useActions(scoutFleetLogic)const { currentTeam } = useValues(teamLogic)const now = new Date()@@ -95,7 +96,7 @@ export function ScoutRosterCard({ row }: { row: ScoutRosterRow }): JSX.Element {{/* A fixed strip width on wide rows keeps every row's newest run on one vertical line. */}<div className="flex min-w-0 justify-end @lg:w-52">{runs.length > 0 ? (- <ScoutRunBoxes runs={runs} costs={scoutRunCosts} />+ <ScoutRunBoxes runs={runs} costs={scoutRunCosts} costThreshold={expensiveRunCostThreshold} />) : (// Until the runs request has landed once, an empty rollup means "not// loaded", not "never ran"; the poll retries a failed load on its own.diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.test.tsxindex c387d241aa9f..129a3b20a5b2 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.test.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.test.tsx@@ -44,6 +44,58 @@ describe('ScoutRunBoxes', () => {expect(labels.filter((label) => label.includes('$'))).toHaveLength(1)})+ it('marks the runs at or over the fleet threshold, and leaves the cheap ones plain', () => {+ // Cost only reached the tooltip, so finding an expensive run meant hovering box by box.+ // The marker is the whole point of the change: without it every box looks the same.+ const { container } = render(+ <ScoutRunBoxes+ runs={[+ makeRun({ run_id: 'run-cheap' }),+ makeRun({ run_id: 'run-at' }),+ makeRun({ run_id: 'run-over' }),+ ]}+ costs={+ new Map([+ ['run-cheap', 0.05],+ ['run-at', 0.49],+ ['run-over', 3.19],+ ])+ }+ costThreshold={0.49}+ />+ )++ expect(container.querySelectorAll('.bg-brand-yellow')).toHaveLength(2)+ const labels = Array.from(container.querySelectorAll('.sr-only')).map((node) => node.textContent ?? '')+ expect(labels.filter((label) => label.includes('top 10% of runs by cost'))).toHaveLength(2)+ })++ it('puts the marker inside the task link, so the whole column opens the task run', () => {+ // The tooltip covers the column and offers to open the task run, and the column reserves+ // height above the box for the marker. With the link around the box alone, a click on the+ // marker does nothing on a roster card, and the roster table's row handler sends the+ // reader to the scout page instead.+ const { container } = render(+ <ScoutRunBoxes+ runs={[makeRun({ run_id: 'run-over', task_url: '/project/2/tasks/run-over' })]}+ costs={new Map([['run-over', 3.19]])}+ costThreshold={0.49}+ />+ )++ const link = container.querySelector('a')+ expect(link).toHaveAttribute('href', '/project/2/tasks/run-over')+ expect(link?.querySelector('.bg-brand-yellow')).not.toBeNull()+ })++ it('marks nothing while the fleet has too few priced runs to rank', () => {+ const { container } = render(+ <ScoutRunBoxes runs={[makeRun()]} costs={new Map([['run-1', 3.19]])} costThreshold={null} />+ )++ expect(container.querySelector('.bg-brand-yellow')).toBeNull()+ })+it('leaves every run unpriced when no costs are given', () => {const { container } = render(<ScoutRunBoxes runs={[makeRun()]} />)diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.tsxindex 5c649b230aa3..809b8676ce8a 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.tsx@@ -32,8 +32,12 @@ const OUTCOME_BOX_CLASS: Record<ScoutRunOutcome, string> = {const MAX_BOXES = 24const BOX_CLASS = 'block h-3 w-2 shrink-0 rounded-[2px] transition-transform duration-100 hover:scale-y-125'+// A box column always keeps the marker's height, priced or not, so the strip does not jump a few+// pixels when the costs land a moment after the runs.+const COLUMN_CLASS = 'flex h-4 w-2 shrink-0 flex-col items-center justify-end gap-px'+const MARKER_CLASS = 'block h-[3px] w-2 rounded-[1px] bg-brand-yellow'-function runTooltip(run: SignalScoutRunSummary, now: Date, costUsd: number | undefined): string {+function runTooltip(run: SignalScoutRunSummary, now: Date, costUsd: number | undefined, expensive: boolean): string {const parts = [scoutRunOutcomeLabel(run, now)]const duration = formatRunDuration(runDurationSeconds(run, now))if (duration) {@@ -47,6 +51,11 @@ function runTooltip(run: SignalScoutRunSummary, now: Date, costUsd: number | undif (costUsd !== undefined) {parts.push(formatRunCost(costUsd))}+ // The marker is a colored bar, so say the same thing in words for anyone reading the tooltip+ // or the screen-reader label.+ if (expensive) {+ parts.push('top 10% of runs by cost')+ }return parts.join(' · ')}@@ -67,18 +76,25 @@ function runTooltip(run: SignalScoutRunSummary, now: Date, costUsd: number | undexport function ScoutRunBoxes({runs,costs,+ costThreshold,}: {runs: SignalScoutRunSummary[]costs?: Map<string, number>+ costThreshold?: number | null}): JSX.Element | null {const visible = useMemo(() => {const now = new Date()- return runs.slice(-MAX_BOXES).map((run) => ({- run,- outcome: deriveRunOutcome(run, now),- tooltip: runTooltip(run, now, costs?.get(run.run_id)),- }))- }, [runs, costs])+ return runs.slice(-MAX_BOXES).map((run) => {+ const costUsd = costs?.get(run.run_id)+ const expensive = costUsd !== undefined && costThreshold != null && costUsd >= costThreshold+ return {+ run,+ outcome: deriveRunOutcome(run, now),+ expensive,+ tooltip: runTooltip(run, now, costUsd, expensive),+ }+ })+ }, [runs, costs, costThreshold])if (runs.length === 0) {return null@@ -91,23 +107,30 @@ export function ScoutRunBoxes({return (<div className="flex flex-row-reverse items-center gap-1 min-w-0 overflow-hidden">- {newestFirst.map(({ run, outcome, tooltip }) => {+ {newestFirst.map(({ run, outcome, expensive, tooltip }) => {const boxClass = `${BOX_CLASS} ${OUTCOME_BOX_CLASS[outcome]}`- if (run.task_url) {- const linkTooltip = `${tooltip} · open task run`- return (- <Tooltip key={run.run_id} title={linkTooltip}>- <Link to={run.task_url} className={boxClass}>- <span className="sr-only">Run {linkTooltip}</span>- </Link>- </Tooltip>- )- }+ const boxTooltip = run.task_url ? `${tooltip} · open task run` : tooltip+ const label = <span className="sr-only">Run {boxTooltip}</span>+ const column = (+ <>+ {expensive ? <span className={MARKER_CLASS} /> : null}+ <span className={boxClass}>{label}</span>+ </>+ )+ // The whole column links, not only the box, because the tooltip spans the column+ // and offers to open the task run. A marker left outside the link would not+ // navigate there: the roster card holds no handler above the box, and the roster+ // table's row handler pushes the scout page for every click that is not inside an+ // `a` or `button`.return (- <Tooltip key={run.run_id} title={tooltip}>- <span className={boxClass}>- <span className="sr-only">Run {tooltip}</span>- </span>+ <Tooltip key={run.run_id} title={boxTooltip}>+ {run.task_url ? (+ <Link to={run.task_url} className={COLUMN_CLASS}>+ {column}+ </Link>+ ) : (+ <span className={COLUMN_CLASS}>{column}</span>+ )}</Tooltip>)})}diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutsRosterTable.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutsRosterTable.tsxindex e991c002010e..3f5570beb108 100644--- a/products/signals/frontend/inbox/components/config/scouts/ScoutsRosterTable.tsx+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutsRosterTable.tsx@@ -30,7 +30,8 @@ import { ScoutStatusDot } from './ScoutStatusDot'* nothing to say about a canonical one.*/export function ScoutsRosterTable({ compact }: { compact: boolean }): JSX.Element {- const { rosterScouts, rollups, updatingScoutIds, scoutRunsLoadedOnce, scoutRunCosts } = useValues(scoutFleetLogic)+ const { rosterScouts, rollups, updatingScoutIds, scoutRunsLoadedOnce, scoutRunCosts, expensiveRunCostThreshold } =+ useValues(scoutFleetLogic)const { updateScoutConfig } = useActions(scoutFleetLogic)if (rosterScouts.length === 0) {@@ -139,7 +140,13 @@ export function ScoutsRosterTable({ compact }: { compact: boolean }): JSX.Elemenrender: (_, row: ScoutRosterRow) => {const runs = rollups.get(row.config.skill_name)?.runs ?? []if (runs.length) {- return <ScoutRunBoxes runs={runs} costs={scoutRunCosts} />+ return (+ <ScoutRunBoxes+ runs={runs}+ costs={scoutRunCosts}+ costThreshold={expensiveRunCostThreshold}+ />+ )}// Until the runs request has landed once, an empty rollup means "not// loaded", not "never ran"; the poll retries a failed load on its own.diff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.tsindex ff22d953f814..6d199e75faf6 100644--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.test.ts@@ -916,6 +916,36 @@ describe('scoutFleetLogic', () => {expect(logic.values.scoutRunCosts.size).toBe(0)})+ it('shows a batch as soon as it lands, and sends the rest of the fleet together', async () => {+ // Holding every batch back until the last one answers leaves the whole strip costless+ // for the first seconds after load, which is the window a reader actually looks at.+ const runIds = Array.from({ length: 401 }, (_, index) => `run-${index}`)+ mockSignalsScoutRunsRecentPerScout.mockResolvedValue(runIds.map((run_id) => makeRun({ run_id })))+ const held: Array<() => void> = []+ mockSignalsScoutRunsTokenCosts.mockImplementation(async (_projectId, body) => {+ const costs = [{ run_id: body.run_ids[0], token_cost_usd: 1 }]+ if (!body.run_ids.includes('run-0')) {+ await new Promise<void>((resolve) => held.push(resolve))+ }+ return { costs, available: true }+ })+ await mountAsStaff(true)++ logic.actions.loadScoutRuns()+ await expectLogic(logic).toDispatchActions(['loadScoutRunsSuccess', 'mergeScoutRunCosts'])+ await new Promise((resolve) => setTimeout(resolve, 0))++ expect(logic.values.scoutRunCosts.get('run-0')).toBe(1)+ expect(logic.values.scoutRunCostsLoading).toBe(true)+ expect(held).toHaveLength(2)++ held.forEach((resolve) => resolve())+ await expectLogic(logic).toDispatchActions(['loadScoutRunCostsSuccess'])++ expect(logic.values.scoutRunCosts.get('run-200')).toBe(1)+ expect(logic.values.scoutRunCosts.get('run-400')).toBe(1)+ })+it('keeps the batches that answered when a later batch fails', async () => {// A materialized fleet is more run ids than one request carries, so the loader sends// several. Discarding the whole load over one failed batch blanks every tooltip in thediff --git a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts b/products/signals/frontend/inbox/logics/scoutFleetLogic.tsindex efdc01704b27..3673a729bedb 100644--- a/products/signals/frontend/inbox/logics/scoutFleetLogic.ts+++ b/products/signals/frontend/inbox/logics/scoutFleetLogic.ts@@ -18,6 +18,7 @@ import { lemonToast } from '@posthog/lemon-ui'import { ApiError, isUnavailableEndpointError, shouldReportApiFailure } from 'lib/api-error'import { dayjs } from 'lib/dayjs'+import { chunk } from 'lib/utils/arrays'import { reconcileById } from 'lib/utils/objects'import { aiConsentLogic } from 'scenes/settings/organization/aiConsentLogic'import { teamLogic } from 'scenes/teamLogic'@@ -67,8 +68,10 @@ import type { ScoutOwnerOption } from '../utils/scoutOwners'import {computeFleetSummary,computeScoutRollups,+ expensiveRunCostThreshold,FleetSummary,isSettledRun,+ rosterRunCosts,scoutDisplayName,SCOUT_ROSTER_WINDOW_HOURS,SCOUT_RUNS_PER_SCOUT,@@ -126,6 +129,9 @@ const MAX_RUNS_PAGES = 15// The cost endpoint takes run ids in batches (`SCOUT_RUNS_BATCH_LIMIT` server-side), and a fleet// holds more runs than one batch, so the roster's runs are sent a batch at a time.const RUN_COST_BATCH_LIMIT = 200+// How many batches are in flight together. Enough to hide the round trips of a materialized fleet,+// few enough that one poll cannot queue every other roster request behind its own burst.+const RUN_COST_BATCH_CONCURRENCY = 4// Roster filter state also lives in the URL so a filtered view survives a refresh and is shareable.// The search param is written on this debounce, so typing does not rewrite the URL per keystroke.@@ -224,6 +230,17 @@ function reuseCostsIfUnchanged(previous: Map<string, number>, next: Map<string,return previous}+// Fold a batch of costs into the map on screen, keeping the reference when the batch says nothing+// new. Only a poll that moved a number allocates.+function mergeCosts(previous: Map<string, number>, incoming: Map<string, number>): Map<string, number> {+ for (const [runId, cost] of incoming) {+ if (previous.get(runId) !== cost) {+ return new Map([...previous, ...incoming])+ }+ }+ return previous+}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface scoutFleetLogicValues {dataProcessingAccepted: boolean // aiConsentLogic@@ -242,6 +259,7 @@ export interface scoutFleetLogicValues {scoutCount: number}enabledCount: number+ expensiveRunCostThreshold: number | nullfleetFindingsSummary: FleetFindingsSummaryApi | nullfleetFindingsSummaryLoadedOnce: booleanfleetFindingsSummaryLoading: boolean@@ -409,6 +427,9 @@ export interface scoutFleetLogicActions {materializeScoutFleet: () => {value: true}+ mergeScoutRunCosts: (costs: Map<string, number>) => {+ costs: Map<string, number>+ }patchScoutConfigLocally: (configId: string,updates: Partial<SignalScoutConfig> | SignalScoutConfigUpdate@@ -513,6 +534,10 @@ export interface scoutFleetLogicMeta {dataProcessingApprovalDisabledReason: string | null) => string | nullrollups: (scoutRuns: SignalScoutRunSummary[]) => Map<string, ScoutRollup>+ expensiveRunCostThreshold: (+ scoutRuns: SignalScoutRunSummary[],+ scoutRunCosts: Map<string, number>+ ) => number | nullisStaff: (user: null | import('~/types').UserType) => booleanfleetSummary: (scoutConfigs: SignalScoutConfigApi[] | null,@@ -623,6 +648,7 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([startScoutChatTaskSuccess: true,startScoutChatTaskFailure: true,setScoutFleetSyncOutcome: (outcome: ScoutFleetSyncOutcome) => ({ outcome }),+ mergeScoutRunCosts: (costs: Map<string, number>) => ({ costs }),}),loaders(({ actions, values }) => ({@@ -762,23 +788,42 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([if (!teamId || !values.isStaff || values.scoutRuns.length === 0) {return values.scoutRunCosts}- const runIds = values.scoutRuns.map((run) => run.run_id)+ const batches = chunk(+ values.scoutRuns.map((run) => run.run_id),+ RUN_COST_BATCH_LIMIT+ )const costs = new Map<string, number>()- try {- for (let start = 0; start < runIds.length; start += RUN_COST_BATCH_LIMIT) {- const response = await signalsScoutRunsTokenCosts(String(teamId), {- run_ids: runIds.slice(start, start + RUN_COST_BATCH_LIMIT),- })- breakpoint()- // This deployment has no internal project to price runs against, so the- // remaining batches would answer the same way and each one costs the- // backend a run-row read and a traceback. Every cost stays unknown.- if (!response.available) {- break+ const priceBatch = async (batch: string[]): Promise<boolean> => {+ const response = await signalsScoutRunsTokenCosts(String(teamId), { run_ids: batch })+ breakpoint()+ // This deployment has no internal project to price runs against, so every+ // batch answers the same way and each one costs the backend a run-row read+ // and a traceback. Every cost stays unknown.+ if (!response.available) {+ return false+ }+ const priced = new Map<string, number>()+ for (const cost of response.costs) {+ if (cost.token_cost_usd !== null) {+ priced.set(cost.run_id, cost.token_cost_usd)}- for (const cost of response.costs) {- if (cost.token_cost_usd !== null) {- costs.set(cost.run_id, cost.token_cost_usd)+ }+ for (const [runId, cost] of priced) {+ costs.set(runId, cost)+ }+ actions.mergeScoutRunCosts(priced)+ return true+ }+ try {+ // The first batch also answers whether this deployment prices runs at all,+ // so it goes on its own. The rest go a wave at a time: a materialized fleet+ // is several batches, and holding them all back leaves the whole strip+ // costless until the slowest one answers.+ if (await priceBatch(batches[0])) {+ for (let start = 1; start < batches.length; start += RUN_COST_BATCH_CONCURRENCY) {+ const wave = batches.slice(start, start + RUN_COST_BATCH_CONCURRENCY)+ if ((await Promise.all(wave.map(priceBatch))).includes(false)) {+ break}}}@@ -798,10 +843,7 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([// A full fleet spans several batches, so keep the ones that answered and// leave the rest on their last known number. Dropping the whole load// would blank every tooltip over one failed batch.- return reuseCostsIfUnchanged(- values.scoutRunCosts,- new Map([...values.scoutRunCosts, ...costs])- )+ return mergeCosts(values.scoutRunCosts, costs)}throw error}@@ -873,6 +915,15 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([})),reducers({+ // The loader owns this map's default and its end-of-load write; this half folds in a batch+ // that landed while the rest of the load is still in flight.+ scoutRunCosts: [+ new Map<string, number>(),+ {+ mergeScoutRunCosts: (state: Map<string, number>, { costs }: { costs: Map<string, number> }) =>+ mergeCosts(state, costs),+ },+ ],// Tracks which CTA's chat-task kickoff is mid-flight, keyed by its chat type, so only the// pressed chip spins (the others merely disable). A shared boolean spun all three at once.runningChatType: [@@ -1031,6 +1082,11 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([(s) => [s.scoutRuns],(scoutRuns: SignalScoutRunSummary[]): Map<string, ScoutRollup> => computeScoutRollups(scoutRuns),],+ expensiveRunCostThreshold: [+ (s) => [s.scoutRuns, s.scoutRunCosts],+ (scoutRuns: SignalScoutRunSummary[], scoutRunCosts: Map<string, number>): number | null =>+ expensiveRunCostThreshold(rosterRunCosts(scoutRuns, scoutRunCosts)),+ ],isStaff: [() => [userLogic.selectors.user],(user: null | import('~/types').UserType): boolean => user?.is_staff ?? false,diff --git a/products/signals/frontend/inbox/utils/scoutRunsWindow.test.ts b/products/signals/frontend/inbox/utils/scoutRunsWindow.test.tsindex 660468b0e749..a6daf7519420 100644--- a/products/signals/frontend/inbox/utils/scoutRunsWindow.test.ts+++ b/products/signals/frontend/inbox/utils/scoutRunsWindow.test.ts@@ -5,8 +5,10 @@ import {computeFleetSummary,computeScoutRollups,deriveRunOutcome,+ expensiveRunCostThreshold,formatRunCost,mostRecentEmittedRuns,+ rosterRunCosts,runMatchesFilter,dayTimeToWeeklyCron,getScoutScheduleMode,@@ -79,6 +81,79 @@ describe('scoutRunsWindow report channel', () => {})})+ describe('expensiveRunCostThreshold', () => {+ function costs(values: number[]): Map<string, number> {+ return new Map(values.map((cost, index) => [`run-${index}`, cost]))+ }++ const skewed = [...Array.from({ length: 27 }, (_, index) => 0.02 + index / 1000), 0.6, 0.9, 3.19]++ it('says nothing until enough runs are priced to rank them', () => {+ // A decile over a handful of runs moves with every run that lands, so the marker would+ // point at a different box each poll.+ expect(expensiveRunCostThreshold(costs(skewed.slice(0, 19)))).toBeNull()+ expect(expensiveRunCostThreshold(costs(skewed.slice(0, 20)))).not.toBeNull()+ })++ it('says nothing when every run costs the same', () => {+ // A flat fleet has no top decile to point at, and a marker over every box is noise.+ expect(expensiveRunCostThreshold(costs(Array.from({ length: 30 }, () => 0.05)))).toBeNull()+ })++ it('lands the line above the cheap majority when spend is skewed', () => {+ // Scout spend is heavily skewed: the priciest run costs 50 times the median. The line+ // has to leave that cheap median unmarked, or the marker points at the whole strip.+ // A fleet of 30 runs has 3 runs in its priciest tenth, and the line marks those 3.+ const threshold = expensiveRunCostThreshold(costs(skewed)) ?? 0++ expect(skewed.filter((cost) => cost >= threshold)).toEqual([0.6, 0.9, 3.19])+ })++ // When most of the fleet shares one cheap price, that price sits on the decile boundary,+ // and a line at the boundary would mark the whole strip. The priciest runs still have to+ // carry the marker.+ it.each<[string, number[], number[]]>([+ ['two priciest runs', [...Array.from({ length: 18 }, () => 0.02), 1.5, 3.19], [1.5, 3.19]],+ ['one priciest run', [...Array.from({ length: 19 }, () => 0.02), 3.19], [3.19]],+ ])('marks the %s when the cheap majority shares one price', (_name, values, expected) => {+ const threshold = expensiveRunCostThreshold(costs(values)) ?? 0++ expect(values.filter((cost) => cost >= threshold)).toEqual(expected)+ })+ })++ describe('rosterRunCosts', () => {+ it('drops the cost of a run that has left the roster', () => {+ const runs = [makeRun({ run_id: 'run-1' }), makeRun({ run_id: 'run-2' })]+ const costs = new Map([+ ['run-1', 0.02],+ ['run-2', 0.03],+ ['run-gone', 9.99],+ ])++ expect(rosterRunCosts(runs, costs)).toEqual(+ new Map([+ ['run-1', 0.02],+ ['run-2', 0.03],+ ])+ )+ })++ it('keeps a run that has left the roster from turning the cost marker on', () => {+ // A cost batch that fails keeps the previous poll's entries, so a run nobody can see+ // could otherwise carry the map over the minimum and rank a line the strip has no+ // runs for.+ const runs = Array.from({ length: 19 }, (_, index) => makeRun({ run_id: `run-${index}` }))+ const costs = new Map<string, number>([+ ...runs.map((run, index): [string, number] => [run.run_id, 0.02 + index / 1000]),+ ['run-gone', 9.99],+ ])++ expect(expensiveRunCostThreshold(costs)).not.toBeNull()+ expect(expensiveRunCostThreshold(rosterRunCosts(runs, costs))).toBeNull()+ })+ })+describe('runMatchesFilter', () => {it('keeps a report-authoring run out of Quiet and inside Emitted', () => {const run = makeRun({ emitted_report_ids: ['r-1'] })diff --git a/products/signals/frontend/inbox/utils/scoutRunsWindow.ts b/products/signals/frontend/inbox/utils/scoutRunsWindow.tsindex 836c824a36d3..2ba3319bfd8d 100644--- a/products/signals/frontend/inbox/utils/scoutRunsWindow.ts+++ b/products/signals/frontend/inbox/utils/scoutRunsWindow.ts@@ -158,6 +158,48 @@ export function formatRunCost(costUsd: number): string {return humanFriendlyCurrency(costUsd, costUsd > 0 && costUsd < 0.01 ? 4 : 2)}+/**+ * The costs of the runs the roster holds right now. A cost batch that fails keeps the previous+ * poll's entries, so the cost map can outlive the runs it priced. A run that has left the roster is+ * invisible on the strip, so it must not move the cost line or count toward the minimum that turns+ * the line on.+ */+export function rosterRunCosts(runs: SignalScoutRunSummary[], costs: Map<string, number>): Map<string, number> {+ const onRoster = new Map<string, number>()+ for (const run of runs) {+ const cost = costs.get(run.run_id)+ if (cost !== undefined) {+ onRoster.set(run.run_id, cost)+ }+ }+ return onRoster+}++// Below this many priced runs the top decile moves with every run that lands, so the marker would+// point at a different box each poll and mean nothing.+const MIN_PRICED_RUNS_FOR_COST_MARKER = 20++/**+ * What the fleet's priciest tenth of runs starts at, or null while too few runs are priced to rank+ * them. Scout spend is heavily skewed: most runs cost about a cent, so a top-decile line is what+ * separates a run worth opening from the cheap majority.+ */+export function expensiveRunCostThreshold(costs: Map<string, number>): number | null {+ if (costs.size < MIN_PRICED_RUNS_FOR_COST_MARKER) {+ return null+ }+ const sorted = [...costs.values()].sort((a, b) => a - b)+ // The cheapest run inside the priciest tenth, so a line here marks that tenth and no more.+ const decileStart = sorted[sorted.length - Math.ceil(sorted.length * 0.1)]+ if (decileStart > sorted[0]) {+ return decileStart+ }+ // More than nine tenths of the fleet costs the cheapest price, so a line at the decile would+ // mark every box. Mark what costs more than that price instead, which is nothing at all when+ // every run costs the same.+ return sorted.find((cost) => cost > sorted[0]) ?? null+}+/*** Scout runs are hard-killed at the ~31-minute Temporal activity deadline and* surface as bare "failed" with no error field. Until the serializer carries a