mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
add setting to control if new terminal spawns windows
This commit is contained in:
parent
81ec1a4a35
commit
a210bae07c
1 changed files with 41 additions and 3 deletions
|
|
@ -42,6 +42,7 @@ export class SessionCreateForm extends LitElement {
|
||||||
@property({ type: Boolean }) disabled = false;
|
@property({ type: Boolean }) disabled = false;
|
||||||
@property({ type: Boolean }) visible = false;
|
@property({ type: Boolean }) visible = false;
|
||||||
@property({ type: Object }) authClient!: AuthClient;
|
@property({ type: Object }) authClient!: AuthClient;
|
||||||
|
@property({ type: Boolean }) spawnWindow = true;
|
||||||
|
|
||||||
@state() private isCreating = false;
|
@state() private isCreating = false;
|
||||||
@state() private showFileBrowser = false;
|
@state() private showFileBrowser = false;
|
||||||
|
|
@ -58,6 +59,7 @@ export class SessionCreateForm extends LitElement {
|
||||||
|
|
||||||
private readonly STORAGE_KEY_WORKING_DIR = 'vibetunnel_last_working_dir';
|
private readonly STORAGE_KEY_WORKING_DIR = 'vibetunnel_last_working_dir';
|
||||||
private readonly STORAGE_KEY_COMMAND = 'vibetunnel_last_command';
|
private readonly STORAGE_KEY_COMMAND = 'vibetunnel_last_command';
|
||||||
|
private readonly STORAGE_KEY_SPAWN_WINDOW = 'vibetunnel_spawn_window';
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
@ -101,9 +103,10 @@ export class SessionCreateForm extends LitElement {
|
||||||
try {
|
try {
|
||||||
const savedWorkingDir = localStorage.getItem(this.STORAGE_KEY_WORKING_DIR);
|
const savedWorkingDir = localStorage.getItem(this.STORAGE_KEY_WORKING_DIR);
|
||||||
const savedCommand = localStorage.getItem(this.STORAGE_KEY_COMMAND);
|
const savedCommand = localStorage.getItem(this.STORAGE_KEY_COMMAND);
|
||||||
|
const savedSpawnWindow = localStorage.getItem(this.STORAGE_KEY_SPAWN_WINDOW);
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`loading from localStorage: workingDir=${savedWorkingDir}, command=${savedCommand}`
|
`loading from localStorage: workingDir=${savedWorkingDir}, command=${savedCommand}, spawnWindow=${savedSpawnWindow}`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (savedWorkingDir) {
|
if (savedWorkingDir) {
|
||||||
|
|
@ -112,6 +115,9 @@ export class SessionCreateForm extends LitElement {
|
||||||
if (savedCommand) {
|
if (savedCommand) {
|
||||||
this.command = savedCommand;
|
this.command = savedCommand;
|
||||||
}
|
}
|
||||||
|
if (savedSpawnWindow !== null) {
|
||||||
|
this.spawnWindow = savedSpawnWindow === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
// Force re-render to update the input values
|
// Force re-render to update the input values
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
|
|
@ -125,7 +131,9 @@ export class SessionCreateForm extends LitElement {
|
||||||
const workingDir = this.workingDir.trim();
|
const workingDir = this.workingDir.trim();
|
||||||
const command = this.command.trim();
|
const command = this.command.trim();
|
||||||
|
|
||||||
logger.debug(`saving to localStorage: workingDir=${workingDir}, command=${command}`);
|
logger.debug(
|
||||||
|
`saving to localStorage: workingDir=${workingDir}, command=${command}, spawnWindow=${this.spawnWindow}`
|
||||||
|
);
|
||||||
|
|
||||||
// Only save non-empty values
|
// Only save non-empty values
|
||||||
if (workingDir) {
|
if (workingDir) {
|
||||||
|
|
@ -134,6 +142,7 @@ export class SessionCreateForm extends LitElement {
|
||||||
if (command) {
|
if (command) {
|
||||||
localStorage.setItem(this.STORAGE_KEY_COMMAND, command);
|
localStorage.setItem(this.STORAGE_KEY_COMMAND, command);
|
||||||
}
|
}
|
||||||
|
localStorage.setItem(this.STORAGE_KEY_SPAWN_WINDOW, String(this.spawnWindow));
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
logger.warn('failed to save to localStorage');
|
logger.warn('failed to save to localStorage');
|
||||||
}
|
}
|
||||||
|
|
@ -176,6 +185,10 @@ export class SessionCreateForm extends LitElement {
|
||||||
this.sessionName = input.value;
|
this.sessionName = input.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleSpawnWindowChange() {
|
||||||
|
this.spawnWindow = !this.spawnWindow;
|
||||||
|
}
|
||||||
|
|
||||||
private handleBrowse() {
|
private handleBrowse() {
|
||||||
this.showFileBrowser = true;
|
this.showFileBrowser = true;
|
||||||
}
|
}
|
||||||
|
|
@ -209,7 +222,7 @@ export class SessionCreateForm extends LitElement {
|
||||||
const sessionData: SessionCreateData = {
|
const sessionData: SessionCreateData = {
|
||||||
command: this.parseCommand(this.command.trim()),
|
command: this.parseCommand(this.command.trim()),
|
||||||
workingDir: this.workingDir.trim(),
|
workingDir: this.workingDir.trim(),
|
||||||
spawn_terminal: true,
|
spawn_terminal: this.spawnWindow,
|
||||||
cols: terminalCols,
|
cols: terminalCols,
|
||||||
rows: terminalRows,
|
rows: terminalRows,
|
||||||
};
|
};
|
||||||
|
|
@ -391,6 +404,31 @@ export class SessionCreateForm extends LitElement {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Spawn Window Toggle -->
|
||||||
|
<div class="mb-4 flex items-center justify-between">
|
||||||
|
<div class="flex-1 pr-4">
|
||||||
|
<span class="text-dark-text text-sm">Spawn window</span>
|
||||||
|
<p class="text-xs text-dark-text-muted mt-1">
|
||||||
|
Opens native terminal window
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
role="switch"
|
||||||
|
aria-checked="${this.spawnWindow}"
|
||||||
|
@click=${this.handleSpawnWindowChange}
|
||||||
|
class="relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-accent-green focus:ring-offset-2 focus:ring-offset-dark-bg ${
|
||||||
|
this.spawnWindow ? 'bg-accent-green' : 'bg-dark-border'
|
||||||
|
}"
|
||||||
|
?disabled=${this.disabled || this.isCreating}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="inline-block h-5 w-5 transform rounded-full bg-white transition-transform ${
|
||||||
|
this.spawnWindow ? 'translate-x-5' : 'translate-x-0.5'
|
||||||
|
}"
|
||||||
|
></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Quick Start Section -->
|
<!-- Quick Start Section -->
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label class="form-label text-dark-text-muted uppercase text-xs tracking-wider"
|
<label class="form-label text-dark-text-muted uppercase text-xs tracking-wider"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue