Skip to content

feat(sidebar): show repository context on pinned tasks - #76471

Closed
charlesvien wants to merge 10 commits into
masterfrom
posthog-code/pinned-task-repository-context
Closed

charlesvien wants to merge 10 commits into
masterfrom
posthog-code/pinned-task-repository-context

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Ports PostHog/code#3808 into the monorepo (PostHog/code main is frozen after the desktop import; open PRs there are remade here). Commits preserve the original authorship.

Problem

Pinned tasks only show a title. They sit above the per-project groups, so unlike every other row they never get a repository from a group header, and once you have a dozen of them pinned there's no way to tell which checkout one belongs to. Supacode's pinned list shows the repo under each task and I wanted the same thing here.

Changes

Before:

Pinned tasks showing only titles

After:

Pinned tasks with a repository and branch under each title

  • Pinned rows get a second line: the repository, plus the branch when the task has one of its own
  • The repo name comes from the registered folder, so it reads the same as the group header the task would sit under. A task with no repo stays on one line (last row above)
  • The branch is the task's linked branch, falling back to a worktree's checked-out branch. Local tasks sitting on the default branch show no branch at all, so you don't get a · main repeated down the whole list
  • Rows inside a project group are untouched, they already have the header above them
  • Quill's Button pins a fixed height, so the two-line row opts out with h-auto! the same way CommandMenu and MessageJumpPicker already do
Light theme Pinned tasks in the light theme

How did you test this code?

  • pnpm typecheck and biome check, both clean
  • Unit tests for the new formatTaskContext: worktree vs local vs cloud, linked branch vs checked-out branch, default-branch suppression, folder naming, and the repo-less fallback
  • vitest run src/features/sidebar in packages/ui (111 pass) and pnpm --filter @posthog/core test (2507 pass)
  • New Sidebar/TaskItem story, which is where the screenshots above come from. Also eyeballed the active-row and hover-toolbar states in both themes
  • node scripts/check-host-boundaries.mjs, no new violations
  • After the port: from products/desktop/, pnpm install --frozen-lockfile, pnpm typecheck (24/24 clean), full @posthog/core suite (2973), UI sidebar tests (117) and the host-boundary check (no new violations) all pass

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

N/A

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

This PR is a port of PostHog/code#3808 (author: haacked) into products/desktop/, done with Claude Code following the repo's /porting-code-prs skill: git am -3 --directory=products/desktop/ over the source patch series, preserving the original commits and authorship (including a posthog[bot] storybook-baseline commit; the baseline file is inert here since the monorepo removed the desktop storybook CI). One conflict: the source PR branched before the pinned tree replaced SidebarItemLabel with OverflowTickerText for the row label, so its last commit edited a helper our tree no longer had. Resolved by keeping the monorepo's OverflowTickerText label and reintroducing SidebarItemLabel (with the quill tooltip imports) solely for the subtitle line, which is what the commit was after.


Created with PostHog Code

haacked and others added 9 commits August 2, 2026 17:30
Pinned tasks float above the per-repository groups, so they lost the one piece
of context the group header would have given them. With a long pinned list
there was no way to tell which checkout a task belonged to.

Each pinned row now carries a second line reading `repository · branch`. The
repository half reuses the registered folder's name so it matches the group
header the task would otherwise sit under; the branch half uses the task's
linked branch, falling back to a worktree's checked-out branch. Neither half
appears when unknown, so a repo-less task stays a single line and a local task
sitting on the default branch never renders a repeated "· main".

Rows inside a repository group are unchanged — their header already says where
they live.

Generated-By: PostHog Code
Task-Id: 7dd3d861-551c-4234-8747-cce924cb7a0b
…Date

The story computed its `timestamp` args at module scope via `Date.now()`, but
the visual-regression runner freezes the clock to a fixed instant in a decorator
that runs at render. The args were therefore measured against a different clock
than they were rendered against, and since the frozen instant is behind real
time every relative label collapsed to "now" in CI — losing the timestamp
variety the story exists to show, and leaving the new snapshots dependent on how
the real and frozen clocks happen to line up.

Fixtures now carry an age in hours and resolve it to a timestamp during render,
so the labels read off the same clock that renders them. Verified the story
renders identically ("now / 3h / 1d / 1d") both under a spoofed
StorybookTestRunner user agent and interactively.

Generated-By: PostHog Code
Task-Id: 7dd3d861-551c-4234-8747-cce924cb7a0b
…shots

The story's task titles and branch names were transcribed from a real pinned
task list, which does not belong in a public repo and made the fixture read as
someone's actual work queue. Replaced with generic equivalents of the same
shape, so the row still demonstrates truncation and the varied workspace modes.

The PNGs are here only so the pull request description can embed them by commit
SHA; the next commit removes them, which leaves the blobs reachable at that SHA
without carrying binaries into the merge.

Generated-By: PostHog Code
Task-Id: 7dd3d861-551c-4234-8747-cce924cb7a0b
The pull request description references these by the commit SHA that added them,
which keeps the blobs reachable on GitHub after this removal — so the images
still render in the description while the merged tree stays free of binaries.

Generated-By: PostHog Code
Task-Id: 7dd3d861-551c-4234-8747-cce924cb7a0b
…context map

`TaskContextFolder` re-declared the folder fields that `findGroupFolder` already
expressed as an inline generic constraint, so the two could drift apart if the
group-matching logic ever needed another field. Names that shape once as
`GroupableFolder` (beside the existing `GroupableTask`) and has both the
constraint and `TaskContextFolder` build on it.

The pinned rows also memoised a taskId-keyed Map of context lines and then read
it back inside the same `.map()` that already had the task in hand. The keyed
lookup bought nothing, and the memo rarely held anyway — `partitionAndSortTasks`
hands back a fresh array on most recomputes, so the dependency changed identity
about as often as the value did. Formatting inline drops the memo, the Map, and
the `?? undefined` round trip.

No behaviour change: same rendered output, same tests.

Generated-By: PostHog Code
Task-Id: 7dd3d861-551c-4234-8747-cce924cb7a0b
4 updated
Run: c415305b-3154-4416-a261-b2198e77b9cc

Co-authored-by: haacked <19977+haacked@users.noreply.github.com>
Referenced from the description by this commit's SHA, so the next commit can
remove them without breaking the images.

The "before" shot is the same story with the subtitle prop withheld, which is
exactly how the row rendered before this branch: with no subtitle, SidebarItem
skips both the second line and the height override.

Generated-By: PostHog Code
Task-Id: 7dd3d861-551c-4234-8747-cce924cb7a0b
The description references them by the commit SHA that added them, so they keep
rendering while the merged tree stays free of binaries.

Generated-By: PostHog Code
Task-Id: 7dd3d861-551c-4234-8747-cce924cb7a0b
…omment

The subtitle inherited `truncate` but not the tooltip that `SidebarItemLabel`
pairs with it, so a clipped `repository · branch` had no way back — the branch
tail is what falls off, since the repository leads the string. Giving
`SidebarItemLabel` an optional className lets the subtitle reuse that same
measure-and-tooltip-only-when-overflowing path instead of a second bare span.
Renders byte-identically, so the approved visual baselines still hold.

Also corrects the comment on `repositoryLabel`, which claimed the line reads
"exactly like the group header". That only holds when a folder is registered:
`groupByRepository` prefixes the organization when two group names collide, and
this cannot reproduce that from a single task. Borrowing the group's name is not
an option either, since groups are built from the unpinned tasks, so a pinned
task's repo may have no group at all. The comment now says what the code does
and why the gap is deliberate.

Generated-By: PostHog Code
Task-Id: 7dd3d861-551c-4234-8747-cce924cb7a0b
@charlesvien charlesvien added the feature/desktop Feature Tag: Desktop label Aug 3, 2026
@trunk-io

trunk-io Bot commented Aug 3, 2026

Copy link
Copy Markdown

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(sidebar): tooltip the truncated cont..." | Re-trigger Greptile

@charlesvien

Copy link
Copy Markdown
Member Author

@haacked this is your PostHog/code#3808 remade in the monorepo (main there is frozen after the desktop import). Your commits are intact, only paths moved plus small conflict fixes noted in the description. Can you review and approve if it looks good?

@trunk-io

trunk-io Bot commented Aug 3, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@charlesvien

Copy link
Copy Markdown
Member Author

@puemos can you review this one? haacked made it on the code repo (PostHog/code#3808) and I remade it here after the desktop import. Given your recent changes in the sidebar you're the right person to review it.

@puemos

puemos commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@puemos can you review this one? haacked made it on the code repo (PostHog/code#3808) and I remade it here after the desktop import. Given your recent changes in the sidebar you're the right person to review it.

overall it looks fine but we are moving away from this layout so this will be gone. In any case I'll review, just in case we decide not to move this week

taskId: string;
label: string;
/** Second line under the title, e.g. the task's `repository · branch`. */
subtitle?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟥 Blocking

When hovering the TaskItem it moves a bit

jumping.mov

depth?: number;
taskId: string;
label: string;
/** Second line under the title, e.g. the task's `repository · branch`. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟦 Nice-to-have:

we can remove this comment

}) {
const canTooltip = typeof label === "string" || typeof label === "number";

const measureRef = useCallback((el: HTMLSpanElement | null) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟦 Nice-to-have

I wonder if this should belong in a reusable hook

@charlesvien charlesvien closed this Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/desktop Feature Tag: Desktop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants