Skip to content
Draft
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
6 changes: 5 additions & 1 deletion client/board/board-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ProjectsView } from "../projects/projects-view";
import { EMPTY_PROMPTS, PromptSettingsView } from "../settings/prompt-settings-view";
import type { Styles } from "../theme/use-styles";
import { openExternalUrl } from "../web";
import type { ChatLink } from "./use-chat-links";

/**
* Everything below the header and the toolbar: the settings screen when it is
Expand Down Expand Up @@ -37,6 +38,7 @@ export function BoardBody({
setBodyWidth,
detailTarget,
detailItem,
detailChatLink,
detailProgress,
closeDetails,
savedFraction,
Expand All @@ -63,6 +65,7 @@ export function BoardBody({
setBodyWidth: (next: number | null) => void;
detailTarget: { item: BoardItem; type: ColumnId } | null;
detailItem: BoardItem | null;
detailChatLink: ChatLink | null;
detailProgress: Animated.Value;
closeDetails: () => void;
savedFraction: number | null;
Expand Down Expand Up @@ -94,7 +97,6 @@ export function BoardBody({
<ProjectsView
theme={surfaceProps.theme}
layout={surfaceProps.layout}
login={board.login}
owners={watchedOwners}
onOpenUrl={openExternalUrl}
/>
Expand Down Expand Up @@ -141,6 +143,7 @@ export function BoardBody({
key={detailItem.id}
item={detailItem}
type={detailTarget.type}
chatLink={detailChatLink}
styles={styles}
accentColor={surfaceProps.theme.colors.accent}
foregroundColor={surfaceProps.theme.colors.foreground}
Expand All @@ -149,6 +152,7 @@ export function BoardBody({
onWidthCommitted={commitWidth}
progress={detailProgress}
onClose={closeDetails}
onOpenChat={(chat) => surfaceProps.navigation?.openAgent({ agentId: chat.agentId })}
onSend={openSendDialog}
onMerged={dropItem}
/>
Expand Down
1 change: 1 addition & 0 deletions client/board/board-row.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function buildBoardRowStyles(
gap: 6,
marginTop: 6,
},
itemRowActions: { flexDirection: "row" as const, alignItems: "center" as const, gap: 4 },
/** Hidden until the row or the action itself is hovered; see `sendButtonHidden`. */
itemRowActionHidden: { opacity: 0 },
label: {
Expand Down
2 changes: 2 additions & 0 deletions client/board/github-board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function GitHubBoard(props: PluginSurfaceProps) {
setBodyWidth,
detailTarget,
detailItem,
detailChatLink,
detailProgress,
closeDetails,
savedFraction,
Expand Down Expand Up @@ -154,6 +155,7 @@ export function GitHubBoard(props: PluginSurfaceProps) {
setBodyWidth={setBodyWidth}
detailTarget={detailTarget}
detailItem={detailItem}
detailChatLink={detailChatLink}
detailProgress={detailProgress}
closeDetails={closeDetails}
savedFraction={savedFraction}
Expand Down
7 changes: 4 additions & 3 deletions client/board/item-row-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface RowDisplay {
*/
export function describeRow({
item,
viewerLogin,
viewerLogins,
order,
type,
accentColor,
Expand All @@ -48,7 +48,7 @@ export function describeRow({
isWeb,
}: {
item: BoardItem;
viewerLogin: string;
viewerLogins: readonly string[];
order: SortOrder;
type: ColumnId;
accentColor: string;
Expand All @@ -73,7 +73,8 @@ export function describeRow({
: "CircleDot";
const iconColor = type === "draft-prs" || type === "discussions" ? mutedColor : accentColor;

const byline = item.author !== null && item.author !== viewerLogin ? item.author : null;
const byline =
item.author !== null && !viewerLogins.includes(item.author) ? item.author : null;

const openedBy = byline === null ? "" : `, opened by ${byline}`;
const linkedTo = closes === "" ? "" : `, closes ${closes}`;
Expand Down
66 changes: 48 additions & 18 deletions client/board/item-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { linkedIssueLabel } from "../lib/formatting";
import { relativeTime } from "../lib/time";
import type { SortOrder } from "../lib/sort";
import type { Styles } from "../theme/use-styles";
import type { ChatLink } from "./use-chat-links";
import { describeRow } from "./item-row-format";
import { ItemRowTrailing } from "./item-row-trailing";

Expand Down Expand Up @@ -52,22 +53,24 @@ function pointerPoint(event: unknown): { x: number; y: number } | null {
*/
export const ItemRow = memo(function ItemRow({
item,
viewerLogin,
viewerLogins,
styles,
platform,
compact,
selected,
accentColor,
mutedColor,
chatLink,
onOpen,
onOpenChat,
onSend,
onLabels,
type,
order,
}: {
item: BoardItem;
/** The login the board was queried for, so a row of someone else's reads as one. */
viewerLogin: string;
viewerLogins: readonly string[];
styles: Styles;
/**
* Decides two things the row cannot ask about itself: whether hovering
Expand All @@ -83,8 +86,11 @@ export const ItemRow = memo(function ItemRow({
accentColor: string;
/** The state glyph's colour for a draft or a discussion, and the send icon's. */
mutedColor: string;
/** The first Paseo chat associated with this pull request's workspace. */
chatLink: ChatLink | null;
/** A press: opens the row in the detail panel, never the browser. */
onOpen: (item: BoardItem, type: ColumnId) => void;
onOpenChat: (chat: ChatLink) => void;
onSend: (item: BoardItem, type: ColumnId) => void;
/** Null where labels cannot be edited, which takes the gesture away entirely. */
onLabels: ((item: BoardItem, point: { x: number; y: number }) => void) | null;
Expand Down Expand Up @@ -120,6 +126,10 @@ export const ItemRow = memo(function ItemRow({
onSend(item, type);
}, [item, onSend, type]);

const openChat = useCallback(() => {
if (chatLink !== null) onOpenChat(chatLink);
}, [chatLink, onOpenChat]);

const openLabels = useCallback(
(event: unknown) => {
const point = pointerPoint(event);
Expand Down Expand Up @@ -148,10 +158,11 @@ export const ItemRow = memo(function ItemRow({
const closes = item.linkedIssues
.map((issue) => linkedIssueLabel(issue, item.repository))
.join(", ");
const hostname = new URL(item.url).hostname;

const display = describeRow({
item,
viewerLogin,
viewerLogins,
order,
type,
accentColor,
Expand Down Expand Up @@ -194,26 +205,45 @@ export const ItemRow = memo(function ItemRow({
{type === "draft-prs" ? <Text style={styles.itemRowDraftPill}>Draft</Text> : null}
</View>
<Text style={styles.itemRowMeta} numberOfLines={1}>
{item.repository} #{item.number} · {display.stampLabel} {relativeTime(display.stampDate)}
{item.repository} #{item.number} · {hostname} · {display.stampLabel}{" "}
{relativeTime(display.stampDate)}
{display.byline !== null ? ` by ${display.byline}` : ""}
</Text>
{compact ? <View style={styles.itemRowTrailingCompact}>{trailing}</View> : null}
</View>
{compact ? null : <View style={styles.itemRowTrailing}>{trailing}</View>}
<Pressable
accessibilityRole="button"
accessibilityLabel={`Send ${item.repository} #${item.number} to a new workspace chat`}
onPress={send}
onHoverIn={() => setActionHovered(true)}
onHoverOut={() => setActionHovered(false)}
style={({ pressed }) => [
styles.iconButton,
revealed ? null : styles.itemRowActionHidden,
pressed ? styles.cardPressed : null,
]}
>
<Icon name="Send" size={14} color={mutedColor} />
</Pressable>
<View style={styles.itemRowActions}>
{chatLink === null ? null : (
<Pressable
accessibilityRole="button"
accessibilityLabel={`Open original chat ${chatLink.agentTitle}`}
onPress={openChat}
onHoverIn={() => setActionHovered(true)}
onHoverOut={() => setActionHovered(false)}
style={({ pressed }) => [
styles.iconButton,
revealed ? null : styles.itemRowActionHidden,
pressed ? styles.cardPressed : null,
]}
>
<Icon name="MessageSquare" size={14} color={mutedColor} />
</Pressable>
)}
<Pressable
accessibilityRole="button"
accessibilityLabel={`Send ${item.repository} #${item.number} to a new workspace chat`}
onPress={send}
onHoverIn={() => setActionHovered(true)}
onHoverOut={() => setActionHovered(false)}
style={({ pressed }) => [
styles.iconButton,
revealed ? null : styles.itemRowActionHidden,
pressed ? styles.cardPressed : null,
]}
>
<Icon name="Send" size={14} color={mutedColor} />
</Pressable>
</View>
</Pressable>
);
});
5 changes: 3 additions & 2 deletions client/board/label-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function LabelMenu({
onChanged: (itemId: string, labels: string[]) => void;
}) {
const { item } = target;
const host = new URL(item.url).hostname;
const list = useRpc(listLabels);
const apply = useRpc(toggleLabel);

Expand All @@ -68,8 +69,8 @@ export function LabelMenu({
* did: the surface unmounts on every workspace switch, the cache does not.
*/
const labelsQuery = useQuery({
queryKey: ["repository-labels", item.repository],
queryFn: () => list({ repository: item.repository }).then((result) => result.labels),
queryKey: ["repository-labels", host, item.repository],
queryFn: () => list({ repository: item.repository, host }).then((result) => result.labels),
staleTime: STALE_AFTER_MS,
});
const labels = labelsQuery.data ?? null;
Expand Down
22 changes: 19 additions & 3 deletions client/board/use-board-overlays.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { BoardRow, SortOrder } from "../lib/sort";
import { DETAIL_CLOSE_MS, DETAIL_OPEN_MS } from "../detail/constants";
import { ItemRow } from "./item-row";
import type { Styles } from "../theme/use-styles";
import type { ChatLink } from "./use-chat-links";
import { LABEL_MENU_MAX_HEIGHT, LABEL_MENU_WIDTH, MENU_MARGIN } from "./label-menu";
import type { LabelMenuTarget } from "./label-menu";

Expand All @@ -23,6 +24,7 @@ export interface UseBoardOverlaysInputs {
mutateBoardCache: (updater: (current: Board) => Board) => void;
/** The active sort's row label and date accessor, for `ItemRow`'s meta line. */
activeOrder: SortOrder;
chatLinkForItem: (item: BoardItem) => ChatLink | null;
}

/** What `useBoardOverlays` exposes to the surface. */
Expand All @@ -31,6 +33,7 @@ export interface UseBoardOverlaysResult {
setBodyWidth: (next: number | null) => void;
detailTarget: { item: BoardItem; type: ColumnId } | null;
detailItem: BoardItem | null;
detailChatLink: ChatLink | null;
detailProgress: Animated.Value;
closeDetails: () => void;
openSendDialog: (item: BoardItem, type: ColumnId) => void;
Expand Down Expand Up @@ -58,7 +61,7 @@ export interface UseBoardOverlaysResult {
export function useBoardOverlays(
props: PluginSurfaceProps,
styles: Styles,
{ board, promptValues, mutateBoardCache, activeOrder }: UseBoardOverlaysInputs,
{ board, promptValues, mutateBoardCache, activeOrder, chatLinkForItem }: UseBoardOverlaysInputs,
): UseBoardOverlaysResult {
const toast = useToast();

Expand Down Expand Up @@ -200,6 +203,14 @@ export function useBoardOverlays(
}, [board, detailTarget]);

const selectedId = detailItem?.id ?? null;
const detailChatLink = detailItem === null ? null : chatLinkForItem(detailItem);

const openChat = useCallback(
(chat: ChatLink) => {
props.navigation?.openAgent({ agentId: chat.agentId });
},
[props.navigation],
);

/**
* Opens the launch dialog on this card, with the card's template already
Expand Down Expand Up @@ -249,29 +260,33 @@ export function useBoardOverlays(
({ item: row }: { item: BoardRow }) => (
<ItemRow
item={row.item}
viewerLogin={board?.login ?? ""}
viewerLogins={board?.viewerLogins ?? []}
styles={styles}
platform={props.layout.platform}
compact={props.layout.compact}
selected={row.item.id === selectedId}
accentColor={props.theme.colors.accent}
mutedColor={props.theme.colors.foregroundMuted}
chatLink={chatLinkForItem(row.item)}
onOpen={openDetails}
onOpenChat={openChat}
onSend={openSendDialog}
onLabels={row.type === "discussions" ? null : openLabelMenu}
type={row.type}
order={activeOrder}
/>
),
[
board?.login,
board?.viewerLogins,
styles,
props.layout.platform,
props.layout.compact,
selectedId,
props.theme.colors.accent,
props.theme.colors.foregroundMuted,
chatLinkForItem,
openDetails,
openChat,
openSendDialog,
openLabelMenu,
activeOrder,
Expand All @@ -283,6 +298,7 @@ export function useBoardOverlays(
setBodyWidth,
detailTarget,
detailItem,
detailChatLink,
detailProgress,
closeDetails,
openSendDialog,
Expand Down
Loading