Skip to content

: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.

feat(notebooks): add a flag that shows the sandbox rate crossed out at $0.00 (#97314)

Sinan Kucukkoselerc3c311fe18ad
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index b511b4273dbe..087adbbc10ea 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8308,18 +8308,22 @@ snapshots:
hash: v1.k794b7964.434383db5739f05638540be4be2f7671cdb35cca73c32df11f324feb17f3685c.suVpXuPkYmQJtBx6L0JVf4p_bj929kIWSY2fds0lPfw
scenes-app-notebooks-components-notebook-select-button--with-slow-network-response--light:
hash: v1.k794b7964.678b0f73befa0690622fd5eb7a920f5c25919af7a9b516a08756e866b37de352.QhzKGfEQA_MQykTL8uuyOryngt75iNv9BydvL5ckPjQ
+ scenes-app-notebooks-kernel-info--free-compute--dark:
+ hash: v1.k794b7964.9f16845ad724b67d68cd068ab5a2f8ca6fc8ab83e710d6e2f28b113fe09b9171._s-RfNP8c5cc0e10ja9PrgPhUh70q_D7letZIoo0vf8
+ scenes-app-notebooks-kernel-info--free-compute--light:
+ hash: v1.k794b7964.eeefc7496054ed3acf0758c2728eb92448a079e8e100bd5f83d95009d87c5553.DqEbRSwEidVqUbSHir-u4pSMfQ7Uh9bfQs-IE1DerWQ
scenes-app-notebooks-kernel-info--running-on-a-preset--dark:
- hash: v1.k794b7964.d62b25b6e0f4fff01b9df44f2f40e0b24cf7e6329dca8e9f6091ad9ea88f017d.wdVwj4YTiAv4gmWs6lmZTH6lWwlUqSbogrXazNvRfI8
+ hash: v1.k794b7964.677cbd7a30829cd3e0e808d46a387ab581b8096c8c67e9e6bd6395e4653558d9.JDYjW_JJS7soXBbosLLG7g_xssiymwwkNcQNmF00T4s
scenes-app-notebooks-kernel-info--running-on-a-preset--light:
- hash: v1.k794b7964.ebc33548c9baf8e642e685eae0264bb557ba88ceb8032bba24eb834005089bc2.SF6y4mNNp--Yrl7XCZXa2SyGyDxM_tkiOrQROWAlouk
+ hash: v1.k794b7964.673dc5cd5a03d75346cef3c8e1293a8e66dbd90edbceddf6a040bec1b5078147.NtxH0gn0hrkTq2tyEi7fD5PiuVOpXNPVmyv91QcrtRs
scenes-app-notebooks-kernel-info--stopped-on-docker--dark:
- hash: v1.k794b7964.d62b25b6e0f4fff01b9df44f2f40e0b24cf7e6329dca8e9f6091ad9ea88f017d.dvIvjZF5xvw5NpLVzfIks8i7MFnIDcvnG2Fpd92Y-Go
+ hash: v1.k794b7964.d4d47762ad9e9b7dee1962999a8a10eb7bc5e1b799a32718047763fa477bc0f2.BMgw1xsCY97eGl6rVy_9vI6mhgT34U5ISlcpNT-etNg
scenes-app-notebooks-kernel-info--stopped-on-docker--light:
- hash: v1.k794b7964.ebc33548c9baf8e642e685eae0264bb557ba88ceb8032bba24eb834005089bc2.Fu-cPnrGmbGNohBcFtwNqF_ueQnGg0sMTFXSY0pwCc4
+ hash: v1.k794b7964.8966d7960865a6c20149572d8a27c3bc66304fd2cd7109d7e9b4d4010603bb42.pahxDY_fRgb8hrmB0SQt4Glpi6x_Yb--W934Xvktx60
scenes-app-notebooks-kernel-info--tuned-by-hand--dark:
- hash: v1.k794b7964.d62b25b6e0f4fff01b9df44f2f40e0b24cf7e6329dca8e9f6091ad9ea88f017d.rthWhOQfoKEqDMuIGx_ZOmvmroexiFo8wln3H6uwFFw
+ hash: v1.k794b7964.315164254176c2572be6094fffd5fee014b405ad7ec1517166408d485a3c2fb5.8LpJDGyNL_xPSE7u9XoFpHkQMH1-BfL8JImtv2w5qW4
scenes-app-notebooks-kernel-info--tuned-by-hand--light:
- hash: v1.k794b7964.ebc33548c9baf8e642e685eae0264bb557ba88ceb8032bba24eb834005089bc2.vMOgc8ABwVSTG1B4eojy8V3xDViIPDZj3BmBVCkvXyc
+ hash: v1.k794b7964.de7fd0786989fbb2a529f1828c004adb9a23866be08f8e36830cf716d49938f9.4TjG4Kh-L6jHhWakS4GiSz8BHUnV6B9xahTdNfKjd5k
scenes-app-notebooks-nodes-customer-journey--all-steps-completed--dark:
hash: v1.k794b7964.21a8db46b074c796548d4e0fc63caf6443807d16fc5bf18de4d8702336870cd8.F16rPJkkmnadbRylNt9D1y4vd-_qggONDZaX0ErA27g
scenes-app-notebooks-nodes-customer-journey--all-steps-completed--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 1b0a3d9ab835..b6f92948759f 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -409,6 +409,7 @@ export const FEATURE_FLAGS = {
NEW_TAB_PROJECT_EXPLORER: 'new-tab-project-explorer', // owner: #team-platform-ux
NEW_TEAM_CORE_EVENTS: 'new-team-core-events', // owner: @jabahamondes #team-web-analytics
NOTEBOOK_GENERATED_WIDGETS: 'notebook-generated-widgets', // owner: #team-data-tools
+ NOTEBOOK_SANDBOX_FREE_COMPUTE: 'notebook-sandbox-free-compute', // owner: #team-data-tools, shows the notebook sandbox rate crossed out at $0.00 / h
NOTEBOOK_SHARING: 'notebook-sharing', // owner: @reecejones #team-platform-features
ONBOARDING_AI_REPORTS: 'onboarding-role-notifications', // owner: @joethreepwood #team-growth multivariate=control,test — offers a role-tailored weekly AI report step at the end of onboarding; code additionally gates on AI subscriptions being available, so keep the flag at 100% rollout (key predates the AI-reports naming; it's bound to the live experiment)
ONBOARDING_DATA_WAREHOUSE_VALUE_PROP: 'onboarding-data-warehouse-value-prop', // owner: @fercgomes #team-growth multivariate=control,table,query
diff --git a/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.test.ts b/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.test.ts
index 4f4de4c759fa..cda9b065aba7 100644
--- a/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.test.ts
+++ b/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.test.ts
@@ -1,9 +1,12 @@
+import { render } from '@testing-library/react'
import { expectLogic } from 'kea-test-utils'
import api from 'lib/api'
import { ApiError } from 'lib/api-error'
import { JSONContent } from 'lib/components/RichContentEditor/types'
+import { FEATURE_FLAGS } from 'lib/constants'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { initKeaTests } from '~/test/init'
@@ -17,6 +20,9 @@ import {
sqlV2RunErrorMessage,
} from './notebookNodeSQLV2Logic'
+const renderToastText = (message: string | JSX.Element): string =>
+ typeof message === 'string' ? message : (render(message).container.textContent ?? '')
+
describe('notebookNodeSQLV2Logic', () => {
let logic: ReturnType<typeof notebookNodeSQLV2Logic.build>
let updateAttributes: jest.Mock
@@ -237,19 +243,29 @@ describe('notebookNodeSQLV2Logic', () => {
// backend decides it at dispatch. A client that guesses from a kernel poll either bills a
// user twice for one sandbox or starts a paid one in silence.
test.each([
- ['names the rate when the run starts a paid sandbox', true, 0.25, ['compute sandbox at $0.25 / h']],
+ ['names the rate when the run starts a paid sandbox', true, 0.25, false, ['compute sandbox at $0.25 / h']],
+ [
+ 'strikes the rate through to $0.00 when the free compute flag is on',
+ true,
+ 0.25,
+ true,
+ ['compute sandbox at $0.25 / h $0.00 / h while it runs'],
+ ],
// The unpriced branch is the only one that ends the sentence here, so matching it also
// proves no rate was quoted.
- ['announces without a rate when the run reports no price', true, null, ['compute sandbox. The cell']],
- ['stays quiet when the run reuses a running sandbox', false, null, []],
- ])('%s', async (_name, startsSandbox, price, expected) => {
+ ['announces without a rate when the run reports no price', true, null, false, ['compute sandbox. The cell']],
+ ['stays quiet when the run reuses a running sandbox', false, null, false, []],
+ ])('%s', async (_name, startsSandbox, price, freeCompute, expected) => {
+ featureFlagLogic.actions.setFeatureFlags(freeCompute ? [FEATURE_FLAGS.NOTEBOOK_SANDBOX_FREE_COMPUTE] : [], {
+ [FEATURE_FLAGS.NOTEBOOK_SANDBOX_FREE_COMPUTE]: freeCompute,
+ })
runSpy.mockResolvedValue({ run_id: 'r1', starts_sandbox: startsSandbox, sandbox_hourly_price: price })
const toastSpy = jest.spyOn(lemonToast, 'info')
mount()
logic.actions.runQuery('select * from new_events', { new_events: { node_id: 'py', kind: 'local' } })
await expectLogic(logic).toFinishAllListeners()
- expect(toastSpy.mock.calls.map(([message]) => message)).toEqual(
+ expect(toastSpy.mock.calls.map(([message]) => renderToastText(message))).toEqual(
expected.map((fragment) => expect.stringContaining(fragment))
)
})
diff --git a/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.ts b/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.ts
index f0e605d66998..b3d22dbd2fb9 100644
--- a/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.ts
+++ b/frontend/src/scenes/notebooks/Nodes/notebookNodeSQLV2Logic.ts
@@ -16,7 +16,9 @@ import {
import api from 'lib/api'
import { ApiError } from 'lib/api-error'
import { JSONContent } from 'lib/components/RichContentEditor/types'
+import { FEATURE_FLAGS } from 'lib/constants'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { notebookKernelInfoLogic } from '../Notebook/notebookKernelInfoLogic'
import {
@@ -27,6 +29,7 @@ import {
import { NotebookOperation, notebookOperationsLogic } from '../Notebook/notebookOperationsLogic'
import { notebookSettingsLogic } from '../Notebook/notebookSettingsLogic'
import { NotebookVariable } from '../Notebook/notebookVariables'
+import { sandboxStartMessage } from '../Notebook/SandboxStartMessage'
import { NotebookNodeType } from '../types'
import {
buildNotebookDependencyGraph,
@@ -162,6 +165,7 @@ export interface NotebookNodeSQLV2LogicProps {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface notebookNodeSQLV2LogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
chainQueue: string[] // notebookNodeStalenessLogic
isChainRunning: boolean // notebookNodeStalenessLogic
lastRunNodeId: string | null // notebookNodeStalenessLogic
@@ -172,6 +176,7 @@ export interface notebookNodeSQLV2LogicValues {
directRows: NotebookNodeSQLV2DirectRows | null
isInterrupting: boolean
isRunning: boolean
+ isSandboxComputeFree: boolean
isStale: boolean
operationBlockReason: string | null
page: number
@@ -286,6 +291,7 @@ export interface notebookNodeSQLV2LogicActions {
export interface notebookNodeSQLV2LogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
+ isSandboxComputeFree: (featureFlags: FeatureFlagsSet) => boolean
operationBlockReason: (activeOperation: NotebookOperation | null) => string | null
isStale: (staleNodeIds: Record<string, NotebookStaleReason>) => boolean
staleReason: (staleNodeIds: Record<string, NotebookStaleReason>) => NotebookStaleReason | null
@@ -306,6 +312,8 @@ export const notebookNodeSQLV2Logic = kea<notebookNodeSQLV2LogicType>([
key((props) => props.nodeId),
connect((props: NotebookNodeSQLV2LogicProps) => ({
values: [
+ featureFlagLogic,
+ ['featureFlags'],
notebookOperationsLogic({ shortId: props.notebookShortId }),
['activeOperation', 'isBusy'],
notebookNodeStalenessLogic({ shortId: props.notebookShortId }),
@@ -610,12 +618,7 @@ export const notebookNodeSQLV2Logic = kea<notebookNodeSQLV2LogicType>([
// toast too. A user who runs a Python cell never opens the panel deliberately and
// would otherwise start paid compute without being told what it costs. The price
// is null for a local docker kernel, which is free.
- lemonToast.info(
- hourlyPrice == null
- ? 'Starting a compute sandbox. The cell will run once it’s ready.'
- : `Starting a compute sandbox at $${hourlyPrice.toFixed(2)} / h while it runs. ` +
- 'Change its size in the kernel panel.'
- )
+ lemonToast.info(sandboxStartMessage(hourlyPrice, values.isSandboxComputeFree))
},
runNode: ({ overrides }) => {
const content = props.getContent?.() ?? null
@@ -798,6 +801,10 @@ export const notebookNodeSQLV2Logic = kea<notebookNodeSQLV2LogicType>([
}
}),
selectors(({ props }) => ({
+ isSandboxComputeFree: [
+ (s) => [s.featureFlags],
+ (featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.NOTEBOOK_SANDBOX_FREE_COMPUTE],
+ ],
// Set while another node's operation is in flight — wire into disabledReason props.
operationBlockReason: [
(s) => [s.activeOperation],
diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookKernelInfo.stories.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookKernelInfo.stories.tsx
index 2bec5ba2d8b9..7e2878cd46f0 100644
--- a/frontend/src/scenes/notebooks/Notebook/NotebookKernelInfo.stories.tsx
+++ b/frontend/src/scenes/notebooks/Notebook/NotebookKernelInfo.stories.tsx
@@ -1,9 +1,11 @@
import { Meta, StoryObj } from '@storybook/react'
import { BindLogic } from 'kea'
+import { FEATURE_FLAGS } from 'lib/constants'
+
import { mswDecorator } from '~/mocks/browser'
+import { MockSignature } from '~/mocks/utils'
-import { NotebookType } from '../types'
import notebook12345Json from './__mocks__/notebook-12345.json'
import { NotebookKernelInfo } from './NotebookKernelInfo'
import { notebookLogic } from './notebookLogic'
@@ -67,6 +69,16 @@ const kernelStatus = (overrides: Record<string, unknown> = {}): Record<string, u
...overrides,
})
+// The notebook arrives over the mocked API rather than through notebookLogic's
+// cachedNotebook prop. That prop marks the notebook as shared, and notebookKernelInfoLogic
+// skips its whole load for a shared notebook, so every story here would snapshot an empty
+// "Kernel status is unavailable" panel.
+const apiMocks = (kernelOverrides: Record<string, unknown> = {}): Record<string, MockSignature> => ({
+ [`/api/projects/:team_id/notebooks/${SHORT_ID}`]: notebook12345Json,
+ [`/api/projects/:team_id/notebooks/${SHORT_ID}/kernel/status`]: kernelStatus(kernelOverrides),
+ '/api/projects/:team_id/notebooks/kernel/compute_options': COMPUTE_OPTIONS,
+})
+
const meta: Meta<typeof NotebookKernelInfo> = {
title: 'Scenes-App/Notebooks/Kernel info',
component: NotebookKernelInfo,
@@ -74,10 +86,7 @@ const meta: Meta<typeof NotebookKernelInfo> = {
// Its price column is the piece most at risk of wrapping when a preset name grows.
decorators: [
(Story) => (
- <BindLogic
- logic={notebookLogic}
- props={{ shortId: SHORT_ID, cachedNotebook: notebook12345Json as unknown as NotebookType }}
- >
+ <BindLogic logic={notebookLogic} props={{ shortId: SHORT_ID }}>
<div className="w-[20rem]">
<Story />
</div>
@@ -94,42 +103,22 @@ export default meta
type Story = StoryObj<typeof NotebookKernelInfo>
export const RunningOnAPreset: Story = {
- decorators: [
- mswDecorator({
- get: {
- [`/api/projects/:team_id/notebooks/${SHORT_ID}/kernel/status`]: kernelStatus(),
- '/api/projects/:team_id/notebooks/kernel/compute_options': COMPUTE_OPTIONS,
- },
- }),
- ],
+ decorators: [mswDecorator({ get: apiMocks() })],
+}
+
+export const FreeCompute: Story = {
+ parameters: { featureFlags: [FEATURE_FLAGS.NOTEBOOK_SANDBOX_FREE_COMPUTE] },
+ decorators: [mswDecorator({ get: apiMocks() })],
}
export const TunedByHand: Story = {
decorators: [
mswDecorator({
- get: {
- [`/api/projects/:team_id/notebooks/${SHORT_ID}/kernel/status`]: kernelStatus({
- cpu_cores: 6,
- memory_gb: 32,
- hourly_price: 2,
- preset_key: null,
- }),
- '/api/projects/:team_id/notebooks/kernel/compute_options': COMPUTE_OPTIONS,
- },
+ get: apiMocks({ cpu_cores: 6, memory_gb: 32, hourly_price: 2, preset_key: null }),
}),
],
}
export const StoppedOnDocker: Story = {
- decorators: [
- mswDecorator({
- get: {
- [`/api/projects/:team_id/notebooks/${SHORT_ID}/kernel/status`]: kernelStatus({
- backend: 'docker',
- status: 'stopped',
- }),
- '/api/projects/:team_id/notebooks/kernel/compute_options': COMPUTE_OPTIONS,
- },
- }),
- ],
+ decorators: [mswDecorator({ get: apiMocks({ backend: 'docker', status: 'stopped' }) })],
}
diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookKernelInfo.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookKernelInfo.tsx
index 454cd5a5fed6..c732b443479e 100644
--- a/frontend/src/scenes/notebooks/Notebook/NotebookKernelInfo.tsx
+++ b/frontend/src/scenes/notebooks/Notebook/NotebookKernelInfo.tsx
@@ -9,6 +9,7 @@ import { LemonTextArea } from 'lib/lemon-ui/LemonTextArea'
import { LemonWidget } from 'lib/lemon-ui/LemonWidget'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { useAttachedLogic } from 'lib/logic/scenes/useAttachedLogic'
+import { SandboxHourlyPrice } from 'scenes/notebooks/Notebook/SandboxHourlyPrice'
import { idleTimeoutOptions, notebookKernelInfoLogic } from './notebookKernelInfoLogic'
import { notebookLogic } from './notebookLogic'
@@ -26,10 +27,9 @@ const formatMemory = (value: number): string => {
return `${value} GB`
}
-const formatHourlyPrice = (value: number): string => `$${value.toFixed(2)} / h`
-
const PRICE_TOOLTIP =
'Billed for as long as the sandbox runs, whether or not a cell is running. Stop it to stop the charge.'
+const FREE_PRICE_TOOLTIP = 'Your organization is not charged for this sandbox. The usual rate is shown crossed out.'
export const NotebookKernelInfo = (): JSX.Element => {
const { shortId, isShared } = useValues(notebookLogic)
@@ -58,6 +58,7 @@ export const NotebookKernelInfo = (): JSX.Element => {
computePresets,
selectedPresetKey,
selectedHourlyPrice,
+ isSandboxComputeFree,
computeBlockedReason,
computeOptionsFailed,
} = useValues(logic)
@@ -176,8 +177,10 @@ export const NotebookKernelInfo = (): JSX.Element => {
{isModalKernel && selectedHourlyPrice != null ? (
<div className="flex items-center justify-between text-xs">
<span className="font-semibold text-muted">Sandbox price</span>
- <Tooltip title={PRICE_TOOLTIP}>
- <span className="font-semibold">{formatHourlyPrice(selectedHourlyPrice)}</span>
+ <Tooltip title={isSandboxComputeFree ? FREE_PRICE_TOOLTIP : PRICE_TOOLTIP}>
+ <span className="font-semibold">
+ <SandboxHourlyPrice value={selectedHourlyPrice} isFree={isSandboxComputeFree} />
+ </span>
</Tooltip>
</div>
) : null}
@@ -218,7 +221,10 @@ export const NotebookKernelInfo = (): JSX.Element => {
</span>
</span>
<span className="font-semibold whitespace-nowrap">
- {formatHourlyPrice(preset.hourly_price)}
+ <SandboxHourlyPrice
+ value={preset.hourly_price}
+ isFree={isSandboxComputeFree}
+ />
</span>
</div>
</LemonButton>
diff --git a/frontend/src/scenes/notebooks/Notebook/SandboxHourlyPrice.tsx b/frontend/src/scenes/notebooks/Notebook/SandboxHourlyPrice.tsx
new file mode 100644
index 000000000000..08abd880703c
--- /dev/null
+++ b/frontend/src/scenes/notebooks/Notebook/SandboxHourlyPrice.tsx
@@ -0,0 +1,18 @@
+export const formatHourlyPrice = (value: number): string => `$${value.toFixed(2)} / h`
+
+export type SandboxHourlyPriceProps = {
+ /** USD per hour. */
+ value: number
+ isFree: boolean
+}
+
+export const SandboxHourlyPrice = ({ value, isFree }: SandboxHourlyPriceProps): JSX.Element => {
+ if (!isFree) {
+ return <span translate="no">{formatHourlyPrice(value)}</span>
+ }
+ return (
+ <span translate="no">
+ <s className="text-muted font-normal">{formatHourlyPrice(value)}</s> <span>{formatHourlyPrice(0)}</span>
+ </span>
+ )
+}
diff --git a/frontend/src/scenes/notebooks/Notebook/SandboxStartMessage.tsx b/frontend/src/scenes/notebooks/Notebook/SandboxStartMessage.tsx
new file mode 100644
index 000000000000..8b8a7c6b57a0
--- /dev/null
+++ b/frontend/src/scenes/notebooks/Notebook/SandboxStartMessage.tsx
@@ -0,0 +1,14 @@
+import { SandboxHourlyPrice } from './SandboxHourlyPrice'
+
+// A null price means a local docker kernel, which has no rate to quote.
+export const sandboxStartMessage = (hourlyPrice: number | null, isFree: boolean): string | JSX.Element => {
+ if (hourlyPrice == null) {
+ return 'Starting a compute sandbox. The cell will run once it’s ready.'
+ }
+ return (
+ <>
+ Starting a compute sandbox at <SandboxHourlyPrice value={hourlyPrice} isFree={isFree} /> while it runs.
+ Change its size in the kernel panel.
+ </>
+ )
+}
diff --git a/frontend/src/scenes/notebooks/Notebook/notebookKernelInfoLogic.ts b/frontend/src/scenes/notebooks/Notebook/notebookKernelInfoLogic.ts
index b78b6cdad92f..552e595e7cdf 100644
--- a/frontend/src/scenes/notebooks/Notebook/notebookKernelInfoLogic.ts
+++ b/frontend/src/scenes/notebooks/Notebook/notebookKernelInfoLogic.ts
@@ -2,6 +2,7 @@ import {
MakeLogicType,
actions,
afterMount,
+ connect,
getContext,
kea,
key,
@@ -15,6 +16,8 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { ApiConfig } from 'lib/api'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { notebooksKernelComputeOptionsRetrieve } from 'products/notebooks/frontend/generated/api'
import type {
@@ -116,6 +119,7 @@ const findClosestOptionIndex = (options: number[], value?: number | null): numbe
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface notebookKernelInfoLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
actionInFlight: KernelActionInFlight
code: string
computeBlockedReason: 'Compute rates are unavailable. Refresh to try again.' | 'Loading compute rates' | null
@@ -137,6 +141,7 @@ export interface notebookKernelInfoLogicValues {
isEditingConfig: boolean
isModalKernel: boolean
isRunning: boolean
+ isSandboxComputeFree: boolean
isStarting: boolean
kernelInfo: NotebookKernelInfo | null
kernelInfoLoading: boolean
@@ -267,6 +272,7 @@ export interface notebookKernelInfoLogicActions {
export interface notebookKernelInfoLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
+ isSandboxComputeFree: (featureFlags: FeatureFlagsSet) => boolean
isRunning: (kernelInfo: NotebookKernelInfo | null) => boolean
statusInfo: (
kernelInfo: NotebookKernelInfo | null,
@@ -326,6 +332,9 @@ export const notebookKernelInfoLogic = kea<notebookKernelInfoLogicType>([
props({} as NotebookKernelInfoLogicProps),
path((key) => ['scenes', 'notebooks', 'Notebook', 'notebookKernelInfoLogic', key]),
key(({ shortId }) => shortId),
+ connect(() => ({
+ values: [featureFlagLogic, ['featureFlags']],
+ })),
actions({
executeKernel: (code) => ({ code }),
setCode: (code: string) => ({ code }),
@@ -477,6 +486,10 @@ export const notebookKernelInfoLogic = kea<notebookKernelInfoLogicType>([
],
})),
selectors({
+ isSandboxComputeFree: [
+ (s) => [s.featureFlags],
+ (featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.NOTEBOOK_SANDBOX_FREE_COMPUTE],
+ ],
isRunning: [
(s) => [s.kernelInfo],
(kernelInfo: NotebookKernelInfo | null) =>