Skip to content

Commit 4a37050

Browse files
committed
Add modern UI configuration tracking and styling support
- panel should hold a boolean 'is modern ui' (when "workbench.experimental.modernUI": true) - we currently changed some css styles, e.g. paddings. Turns out, these should be only changed when 'modern ui' is enabled. - consider changes in this commit [Commit]: when not using 'modern ui', padding on configuration item is incorrect - consider changes in this commit [Commit]: when not using 'modern ui', padding on list header is incorrect - consider changes in this commit [Commit]: when not using 'modern ui', scrollbar width is incorrect - settings view should also set proper data-moderl-ui, just like panel view
1 parent 7dfc5c9 commit 4a37050

18 files changed

Lines changed: 160 additions & 30 deletions

File tree

‎apps/editor/src/views/panel/backend/panel-view-provider.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,15 @@ export class PanelViewProvider implements vscode.WebviewViewProvider {
316316
})
317317
}
318318

319+
private _send_is_modern_ui() {
320+
const config = vscode.workspace.getConfiguration('workbench')
321+
const is_modern_ui = config.get<boolean>('experimental.modernUI', false)
322+
this.send_message({
323+
command: 'IS_MODERN_UI',
324+
is_modern_ui
325+
})
326+
}
327+
319328
public async send_setup_progress() {
320329
const providers_manager = new ModelProvidersManager(this.extension_context)
321330
const [model_providers, configs] = await Promise.all([
@@ -483,6 +492,10 @@ export class PanelViewProvider implements vscode.WebviewViewProvider {
483492
if (event.affectsConfiguration('codeWebChat.voiceInputPushToTalk')) {
484493
this._send_voice_input_push_to_talk()
485494
}
495+
496+
if (event.affectsConfiguration('workbench.experimental.modernUI')) {
497+
this._send_is_modern_ui()
498+
}
486499
}
487500
)
488501

@@ -920,6 +933,8 @@ export class PanelViewProvider implements vscode.WebviewViewProvider {
920933
)
921934
} else if (message.command == 'GET_VOICE_INPUT_PUSH_TO_TALK') {
922935
this._send_voice_input_push_to_talk()
936+
} else if (message.command == 'GET_IS_MODERN_UI') {
937+
this._send_is_modern_ui()
923938
} else if (message.command == 'PICK_TASKS_WORKSPACE') {
924939
await handle_pick_tasks_workspace(this, message)
925940
}

‎apps/editor/src/views/panel/frontend/Home/Home.module.scss‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
justify-content: space-between;
55
gap: 4px;
66
width: 100%;
7-
padding: 4px 10px;
7+
padding: 4px 14px;
8+
9+
:global([data-modern-ui='true']) & {
10+
padding: 4px 10px;
11+
}
812

913
&__left {
1014
display: flex;
@@ -65,9 +69,13 @@
6569
border-radius: 10px;
6670
border: 1px solid var(--cwc-border-color);
6771
overflow: hidden;
68-
margin: 0 10px;
72+
margin: 0 14px;
6973
z-index: 1;
7074

75+
:global([data-modern-ui='true']) & {
76+
margin: 0 10px;
77+
}
78+
7179
> button {
7280
flex: 1;
7381
}
@@ -106,8 +114,12 @@
106114
}
107115

108116
&__empty {
109-
padding: 0 12px;
117+
padding: 0 16px;
110118
color: var(--cwc-text-color-dimmed);
119+
120+
:global([data-modern-ui='true']) & {
121+
padding: 0 12px;
122+
}
111123
}
112124

113125
&__buttons {

‎apps/editor/src/views/panel/frontend/Main/MainView/MainView.module.scss‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
display: flex;
2020
flex-direction: column;
2121
gap: 6px;
22-
margin: 0 10px;
22+
margin: 0 14px;
23+
24+
:global([data-modern-ui='true']) & {
25+
margin: 0 10px;
26+
}
2327
}
2428

2529
.edit-format {
@@ -43,7 +47,11 @@
4347
display: flex;
4448
align-items: center;
4549
gap: 6px;
46-
padding: 0 12px 8px 16px;
50+
padding: 0 16px 8px 16px;
51+
52+
:global([data-modern-ui='true']) & {
53+
padding: 0 12px 8px 16px;
54+
}
4755

4856
label {
4957
font-size: 12px;

‎apps/editor/src/views/panel/frontend/Main/MainView/components/Header/Header.module.scss‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
display: flex;
33
justify-content: space-between;
44
align-items: center;
5-
padding: 4px 10px;
5+
padding: 4px 14px;
66
gap: 14px;
77

8+
:global([data-modern-ui='true']) & {
9+
padding: 4px 10px;
10+
}
11+
812
&__left {
913
display: flex;
1014
align-items: center;

‎apps/editor/src/views/panel/frontend/Panel.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const Panel = () => {
8383
handle_tab_delete,
8484
handle_tabs_reorder,
8585
voice_input_push_to_talk,
86+
is_modern_ui,
8687
token_count
8788
} = use_panel(vscode)
8889

@@ -299,7 +300,7 @@ export const Panel = () => {
299300

300301
return (
301302
<LayoutContext.Provider value={layout_context_value}>
302-
<div className={styles.container}>
303+
<div className={styles.container} data-modern-ui={is_modern_ui}>
303304
<div className={styles.slot}>
304305
<Layout>
305306
<div

‎apps/editor/src/views/panel/frontend/components/Layout/Footer/Footer.module.scss‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
z-index: -1; // Makes context menu of a web configuration appear above
55
display: flex;
66
justify-content: space-between;
7-
padding: 5px 4px 0 4px;
7+
padding: 8px 12px 8px 12px;
88
border-top: 1px solid var(--cwc-border-color-dimmed);
99

10+
:global([data-modern-ui='true']) & {
11+
padding: 5px 4px 0 4px;
12+
}
13+
1014
> div {
1115
display: flex;
1216
gap: 6px;

‎apps/editor/src/views/panel/frontend/hooks/panel/use-panel.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const use_panel = (vscode: any) => {
5656
] = useState<boolean>(false)
5757
const [voice_input_push_to_talk, set_voice_input_push_to_talk] =
5858
useState(false)
59+
const [is_modern_ui, set_is_modern_ui] = useState(false)
5960

6061
const handle_task_forward = (text: string) => {
6162
handle_instructions_change(text, 'edit-files')
@@ -155,6 +156,8 @@ export const use_panel = (vscode: any) => {
155156
set_voice_input_push_to_talk(message.enabled)
156157
} else if (message.command == 'TOKEN_COUNT_UPDATED') {
157158
set_token_count(message.token_count)
159+
} else if (message.command == 'IS_MODERN_UI') {
160+
set_is_modern_ui(message.is_modern_ui)
158161
}
159162
}
160163
window.addEventListener('message', handle_message)
@@ -171,7 +174,8 @@ export const use_panel = (vscode: any) => {
171174
{ command: 'REQUEST_CAN_UNDO' },
172175
{ command: 'GET_SETUP_PROGRESS' },
173176
{ command: 'GET_FIND_RELEVANT_FILES_SHRINK_SOURCE_CODE' },
174-
{ command: 'GET_VOICE_INPUT_PUSH_TO_TALK' }
177+
{ command: 'GET_VOICE_INPUT_PUSH_TO_TALK' },
178+
{ command: 'GET_IS_MODERN_UI' }
175179
]
176180
initial_messages.forEach((message) => post_message(vscode, message))
177181

@@ -304,6 +308,7 @@ export const use_panel = (vscode: any) => {
304308
handle_tab_delete,
305309
handle_tabs_reorder,
306310
voice_input_push_to_talk,
311+
is_modern_ui,
307312
token_count
308313
}
309314
}

‎apps/editor/src/views/panel/types/messages.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,10 @@ export interface PickTasksWorkspaceMessage extends BaseMessage {
542542
active_root?: string
543543
}
544544

545+
export interface GetIsModernUiMessage extends BaseMessage {
546+
command: 'GET_IS_MODERN_UI'
547+
}
548+
545549
export type FrontendMessage =
546550
| GetInstructionsMessage
547551
| SaveInstructionsMessage
@@ -632,6 +636,7 @@ export type FrontendMessage =
632636
| PickApiModelMessage
633637
| PickApiReasoningEffortMessage
634638
| PickTasksWorkspaceMessage
639+
| GetIsModernUiMessage
635640

636641
// === FROM BACKEND TO FRONTEND ===
637642
export interface InstructionsMessage extends BaseMessage {
@@ -896,6 +901,11 @@ export interface TasksWorkspacePickedMessage extends BaseMessage {
896901
root: string
897902
}
898903

904+
export interface IsModernUiMessage extends BaseMessage {
905+
command: 'IS_MODERN_UI'
906+
is_modern_ui: boolean
907+
}
908+
899909
export type BackendMessage =
900910
| InstructionsMessage
901911
| FocusPromptFieldMessage
@@ -951,3 +961,4 @@ export type BackendMessage =
951961
| StartWebConfigurationCreationMessage
952962
| StartApiConfigurationCreationMessage
953963
| TasksWorkspacePickedMessage
964+
| IsModernUiMessage

‎apps/editor/src/views/settings/backend/settings-view-provider.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ export class SettingsViewProvider {
9191
})
9292
}
9393

94+
private _send_is_modern_ui() {
95+
const config = vscode.workspace.getConfiguration('workbench')
96+
const is_modern_ui = config.get<boolean>('experimental.modernUI', false)
97+
this.postMessage({
98+
command: 'IS_MODERN_UI',
99+
is_modern_ui
100+
})
101+
}
102+
94103
public createOrShow(section_to_show?: string) {
95104
const column = vscode.window.activeTextEditor
96105
? vscode.window.activeTextEditor.viewColumn
@@ -285,6 +294,8 @@ export class SettingsViewProvider {
285294
await handle_pick_api_model(this, message)
286295
} else if (message.command == 'PICK_API_REASONING_EFFORT') {
287296
await handle_pick_api_reasoning_effort(this, message)
297+
} else if (message.command == 'GET_IS_MODERN_UI') {
298+
this._send_is_modern_ui()
288299
}
289300
},
290301
null,
@@ -315,6 +326,9 @@ export class SettingsViewProvider {
315326
void handle_get_auto_run_intelligent_update(this)
316327
this._send_web_configurations()
317328
}
329+
if (e.affectsConfiguration('workbench.experimental.modernUI')) {
330+
this._send_is_modern_ui()
331+
}
318332
})
319333
)
320334
}

‎apps/editor/src/views/settings/frontend/Settings.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export const Settings = () => {
6868
settings_hook.reuse_last_tab !== undefined &&
6969
settings_hook.copy_paths_format !== undefined &&
7070
settings_hook.clear_checks_in_workspace_behavior !== undefined &&
71-
settings_hook.auto_run_intelligent_update !== undefined
71+
settings_hook.auto_run_intelligent_update !== undefined &&
72+
settings_hook.is_modern_ui !== undefined
7273
)
7374
}, [settings_hook])
7475

@@ -87,7 +88,7 @@ export const Settings = () => {
8788
if (!all_data_loaded) return null
8889

8990
return (
90-
<>
91+
<div data-modern-ui={settings_hook.is_modern_ui}>
9192
<Home
9293
providers={settings_hook.providers!}
9394
api_configurations={settings_hook.api_configurations!}
@@ -315,6 +316,6 @@ export const Settings = () => {
315316
</UiModal.Form>
316317
</UiModal>
317318
)}
318-
</>
319+
</div>
319320
)
320321
}

0 commit comments

Comments
 (0)