diff --git a/build/lib/stylelint/vscode-known-variables.json b/build/lib/stylelint/vscode-known-variables.json index 32df923c527398..204062c1ee1d37 100644 --- a/build/lib/stylelint/vscode-known-variables.json +++ b/build/lib/stylelint/vscode-known-variables.json @@ -733,7 +733,6 @@ "--vscode-agentsUpdateButton-downloadedBackground", "--vscode-agentsUpdateButton-downloadingBackground", "--vscode-agentsMobileDiff-addedForeground", - "--vscode-agentsMobileDiff-modifiedForeground", "--vscode-agentsMobileDiff-deletedForeground", "--vscode-agentsCIBanner-border", "--vscode-agentsCIBanner-iconForeground", diff --git a/src/vs/sessions/browser/parts/mobile/contributions/media/mobileOverlayViews.css b/src/vs/sessions/browser/parts/mobile/contributions/media/mobileOverlayViews.css index 1dbe1cc0fbd9dd..4036921e29d622 100644 --- a/src/vs/sessions/browser/parts/mobile/contributions/media/mobileOverlayViews.css +++ b/src/vs/sessions/browser/parts/mobile/contributions/media/mobileOverlayViews.css @@ -430,148 +430,7 @@ -webkit-user-select: none; } -/* -- Changes list (master overlay) ---------------------------------------- */ - -.mobile-overlay-empty-state { - flex: 1; - display: flex; - align-items: center; - justify-content: center; - color: var(--vscode-descriptionForeground); - font-size: 14px; - padding: 32px; - text-align: center; -} - -.mobile-changes-list { - display: flex; - flex-direction: column; - min-height: 100%; - box-sizing: border-box; - padding: 4px 0 8px; -} - -.mobile-changes-row { - display: flex; - align-items: center; - gap: 8px; - width: 100%; - min-height: 56px; - padding: 8px 16px; - border: none; - border-bottom: 1px solid color-mix(in srgb, var(--vscode-foreground) 6%, transparent); - background: transparent; - color: var(--vscode-foreground); - text-align: left; - cursor: pointer; - touch-action: manipulation; - box-sizing: border-box; -} - -.mobile-changes-row:last-child { - border-bottom: none; -} - -.mobile-changes-row:active { - background: var(--vscode-list-activeSelectionBackground, var(--vscode-toolbar-hoverBackground)); -} - -.mobile-changes-row-label { - flex: 1; - display: flex; - align-items: center; - gap: 8px; - min-width: 0; - overflow: hidden; -} - -/* Direct DOM label rendering (codicon icon + filename + dir) */ - -.mobile-changes-row-icon { - flex-shrink: 0; - font-size: 16px; - color: var(--vscode-icon-foreground); -} - -.mobile-changes-row.change-added .mobile-changes-row-icon { - color: var(--vscode-agentsMobileDiff-addedForeground); -} - -.mobile-changes-row.change-modified .mobile-changes-row-icon { - color: var(--vscode-agentsMobileDiff-modifiedForeground); -} - -.mobile-changes-row.change-deleted .mobile-changes-row-icon { - color: var(--vscode-agentsMobileDiff-deletedForeground); -} - -.mobile-changes-row-text { - display: flex; - flex-direction: column; - align-items: flex-start; - min-width: 0; -} - -.mobile-changes-row-filename { - font-size: 14px; - font-weight: var(--vscode-fontWeight-semiBold); - color: var(--vscode-foreground); - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - max-width: 100%; -} - -.mobile-changes-row-dir { - font-size: 11px; - color: var(--vscode-descriptionForeground); - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - max-width: 100%; -} - -.mobile-changes-row-meta { - display: flex; - align-items: center; - gap: 8px; - flex-shrink: 0; -} - -.mobile-changes-row-pill { - display: inline-flex; - align-items: center; - justify-content: center; - width: 22px; - height: 22px; - border-radius: var(--vscode-cornerRadius-circle); - font-size: 11px; - font-weight: 600; - font-family: var(--monaco-monospace-font, 'SF Mono', Menlo, Monaco, Consolas, monospace); - flex-shrink: 0; -} - -.mobile-changes-row-pill.change-added { - background: color-mix(in srgb, var(--vscode-agentsMobileDiff-addedForeground) 18%, transparent); - color: var(--vscode-agentsMobileDiff-addedForeground); -} - -.mobile-changes-row-pill.change-modified { - background: color-mix(in srgb, var(--vscode-agentsMobileDiff-modifiedForeground) 18%, transparent); - color: var(--vscode-agentsMobileDiff-modifiedForeground); -} - -.mobile-changes-row-pill.change-deleted { - background: color-mix(in srgb, var(--vscode-agentsMobileDiff-deletedForeground) 18%, transparent); - color: var(--vscode-agentsMobileDiff-deletedForeground); -} - -.mobile-changes-row-counts { - display: inline-flex; - gap: 6px; - font-size: 12px; - font-family: var(--monaco-monospace-font, 'SF Mono', Menlo, Monaco, Consolas, monospace); -} +/* -- Added / removed line counters ---------------------------------------- */ .mobile-changes-row-added { color: var(--vscode-agentsMobileDiff-addedForeground); diff --git a/src/vs/sessions/browser/parts/mobile/contributions/mobileChangesView.ts b/src/vs/sessions/browser/parts/mobile/contributions/mobileChangesView.ts index c5f9d6047d4a89..f51324df4feaea 100644 --- a/src/vs/sessions/browser/parts/mobile/contributions/mobileChangesView.ts +++ b/src/vs/sessions/browser/parts/mobile/contributions/mobileChangesView.ts @@ -3,83 +3,32 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import './media/mobileOverlayViews.css'; -import './mobileDiffColors.js'; -import * as DOM from '../../../../../base/browser/dom.js'; -import { Disposable, DisposableStore, toDisposable } from '../../../../../base/common/lifecycle.js'; -import { Emitter, Event } from '../../../../../base/common/event.js'; -import { Gesture, EventType as TouchEventType } from '../../../../../base/browser/touch.js'; -import { Codicon } from '../../../../../base/common/codicons.js'; -import { ThemeIcon } from '../../../../../base/common/themables.js'; -import { autorun } from '../../../../../base/common/observable.js'; -import { localize } from '../../../../../nls.js'; import { URI } from '../../../../../base/common/uri.js'; -import { comparePaths } from '../../../../../base/common/comparers.js'; -import { basename, dirname } from '../../../../../base/common/resources.js'; -import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js'; -import { getMainWindowHost, ISessionHostService } from '../../../../../workbench/services/sessions/browser/sessionHost.js'; import { ISessionFileChange } from '../../../../../workbench/services/sessions/common/session.js'; import { IFileDiffViewData } from './mobileDiffView.js'; -const $ = DOM.$; - /** - * Command id for opening the {@link MobileChangesView}. + * Command id for opening the mobile changes overlay. * - * Takes no arguments. The view reads the active chat's changes from - * {@link ISessionsService}. Phone-only. + * Takes no arguments. The overlay shows the active chat's changes. Phone-only. */ export const MOBILE_OPEN_CHANGES_VIEW_COMMAND_ID = 'sessions.mobile.openChangesView'; /** - * Visual change-type for a mobile changes-list row. - */ -type MobileChangeType = 'added' | 'modified' | 'deleted'; - -/** - * Normalised view-model for a single row in {@link MobileChangesView}. We - * read the live `ISessionFileChange` observable on every render and reduce - * each entry into this minimal shape so the row template stays pure DOM. + * Normalised per-file shape reduced from an `ISessionFileChange`, used to + * build the diff overlay payload. */ interface IMobileChangesRow { - readonly displayUri: URI; readonly originalUri: URI | undefined; readonly modifiedUri: URI | undefined; - readonly changeType: MobileChangeType; readonly added: number; readonly removed: number; } -/** - * Callback invoked when the user taps a row. Receives the per-file - * payload along with the full sibling list and the tapped index — these - * are forwarded to the diff overlay so it can render prev/next chevrons. - */ -export type MobileChangesOpenHandler = (diff: IFileDiffViewData, siblings: readonly IFileDiffViewData[], index: number) => void; - export function toRow(change: ISessionFileChange): IMobileChangesRow { - // `IChatSessionFileChange2` carries `uri` as the canonical identity; the - // legacy `IChatSessionFileChange` only has `modifiedUri` (required, never - // absent). We detect v2 by the presence of `uri` (it's a non-optional - // field on v2 only). Avoiding the import of the type-guard keeps this - // file inside the `vs/sessions/browser` layering rule — workbench/contrib - // imports are not allowed here. - const v2Uri = (change as { uri?: URI }).uri; - const displayUri: URI = v2Uri ?? (change as { modifiedUri: URI }).modifiedUri; - const originalUri = change.originalUri; - const modifiedUri = (change as { modifiedUri?: URI }).modifiedUri; - - const changeType: MobileChangeType = originalUri === undefined - ? 'added' - : modifiedUri === undefined - ? 'deleted' - : 'modified'; - return { - displayUri, - originalUri, - modifiedUri, - changeType, + originalUri: change.originalUri, + modifiedUri: (change as { modifiedUri?: URI }).modifiedUri, added: change.insertions, removed: change.deletions, }; @@ -94,234 +43,3 @@ export function rowToDiffData(row: IMobileChangesRow): IFileDiffViewData { removed: row.removed, }; } - -function compareRows(a: IMobileChangesRow, b: IMobileChangesRow): number { - return comparePaths(a.displayUri.fsPath, b.displayUri.fsPath); -} - -/** - * Full-screen overlay listing every file changed in the active session. - * - * Visually matches {@link MobileDiffView}: uses the same `mobile-overlay-*` - * chrome (header with back button + title, scrollable body). Each row is - * a tap target showing a themed file icon, filename, relative path, - * change-type pill, and `+N -N` counters. - * - * Tapping a row invokes the supplied {@link MobileChangesOpenHandler} - * with the row's diff payload along with the sibling list — used by the - * diff overlay to support prev/next navigation. - */ -export class MobileChangesView extends Disposable { - - private readonly _onDidDispose = this._register(new Emitter()); - /** - * Fires when this view has been disposed (either externally or because - * the user tapped Back). Used by the mobile overlay contribution to - * clear its `MutableDisposable` slot so it doesn't - * keep a stale reference around — preserving the "value === undefined - * <=> no overlay open" invariant. - */ - readonly onDidDispose: Event = this._onDidDispose.event; - - private readonly viewStore = this._register(new DisposableStore()); - /** - * Disposables that belong to the rows currently rendered in the list. - * `renderList` runs on every reactive change to the active session - * (potentially many times per session) — each render registers - * per-row gesture targets and click/tap listeners. We hold those in a - * dedicated store and `clear()` it at the top of every render so the - * disposable count and gesture-target list don't grow unbounded. - */ - private readonly rowsStore = this._register(new DisposableStore()); - private readonly listContainer: HTMLElement; - private readonly subtitleEl: HTMLElement; - private readonly emptyEl: HTMLElement; - - constructor( - workbenchContainer: HTMLElement, - private readonly onOpen: MobileChangesOpenHandler, - @IInstantiationService _instantiationService: IInstantiationService, - @ISessionHostService private readonly sessionHostService: ISessionHostService, - ) { - super(); - - // -- Root overlay ----------------------------------------- - const overlay = DOM.append(workbenchContainer, $('div.mobile-overlay-view')); - this.viewStore.add(DOM.addDisposableListener(overlay, DOM.EventType.CONTEXT_MENU, e => e.preventDefault())); - this.viewStore.add(toDisposable(() => overlay.remove())); - - // -- Header ----------------------------------------------- - const header = DOM.append(overlay, $('div.mobile-overlay-header')); - - const backBtn = DOM.append(header, $('button.mobile-overlay-back-btn', { type: 'button' })) as HTMLButtonElement; - backBtn.setAttribute('aria-label', localize('changesView.back', "Back")); - DOM.append(backBtn, $('span')).classList.add(...ThemeIcon.asClassNameArray(Codicon.chevronLeft)); - DOM.append(backBtn, $('span.back-btn-label')).textContent = localize('changesView.backLabel', "Back"); - this.viewStore.add(Gesture.addTarget(backBtn)); - this.viewStore.add(DOM.addDisposableListener(backBtn, DOM.EventType.CLICK, () => this.dispose())); - this.viewStore.add(DOM.addDisposableListener(backBtn, TouchEventType.Tap, () => this.dispose())); - - const info = DOM.append(header, $('div.mobile-overlay-header-info')); - DOM.append(info, $('div.mobile-overlay-header-title')).textContent = localize('changesView.title', "Changes"); - this.subtitleEl = DOM.append(info, $('div.mobile-overlay-header-subtitle')); - - // -- Body ------------------------------------------------- - const body = DOM.append(overlay, $('div.mobile-overlay-body')); - const scrollWrapper = DOM.append(body, $('div.mobile-overlay-scroll')); - this.listContainer = DOM.append(scrollWrapper, $('div.mobile-changes-list')); - - this.emptyEl = DOM.append(body, $('div.mobile-overlay-empty-state')); - this.emptyEl.style.display = 'none'; - this.emptyEl.textContent = localize('changesView.empty', "No changes yet."); - - // -- Subscribe to live changes ----------------------------- - this.viewStore.add(autorun(reader => { - const chat = getMainWindowHost(this.sessionHostService).chat.read(reader); - const rows = (chat?.changes.read(reader) ?? []).map(toRow).sort(compareRows); - this.renderList(rows); - })); - } - - private renderList(rows: readonly IMobileChangesRow[]): void { - // Drop per-row disposables from the previous render before - // detaching the DOM. `autorun` may re-fire many times during a - // long agent session as files stream into the change list. - this.rowsStore.clear(); - DOM.clearNode(this.listContainer); - - // Update subtitle counters from the full list. - let totalAdded = 0; - let totalRemoved = 0; - for (const row of rows) { - totalAdded += row.added; - totalRemoved += row.removed; - } - if (rows.length === 0) { - this.subtitleEl.textContent = ''; - this.emptyEl.style.display = ''; - this.listContainer.style.display = 'none'; - return; - } - this.emptyEl.style.display = 'none'; - this.listContainer.style.display = ''; - - // Render the subtitle as styled spans so the +N / -N counters - // pick up the same accent colours as the per-row counters. We - // can't use the `localize` template here directly because it - // returns a flat string — instead construct the DOM manually. - DOM.clearNode(this.subtitleEl); - const fileWord = rows.length === 1 - ? localize('changesView.subtitleFileSingular', "1 file") - : localize('changesView.subtitleFilePlural', "{0} files", rows.length); - DOM.append(this.subtitleEl, $('span.mobile-overlay-header-subtitle-files')).textContent = fileWord; - DOM.append(this.subtitleEl, $('span.mobile-overlay-header-subtitle-sep')).textContent = ' · '; - DOM.append(this.subtitleEl, $('span.mobile-changes-row-added')).textContent = `+${totalAdded}`; - DOM.append(this.subtitleEl, document.createTextNode(' ')); - DOM.append(this.subtitleEl, $('span.mobile-changes-row-removed')).textContent = `-${totalRemoved}`; - - // Build the sibling list once so each row passes the same - // reference to the open-handler — keeps prev/next navigation - // consistent regardless of which row was tapped. - const siblings = rows.map(rowToDiffData); - - for (let i = 0; i < rows.length; i++) { - this.renderRow(rows[i], siblings, i); - } - } - - private renderRow(row: IMobileChangesRow, siblings: readonly IFileDiffViewData[], index: number): void { - const button = DOM.append(this.listContainer, $('button.mobile-changes-row', { type: 'button' })) as HTMLButtonElement; - button.classList.add(`change-${row.changeType}`); - button.setAttribute('aria-label', localize( - 'changesView.rowAria', - "{0}, {1}, +{2} -{3}", - row.displayUri.path, - localizeChangeType(row.changeType), - row.added, - row.removed, - )); - - // File icon (codicon, varies by change type) + filename + directory path - const labelHost = DOM.append(button, $('div.mobile-changes-row-label')); - - const iconEl = DOM.append(labelHost, $('span.mobile-changes-row-icon')); - iconEl.classList.add(...ThemeIcon.asClassNameArray(changeTypeIcon(row.changeType))); - - const textHost = DOM.append(labelHost, $('div.mobile-changes-row-text')); - DOM.append(textHost, $('span.mobile-changes-row-filename')).textContent = basename(row.displayUri); - // Show only the directory portion relative to the tunnel root — strip - // the scheme-specific `/file/-` prefix if present so the user sees a - // clean path like `/Users/osvaldortega/project` rather than noise. - const rawDir = dirname(row.displayUri).path.replace(/^\/file\/-/, ''); - if (rawDir && rawDir !== '/') { - DOM.append(textHost, $('span.mobile-changes-row-dir')).textContent = rawDir; - } - - // Trailing pill (A/M/D) + numeric counters. - const meta = DOM.append(button, $('div.mobile-changes-row-meta')); - const pill = DOM.append(meta, $('span.mobile-changes-row-pill')); - pill.classList.add(`change-${row.changeType}`); - pill.textContent = changeTypeGlyph(row.changeType); - pill.setAttribute('aria-hidden', 'true'); - - const counts = DOM.append(meta, $('span.mobile-changes-row-counts')); - if (row.added > 0) { - DOM.append(counts, $('span.mobile-changes-row-added')).textContent = `+${row.added}`; - } - if (row.removed > 0) { - DOM.append(counts, $('span.mobile-changes-row-removed')).textContent = `-${row.removed}`; - } - - // Activate via both click and tap so quick taps don't get - // swallowed by the 300ms click delay on touch devices. Per-row - // listeners go on `rowsStore` so they're cleared on the next - // reactive re-render. - this.rowsStore.add(Gesture.addTarget(button)); - const onActivate = () => this.onOpen(siblings[index], siblings, index); - this.rowsStore.add(DOM.addDisposableListener(button, DOM.EventType.CLICK, onActivate)); - this.rowsStore.add(DOM.addDisposableListener(button, TouchEventType.Tap, onActivate)); - } - - override dispose(): void { - // Fire before the registered emitter is itself disposed. Listeners - // are notified that the view has gone away — see `onDidDispose`. - this._onDidDispose.fire(); - super.dispose(); - } -} - -function changeTypeGlyph(type: MobileChangeType): string { - switch (type) { - case 'added': return 'A'; - case 'modified': return 'M'; - case 'deleted': return 'D'; - } -} - -function changeTypeIcon(type: MobileChangeType): ThemeIcon { - switch (type) { - case 'added': return Codicon.diffAdded; - case 'modified': return Codicon.diffModified; - case 'deleted': return Codicon.diffRemoved; - } -} - -function localizeChangeType(type: MobileChangeType): string { - switch (type) { - case 'added': return localize('changesView.changeAdded', "added"); - case 'modified': return localize('changesView.changeModified', "modified"); - case 'deleted': return localize('changesView.changeDeleted', "deleted"); - } -} - -/** - * Opens a {@link MobileChangesView}. Returns the view instance — dispose - * to close (the view also disposes itself when the user taps Back). - */ -export function openMobileChangesView( - instantiationService: IInstantiationService, - workbenchContainer: HTMLElement, - onOpen: MobileChangesOpenHandler, -): MobileChangesView { - return instantiationService.createInstance(MobileChangesView, workbenchContainer, onOpen); -} diff --git a/src/vs/sessions/browser/parts/mobile/contributions/mobileDiffColors.ts b/src/vs/sessions/browser/parts/mobile/contributions/mobileDiffColors.ts index ef76c34b8dfb25..b5e726e861b2cf 100644 --- a/src/vs/sessions/browser/parts/mobile/contributions/mobileDiffColors.ts +++ b/src/vs/sessions/browser/parts/mobile/contributions/mobileDiffColors.ts @@ -3,13 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -// Mobile diff / changes overlay color tokens. +// Mobile diff overlay color tokens. // -// These tokens back the phone-layout changes-list and diff overlay -// (icons, A/M/D pills, +N/-N counters, edge bars on diff rows). They -// live next to the views that consume them rather than in the global -// `vs/workbench/contrib/sessions/common/theme.ts`, since they are mobile-specific and -// have no consumers in any other layer. +// These tokens back the phone-layout diff overlay (+N/-N counters, edge +// bars on diff rows). They live next to the views that consume them rather +// than in the global `vs/workbench/contrib/sessions/common/theme.ts`, since +// they are mobile-specific and have no consumers in any other layer. // // Why register them at all? `vs/workbench/contrib/scm` is not loaded in // the agents window, so the `gitDecoration.*` color tokens that the @@ -18,9 +17,8 @@ // `--vscode-agentsMobileDiff-*` variables. Defaults mirror the // git-extension palette so they look the same as the rest of VS Code. // -// The file is imported as a side-effect from the mobile diff/changes -// views, which is enough to register the tokens with the global color -// registry on startup. +// The file is imported as a side-effect from the mobile diff view, which is +// enough to register the tokens with the global color registry on startup. import { localize } from '../../../../../nls.js'; import { registerColor } from '../../../../../platform/theme/common/colorUtils.js'; @@ -31,12 +29,6 @@ export const agentsMobileDiffAddedForeground = registerColor( localize('agentsMobileDiff.addedForeground', 'Foreground color used for added files / lines in the mobile changes-list and diff overlay in the agent sessions window.') ); -export const agentsMobileDiffModifiedForeground = registerColor( - 'agentsMobileDiff.modifiedForeground', - { dark: '#E2C08D', light: '#895503', hcDark: '#E2C08D', hcLight: '#895503' }, - localize('agentsMobileDiff.modifiedForeground', 'Foreground color used for modified files in the mobile changes-list in the agent sessions window.') -); - export const agentsMobileDiffDeletedForeground = registerColor( 'agentsMobileDiff.deletedForeground', { dark: '#c74e39', light: '#ad0707', hcDark: '#c74e39', hcLight: '#ad0707' }, diff --git a/src/vs/sessions/browser/parts/mobile/contributions/mobileDiffView.ts b/src/vs/sessions/browser/parts/mobile/contributions/mobileDiffView.ts index 50e9f3713c3f60..04c4729970ce96 100644 --- a/src/vs/sessions/browser/parts/mobile/contributions/mobileDiffView.ts +++ b/src/vs/sessions/browser/parts/mobile/contributions/mobileDiffView.ts @@ -295,10 +295,10 @@ export class MobileDiffView extends Disposable { // Header content this.titleEl.textContent = fileName; - // Render +N / -N as styled spans so they pick up the same accent - // colours as the changes-list (`mobile-changes-row-added` / - // `mobile-changes-row-removed`). The previous flat textContent - // rendered everything as foreground colour. + // Render +N / -N as styled spans so they pick up the added / removed + // accent colours (`mobile-changes-row-added` / + // `mobile-changes-row-removed`). A flat textContent would render + // everything as foreground colour. DOM.clearNode(this.subtitleEl); if (!diff.identical) { if (diff.added) {