Repository navigation
feat: /focus command and focus view for the fullscreen transcript #2546
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
Open
beardthelion
wants to merge
14
commits into
Twigpine:main
Choose a base branch
from
beardthelion:feat/focus-view
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,512
−29
Open
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d864962
feat(config): add focusView setting and /config entry
beardthelion 4eeb8cc
feat(commands): add /focus to toggle focus view
beardthelion 1f3ebb5
feat(focus): add the focus view selection function
beardthelion 08c8dda
feat(focus): add the marker and summary rows for focus view
beardthelion a8887aa
feat(focus): apply focus view in the fullscreen prompt screen
beardthelion cdafa0a
perf(focus): stop recomputing message memos on loading flips when foc…
beardthelion 51cf9ab
fix(focus): address review feedback on focus view selection and toggle
beardthelion a4c5e95
Merge origin/main into feat/focus-view
beardthelion 4ea69be
fix(focus): keep shell stderr, judge warnings per scheduled segment, …
beardthelion 096fdd5
Merge remote-tracking branch 'origin/main' into feat/focus-view
beardthelion b2e314e
fix(focus): keep hook stops, unknown-skill notices and Advisor errors…
beardthelion 47556f2
fix(focus): tell local notices from typed prompts by provenance, coun…
beardthelion 2fbcd58
Merge remote-tracking branch 'origin/main' into feat/focus-view
beardthelion 2ea86f0
fix(focus): mark the model-only skill notice as a local notice
beardthelion 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { afterEach, beforeEach, describe, expect, test } from 'bun:test' | ||
| import type { LocalCommandResult } from '../../types/command.js' | ||
| import { getGlobalConfig, saveGlobalConfig } from '../../utils/config.js' | ||
| import { _resetTmuxControlModeProbeForTesting } from '../../utils/fullscreen.js' | ||
| import { call } from './focus.js' | ||
|
|
||
| const noopContext = {} as Parameters<typeof call>[1] | ||
|
|
||
| function expectText( | ||
| res: LocalCommandResult, | ||
| ): Extract<LocalCommandResult, { type: 'text' }> { | ||
| if (res.type !== 'text') throw new Error(`expected a text result, got ${res.type}`) | ||
| return res | ||
| } | ||
|
|
||
| const ENV_KEYS = ['CLAUDE_CODE_NO_FLICKER', 'TMUX', 'TERM_PROGRAM', 'TERM'] as const | ||
| const savedEnv = new Map<string, string | undefined>( | ||
| ENV_KEYS.map(k => [k, process.env[k]]), | ||
| ) | ||
|
|
||
| function setFocus(value: boolean | undefined): void { | ||
| saveGlobalConfig(current => ({ ...current, focusView: value })) | ||
| } | ||
|
|
||
| describe('/focus', () => { | ||
| beforeEach(() => { | ||
| for (const k of ENV_KEYS) delete process.env[k] | ||
| process.env.CLAUDE_CODE_NO_FLICKER = '1' | ||
| _resetTmuxControlModeProbeForTesting() | ||
| setFocus(undefined) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| setFocus(undefined) | ||
| for (const k of ENV_KEYS) { | ||
| const v = savedEnv.get(k) | ||
| if (v === undefined) delete process.env[k] | ||
| else process.env[k] = v | ||
| } | ||
| _resetTmuxControlModeProbeForTesting() | ||
| }) | ||
|
|
||
| test('turns focus on from off and says so', async () => { | ||
| setFocus(false) | ||
| const res = expectText(await call('', noopContext)) | ||
| expect(getGlobalConfig().focusView).toBe(true) | ||
| expect(res.value).toContain('Focus view is on') | ||
| }) | ||
|
|
||
| test('turns focus on when the setting was never stored', async () => { | ||
| const res = expectText(await call('', noopContext)) | ||
| expect(getGlobalConfig().focusView).toBe(true) | ||
| expect(res.value).toContain('Focus view is on') | ||
| }) | ||
|
|
||
| test('turns focus off from on and says so', async () => { | ||
| setFocus(true) | ||
| const res = expectText(await call('', noopContext)) | ||
| expect(getGlobalConfig().focusView).toBe(false) | ||
| expect(res.value).toContain('Focus view is off') | ||
| }) | ||
|
|
||
| test('ignores arguments: "on" with focus already on still toggles off', async () => { | ||
| setFocus(true) | ||
| const res = expectText(await call('on', noopContext)) | ||
| expect(getGlobalConfig().focusView).toBe(false) | ||
| expect(res.value).toContain('Focus view is off') | ||
| }) | ||
|
|
||
| for (const start of [false, true]) { | ||
| test(`outside fullscreen it points to /tui fullscreen and leaves focus ${start}`, async () => { | ||
| process.env.CLAUDE_CODE_NO_FLICKER = '0' | ||
| setFocus(start) | ||
| const res = expectText(await call('', noopContext)) | ||
| expect(res.value).toContain('/tui fullscreen') | ||
| expect(getGlobalConfig().focusView).toBe(start) | ||
| }) | ||
| } | ||
|
|
||
| test('outside fullscreen it leaves an unset setting unset', async () => { | ||
| process.env.CLAUDE_CODE_NO_FLICKER = '0' | ||
| const res = expectText(await call('', noopContext)) | ||
| expect(res.value).toContain('/tui fullscreen') | ||
| expect(getGlobalConfig().focusView).toBeUndefined() | ||
| }) | ||
| }) |
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,22 @@ | ||
| import type { LocalCommandCall } from '../../types/command.js' | ||
| import { getGlobalConfig, saveGlobalConfig } from '../../utils/config.js' | ||
| import { isFullscreenEnvEnabled } from '../../utils/fullscreen.js' | ||
|
|
||
| export const call: LocalCommandCall = async () => { | ||
| if (!isFullscreenEnvEnabled()) { | ||
| return { | ||
| type: 'text', | ||
| value: | ||
| 'Focus view needs the fullscreen display mode. Run /tui fullscreen first.', | ||
| } | ||
| } | ||
|
|
||
| const next = !(getGlobalConfig().focusView ?? false) | ||
| saveGlobalConfig(current => ({ ...current, focusView: next })) | ||
| return { | ||
| type: 'text', | ||
| value: next | ||
| ? 'Focus view is on. Only your latest prompt, a tool summary and the response show.' | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| : 'Focus view is off.', | ||
| } | ||
| } | ||
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,11 @@ | ||
| import type { Command } from '../../commands.js' | ||
|
|
||
| const focus = { | ||
| type: 'local', | ||
| name: 'focus', | ||
| description: 'Toggle focus view (latest prompt, tool summary and response)', | ||
| supportsNonInteractive: false, | ||
| load: () => import('./focus.js'), | ||
| } satisfies Command | ||
|
|
||
| export default focus |
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,31 @@ | ||
| import * as React from 'react' | ||
| import { Box, Text } from '../../ink.js' | ||
| import { useShortcutDisplay } from '../../keybindings/useShortcutDisplay.js' | ||
| import { CompactBoundaryMessage } from './CompactBoundaryMessage.js' | ||
|
|
||
| type Props = { | ||
| hiddenTurns: number | ||
| compacted: boolean | ||
| } | ||
|
|
||
| export function FocusMarkerMessage({ | ||
| hiddenTurns, | ||
| compacted, | ||
| }: Props): React.ReactNode { | ||
| const historyShortcut = useShortcutDisplay( | ||
| 'app:toggleTranscript', | ||
| 'Global', | ||
| 'ctrl+o', | ||
| ) | ||
| return ( | ||
| <Box flexDirection="column"> | ||
| {hiddenTurns > 0 && ( | ||
| <Text dimColor> | ||
| {hiddenTurns} earlier {hiddenTurns === 1 ? 'turn' : 'turns'} hidden,{' '} | ||
| {historyShortcut} for transcript, /focus to turn off | ||
| </Text> | ||
| )} | ||
| {compacted && <CompactBoundaryMessage />} | ||
| </Box> | ||
| ) | ||
| } |
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.