-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompact-layout.patch
More file actions
143 lines (140 loc) · 5.82 KB
/
Copy pathcompact-layout.patch
File metadata and controls
143 lines (140 loc) · 5.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
diff --git a/packages/tui/src/component/prompt/index.tsx b/packages/tui/src/component/prompt/index.tsx
index 0fb04c5c1..59458673b 100644
--- a/packages/tui/src/component/prompt/index.tsx
+++ b/packages/tui/src/component/prompt/index.tsx
@@ -165,6 +165,7 @@ export function Prompt(props: PromptProps) {
const renderer = useRenderer()
const exit = useExit()
const dimensions = useTerminalDimensions()
+ const compact = createMemo(() => dimensions().width <= 80)
const { theme, syntax } = useTheme()
const kv = useKV()
const animationsEnabled = createMemo(() => kv.get("animations_enabled", true))
@@ -1353,8 +1354,8 @@ export function Prompt(props: PromptProps) {
}}
>
<box
- paddingLeft={2}
- paddingRight={2}
+ paddingLeft={compact() ? 1 : 2}
+ paddingRight={compact() ? 1 : 2}
paddingTop={1}
flexShrink={0}
backgroundColor={theme.backgroundElement}
diff --git a/packages/tui/src/routes/session/index.tsx b/packages/tui/src/routes/session/index.tsx
index 6df6b00d2..45db730ba 100644
--- a/packages/tui/src/routes/session/index.tsx
+++ b/packages/tui/src/routes/session/index.tsx
@@ -156,6 +156,7 @@ const sessionGlobalUnfocusedBindingCommands = ["session.first", "session.last"]
const context = createContext<{
width: number
+ compact: () => boolean
sessionID: string
conceal: () => boolean
thinkingMode: () => ThinkingMode
@@ -261,6 +262,7 @@ export function Session() {
const [showGenericToolOutput, setShowGenericToolOutput] = kv.signal("generic_tool_output_visibility", false)
const wide = createMemo(() => dimensions().width > 120)
+ const compact = createMemo(() => dimensions().width <= 80)
const sidebarVisible = createMemo(() => {
if (session()?.parentID) return false
if (sidebarOpen()) return true
@@ -268,7 +270,7 @@ export function Session() {
return false
})
const showTimestamps = createMemo(() => timestamps() === "show")
- const contentWidth = createMemo(() => dimensions().width - (sidebarVisible() ? 42 : 0) - 4)
+ const contentWidth = createMemo(() => dimensions().width - (sidebarVisible() ? 42 : 0) - (compact() ? 2 : 4))
const providers = createMemo(() => Model.index(sync.data.provider))
const scrollAcceleration = createMemo(() => getScrollAcceleration(tuiConfig))
@@ -1149,6 +1151,7 @@ export function Session() {
get width() {
return contentWidth()
},
+ compact,
sessionID: route.sessionID,
conceal,
thinkingMode,
@@ -1163,7 +1166,7 @@ export function Session() {
}}
>
<box flexDirection="row" flexGrow={1} minHeight={0}>
- <box flexGrow={1} minHeight={0} paddingBottom={1} paddingLeft={2} paddingRight={2} gap={1}>
+ <box flexGrow={1} minHeight={0} paddingBottom={1} paddingLeft={compact() ? 1 : 2} paddingRight={compact() ? 1 : 2} gap={1}>
<Show when={session()}>
<scrollbox
ref={(r) => (scroll = r)}
@@ -1398,7 +1401,7 @@ function UserMessage(props: {
onMouseUp={props.onMouseUp}
paddingTop={1}
paddingBottom={1}
- paddingLeft={2}
+ paddingLeft={ctx.compact() ? 0 : 2}
backgroundColor={hover() ? theme.backgroundElement : theme.backgroundPanel}
flexShrink={0}
>
@@ -1600,7 +1603,7 @@ function ReasoningPart(props: { last: boolean; part: ReasoningPart; message: Ass
<Show when={content()}>
<box
ref={(el: BoxRenderable) => alwaysSeparate.add(el)}
- paddingLeft={3}
+ paddingLeft={ctx.compact() ? 0 : 3}
marginTop={1}
flexDirection="column"
flexShrink={0}
@@ -1681,7 +1684,7 @@ function TextPart(props: { last: boolean; part: TextPart; message: AssistantMess
const { theme, syntax } = useTheme()
return (
<Show when={props.part.text.trim()}>
- <box ref={(el: BoxRenderable) => alwaysSeparate.add(el)} paddingLeft={3} marginTop={1} flexShrink={0}>
+ <box ref={(el: BoxRenderable) => alwaysSeparate.add(el)} paddingLeft={ctx.compact() ? 0 : 3} marginTop={1} flexShrink={0}>
<markdown
syntaxStyle={syntax()}
streaming={true}
@@ -1923,9 +1926,10 @@ export function InlineToolRow(props: {
onMouseOut?: () => void
onMouseUp?: () => void
}) {
+ const ctx = use()
return (
<box
- paddingLeft={3}
+ paddingLeft={ctx.compact() ? 0 : 3}
onMouseOver={props.onMouseOver}
onMouseOut={props.onMouseOut}
onMouseUp={props.onMouseUp}
@@ -1947,7 +1951,7 @@ export function InlineToolRow(props: {
<Show
fallback={
<text
- paddingLeft={3}
+ paddingLeft={ctx.compact() ? 0 : 3}
fg={props.color}
attributes={props.denied ? TextAttributes.STRIKETHROUGH : undefined}
>
@@ -1992,6 +1996,7 @@ function BlockTool(props: {
spinner?: boolean
}) {
const { theme } = useTheme()
+ const ctx = use()
const renderer = useRenderer()
const [hover, setHover] = createSignal(false)
const error = createMemo(() => (props.part?.state.status === "error" ? props.part.state.error : undefined))
@@ -2001,7 +2006,7 @@ function BlockTool(props: {
border={["left"]}
paddingTop={1}
paddingBottom={1}
- paddingLeft={2}
+ paddingLeft={ctx.compact() ? 0 : 2}
marginTop={1}
gap={1}
backgroundColor={hover() ? theme.backgroundMenu : theme.backgroundPanel}
@@ -2019,7 +2024,7 @@ function BlockTool(props: {
<Show
when={props.spinner}
fallback={
- <text paddingLeft={3} fg={theme.textMuted}>
+ <text paddingLeft={ctx.compact() ? 0 : 3} fg={theme.textMuted}>
{title()}
</text>
}