Archived
fix: move workspace panel collapse control to edge
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jmfederico/pi-web": patch
|
||||
---
|
||||
|
||||
Add a desktop edge control for collapsing and expanding the workspace tools panel.
|
||||
@@ -45,7 +45,6 @@ export interface AppState {
|
||||
activeTerminalCount: number;
|
||||
selectedTerminalId: string | undefined;
|
||||
piWebStatus: PiWebStatusResponse | undefined;
|
||||
workspacePanelCollapsed: boolean;
|
||||
error: string;
|
||||
}
|
||||
|
||||
@@ -134,7 +133,6 @@ export function initialAppState(): AppState {
|
||||
activeTerminalCount: 0,
|
||||
selectedTerminalId: undefined,
|
||||
piWebStatus: undefined,
|
||||
workspacePanelCollapsed: false,
|
||||
error: "",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ const REFRESH_LONG_PRESS_MS = 550;
|
||||
@customElement("pi-web-app")
|
||||
export class PiWebApp extends LitElement {
|
||||
@state() private state: AppState = initialAppState();
|
||||
@state() private workspacePanelCollapsed = false;
|
||||
@query("chat-view") private chatView?: ChatView;
|
||||
@query("prompt-editor") private promptEditor?: PromptEditor;
|
||||
@query(".context-items") private contextItems?: HTMLElement | null;
|
||||
@@ -513,6 +514,7 @@ export class PiWebApp extends LitElement {
|
||||
const emptyState = workspace === undefined ? this.workspacePanelEmptyState() : undefined;
|
||||
return html`
|
||||
<workspace-panel
|
||||
id="workspace-panel"
|
||||
.workspace=${workspace}
|
||||
.panelContext=${panelContext}
|
||||
.emptyState=${emptyState}
|
||||
@@ -520,28 +522,37 @@ export class PiWebApp extends LitElement {
|
||||
.panels=${this.visibleWorkspacePanels()}
|
||||
.workspaceLabelItems=${workspaceLabelItems}
|
||||
.onSelectTool=${(tool: QualifiedContributionId) => { this.openWorkspaceTool(tool); }}
|
||||
.onToggleCollapse=${() => { this.toggleWorkspacePanelCollapse(); }}
|
||||
></workspace-panel>
|
||||
`;
|
||||
}
|
||||
|
||||
private toggleWorkspacePanelCollapse(): void {
|
||||
this.setState({ workspacePanelCollapsed: !this.state.workspacePanelCollapsed });
|
||||
this.workspacePanelCollapsed = !this.workspacePanelCollapsed;
|
||||
}
|
||||
|
||||
private renderExpandWorkspacePanelButton() {
|
||||
private renderWorkspacePanelEdgeControl() {
|
||||
const collapsed = this.workspacePanelCollapsed;
|
||||
const label = collapsed ? "Expand workspace panel" : "Collapse workspace panel";
|
||||
return html`
|
||||
<div class="expand-panel-strip">
|
||||
<div class="workspace-panel-edge">
|
||||
<button
|
||||
class="expand-workspace-panel-button"
|
||||
title="Toggle Panel"
|
||||
aria-label="Toggle Panel"
|
||||
type="button"
|
||||
class="workspace-panel-edge-button"
|
||||
title=${label}
|
||||
aria-label=${label}
|
||||
aria-controls="workspace-panel"
|
||||
aria-expanded=${String(!collapsed)}
|
||||
@click=${() => { this.toggleWorkspacePanelCollapse(); }}
|
||||
><svg class="expand-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M15 18l-6-6 6-6"/></svg></button>
|
||||
>${this.renderWorkspacePanelEdgeIcon(collapsed)}</button>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
private renderWorkspacePanelEdgeIcon(collapsed: boolean) {
|
||||
const path = collapsed ? "M15 18l-6-6 6-6" : "M9 18l6-6-6-6";
|
||||
return html`<svg class="workspace-panel-edge-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d=${path}/></svg>`;
|
||||
}
|
||||
|
||||
private renderNavigationPanel(autoSwitchToChat: boolean) {
|
||||
const openChatAfter = (action: () => Promise<void>) => this.withChatScrollTransition(async () => {
|
||||
await action();
|
||||
@@ -1220,11 +1231,10 @@ export class PiWebApp extends LitElement {
|
||||
override render() {
|
||||
const state = this.state;
|
||||
return html`
|
||||
<div class=${`shell ${state.mainView === "navigation" ? "navigation-view" : state.mainView === "chat" ? "chat-view" : "workspace-view"}${state.workspacePanelCollapsed ? " workspace-panel-collapsed" : ""}`}>
|
||||
<div class=${`shell ${state.mainView === "navigation" ? "navigation-view" : state.mainView === "chat" ? "chat-view" : "workspace-view"}${this.workspacePanelCollapsed ? " workspace-panel-collapsed" : ""}`}>
|
||||
<aside>${this.isMobileNavigationLayout ? null : this.renderNavigationPanel(false)}</aside>
|
||||
<main class=${state.mainView === "chat" ? "chat-view" : state.mainView === "navigation" ? "navigation-view" : "workspace-view"}>
|
||||
${this.renderContextBar()}
|
||||
${state.workspacePanelCollapsed ? this.renderExpandWorkspacePanelButton() : null}
|
||||
<div class=${this.mobileTabsFrameClass()}>
|
||||
<div class="mobile-tabs" @scroll=${this.onMobileTabsScroll}>
|
||||
<button class=${state.mainView === "navigation" ? "mobile-navigation-tab selected" : "mobile-navigation-tab"} @click=${() => { this.selectMainView("navigation"); }}>Sessions</button>
|
||||
@@ -1246,6 +1256,7 @@ export class PiWebApp extends LitElement {
|
||||
${state.authDialog !== undefined ? html`<auth-dialog .state=${state.authDialog} .onChooseMethod=${(authType: "oauth" | "api_key") => { void this.auth.chooseLoginMethod(authType); }} .onSelectProvider=${(providerId: string, authType: "oauth" | "api_key") => { void this.auth.selectLoginProvider(providerId, authType); }} .onApiKeyInput=${(value: string) => { this.auth.updateApiKey(value); }} .onSaveApiKey=${() => { void this.auth.saveApiKey(); }} .onLogoutProvider=${(providerId: string) => { void this.auth.logoutProvider(providerId); }} .onOAuthInput=${(value: string) => { this.auth.updateOAuthInput(value); }} .onOAuthRespond=${(value?: string) => { void this.auth.respondOAuth(value); }} .onOAuthCancel=${() => { void this.auth.cancelOAuth(); }} .onCancel=${() => { this.auth.closeDialog(); }}></auth-dialog>` : null}
|
||||
` : html`<div class="empty">${this.sessionEmptyMessage()}</div>`}
|
||||
</main>
|
||||
${this.renderWorkspacePanelEdgeControl()}
|
||||
${this.renderWorkspacePanel()}
|
||||
${state.actionPaletteOpen ? html`<action-palette .actions=${this.getActions()} .onRun=${(action: AppAction) => { this.setState({ actionPaletteOpen: false }); this.runAction(action); }} .onCancel=${() => { this.setState({ actionPaletteOpen: false }); }}></action-palette>` : null}
|
||||
${state.projectDialogOpen ? html`<project-dialog .onSubmit=${(path: string, create: boolean) => this.projects.addProject(path, create)} .onCancel=${() => { this.setState({ projectDialogOpen: false }); }}></project-dialog>` : null}
|
||||
|
||||
@@ -20,7 +20,6 @@ export class WorkspacePanel extends LitElement {
|
||||
@property({ attribute: false }) workspaceLabelItems: WorkspaceLabelItem[] = [];
|
||||
@property({ type: Boolean }) hideToolTabs = false;
|
||||
@property({ attribute: false }) onSelectTool: (tool: QualifiedContributionId) => void = () => undefined;
|
||||
@property({ attribute: false }) onToggleCollapse: () => void = () => undefined;
|
||||
@query(".workspace-header-strip") private workspaceHeaderStrip?: HTMLElement | null;
|
||||
@state() private workspaceHeaderCanScrollLeft = false;
|
||||
@state() private workspaceHeaderCanScrollRight = false;
|
||||
@@ -70,7 +69,6 @@ export class WorkspacePanel extends LitElement {
|
||||
${visiblePanels.map((panel) => html`
|
||||
<button class=${selectedPanel?.id === panel.id ? "selected" : ""} @click=${() => { this.onSelectTool(panel.id); }}>${this.renderPanelTitle(panel, context)}</button>
|
||||
`)}
|
||||
<button class="collapse-button" title="Toggle Panel" aria-label="Toggle Panel" @click=${() => { this.onToggleCollapse(); }}>${this.renderCollapseIcon()}</button>
|
||||
</div>
|
||||
`}
|
||||
<small>${renderWorkspaceLabel(workspace.label, this.workspaceLabelItems, workspace.path)}</small>
|
||||
@@ -94,10 +92,6 @@ export class WorkspacePanel extends LitElement {
|
||||
return html`${panel.title} <span class="tab-badge">${badge}</span>`;
|
||||
}
|
||||
|
||||
private renderCollapseIcon(): TemplateResult {
|
||||
return html`<svg class="collapse-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 18l6-6-6-6"/></svg>`;
|
||||
}
|
||||
|
||||
private renderEmptyState(state: WorkspacePanelEmptyState): TemplateResult {
|
||||
return html`
|
||||
<section class="empty-state" role="status">
|
||||
|
||||
@@ -51,15 +51,13 @@ export interface CompletionItem {
|
||||
|
||||
export const appStyles = css`
|
||||
:host { display: block; height: 100dvh; box-sizing: border-box; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); color: var(--pi-text); background: var(--pi-bg); font: 14px system-ui, sans-serif; }
|
||||
.shell { display: grid; grid-template-columns: 340px minmax(420px, 1fr) minmax(360px, 42vw); height: 100%; min-height: 0; }
|
||||
.shell.workspace-panel-collapsed { grid-template-columns: 340px minmax(420px, 1fr); }
|
||||
.shell.workspace-panel-collapsed > workspace-panel { display: none; }
|
||||
aside { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--pi-border); overflow: hidden; }
|
||||
.shell { display: grid; grid-template-columns: 340px minmax(420px, 1fr) 1px minmax(360px, 42vw); height: 100%; min-height: 0; }
|
||||
aside { grid-column: 1; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--pi-border); overflow: hidden; }
|
||||
header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
||||
.header-actions { display: flex; align-items: center; gap: 8px; }
|
||||
project-list, workspace-list { flex: 0 0 auto; max-height: 26%; overflow: auto; border-bottom: 1px solid var(--pi-border-muted); }
|
||||
session-list { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
||||
main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
|
||||
main { grid-column: 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
|
||||
.context-bar { position: relative; flex: 0 0 auto; min-width: 0; display: none; align-items: center; gap: 0; padding: 6px 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
||||
.context-bar::before, .context-bar::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
||||
.context-bar::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
||||
@@ -95,28 +93,30 @@ export const appStyles = css`
|
||||
.mobile-navigation-tab, .mobile-navigation-panel { display: none; }
|
||||
.mobile-tabs button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
||||
.tab-badge { display: inline-block; min-width: 14px; margin-left: 4px; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
||||
.expand-panel-strip { flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; padding: 4px 8px; border-bottom: 1px solid var(--pi-border-muted); }
|
||||
.expand-workspace-panel-button { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border-radius: 6px; }
|
||||
.expand-workspace-panel-button .expand-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
||||
workspace-panel { min-width: 0; min-height: 0; border-left: 1px solid var(--pi-border); overflow: hidden; }
|
||||
.workspace-panel-edge { grid-column: 3; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: visible; background: var(--pi-border-muted); z-index: 2; }
|
||||
.workspace-panel-edge-button { position: relative; z-index: 1; display: grid; place-items: center; width: 18px; height: 48px; padding: 0; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-bg); color: var(--pi-muted); opacity: .75; cursor: pointer; }
|
||||
.workspace-panel-edge-button:hover, .workspace-panel-edge-button:focus-visible { color: var(--pi-text); background: var(--pi-surface-hover); opacity: 1; }
|
||||
.workspace-panel-edge-icon { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
||||
workspace-panel { grid-column: 4; min-width: 0; min-height: 0; overflow: hidden; }
|
||||
@media (min-width: 1181px) {
|
||||
.shell.workspace-panel-collapsed { grid-template-columns: 340px minmax(420px, 1fr) 1px; }
|
||||
.shell.workspace-panel-collapsed > workspace-panel { display: none; }
|
||||
}
|
||||
@media (max-width: 1180px) {
|
||||
.shell { grid-template-columns: 340px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
|
||||
.shell.workspace-panel-collapsed { grid-template-columns: 340px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
|
||||
aside { grid-row: 1 / 3; }
|
||||
main { grid-column: 2; grid-row: 1 / 3; }
|
||||
.mobile-tabs-frame { display: flex; }
|
||||
.shell.workspace-view main { grid-row: 1; min-height: auto; }
|
||||
.shell.workspace-view > workspace-panel { grid-column: 2; grid-row: 2; display: flex; border-left: 0; }
|
||||
.shell:not(.workspace-view) > workspace-panel { display: none; }
|
||||
.shell.workspace-panel-collapsed > workspace-panel { display: none; }
|
||||
.expand-panel-strip { display: none; }
|
||||
.workspace-panel-edge { display: none; }
|
||||
main.workspace-view chat-view, main.workspace-view prompt-editor, main.workspace-view status-bar,
|
||||
main.workspace-view .empty { display: none; }
|
||||
main.workspace-view { overflow: hidden; }
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.shell { grid-template-columns: minmax(0, 1fr); }
|
||||
.shell.workspace-panel-collapsed { grid-template-columns: minmax(0, 1fr); }
|
||||
aside { display: none; }
|
||||
main, .shell.workspace-view > workspace-panel { grid-column: 1; }
|
||||
.context-bar { display: flex; }
|
||||
@@ -151,8 +151,6 @@ export const workspacePanelStyles = css`
|
||||
.workspace-header-strip { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; padding: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
|
||||
.tabs { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
|
||||
.tabs button { flex: 0 0 auto; white-space: nowrap; }
|
||||
.collapse-button { display: inline-flex; align-items: center; justify-content: center; width: auto; height: auto; padding: 5px 7px; }
|
||||
.collapse-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
||||
button { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); color: var(--pi-text); padding: 5px 7px; cursor: pointer; }
|
||||
button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
||||
.tab-badge { display: inline-block; min-width: 14px; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
||||
|
||||
Reference in New Issue
Block a user