Skip to content

Commit 56362f8

Browse files
committed
feat(agent-files): add word wrap toggle functionality and related styles
1 parent a4850b1 commit 56362f8

6 files changed

Lines changed: 70 additions & 11 deletions

File tree

‎ui/src/styles/components.css‎

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@
265265
width: var(--theme-item);
266266
height: var(--theme-item);
267267
border-radius: var(--radius-full);
268-
transform: translateY(-50%)
269-
translateX(calc(var(--theme-index, 0) * (var(--theme-item) + var(--theme-gap))));
268+
transform: translateY(-50%) translateX(calc(var(--theme-index, 0) * (var(--theme-item) + var(--theme-gap))));
270269
background: var(--accent);
271270
transition: transform var(--duration-normal) var(--ease-out);
272271
z-index: 0;
@@ -839,11 +838,11 @@
839838
position: relative;
840839
}
841840

842-
.cron-filter-dropdown__details > summary {
841+
.cron-filter-dropdown__details>summary {
843842
list-style: none;
844843
}
845844

846-
.cron-filter-dropdown__details > summary::-webkit-details-marker {
845+
.cron-filter-dropdown__details>summary::-webkit-details-marker {
847846
display: none;
848847
}
849848

@@ -1768,10 +1767,12 @@
17681767
}
17691768

17701769
@keyframes chatStreamPulse {
1770+
17711771
0%,
17721772
100% {
17731773
border-color: var(--border);
17741774
}
1775+
17751776
50% {
17761777
border-color: var(--accent);
17771778
}
@@ -1801,7 +1802,7 @@
18011802
height: 12px;
18021803
}
18031804

1804-
.chat-reading-indicator__dots > span {
1805+
.chat-reading-indicator__dots>span {
18051806
display: inline-block;
18061807
width: 6px;
18071808
height: 6px;
@@ -1813,29 +1814,31 @@
18131814
will-change: transform, opacity;
18141815
}
18151816

1816-
.chat-reading-indicator__dots > span:nth-child(2) {
1817+
.chat-reading-indicator__dots>span:nth-child(2) {
18171818
animation-delay: 0.15s;
18181819
}
18191820

1820-
.chat-reading-indicator__dots > span:nth-child(3) {
1821+
.chat-reading-indicator__dots>span:nth-child(3) {
18211822
animation-delay: 0.3s;
18221823
}
18231824

18241825
@keyframes chatReadingDot {
1826+
18251827
0%,
18261828
80%,
18271829
100% {
18281830
opacity: 0.4;
18291831
transform: translateY(0);
18301832
}
1833+
18311834
40% {
18321835
opacity: 1;
18331836
transform: translateY(-3px);
18341837
}
18351838
}
18361839

18371840
@media (prefers-reduced-motion: reduce) {
1838-
.chat-reading-indicator__dots > span {
1841+
.chat-reading-indicator__dots>span {
18391842
animation: none;
18401843
opacity: 0.6;
18411844
}
@@ -2363,7 +2366,7 @@
23632366
min-width: 0;
23642367
}
23652368

2366-
.agent-kv > div {
2369+
.agent-kv>div {
23672370
min-width: 0;
23682371
overflow-wrap: anywhere;
23692372
word-break: break-word;
@@ -2384,15 +2387,25 @@
23842387
min-width: 200px;
23852388
}
23862389

2390+
.agent-files-card {
2391+
display: flex;
2392+
flex-direction: column;
2393+
min-height: 70vh;
2394+
}
2395+
23872396
.agent-files-grid {
23882397
display: grid;
23892398
grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
23902399
gap: 16px;
2400+
flex: 1;
2401+
min-height: 0;
2402+
align-items: stretch;
23912403
}
23922404

23932405
.agent-files-list {
23942406
display: grid;
23952407
gap: 8px;
2408+
align-content: start;
23962409
}
23972410

23982411
.agent-file-row {
@@ -2434,6 +2447,26 @@
24342447
border-radius: var(--radius-lg);
24352448
padding: 16px;
24362449
background: var(--card);
2450+
display: flex;
2451+
flex-direction: column;
2452+
}
2453+
2454+
.agent-files-editor .field {
2455+
flex: 1;
2456+
display: flex;
2457+
flex-direction: column;
2458+
min-height: 0;
2459+
}
2460+
2461+
.agent-files-editor .field textarea {
2462+
flex: 1;
2463+
min-height: 120px;
2464+
resize: vertical;
2465+
}
2466+
2467+
.agent-file-textarea--wrap {
2468+
white-space: pre-wrap !important;
2469+
overflow-wrap: break-word;
24372470
}
24382471

24392472
.agent-file-header {
@@ -2543,7 +2576,7 @@
25432576
gap: 8px;
25442577
}
25452578

2546-
.agent-skills-header > span:last-child {
2579+
.agent-skills-header>span:last-child {
25472580
margin-left: auto;
25482581
}
25492582

‎ui/src/ui/app-render.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ export function renderApp(state: AppViewState) {
553553
channelsSnapshot: state.channelsSnapshot,
554554
channelsLastSuccess: state.channelsLastSuccess,
555555
cronLoading: state.cronLoading,
556+
agentFileWordWrap: state.agentFileWordWrap,
556557
cronStatus: state.cronStatus,
557558
cronJobs: state.cronJobs,
558559
cronError: state.cronError,
@@ -662,6 +663,9 @@ export function renderApp(state: AppViewState) {
662663
state.agentFileDrafts[name] ?? state.agentFileContents[name] ?? "";
663664
void saveAgentFile(state, resolvedAgentId, name, content);
664665
},
666+
onToggleWordWrap: () => {
667+
state.agentFileWordWrap = !state.agentFileWordWrap;
668+
},
665669
onToolsProfileChange: (agentId, profile, clearAllow) => {
666670
if (!configValue) {
667671
return;

‎ui/src/ui/app-view-state.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export type AppViewState = {
139139
agentFileDrafts: Record<string, string>;
140140
agentFileActive: string | null;
141141
agentFileSaving: boolean;
142+
agentFileWordWrap: boolean;
142143
agentIdentityLoading: boolean;
143144
agentIdentityError: string | null;
144145
agentIdentityById: Record<string, AgentIdentityResult>;

‎ui/src/ui/app.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ export class OpenClawApp extends LitElement {
230230
@state() agentFileDrafts: Record<string, string> = {};
231231
@state() agentFileActive: string | null = null;
232232
@state() agentFileSaving = false;
233+
@state() agentFileWordWrap = true;
233234
@state() agentIdentityLoading = false;
234235
@state() agentIdentityError: string | null = null;
235236
@state() agentIdentityById: Record<string, AgentIdentityResult> = {};

‎ui/src/ui/views/agents-panels-status-files.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,13 @@ export function renderAgentFiles(params: {
317317
agentFileContents: Record<string, string>;
318318
agentFileDrafts: Record<string, string>;
319319
agentFileSaving: boolean;
320+
agentFileWordWrap: boolean;
320321
onLoadFiles: (agentId: string) => void;
321322
onSelectFile: (name: string) => void;
322323
onFileDraftChange: (name: string, content: string) => void;
323324
onFileReset: (name: string) => void;
324325
onFileSave: (name: string) => void;
326+
onToggleWordWrap: () => void;
325327
}) {
326328
const list = params.agentFilesList?.agentId === params.agentId ? params.agentFilesList : null;
327329
const files = list?.files ?? [];
@@ -332,7 +334,7 @@ export function renderAgentFiles(params: {
332334
const isDirty = active ? draft !== baseContent : false;
333335

334336
return html`
335-
<section class="card">
337+
<section class="card agent-files-card">
336338
<div class="row" style="justify-content: space-between;">
337339
<div>
338340
<div class="card-title">Core Files</div>
@@ -389,6 +391,19 @@ export function renderAgentFiles(params: {
389391
<div class="agent-file-sub mono">${activeEntry.path}</div>
390392
</div>
391393
<div class="agent-file-actions">
394+
<button
395+
class="btn btn--sm ${params.agentFileWordWrap ? "primary" : ""}"
396+
title="${params.agentFileWordWrap ? "Word wrap on" : "Word wrap off"}"
397+
@click=${() => params.onToggleWordWrap()}
398+
>
399+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" width="14" height="14" style="flex-shrink:0;">
400+
<line x1="3" y1="6" x2="21" y2="6"/>
401+
<path d="M3 12h15a3 3 0 0 1 0 6h-4"/>
402+
<polyline points="14 15 11 18 14 21"/>
403+
<line x1="3" y1="18" x2="7" y2="18"/>
404+
</svg>
405+
Wrap
406+
</button>
392407
<button
393408
class="btn btn--sm"
394409
?disabled=${!isDirty}
@@ -417,6 +432,7 @@ export function renderAgentFiles(params: {
417432
<label class="field" style="margin-top: 12px;">
418433
<span>Content</span>
419434
<textarea
435+
class="${params.agentFileWordWrap ? "agent-file-textarea--wrap" : ""}"
420436
.value=${draft}
421437
@input=${(e: Event) =>
422438
params.onFileDraftChange(

‎ui/src/ui/views/agents.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export type AgentsProps = {
5757
agentFileDrafts: Record<string, string>;
5858
agentFileSaving: boolean;
5959
agentIdentityLoading: boolean;
60+
agentFileWordWrap: boolean;
6061
agentIdentityError: string | null;
6162
agentIdentityById: Record<string, AgentIdentityResult>;
6263
agentSkillsLoading: boolean;
@@ -76,6 +77,7 @@ export type AgentsProps = {
7677
onFileReset: (name: string) => void;
7778
onFileSave: (name: string) => void;
7879
onToolsProfileChange: (agentId: string, profile: string | null, clearAllow: boolean) => void;
80+
onToggleWordWrap: () => void;
7981
onToolsOverridesChange: (agentId: string, alsoAllow: string[], deny: string[]) => void;
8082
onConfigReload: () => void;
8183
onConfigSave: () => void;
@@ -198,11 +200,13 @@ export function renderAgents(props: AgentsProps) {
198200
agentFileContents: props.agentFileContents,
199201
agentFileDrafts: props.agentFileDrafts,
200202
agentFileSaving: props.agentFileSaving,
203+
agentFileWordWrap: props.agentFileWordWrap,
201204
onLoadFiles: props.onLoadFiles,
202205
onSelectFile: props.onSelectFile,
203206
onFileDraftChange: props.onFileDraftChange,
204207
onFileReset: props.onFileReset,
205208
onFileSave: props.onFileSave,
209+
onToggleWordWrap: props.onToggleWordWrap,
206210
})
207211
: nothing
208212
}

0 commit comments

Comments
 (0)