Skip to content

Commit c77bc86

Browse files
committed
feat: creaded creator mode view
1 parent 1070368 commit c77bc86

File tree

8 files changed

+337
-4
lines changed

8 files changed

+337
-4
lines changed

extensions/pearai-submodule

Submodule pearai-submodule updated 110 files

src/vs/workbench/browser/actions/layoutActions.ts

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { IPaneCompositePartService } from '../../services/panecomposite/browser/
2222
import { ToggleAuxiliaryBarAction } from '../parts/auxiliarybar/auxiliaryBarActions.js';
2323
import { TogglePanelAction } from '../parts/panel/panelActions.js';
2424
import { ICommandService } from '../../../platform/commands/common/commands.js';
25-
import { AuxiliaryBarVisibleContext, PanelAlignmentContext, PanelVisibleContext, SideBarVisibleContext, FocusedViewContext, InEditorZenModeContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, IsMainWindowFullscreenContext, PanelPositionContext, IsAuxiliaryWindowFocusedContext, TitleBarStyleContext, PearAIVisibleContext, PearAICreatorVisibleContext } from '../../common/contextkeys.js';
25+
import { AuxiliaryBarVisibleContext, PanelAlignmentContext, PanelVisibleContext, SideBarVisibleContext, FocusedViewContext, InEditorZenModeContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, IsMainWindowFullscreenContext, PanelPositionContext, IsAuxiliaryWindowFocusedContext, TitleBarStyleContext, PearAIVisibleContext, PearAICreatorVisibleContext, InEditorCreatorModeContext } from '../../common/contextkeys.js';
2626
import { Codicon } from '../../../base/common/codicons.js';
2727
import { ThemeIcon } from '../../../base/common/themables.js';
2828
import { DisposableStore } from '../../../base/common/lifecycle.js';
@@ -776,6 +776,55 @@ registerAction2(class extends Action2 {
776776
}
777777
});
778778

779+
// --- Enter Creator Mode
780+
781+
registerAction2(class extends Action2 {
782+
783+
constructor() {
784+
super({
785+
id: 'workbench.action.enterCreatorMode',
786+
title: {
787+
original: 'Enter Creator Mode',
788+
value: "Enter Creator Mode"
789+
},
790+
// precondition: InEditorCreatorModeContext.toNegated(),
791+
category: Categories.View,
792+
f1: true
793+
});
794+
}
795+
796+
run(accessor: ServicesAccessor): void {
797+
return accessor.get(IWorkbenchLayoutService).enterCreatorMode();
798+
}
799+
});
800+
801+
// --- Exit Creator Mode
802+
803+
registerAction2(class extends Action2 {
804+
805+
constructor() {
806+
super({
807+
id: 'workbench.action.exitCreatorMode',
808+
title: {
809+
original: 'Exit Creator Mode',
810+
value: "Exit Creator Mode"
811+
},
812+
// precondition: InEditorCreatorModeContext,
813+
category: Categories.View,
814+
f1: true,
815+
keybinding: {
816+
weight: KeybindingWeight.EditorContrib - 1,
817+
primary: KeyCode.Escape,
818+
secondary: [KeyMod.Shift | KeyCode.Escape]
819+
}
820+
});
821+
}
822+
823+
run(accessor: ServicesAccessor): void {
824+
return accessor.get(IWorkbenchLayoutService).exitCreatorMode();
825+
}
826+
});
827+
779828
KeybindingsRegistry.registerCommandAndKeybindingRule({
780829
id: 'workbench.action.exitZenMode',
781830
weight: KeybindingWeight.EditorContrib - 1000,
@@ -1413,6 +1462,7 @@ const AlignPanelActions: CustomizeLayoutItem[] = [
14131462
const MiscLayoutOptions: CustomizeLayoutItem[] = [
14141463
CreateOptionLayoutItem('workbench.action.toggleFullScreen', IsMainWindowFullscreenContext, localize('fullscreen', "Full Screen"), fullscreenIcon),
14151464
CreateOptionLayoutItem('workbench.action.toggleZenMode', InEditorZenModeContext, localize('zenMode', "Zen Mode"), zenModeIcon),
1465+
CreateOptionLayoutItem('workbench.action.toggleCreatorMode', InEditorCreatorModeContext, "Creator Mode", zenModeIcon),// TODO: REMOVE - ONLY USED FOR TESTING
14161466
CreateOptionLayoutItem('workbench.action.toggleCenteredLayout', IsMainEditorCenteredLayoutContext, localize('centeredLayout', "Centered Layout"), centerLayoutIcon),
14171467
];
14181468

src/vs/workbench/browser/contextkeys.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
5252
private temporaryWorkspaceContext: IContextKey<boolean>;
5353

5454
private inZenModeContext: IContextKey<boolean>;
55+
private inCreatorModeContext: IContextKey<boolean>;
5556
private isMainWindowFullscreenContext: IContextKey<boolean>;
5657
private isAuxiliaryWindowFocusedContext: IContextKey<boolean>;
5758
private isMainEditorCenteredLayoutContext: IContextKey<boolean>;
@@ -168,6 +169,9 @@ export class WorkbenchContextKeysHandler extends Disposable {
168169
// Zen Mode
169170
this.inZenModeContext = InEditorZenModeContext.bindTo(this.contextKeyService);
170171

172+
// Creator Mode
173+
this.inCreatorModeContext = InEditorZenModeContext.bindTo(this.contextKeyService);
174+
171175
// Centered Layout (Main Editor)
172176
this.isMainEditorCenteredLayoutContext = IsMainEditorCenteredLayoutContext.bindTo(this.contextKeyService);
173177

@@ -231,6 +235,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
231235
}));
232236

233237
this._register(this.layoutService.onDidChangeZenMode(enabled => this.inZenModeContext.set(enabled)));
238+
this._register(this.layoutService.onDidChangeCreatorMode(enabled => this.inCreatorModeContext.set(enabled)));
234239
this._register(this.layoutService.onDidChangeActiveContainer(() => this.isAuxiliaryWindowFocusedContext.set(this.layoutService.activeContainer !== this.layoutService.mainContainer)));
235240
this._register(onDidChangeFullscreen(windowId => {
236241
if (windowId === mainWindow.vscodeWindowId) {

src/vs/workbench/browser/layout.ts

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ interface ILayoutRuntimeState {
6363
readonly zenMode: {
6464
readonly transitionDisposables: DisposableMap<string, IDisposable>;
6565
};
66+
readonly creatorMode: {
67+
readonly transitionDisposables: DisposableMap<string, IDisposable>;
68+
}
6669
}
6770

6871
interface IEditorToOpen {
@@ -136,6 +139,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
136139
private readonly _onDidChangeZenMode = this._register(new Emitter<boolean>());
137140
readonly onDidChangeZenMode = this._onDidChangeZenMode.event;
138141

142+
private readonly _onDidChangeCreatorMode = this._register(new Emitter<boolean>());
143+
readonly onDidChangeCreatorMode = this._onDidChangeCreatorMode.event;
144+
145+
139146
private readonly _onDidChangeMainEditorCenteredLayout = this._register(new Emitter<boolean>());
140147
readonly onDidChangeMainEditorCenteredLayout = this._onDidChangeMainEditorCenteredLayout.event;
141148

@@ -666,6 +673,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
666673
},
667674
zenMode: {
668675
transitionDisposables: new DisposableMap(),
676+
},
677+
creatorMode: {
678+
transitionDisposables: new DisposableMap(),
669679
}
670680
};
671681

@@ -1466,6 +1476,228 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
14661476
this._onDidChangeZenMode.fire(this.isZenModeActive());
14671477
}
14681478

1479+
1480+
// Helper methods to check and set Creator Mode state
1481+
private isCreatorModeActive(): boolean {
1482+
return this.stateModel.getRuntimeValue(LayoutStateKeys.CREATOR_MODE_ACTIVE);
1483+
}
1484+
1485+
private setCreatorModeActive(active: boolean) {
1486+
this.stateModel.setRuntimeValue(LayoutStateKeys.CREATOR_MODE_ACTIVE, active);
1487+
}
1488+
1489+
// Enter Creator Mode
1490+
enterCreatorMode(restoring = false): void {
1491+
console.log("Entering Creator Mode");
1492+
if (this.isCreatorModeActive()) {
1493+
console.warn('Creator Mode is already active');
1494+
return; // Already in Creator Mode
1495+
}
1496+
1497+
this.setCreatorModeActive(true);
1498+
this.state.runtime.creatorMode.transitionDisposables.clearAndDisposeAll();
1499+
1500+
const setLineNumbers = (lineNumbers?: LineNumbersType) => {
1501+
for (const editor of this.mainPartEditorService.visibleTextEditorControls) {
1502+
// To properly reset line numbers we need to read the configuration for each editor respecting it's uri.
1503+
if (!lineNumbers && isCodeEditor(editor) && editor.hasModel()) {
1504+
const model = editor.getModel();
1505+
lineNumbers = this.configurationService.getValue('editor.lineNumbers', { resource: model.uri, overrideIdentifier: model.getLanguageId() }) as LineNumbersType | undefined;
1506+
}
1507+
if (!lineNumbers) {
1508+
lineNumbers = this.configurationService.getValue('editor.lineNumbers') as LineNumbersType | undefined;
1509+
}
1510+
1511+
editor.updateOptions({ lineNumbers });
1512+
}
1513+
};
1514+
1515+
// Check if we need to go to full screen
1516+
let toggleMainWindowFullScreen = false;
1517+
// TODO: Create Creator Mode specific configuration service
1518+
const config = getCreatorModeConfiguration(this.configurationService);
1519+
const creatorModeExitInfo = this.stateModel.getRuntimeValue(LayoutStateKeys.CREATOR_MODE_EXIT_INFO);
1520+
1521+
if (!restoring) {
1522+
// Store current state to restore when exiting
1523+
toggleMainWindowFullScreen = !this.state.runtime.mainWindowFullscreen && config.fullScreen && !isIOS;
1524+
1525+
creatorModeExitInfo.transitionedToFullScreen = toggleMainWindowFullScreen;
1526+
creatorModeExitInfo.transitionedToCenteredEditorLayout = !this.isMainEditorLayoutCentered() && config.centerLayout;
1527+
creatorModeExitInfo.handleNotificationsDoNotDisturbMode = this.notificationService.getFilter() === NotificationsFilter.OFF;
1528+
creatorModeExitInfo.wasVisible.sideBar = this.isVisible(Parts.SIDEBAR_PART);
1529+
creatorModeExitInfo.wasVisible.panel = this.isVisible(Parts.PANEL_PART);
1530+
creatorModeExitInfo.wasVisible.auxiliaryBar = this.isVisible(Parts.AUXILIARYBAR_PART);
1531+
this.stateModel.setRuntimeValue(LayoutStateKeys.CREATOR_MODE_EXIT_INFO, creatorModeExitInfo);
1532+
}
1533+
1534+
// TODO: Configure what should be hidden in Creator Mode
1535+
this.setPanelHidden(true, true);
1536+
this.setAuxiliaryBarHidden(true, true);
1537+
this.setSideBarHidden(true, true);
1538+
1539+
if (config.hideActivityBar) {
1540+
this.setActivityBarHidden(true, true);
1541+
}
1542+
1543+
if (config.hideStatusBar) {
1544+
this.setStatusBarHidden(true, true);
1545+
}
1546+
1547+
if (config.hideLineNumbers) {
1548+
setLineNumbers('off');
1549+
this.state.runtime.creatorMode.transitionDisposables.set('hideLineNumbers', this.mainPartEditorService.onDidVisibleEditorsChange(() => setLineNumbers('off')));
1550+
}
1551+
1552+
if (config.showTabs !== this.editorGroupService.partOptions.showTabs) {
1553+
this.state.runtime.creatorMode.transitionDisposables.set('showTabs', this.editorGroupService.mainPart.enforcePartOptions({ showTabs: config.showTabs }));
1554+
}
1555+
1556+
if (config.silentNotifications && creatorModeExitInfo.handleNotificationsDoNotDisturbMode) {
1557+
this.notificationService.setFilter(NotificationsFilter.ERROR);
1558+
}
1559+
1560+
if (config.centerLayout) {
1561+
this.centerMainEditorLayout(true, true);
1562+
}
1563+
1564+
// TODO: Set up Creator Mode specific configuration
1565+
// Creator Mode Configuration Changes
1566+
this.state.runtime.creatorMode.transitionDisposables.set('configurationChange', this.configurationService.onDidChangeConfiguration(e => {
1567+
// Handle configuration changes for Creator Mode
1568+
// Activity Bar
1569+
if (e.affectsConfiguration('creatorMode.hideActivityBar')) {
1570+
const creatorModeHideActivityBar = this.configurationService.getValue<boolean>('creatorMode.hideActivityBar');
1571+
this.setActivityBarHidden(creatorModeHideActivityBar, true);
1572+
}
1573+
1574+
// Status Bar
1575+
if (e.affectsConfiguration('creatorMode.hideStatusBar')) {
1576+
const creatorModeHideStatusBar = this.configurationService.getValue<boolean>('creatorMode.hideStatusBar');
1577+
this.setStatusBarHidden(creatorModeHideStatusBar, true);
1578+
}
1579+
1580+
// Center Layout
1581+
if (e.affectsConfiguration('creatorMode.centerLayout')) {
1582+
const creatorModeCenterLayout = this.configurationService.getValue<boolean>('creatorMode.centerLayout');
1583+
this.centerMainEditorLayout(creatorModeCenterLayout, true);
1584+
}
1585+
1586+
// Show Tabs
1587+
if (e.affectsConfiguration('creatorMode.showTabs')) {
1588+
const creatorModeShowTabs = this.configurationService.getValue<EditorTabsMode | undefined>('creatorMode.showTabs') ?? 'multiple';
1589+
this.state.runtime.creatorMode.transitionDisposables.set('showTabs', this.editorGroupService.mainPart.enforcePartOptions({ showTabs: creatorModeShowTabs }));
1590+
}
1591+
1592+
// Notifications
1593+
if (e.affectsConfiguration('creatorMode.silentNotifications')) {
1594+
const creatorModeSilentNotifications = !!this.configurationService.getValue('creatorMode.silentNotifications');
1595+
if (creatorModeExitInfo.handleNotificationsDoNotDisturbMode) {
1596+
this.notificationService.setFilter(creatorModeSilentNotifications ? NotificationsFilter.ERROR : NotificationsFilter.OFF);
1597+
}
1598+
}
1599+
1600+
// Line Numbers
1601+
if (e.affectsConfiguration('creatorMode.hideLineNumbers')) {
1602+
const lineNumbersType = this.configurationService.getValue<boolean>('creatorMode.hideLineNumbers') ? 'off' : undefined;
1603+
setLineNumbers(lineNumbersType);
1604+
this.state.runtime.creatorMode.transitionDisposables.set('hideLineNumbers', this.mainPartEditorService.onDidVisibleEditorsChange(() => setLineNumbers(lineNumbersType)));
1605+
}
1606+
}));
1607+
1608+
// Layout and toggle fullscreen if needed
1609+
this.layout();
1610+
if (toggleMainWindowFullScreen) {
1611+
this.hostService.toggleFullScreen(mainWindow);
1612+
}
1613+
1614+
// Fire event for Creator Mode activation
1615+
this._onDidChangeCreatorMode.fire(true);
1616+
}
1617+
1618+
// Exit Creator Mode
1619+
exitCreatorMode(): void {
1620+
if (!this.isCreatorModeActive()) {
1621+
return; // Not in Creator Mode
1622+
}
1623+
1624+
this.setCreatorModeActive(false);
1625+
this.state.runtime.creatorMode.transitionDisposables.clearAndDisposeAll();
1626+
1627+
// Reset line numbers
1628+
const setLineNumbers = () => {
1629+
for (const editor of this.mainPartEditorService.visibleTextEditorControls) {
1630+
if (isCodeEditor(editor) && editor.hasModel()) {
1631+
const model = editor.getModel();
1632+
const lineNumbers = this.configurationService.getValue('editor.lineNumbers', { resource: model.uri, overrideIdentifier: model.getLanguageId() }) as LineNumbersType | undefined;
1633+
editor.updateOptions({ lineNumbers });
1634+
} else {
1635+
const lineNumbers = this.configurationService.getValue('editor.lineNumbers') as LineNumbersType | undefined;
1636+
editor.updateOptions({ lineNumbers });
1637+
}
1638+
}
1639+
};
1640+
1641+
const creatorModeExitInfo = this.stateModel.getRuntimeValue(LayoutStateKeys.CREATOR_MODE_EXIT_INFO);
1642+
let toggleMainWindowFullScreen = false;
1643+
1644+
// Restore previous state
1645+
if (creatorModeExitInfo.wasVisible.panel) {
1646+
this.setPanelHidden(false, true);
1647+
}
1648+
1649+
if (creatorModeExitInfo.wasVisible.auxiliaryBar) {
1650+
this.setAuxiliaryBarHidden(false, true);
1651+
}
1652+
1653+
if (creatorModeExitInfo.wasVisible.sideBar) {
1654+
this.setSideBarHidden(false, true);
1655+
}
1656+
1657+
if (!this.stateModel.getRuntimeValue(LayoutStateKeys.ACTIVITYBAR_HIDDEN, true)) {
1658+
this.setActivityBarHidden(false, true);
1659+
}
1660+
1661+
if (!this.stateModel.getRuntimeValue(LayoutStateKeys.STATUSBAR_HIDDEN, true)) {
1662+
this.setStatusBarHidden(false, true);
1663+
}
1664+
1665+
if (creatorModeExitInfo.transitionedToCenteredEditorLayout) {
1666+
this.centerMainEditorLayout(false, true);
1667+
}
1668+
1669+
if (creatorModeExitInfo.handleNotificationsDoNotDisturbMode) {
1670+
this.notificationService.setFilter(NotificationsFilter.OFF);
1671+
}
1672+
1673+
setLineNumbers();
1674+
this.focus();
1675+
1676+
toggleMainWindowFullScreen = creatorModeExitInfo.transitionedToFullScreen && this.state.runtime.mainWindowFullscreen;
1677+
1678+
// Layout and toggle fullscreen if needed
1679+
this.layout();
1680+
if (toggleMainWindowFullScreen) {
1681+
this.hostService.toggleFullScreen(mainWindow);
1682+
}
1683+
1684+
// Fire event for Creator Mode deactivation
1685+
this._onDidChangeCreatorMode.fire(false);
1686+
}
1687+
1688+
toggleCreatorMode(skipLayout?: boolean): void {
1689+
if (this.isCreatorModeActive()) {
1690+
this.exitCreatorMode();
1691+
} else {
1692+
this.enterCreatorMode();
1693+
}
1694+
1695+
if (!skipLayout) {
1696+
this.layout();
1697+
}
1698+
}
1699+
1700+
14691701
private setStatusBarHidden(hidden: boolean, skipLayout?: boolean): void {
14701702
this.stateModel.setRuntimeValue(LayoutStateKeys.STATUSBAR_HIDDEN, hidden);
14711703

@@ -2517,6 +2749,12 @@ function getZenModeConfiguration(configurationService: IConfigurationService): Z
25172749
return configurationService.getValue<ZenModeConfiguration>(WorkbenchLayoutSettings.ZEN_MODE_CONFIG);
25182750
}
25192751

2752+
type CreatorModeConfiguration = ZenModeConfiguration;
2753+
2754+
function getCreatorModeConfiguration(configurationService: IConfigurationService): CreatorModeConfiguration {
2755+
return configurationService.getValue<CreatorModeConfiguration>(WorkbenchLayoutSettings.ZEN_MODE_CONFIG);
2756+
}
2757+
25202758
//#endregion
25212759

25222760
//#region Layout State Model
@@ -2570,6 +2808,20 @@ const LayoutStateKeys = {
25702808
},
25712809
}),
25722810

2811+
// Creator Mode
2812+
CREATOR_MODE_ACTIVE: new RuntimeStateKey<boolean>('creatorMode.active', StorageScope.WORKSPACE, StorageTarget.MACHINE, false),
2813+
CREATOR_MODE_EXIT_INFO: new RuntimeStateKey('creatorMode.exitInfo', StorageScope.WORKSPACE, StorageTarget.MACHINE, {
2814+
transitionedToCenteredEditorLayout: false,
2815+
transitionedToFullScreen: false,
2816+
handleNotificationsDoNotDisturbMode: false,
2817+
wasVisible: {
2818+
auxiliaryBar: false,
2819+
panel: false,
2820+
sideBar: false,
2821+
},
2822+
}),
2823+
2824+
25732825
// Part Sizing
25742826
GRID_SIZE: new InitializationStateKey('grid.size', StorageScope.PROFILE, StorageTarget.MACHINE, { width: 800, height: 600 }),
25752827
SIDEBAR_SIZE: new InitializationStateKey<number>('sideBar.size', StorageScope.PROFILE, StorageTarget.MACHINE, 200),

0 commit comments

Comments
 (0)