Repository navigation
v0.9.40: shared file streaming, paid plan for chat, workbench stop fix #9552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cdff0e5
fix(sandbox): initialize workbench history before honoring a stop dur…
waleedlatif1 1defff3
fix(public-shares): stream shared files with byte ranges instead of b…
waleedlatif1 9491d3f
feat(billing): require a paid plan or prepaid credits for Chat (#9551)
waleedlatif1 f8a561d
fix(billing): fail closed on legacy Chat payer reads and cover the Ch…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat-plan-gate.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| 'use client' | ||
|
|
||
| import { useCallback } from 'react' | ||
| import { toast } from '@sim/emcn' | ||
| import { useRouter } from 'next/navigation' | ||
| import { useSession } from '@/lib/auth/client' | ||
| import { CHAT_PLAN_REQUIRED_MESSAGE } from '@/lib/billing/chat-plan' | ||
| import { buildUpgradeHref } from '@/lib/billing/upgrade-reasons' | ||
| import { canManageWorkspaceBilling } from '@/lib/billing/workspace-permissions' | ||
| import { useOptionalWorkspaceHostContext } from '@/app/workspace/[workspaceId]/providers/workspace-host-provider' | ||
|
|
||
| /** | ||
| * Stops a send from a workspace whose payer may not use Chat before it starts a turn that run | ||
| * admission would refuse. A member who can manage the workspace's billing goes to its upgrade | ||
| * page; anyone else is told who can upgrade. The returned callback reports whether the send was | ||
| * stopped. | ||
| * | ||
| * The verdict is the host context's `features.chat`, which the server resolves with the same | ||
| * check admission runs. A surface without a workspace host (an organization conversation), or a | ||
| * context that predates the flag, is not stopped here; admission still answers it with the | ||
| * upgrade card. | ||
| */ | ||
| export function useChatPlanGate(): () => boolean { | ||
| const hostContext = useOptionalWorkspaceHostContext() | ||
| const { data: session } = useSession() | ||
| const viewerId = session?.user?.id | ||
| const router = useRouter() | ||
|
|
||
| return useCallback(() => { | ||
| if (!hostContext || hostContext.features?.chat !== false) return false | ||
|
|
||
| if (canManageWorkspaceBilling(hostContext, viewerId)) { | ||
| router.push(buildUpgradeHref(hostContext.workspace.id)) | ||
| } else { | ||
| toast.error( | ||
| hostContext.hostOrganizationId | ||
| ? `${CHAT_PLAN_REQUIRED_MESSAGE} Contact an organization admin to upgrade this workspace’s plan.` | ||
| : `${CHAT_PLAN_REQUIRED_MESSAGE} Ask the workspace owner to upgrade this workspace’s plan.` | ||
| ) | ||
| } | ||
| return true | ||
| }, [hostContext, viewerId, router]) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| /** The upgrade card's `reason` for a payer whose plan does not include Chat. */ | ||
| export const CHAT_PLAN_REQUIRED_REASON = 'plan_required' as const | ||
|
|
||
| /** Lead sentence of every refusal that withholds Chat from a plan. */ | ||
| export const CHAT_PLAN_REQUIRED_MESSAGE = 'Chat is included on paid plans.' |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.