Skip to content

Commit af93b6f

Browse files
committed
Don't allow escaping the subscription limit banner unless you click to use credits
1 parent 7c7710e commit af93b6f

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

cli/src/components/subscription-limit-banner.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ export const SubscriptionLimitBanner = () => {
6565
open(WEBSITE_URL + '/pricing')
6666
}
6767

68-
const handleWait = () => {
69-
setInputMode('default')
70-
}
71-
7268
const borderColor = isWeeklyLimit ? theme.error : theme.warning
7369

7470
return (
@@ -169,9 +165,6 @@ export const SubscriptionLimitBanner = () => {
169165
<text style={{ fg: theme.background, bg: theme.muted }}>{' '}Buy Credits ↗{' '}</text>
170166
</Button>
171167
)}
172-
<Button onClick={handleWait}>
173-
<text style={{ fg: theme.background, bg: theme.muted }}>{' '}Wait{' '}</text>
174-
</Button>
175168
</>
176169
)}
177170
</box>

cli/src/utils/input-modes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export type InputModeConfig = {
4040
showAgentModeToggle: boolean
4141
/** Whether to disable slash command suggestions */
4242
disableSlashSuggestions: boolean
43+
/** Whether keyboard shortcuts (Escape, Backspace) can exit this mode */
44+
blockKeyboardExit: boolean
4345
}
4446

4547
export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
@@ -50,6 +52,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
5052
widthAdjustment: 0,
5153
showAgentModeToggle: true,
5254
disableSlashSuggestions: false,
55+
blockKeyboardExit: false,
5356
},
5457
bash: {
5558
icon: '!',
@@ -58,6 +61,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
5861
widthAdjustment: 2, // 1 char + 1 padding
5962
showAgentModeToggle: false,
6063
disableSlashSuggestions: true,
64+
blockKeyboardExit: false,
6165
},
6266
homeDir: {
6367
icon: null,
@@ -66,6 +70,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
6670
widthAdjustment: 0,
6771
showAgentModeToggle: true,
6872
disableSlashSuggestions: false,
73+
blockKeyboardExit: false,
6974
},
7075
referral: {
7176
icon: '◎',
@@ -74,6 +79,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
7479
widthAdjustment: 2, // 1 char + 1 padding
7580
showAgentModeToggle: false,
7681
disableSlashSuggestions: true,
82+
blockKeyboardExit: false,
7783
},
7884
usage: {
7985
icon: null,
@@ -82,6 +88,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
8288
widthAdjustment: 0,
8389
showAgentModeToggle: true,
8490
disableSlashSuggestions: false,
91+
blockKeyboardExit: false,
8592
},
8693
image: {
8794
icon: '📎',
@@ -90,6 +97,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
9097
widthAdjustment: 3, // emoji width + padding
9198
showAgentModeToggle: false,
9299
disableSlashSuggestions: true,
100+
blockKeyboardExit: false,
93101
},
94102
help: {
95103
icon: null,
@@ -98,6 +106,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
98106
widthAdjustment: 0,
99107
showAgentModeToggle: true,
100108
disableSlashSuggestions: false,
109+
blockKeyboardExit: false,
101110
},
102111
'connect:claude': {
103112
icon: '🔗',
@@ -106,6 +115,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
106115
widthAdjustment: 3, // emoji width + padding
107116
showAgentModeToggle: false,
108117
disableSlashSuggestions: true,
118+
blockKeyboardExit: false,
109119
},
110120
outOfCredits: {
111121
icon: null,
@@ -114,6 +124,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
114124
widthAdjustment: 0,
115125
showAgentModeToggle: false,
116126
disableSlashSuggestions: true,
127+
blockKeyboardExit: false,
117128
},
118129
subscriptionLimit: {
119130
icon: null,
@@ -122,6 +133,7 @@ export const INPUT_MODE_CONFIGS: Record<InputMode, InputModeConfig> = {
122133
widthAdjustment: 0,
123134
showAgentModeToggle: false,
124135
disableSlashSuggestions: true,
136+
blockKeyboardExit: true, // User must click "Continue with credits" or wait for reset
125137
},
126138
}
127139

cli/src/utils/keyboard-actions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { InputMode } from './input-modes'
1+
import { getInputModeConfig, type InputMode } from './input-modes'
22
import type { KeyEvent } from '@opentui/core'
33

44

@@ -168,7 +168,9 @@ export function resolveChatKeyboardAction(
168168

169169
// Priority 2: Non-default input mode escape
170170
// Escape should exit the current mode BEFORE interrupting streams
171-
if (isEscape && state.inputMode !== 'default') {
171+
// Exception: modes with blockKeyboardExit cannot be escaped
172+
const modeConfig = getInputModeConfig(state.inputMode)
173+
if (isEscape && state.inputMode !== 'default' && !modeConfig.blockKeyboardExit) {
172174
return { type: 'exit-input-mode' }
173175
}
174176

@@ -186,10 +188,12 @@ export function resolveChatKeyboardAction(
186188
}
187189

188190
// Priority 5: Backspace at position 0 exits non-default mode
191+
// Exception: modes with blockKeyboardExit cannot be exited via keyboard
189192
if (
190193
isBackspace &&
191194
state.cursorPosition === 0 &&
192195
state.inputMode !== 'default' &&
196+
!modeConfig.blockKeyboardExit &&
193197
state.inputValue.length === 0
194198
) {
195199
return { type: 'backspace-exit-mode' }

0 commit comments

Comments
 (0)