Skip to content
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

feat: add enable persistent terminal session preference #3127

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/i18n/src/common/en-US.lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ export const localizationBundle = {
'preference.terminal.integrated.xtermRenderType': 'Xterm Render Type',
'preference.terminal.integrated.xtermRenderTypeDesc':
'Choose Xterm render type, Webgl for better performance, Canvas better compatibility',
'preference.terminal.integrated.enablePersistentSessionDesc': 'Persist terminal sessions/history for the workspace across window reloads.',
'preference.terminal.integrated.cursorStyle': 'Terminal > Cursor Style',
'preference.terminal.integrated.cursorStyleDesc': 'Control the style of terminal cursor',
'common.preference.open': 'Settings',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/common/zh-CN.lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export const localizationBundle = {
'preference.terminal.integrated.localEchoStyleDesc': '本地回显文本的终端样式;字体样式或 RGB 颜色。',
'preference.terminal.integrated.xtermRenderType': 'Xterm 渲染类型',
'preference.terminal.integrated.xtermRenderTypeDesc': '选择 Xterm 渲染类型,WebGL 性能更强,Canvas 兼容性更佳。',
'preference.terminal.integrated.enablePersistentSessionDesc': '窗口重载时持久化终端会话',
'preference.terminal.integrated.cursorStyle': '终端输入指针样式',
'preference.terminal.integrated.cursorStyleDesc': '修改终端输入指针样式',
'settings.group.general': '常规',
Expand Down
17 changes: 9 additions & 8 deletions packages/terminal-next/src/browser/terminal.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { TERMINAL_CONTAINER_ID } from '@opensumi/ide-core-browser/lib/common/con
import { ICtxMenuRenderer, IMenuRegistry, MenuId } from '@opensumi/ide-core-browser/lib/menu/next';
import { generateCtxMenu } from '@opensumi/ide-core-browser/lib/menu/next/menu-util';
import { AbstractMenuService } from '@opensumi/ide-core-browser/lib/menu/next/menu.interface';
import { PreferenceService } from '@opensumi/ide-core-browser/lib/preferences/types';
import {
WithEventBus,
Emitter,
Expand Down Expand Up @@ -55,6 +56,7 @@ import {
TerminalCliterFilter,
TerminalLocation,
} from '../common';
import { CodeTerminalSettingId } from '../common/preference';

import { TerminalContextKey } from './terminal.context-key';
import { TerminalGroupViewService } from './terminal.view';
Expand Down Expand Up @@ -136,6 +138,9 @@ export class TerminalController extends WithEventBus implements ITerminalControl
@Autowired(ICtxMenuRenderer)
private ctxMenuRenderer: ICtxMenuRenderer;

@Autowired(PreferenceService)
private readonly preferenceService: PreferenceService;

@Autowired(AppConfig)
protected readonly appConfig: AppConfig;

Expand Down Expand Up @@ -556,15 +561,11 @@ export class TerminalController extends WithEventBus implements ITerminalControl

wGroup.widgets.forEach((widget) => {
const client = this._clients.get(widget.id);
if (!client) {
return;
}

if (client.launchConfig?.isExtensionOwnedTerminal || client.launchConfig?.disablePersistence) {
return;
}
const disablePersistence =
!this.preferenceService.get(CodeTerminalSettingId.EnablePersistentSessions) ||
client?.launchConfig?.disablePersistence;

if (client.isTaskExecutor) {
if (!client || disablePersistence || client?.isTaskExecutor) {
return;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/terminal-next/src/common/preference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const enum CodeTerminalSettingId {
PersistentSessionReviveProcess = 'terminal.integrated.persistentSessionReviveProcess',
CustomGlyphs = 'terminal.integrated.customGlyphs',
PersistentSessionScrollback = 'terminal.integrated.persistentSessionScrollback',
PersistentSession = 'terminal.integrated.enablePersistentSession',
InheritEnv = 'terminal.integrated.inheritEnv',
ShowLinkHover = 'terminal.integrated.showLinkHover',
IgnoreProcessNames = 'terminal.integrated.ignoreProcessNames',
Expand Down Expand Up @@ -344,5 +345,10 @@ export const terminalPreferenceSchema: PreferenceSchema = {
enum: [RenderType.WebGL, RenderType.Canvas, RenderType.Dom],
default: RenderType.WebGL,
},
[CodeTerminalSettingId.PersistentSession]: {
type: 'boolean',
description: '%preference.terminal.integrated.enablePersistentSessionDesc%',
default: true,
},
},
};
Loading