mirror of
https://github.com/block/buzz.git
synced 2026-11-29 04:32:08 +00:00
feat(desktop): refine repository-aware project workspaces (#6003)
## Summary - Makes Projects repository-aware across browsing, branch and tag selection, local and remote source management, work items, commits, and contextual repository actions. - Refines project details into consistent single-column reading surfaces with a resizable, section-aware context pod, while keeping project conversations available in the attached chat panel. - Adds persistent sidebar project navigation, direct entity links, repository discussion channels, contributor identity matching, and consistent loading and activity presentation. - Keeps branch-specific controls on code-oriented sections while Tasks, Reviews, and Channels remain repository-scoped, reducing misleading context and actions. Replacement for #5981 with an identical final tree flattened into one signed-off commit because the required DCO check suite remained stalled. ### Related issue N/A ### Testing - [x] Desktop pre-push checks, TypeScript typecheck, and unit tests - [x] E2E production build with `pnpm build:e2e` - [x] Focused Playwright smoke coverage for project workspace, task, review, commit, sidebar, and contextual-panel behavior - [ ] Attach final before/after screenshots after design review --------- Signed-off-by: Thomas Petersen <thomasp@squareup.com> Signed-off-by: Wintermute <165f0c871dd2586bb18b6aa109eeaf57bb2132ff4d27b10120f4368a0f627022@buzz.block.builderlab.xyz> Co-authored-by: Wintermute <165f0c871dd2586bb18b6aa109eeaf57bb2132ff4d27b10120f4368a0f627022@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -2,11 +2,18 @@ import * as React from "react";
|
||||
|
||||
import {
|
||||
AUXILIARY_PANEL_DEFAULT_WIDTH_PX,
|
||||
clampAuxiliaryPanelWidth,
|
||||
AUXILIARY_PANEL_MIN_WIDTH_PX,
|
||||
getAuxiliaryPanelMaxWidth,
|
||||
} from "@/shared/layout/AuxiliaryPanel";
|
||||
|
||||
const THREAD_PANEL_WIDTH_SESSION_KEY = "buzz.desktop.thread-panel-width";
|
||||
|
||||
type ThreadPanelWidthOptions = {
|
||||
defaultWidthPx?: number;
|
||||
minWidthPx?: number;
|
||||
sessionKey?: string;
|
||||
};
|
||||
|
||||
function getViewportWidth(): number {
|
||||
return typeof window === "undefined" ? 0 : window.innerWidth;
|
||||
}
|
||||
@@ -19,39 +26,53 @@ function getViewportWidth(): number {
|
||||
* clamps the rendered width to `calc(100% - MIN)` at paint time, so a stored width
|
||||
* larger than the current viewport never collapses the main pane.
|
||||
*/
|
||||
function clampThreadPanelWidth(width: number): number {
|
||||
return clampAuxiliaryPanelWidth(width, getViewportWidth());
|
||||
function clampThreadPanelWidth(width: number, minWidthPx: number): number {
|
||||
return Math.max(
|
||||
minWidthPx,
|
||||
Math.min(getAuxiliaryPanelMaxWidth(getViewportWidth()), width),
|
||||
);
|
||||
}
|
||||
|
||||
function getInitialThreadPanelWidth(): number {
|
||||
function getInitialThreadPanelWidth({
|
||||
defaultWidthPx,
|
||||
minWidthPx,
|
||||
sessionKey,
|
||||
}: Required<ThreadPanelWidthOptions>): number {
|
||||
if (typeof window === "undefined") {
|
||||
return AUXILIARY_PANEL_DEFAULT_WIDTH_PX;
|
||||
return defaultWidthPx;
|
||||
}
|
||||
|
||||
try {
|
||||
const raw = window.sessionStorage.getItem(THREAD_PANEL_WIDTH_SESSION_KEY);
|
||||
const raw = window.sessionStorage.getItem(sessionKey);
|
||||
if (!raw) {
|
||||
return AUXILIARY_PANEL_DEFAULT_WIDTH_PX;
|
||||
return defaultWidthPx;
|
||||
}
|
||||
|
||||
const parsed = Number.parseInt(raw, 10);
|
||||
if (!Number.isFinite(parsed)) {
|
||||
return AUXILIARY_PANEL_DEFAULT_WIDTH_PX;
|
||||
return defaultWidthPx;
|
||||
}
|
||||
|
||||
return clampThreadPanelWidth(parsed);
|
||||
return clampThreadPanelWidth(parsed, minWidthPx);
|
||||
} catch {
|
||||
return AUXILIARY_PANEL_DEFAULT_WIDTH_PX;
|
||||
return defaultWidthPx;
|
||||
}
|
||||
}
|
||||
|
||||
export function useThreadPanelWidth(availableWidthPx?: number) {
|
||||
export function useThreadPanelWidth(
|
||||
availableWidthPx?: number,
|
||||
options: ThreadPanelWidthOptions = {},
|
||||
) {
|
||||
const defaultWidthPx =
|
||||
options.defaultWidthPx ?? AUXILIARY_PANEL_DEFAULT_WIDTH_PX;
|
||||
const minWidthPx = options.minWidthPx ?? AUXILIARY_PANEL_MIN_WIDTH_PX;
|
||||
const sessionKey = options.sessionKey ?? THREAD_PANEL_WIDTH_SESSION_KEY;
|
||||
const getAvailableWidth = React.useCallback(
|
||||
() => availableWidthPx ?? getViewportWidth(),
|
||||
[availableWidthPx],
|
||||
);
|
||||
const [widthPx, setWidthPx] = React.useState<number>(() =>
|
||||
getInitialThreadPanelWidth(),
|
||||
getInitialThreadPanelWidth({ defaultWidthPx, minWidthPx, sessionKey }),
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -60,14 +81,11 @@ export function useThreadPanelWidth(availableWidthPx?: number) {
|
||||
}
|
||||
|
||||
try {
|
||||
window.sessionStorage.setItem(
|
||||
THREAD_PANEL_WIDTH_SESSION_KEY,
|
||||
String(widthPx),
|
||||
);
|
||||
window.sessionStorage.setItem(sessionKey, String(widthPx));
|
||||
} catch {
|
||||
// Ignore storage failures and keep in-memory width for this session.
|
||||
}
|
||||
}, [widthPx]);
|
||||
}, [sessionKey, widthPx]);
|
||||
|
||||
const onResizeStart = React.useCallback(
|
||||
(event: React.PointerEvent<HTMLButtonElement>) => {
|
||||
@@ -83,9 +101,12 @@ export function useThreadPanelWidth(availableWidthPx?: number) {
|
||||
|
||||
const handlePointerMove = (moveEvent: PointerEvent) => {
|
||||
const deltaX = startX - moveEvent.clientX;
|
||||
const nextWidth = clampAuxiliaryPanelWidth(
|
||||
startWidth + deltaX,
|
||||
getAvailableWidth(),
|
||||
const nextWidth = Math.max(
|
||||
minWidthPx,
|
||||
Math.min(
|
||||
getAuxiliaryPanelMaxWidth(getAvailableWidth()),
|
||||
startWidth + deltaX,
|
||||
),
|
||||
);
|
||||
setWidthPx(nextWidth);
|
||||
};
|
||||
@@ -99,15 +120,15 @@ export function useThreadPanelWidth(availableWidthPx?: number) {
|
||||
window.addEventListener("pointermove", handlePointerMove);
|
||||
window.addEventListener("pointerup", handlePointerUp, { once: true });
|
||||
},
|
||||
[getAvailableWidth, widthPx],
|
||||
[getAvailableWidth, minWidthPx, widthPx],
|
||||
);
|
||||
|
||||
const onResetWidth = React.useCallback(() => {
|
||||
setWidthPx(AUXILIARY_PANEL_DEFAULT_WIDTH_PX);
|
||||
}, []);
|
||||
setWidthPx(defaultWidthPx);
|
||||
}, [defaultWidthPx]);
|
||||
|
||||
return {
|
||||
canReset: widthPx !== AUXILIARY_PANEL_DEFAULT_WIDTH_PX,
|
||||
canReset: widthPx !== defaultWidthPx,
|
||||
onResetWidth,
|
||||
onResizeStart,
|
||||
widthPx,
|
||||
|
||||
Reference in New Issue
Block a user