@gperezmz/bb-plugin-thread-glance 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/app.tsx +3 -11
  3. package/dist/app.css +1 -1
  4. package/dist/app.js +31 -31
  5. package/dist/app.meta.json +1 -1
  6. package/dist/server.js +10 -10
  7. package/dist/server.js.map +3 -3
  8. package/dist/server.meta.json +1 -1
  9. package/features/thread-list/components/FoldRows.tsx +21 -30
  10. package/features/thread-list/components/GroupSection.tsx +7 -45
  11. package/features/thread-list/components/ListHeader.tsx +79 -0
  12. package/features/thread-list/components/ProviderBadge.tsx +0 -1
  13. package/features/thread-list/components/PullRequestProbes.tsx +27 -0
  14. package/features/thread-list/components/SettingsPanel.tsx +20 -34
  15. package/features/thread-list/components/ThreadDetails.tsx +3 -3
  16. package/features/thread-list/components/ThreadList.tsx +117 -83
  17. package/features/thread-list/components/ThreadRowView.tsx +70 -78
  18. package/features/thread-list/components/controller.ts +5 -10
  19. package/features/thread-list/components/glyphs.tsx +26 -13
  20. package/features/thread-list/data/useAutoExpand.ts +1 -1
  21. package/features/thread-list/data/useDefaultBranches.ts +35 -0
  22. package/features/thread-list/data/usePullRequestAnswers.ts +36 -0
  23. package/features/thread-list/data/useSystemFacts.ts +52 -0
  24. package/features/thread-list/icons.ts +1 -0
  25. package/features/thread-list/index.ts +0 -1
  26. package/features/thread-list/model/attention.ts +2 -66
  27. package/features/thread-list/model/branches.ts +27 -0
  28. package/features/thread-list/model/counters.ts +5 -5
  29. package/features/thread-list/model/details.ts +6 -6
  30. package/features/thread-list/model/expansion.ts +5 -5
  31. package/features/thread-list/model/groups.ts +2 -2
  32. package/features/thread-list/model/labels.ts +28 -17
  33. package/features/thread-list/model/menu.ts +1 -0
  34. package/features/thread-list/model/move.ts +1 -1
  35. package/features/thread-list/model/notes.ts +2 -28
  36. package/features/thread-list/model/settings.ts +1 -17
  37. package/features/thread-list/model/settled.ts +122 -0
  38. package/features/thread-list/model/share.ts +1 -7
  39. package/features/thread-list/model/sort.ts +5 -16
  40. package/features/thread-list/model/state.ts +19 -6
  41. package/features/thread-list/model/toggles.ts +35 -24
  42. package/features/thread-list/model/{families.ts → trees.ts} +40 -28
  43. package/features/thread-list/model/view.ts +200 -274
  44. package/features/thread-list/testing/fixtures.ts +41 -12
  45. package/package.json +1 -1
  46. package/server/cli.ts +1 -1
  47. package/server/import.ts +36 -6
  48. package/server/preference-store.ts +2 -1
  49. package/server.ts +1 -1
  50. package/shared/preferences.ts +38 -27
  51. package/skills/thread-glance/SKILL.md +11 -12
  52. package/features/thread-list/data/useAttentionHold.ts +0 -19
@@ -6,9 +6,9 @@ import type { PluginSidebarSection, PluginSidebarThread } from "@get-bb/plugin-s
6
6
  import type { Stamps } from "@/shared/contract";
7
7
  import type { HarnessIcon, OrganizationMode } from "@/shared/preferences";
8
8
  import type { ThreadNotes } from "@/shared/contract";
9
- import type { Family } from "../model/families";
9
+ import type { ThreadTree } from "../model/trees";
10
10
  import type { RowMenuAction } from "../model/menu";
11
- import type { OlderRow, ThreadRow } from "../model/view";
11
+ import type { OlderRow, SettledRow, ThreadRow } from "../model/view";
12
12
  import type { ProviderDisplay } from "./ProviderBadge";
13
13
 
14
14
  export interface ModelInfo {
@@ -21,11 +21,7 @@ export interface RowController {
21
21
  compact: boolean;
22
22
  comfortable: boolean;
23
23
  setEditingId(id: string | null): void;
24
- showPullRequests: boolean;
25
24
  harnessIcon: HarnessIcon;
26
- /** Undefined while unknown; the lookup starts on first ask. */
27
- defaultBranchOf(thread: PluginSidebarThread): string | null | undefined;
28
- multiHost: boolean;
29
25
  /** One object per harness, the same one on every call. */
30
26
  provider(providerId: string): ProviderDisplay;
31
27
  sections: readonly PluginSidebarSection[];
@@ -33,8 +29,7 @@ export interface RowController {
33
29
  onNavigate(): void;
34
30
  onToggleChip(row: ThreadRow): void;
35
31
  onToggleOlder(row: OlderRow): void;
36
- /** Opens a family's children from its "+N more" line in Needs attention. */
37
- onOpenChildren(rootId: string): void;
32
+ onToggleSettled(row: SettledRow): void;
38
33
  onToggleEnvironment(environmentId: string): void;
39
34
  onMenuAction(action: RowMenuAction, thread: PluginSidebarThread, sectionId?: string | null): void;
40
35
  onRename(threadId: string, title: string): Promise<void>;
@@ -54,12 +49,12 @@ export interface ListLive {
54
49
  now: number;
55
50
  stamps: Stamps;
56
51
  notes: Readonly<Record<string, ThreadNotes>>;
57
- familyOf(threadId: string): Family | undefined;
52
+ treeOf(threadId: string): ThreadTree | undefined;
58
53
  }
59
54
 
60
55
  export const ListLiveContext = createContext<ListLive>({
61
56
  now: 0,
62
57
  stamps: { startedAt: {}, finishedAt: {}, pendingAt: {}, seenAt: {} },
63
58
  notes: {},
64
- familyOf: () => undefined,
59
+ treeOf: () => undefined,
65
60
  });
@@ -1,11 +1,11 @@
1
- // State glyphs, chip glyphs and header counters. They draw what the model
1
+ // State glyphs, the child dot and header counters. They draw what the model
2
2
  // decided; tone and animation come from host token classes only.
3
3
  import { experimental_Icon as Icon } from "@get-bb/plugin-sdk/app";
4
4
  import type { PluginSidebarThreadRowStatus } from "@get-bb/plugin-sdk/app";
5
5
  import { cn } from "@/lib/utils";
6
6
  import type { Counters } from "../model/counters";
7
7
  import type { RowNote } from "../model/notes";
8
- import { FLAG_GLYPHS, type ChipTone, type Flag, type Glyph, type Tone } from "../model/state";
8
+ import { dotTone, FLAG_GLYPHS, type DotTone, type Flag, type Glyph, type Tone } from "../model/state";
9
9
 
10
10
  export const TONE_CLASS: Record<Tone, string> = {
11
11
  attention: "text-attention",
@@ -18,19 +18,32 @@ export const TONE_CLASS: Record<Tone, string> = {
18
18
  none: "",
19
19
  };
20
20
 
21
- // The tone colour is one of bb's tokens, mixed toward the foreground for the
22
- // text so it clears 4.5:1 on the sidebar in both themes; the border and fill
23
- // are the same colour, thinned. Written out in full so the class scan sees them.
24
- export const CHIP_TONE_CLASS: Record<ChipTone, string> = {
25
- attention:
26
- "border-[color:color-mix(in_oklch,var(--attention)_45%,transparent)] bg-[color-mix(in_oklch,var(--attention)_10%,transparent)] text-[color:color-mix(in_oklch,var(--attention),var(--foreground)_55%)] hover:bg-[color-mix(in_oklch,var(--attention)_20%,transparent)]",
27
- destructive:
28
- "border-[color:color-mix(in_oklch,var(--destructive-text)_45%,transparent)] bg-[color-mix(in_oklch,var(--destructive-text)_10%,transparent)] text-[color:color-mix(in_oklch,var(--destructive-text),var(--foreground)_55%)] hover:bg-[color-mix(in_oklch,var(--destructive-text)_20%,transparent)]",
29
- working:
30
- "border-[color:color-mix(in_oklch,var(--timeline-accent)_45%,transparent)] bg-[color-mix(in_oklch,var(--timeline-accent)_10%,transparent)] text-[color:color-mix(in_oklch,var(--timeline-accent),var(--foreground)_55%)] hover:bg-[color-mix(in_oklch,var(--timeline-accent)_20%,transparent)]",
31
- neutral: "border-border/70 text-muted-foreground hover:bg-state-hover hover:text-foreground",
21
+ // The child dot's colours: the tone of the state it stands for, and the
22
+ // unread dot's accent for unread.
23
+ const DOT_TONE_CLASS: Record<DotTone, string> = {
24
+ attention: "bg-attention",
25
+ destructive: "bg-destructive",
26
+ working: "bg-[var(--timeline-accent)]",
27
+ unread: "bg-[var(--timeline-accent)]",
32
28
  };
33
29
 
30
+ /**
31
+ * The child dot on a parent's status glyph, at its lower right corner. A
32
+ * ring of the sidebar's colour keeps it apart from the glyph under it.
33
+ */
34
+ export function ChildDot({ flag }: { flag: Flag }) {
35
+ return (
36
+ <span
37
+ aria-hidden
38
+ data-child-dot={flag}
39
+ className={cn(
40
+ "pointer-events-none absolute -right-0.5 -bottom-0.5 size-[7px] rounded-full ring-[1.5px] ring-sidebar",
41
+ DOT_TONE_CLASS[dotTone(flag)],
42
+ )}
43
+ />
44
+ );
45
+ }
46
+
34
47
  const SHINE = "animate-shine-icon motion-reduce:animate-none";
35
48
  const SPIN = "animate-spin motion-reduce:animate-none";
36
49
 
@@ -1,7 +1,7 @@
1
1
  // Transient auto-expansion. Transitions are diffed against the previous
2
2
  // render, as bb does; nothing here is persisted.
3
3
  import { useCallback, useRef, useState } from "react";
4
- import type { Forest } from "../model/families";
4
+ import type { Forest } from "../model/trees";
5
5
  import {
6
6
  detectTransitions,
7
7
  mergeTargets,
@@ -0,0 +1,35 @@
1
+ // Each project's default branch, looked up once per list through the
2
+ // machine of the project's default source.
3
+ //
4
+ // Debt: the answers are kept in component state, with no refresh, because
5
+ // the SDK offers no cached query for a project's branches. It clears when
6
+ // the SDK does, or when a default branch changing mid-session matters.
7
+ import { useEffect, useRef, useState } from "react";
8
+ import { useSdk } from "@get-bb/plugin-sdk/app";
9
+ import { defaultSourceHostId } from "../model/branches";
10
+
11
+ /** Project id → default branch; undefined while unknown, null when the lookup found none. */
12
+ export type DefaultBranches = ReadonlyMap<string, string | null>;
13
+
14
+ export function useDefaultBranches(projectIds: readonly string[]): DefaultBranches {
15
+ const sdk = useSdk();
16
+ const [branches, setBranches] = useState<DefaultBranches>(() => new Map());
17
+ const requested = useRef(new Set<string>());
18
+ useEffect(() => {
19
+ for (const projectId of projectIds) {
20
+ if (requested.current.has(projectId)) continue;
21
+ requested.current.add(projectId);
22
+ const settle = (branch: string | null) => setBranches((current) => new Map(current).set(projectId, branch));
23
+ sdk.projects
24
+ .get({ projectId })
25
+ .then(async (project) => {
26
+ const hostId = defaultSourceHostId(project.sources);
27
+ if (hostId === null) return null;
28
+ const result = await sdk.projects.branches({ projectId, hostId, limit: "1" });
29
+ return result.defaultBranch ?? null;
30
+ })
31
+ .then(settle, () => settle(null));
32
+ }
33
+ }, [projectIds, sdk]);
34
+ return branches;
35
+ }
@@ -0,0 +1,36 @@
1
+ // The pull request lookups that answered, by thread id. Answers arriving in
2
+ // one burst (a list's worth of lookups on load) land in one state update.
3
+ //
4
+ // Debt: this copies server state the host's per-row pull request hook owns,
5
+ // because settling reads every thread's pull request at once and the SDK
6
+ // offers no query over many threads. It clears when the SDK does.
7
+ import { useCallback, useRef, useState } from "react";
8
+ import type { PullRequestState } from "../model/settled";
9
+
10
+ export type PullRequestAnswers = ReadonlyMap<string, PullRequestState | null>;
11
+
12
+ export function usePullRequestAnswers(): [PullRequestAnswers, (threadId: string, state: PullRequestState | null) => void] {
13
+ const [answers, setAnswers] = useState<PullRequestAnswers>(() => new Map());
14
+ const pending = useRef(new Map<string, PullRequestState | null>());
15
+ const scheduled = useRef(false);
16
+ const onAnswer = useCallback((threadId: string, state: PullRequestState | null) => {
17
+ pending.current.set(threadId, state);
18
+ if (scheduled.current) return;
19
+ scheduled.current = true;
20
+ setTimeout(() => {
21
+ scheduled.current = false;
22
+ const batch = pending.current;
23
+ pending.current = new Map();
24
+ setAnswers((current) => {
25
+ let next: Map<string, PullRequestState | null> | null = null;
26
+ for (const [id, value] of batch) {
27
+ if (current.has(id) && current.get(id) === value) continue;
28
+ next ??= new Map(current);
29
+ next.set(id, value);
30
+ }
31
+ return next ?? current;
32
+ });
33
+ }, 0);
34
+ }, []);
35
+ return [answers, onAnswer];
36
+ }
@@ -0,0 +1,52 @@
1
+ // What Thread Glance reads of bb's own configuration: its default harness
2
+ // and its primary machine. Asked once per list; null until answered.
3
+ import { useEffect, useState } from "react";
4
+ import { useSdk } from "@get-bb/plugin-sdk/app";
5
+
6
+ export interface SystemFacts {
7
+ /** The harness a new thread starts with, when bb says. */
8
+ defaultProviderId: string | null;
9
+ /** The machine bb itself runs on, when one is connected. */
10
+ primaryHostId: string | null;
11
+ }
12
+
13
+ export const UNKNOWN_SYSTEM: SystemFacts = { defaultProviderId: null, primaryHostId: null };
14
+
15
+ interface SystemConfig {
16
+ primaryHostId: string | null;
17
+ generalSettings: { defaultProviderId: string | null };
18
+ serverAccess: { defaultProviderId: string };
19
+ }
20
+
21
+ /**
22
+ * The facts in `system.config()`'s answer. The default harness is the one
23
+ * the user chose in bb's settings, else the one bb falls back to.
24
+ */
25
+ export function readSystemFacts(config: SystemConfig): SystemFacts {
26
+ return {
27
+ defaultProviderId: config.generalSettings.defaultProviderId ?? config.serverAccess.defaultProviderId ?? null,
28
+ primaryHostId: config.primaryHostId,
29
+ };
30
+ }
31
+
32
+ export function useSystemFacts(): SystemFacts {
33
+ const sdk = useSdk();
34
+ const [facts, setFacts] = useState<SystemFacts>(UNKNOWN_SYSTEM);
35
+ useEffect(() => {
36
+ let cancelled = false;
37
+ // Called inside the chain, so a host that throws for an area it lacks
38
+ // lands in the rejection handler and leaves the facts unknown.
39
+ Promise.resolve()
40
+ .then(() => sdk.system.config())
41
+ .then(
42
+ (config) => {
43
+ if (!cancelled) setFacts(readSystemFacts(config));
44
+ },
45
+ () => undefined,
46
+ );
47
+ return () => {
48
+ cancelled = true;
49
+ };
50
+ }, [sdk]);
51
+ return facts;
52
+ }
@@ -25,6 +25,7 @@ export const ICONS = {
25
25
  newThread: "Plus",
26
26
  newSection: "SectionAdd",
27
27
  customize: "SlidersHorizontal",
28
+ settings: "SlidersHorizontal",
28
29
  check: "Check",
29
30
  pullRequest: "GitPullRequest",
30
31
  branch: "GitBranch",
@@ -1,3 +1,2 @@
1
1
  // The sidebar thread list feature: what the app entry may use.
2
2
  export { ThreadList } from "./components/ThreadList";
3
- export { SettingsDisclosure } from "./components/SettingsPanel";
@@ -1,9 +1,8 @@
1
- // What needs attention, thread by thread. The Needs attention section, the header
2
- // counters, the section's order and auto-reveal all read the set this
1
+ // What needs attention, thread by thread. Collapsed groups, the header
2
+ // counters, the need-you filter and auto-reveal all read the set this
3
3
  // builds. Pure.
4
4
  import type { PluginSidebarThread } from "@get-bb/plugin-sdk/app";
5
5
  import type { ChildAttention } from "@/shared/preferences";
6
- import type { Family, Forest } from "./families";
7
6
  import { type Flag, type StateKind, type ThreadState } from "./state";
8
7
 
9
8
  /** The flags that count for a root thread. Working is not one. */
@@ -88,66 +87,3 @@ export function revealsOn(attention: ReadonlySet<Flag>, isRoot: boolean): boolea
88
87
  if (attention.has("waits-on-you") || attention.has("unread-failed")) return true;
89
88
  return !isRoot && attention.has("queue-failed");
90
89
  }
91
-
92
- /** What the section reads of a family. */
93
- export type SectionFamily = Pick<Family, "root" | "attentionFlags" | "latestAttentionAt">;
94
-
95
- /** What Needs attention remembers between renders: the family it holds, and the family that was open. */
96
- export interface AttentionHold {
97
- /**
98
- * The family held in the section, if any, as it was when opened. The section
99
- * orders it by this, so nothing that happens inside it moves it.
100
- */
101
- held: SectionFamily | null;
102
- /** The root of the family the open thread belonged to at the last render, if any. */
103
- openRootId: string | null;
104
- }
105
-
106
- export const NO_HOLD: AttentionHold = { held: null, openRootId: null };
107
-
108
- /**
109
- * Whether a family is in the Needs attention section: it is the held family, or one
110
- * of its threads needs attention and none of them is open. Nothing moves while you
111
- * are inside a family, so the open family only enters by being judged when
112
- * opened (see `holdAttention`).
113
- */
114
- export function inAttention(family: SectionFamily, heldRootId: string | null, openRootId: string | null): boolean {
115
- const rootId = family.root.thread.id;
116
- if (rootId === heldRootId) return true;
117
- return family.attentionFlags.size > 0 && rootId !== openRootId;
118
- }
119
-
120
- /**
121
- * Whether a family is attended: held in the section with nothing in it needing
122
- * attention any more. It keeps its place and draws and counts as in its home group.
123
- */
124
- export function isAttended(family: SectionFamily, heldRootId: string | null): boolean {
125
- return family.root.thread.id === heldRootId && family.attentionFlags.size === 0;
126
- }
127
-
128
- /**
129
- * The hold after a render. A family is judged when a thread in it is opened
130
- * from outside it: it is held if something in it needs attention then, and it stays
131
- * held while one of its threads is open, after nothing in it needs attention any
132
- * more, until none of its threads is open. An attended family whose open thread
133
- * is archived counts as closed. A family that does not need attention
134
- * when opened is not pulled in later, whatever happens in it; nor is one
135
- * that never needed attention. Opening another thread of the open family judges
136
- * nothing again.
137
- */
138
- export function holdAttention(
139
- previous: AttentionHold,
140
- forest: Pick<Forest, "infos" | "familyOf">,
141
- activeThreadId: string | null,
142
- ): AttentionHold {
143
- if (activeThreadId === null) return NO_HOLD;
144
- const openFamily = forest.familyOf.get(activeThreadId);
145
- if (openFamily === undefined) return NO_HOLD;
146
- const openRootId = openFamily.root.thread.id;
147
- if (openRootId === previous.openRootId) {
148
- const archived = forest.infos.get(activeThreadId)?.thread.isArchived ?? false;
149
- const held = previous.held?.root.thread.id === openRootId && !(archived && openFamily.attentionFlags.size === 0);
150
- return held ? previous : { held: null, openRootId };
151
- }
152
- return { held: openFamily.attentionFlags.size > 0 ? openFamily : null, openRootId };
153
- }
@@ -0,0 +1,27 @@
1
+ // The project's default branch, and whether a thread's branch is another
2
+ // one. Pure.
3
+
4
+ /** A project source as `projects.get` returns it, narrowed to what the lookup reads. */
5
+ export interface ProjectSourceRef {
6
+ hostId: string;
7
+ isDefault: boolean;
8
+ }
9
+
10
+ /**
11
+ * The machine to ask for a project's default branch: its default source's,
12
+ * else its first source's. Null when the project has no source, as a
13
+ * personal project may not. A thread's own machine may have no source for
14
+ * the project, and bb answers 404 there.
15
+ */
16
+ export function defaultSourceHostId(sources: readonly ProjectSourceRef[]): string | null {
17
+ return (sources.find((source) => source.isDefault) ?? sources[0])?.hostId ?? null;
18
+ }
19
+
20
+ /**
21
+ * Whether a thread's branch is known to differ from its project's default:
22
+ * `defaultBranch` is undefined while the lookup runs and null when it found
23
+ * none, and in both cases the branch is not known to differ.
24
+ */
25
+ export function isOffDefaultBranch(branch: string | null, defaultBranch: string | null | undefined): branch is string {
26
+ return branch !== null && typeof defaultBranch === "string" && branch !== defaultBranch;
27
+ }
@@ -1,5 +1,5 @@
1
1
  // Group header counters. Pure.
2
- import type { Family } from "./families";
2
+ import type { ThreadTree } from "./trees";
3
3
 
4
4
  export interface Counters {
5
5
  waitsOnYou: number;
@@ -13,16 +13,16 @@ export interface Counters {
13
13
  export const EMPTY_COUNTERS: Counters = { waitsOnYou: 0, failed: 0, offline: 0, working: 0, unread: 0 };
14
14
 
15
15
  /**
16
- * Counts the threads in the families. A thread counts what its Needs attention
16
+ * Counts the threads in the trees. A thread counts what its Needs attention
17
17
  * flags say, so a child adds to waits-on-you, failed, offline and unread only
18
18
  * as "Needs attention counts every child" lets it; working counts every thread that
19
19
  * runs. Hidden threads carry only waits-on-you and unread-failed flags
20
20
  * already; archived threads never count.
21
21
  */
22
- export function countFamilies(families: readonly Family[]): Counters {
22
+ export function countTrees(trees: readonly ThreadTree[]): Counters {
23
23
  const counters = { ...EMPTY_COUNTERS };
24
- for (const family of families) {
25
- for (const info of [family.root, ...family.descendants]) {
24
+ for (const tree of trees) {
25
+ for (const info of [tree.root, ...tree.descendants]) {
26
26
  if (info.thread.isArchived) continue;
27
27
  const flags = info.attentionFlags;
28
28
  if (flags.has("waits-on-you")) counters.waitsOnYou += 1;
@@ -1,5 +1,5 @@
1
1
  // Hover card and details drawer content. Pure.
2
- import type { Family, ThreadInfo } from "./families";
2
+ import type { ThreadTree, ThreadInfo } from "./trees";
3
3
  import type { StateKind } from "./state";
4
4
 
5
5
  const SUMMARY_ORDER: readonly [StateKind, string][] = [
@@ -29,13 +29,13 @@ export function childSummary(descendants: readonly ThreadInfo[]): string | null
29
29
  return parts.length > 0 ? parts.join(", ") : null;
30
30
  }
31
31
 
32
- /** Descendants of `id` inside its family, for the card of any row. */
33
- export function descendantsOf(family: Family | undefined, id: string): ThreadInfo[] {
34
- if (family === undefined) return [];
35
- if (family.root.thread.id === id) return family.descendants;
32
+ /** Descendants of `id` inside its tree, for the card of any row. */
33
+ export function descendantsOf(tree: ThreadTree | undefined, id: string): ThreadInfo[] {
34
+ if (tree === undefined) return [];
35
+ if (tree.root.thread.id === id) return tree.descendants;
36
36
  const result: ThreadInfo[] = [];
37
37
  const within = new Set([id]);
38
- for (const info of family.descendants) {
38
+ for (const info of tree.descendants) {
39
39
  if (info.parentId !== null && within.has(info.parentId)) {
40
40
  within.add(info.thread.id);
41
41
  result.push(info);
@@ -1,13 +1,13 @@
1
1
  // Auto-expansion: transitions found by diffing snapshots, and the
2
2
  // transient targets they leave behind. Pure.
3
3
  import { revealsOn } from "./attention";
4
- import type { Forest } from "./families";
4
+ import type { Forest } from "./trees";
5
5
 
6
6
  /**
7
- * `reveal` targets open their group, their `N older` fold and the parent
8
- * chips on their path. `open` targets (a thread that newly became unread)
9
- * open the group and the fold only, so finished children don't expand
10
- * their parent's chip.
7
+ * `reveal` targets open the parent chips on their path. `open` targets (a
8
+ * thread that newly became unread) open no chip, so finished children don't
9
+ * expand their parent's. The open thread's target, of either kind, also
10
+ * opens its collapsed group. No target opens a settled fold.
11
11
  */
12
12
  export type TargetKind = "reveal" | "open";
13
13
  export type Targets = ReadonlyMap<string, TargetKind>;
@@ -1,4 +1,4 @@
1
- // Top-level groups: which group a family lands in, and the order
1
+ // Top-level groups: which group a tree lands in, and the order
2
2
  // groups appear in. Pure.
3
3
  import type {
4
4
  PluginSidebarProject,
@@ -43,7 +43,7 @@ export function personalProject(
43
43
  }
44
44
 
45
45
  /**
46
- * The group a family root belongs to. Pinned roots go to Pinned. A root
46
+ * The group a tree root belongs to. Pinned roots go to Pinned. A root
47
47
  * whose project, section or machine isn't known goes to the loose Threads
48
48
  * bucket, except an unknown section, which gets a placeholder group as in
49
49
  * bb.
@@ -1,7 +1,8 @@
1
1
  // Accessible names: everything a tooltip says is in the aria-label.
2
- import type { OlderRow, ThreadRow } from "./view";
2
+ import type { OlderRow, SettledRow, ThreadRow } from "./view";
3
3
  import { FLAG_GLYPHS, type Flag } from "./state";
4
4
  import { formatDateTime } from "./details";
5
+ import type { OrganizationMode } from "@/shared/preferences";
5
6
 
6
7
  export function stateText(row: ThreadRow, pluginLabel: string | null): string {
7
8
  const state = row.info.state;
@@ -19,33 +20,43 @@ export function rowAriaLabel(
19
20
  ): string {
20
21
  const parts = [stateText(row, options.pluginLabel), options.providerName];
21
22
  if (row.parentTitle !== null && row.depth > 0) parts.push(`child of ${row.parentTitle}`);
23
+ if (row.childDot !== null) parts.push(`child threads: ${FLAG_GLYPHS[row.childDot].label}`);
22
24
  if (row.crossGroupLabel !== null) parts.push(row.crossGroupLabel.toLowerCase());
23
- if (row.homeGroupLabel !== null) parts.push(`in ${row.homeGroupLabel}`);
24
25
  if (row.hiddenBadge) parts.push("hidden thread");
25
26
  if (row.info.unread && row.info.state.kind !== "unread") parts.push("unread");
26
27
  if (options.hasDraft && row.info.state.kind !== "draft") parts.push("unsubmitted draft");
27
28
  return `Open ${row.info.thread.displayTitle} — ${parts.join("; ")}`;
28
29
  }
29
30
 
30
- export function chipLabel(title: string, count: number, flag: Flag | null, expanded: boolean): string {
31
+ export function chipLabel(title: string, count: number, expanded: boolean): string {
31
32
  const noun = count === 1 ? "child thread" : "child threads";
32
- const detail = flag === null ? "" : `, ${FLAG_GLYPHS[flag].label}`;
33
- return `${expanded ? "Collapse" : "Show"} ${count} ${noun} of ${title}${detail}`;
33
+ return `${expanded ? "Collapse" : "Show"} ${count} ${noun} of ${title}`;
34
34
  }
35
35
 
36
- /**
37
- * The fold row's text and accessible name. The family's row says "child
38
- * threads" so it never reads like the group's "older" row.
39
- */
36
+ /** The text and accessible name of an open tree's fold row. */
40
37
  export function olderRowText(row: OlderRow): { label: string; ariaLabel: string } {
41
- const noun = row.count === 1 ? "thread" : "threads";
42
- if (row.scope === "group") {
43
- return {
44
- label: row.expanded ? "Show fewer" : `${row.count} older`,
45
- ariaLabel: `${row.expanded ? "Hide" : "Show"} ${row.count} older ${noun}`,
46
- };
47
- }
48
38
  const children = row.count === 1 ? "child thread" : "child threads";
49
- if (row.expanded) return { label: "Show fewer", ariaLabel: `Hide ${row.count} older ${children}` };
39
+ if (row.expanded) return { label: "Show fewer", ariaLabel: `Hide ${row.count} more ${children}` };
50
40
  return { label: `${row.count} more ${children}`, ariaLabel: `Show ${row.count} more ${children}` };
51
41
  }
42
+
43
+ /** The settled fold's text: "Settled (N)" while closed, "Settled" while open. N counts trees. */
44
+ export function settledRowText(row: SettledRow): { label: string; ariaLabel: string } {
45
+ const noun = row.count === 1 ? "settled thread tree" : "settled thread trees";
46
+ return {
47
+ label: row.expanded ? "Settled" : `Settled (${row.count})`,
48
+ ariaLabel: `${row.expanded ? "Hide" : "Show"} ${row.count} ${noun}`,
49
+ };
50
+ }
51
+
52
+ /** The list header's name for the current grouping. */
53
+ export function groupingName(mode: OrganizationMode): string {
54
+ switch (mode) {
55
+ case "project":
56
+ return "Projects";
57
+ case "chronological":
58
+ return "Sections";
59
+ case "machine":
60
+ return "Machines";
61
+ }
62
+ }
@@ -30,6 +30,7 @@ export interface RowMenuItem {
30
30
 
31
31
  export interface RowMenuInputs {
32
32
  thread: PluginSidebarThread;
33
+ /** The thread is unread; for a root, anything in its tree is, and Mark read marks the tree. */
33
34
  unread: boolean;
34
35
  splitAvailable: boolean;
35
36
  /** True for a thread with no parent (bb: Move to section on roots only). */
@@ -1,5 +1,5 @@
1
1
  // "Move…": the keyboard route to what drag and drop does. Pure.
2
- import type { Forest } from "./families";
2
+ import type { Forest } from "./trees";
3
3
  import { isInSubtree } from "./drag";
4
4
 
5
5
  export interface MoveTarget {
@@ -2,10 +2,10 @@
2
2
  // the server stores what it saw; this decides what a row says.
3
3
  import type { PluginSidebarThread } from "@get-bb/plugin-sdk/app";
4
4
  import type { Note, ThreadNotes } from "@/shared/contract";
5
- import { normalizeQueued, normalizeStatus, type Flag, type NeedsKind } from "./state";
5
+ import { normalizeQueued, normalizeStatus, type NeedsKind } from "./state";
6
6
 
7
7
  export interface RowNote {
8
- /** "Asks", "Approve", "Plan", "Failed", "Offline", "Finished"… */
8
+ /** "Asks", "Approve", "Plan", "Needs" or "Failed". */
9
9
  prefix: string;
10
10
  /** Empty when there is nothing to add: the prefix stands alone. */
11
11
  text: string;
@@ -48,32 +48,6 @@ export function rowNote(thread: PluginSidebarThread, notes: ThreadNotes | undefi
48
48
  return null;
49
49
  }
50
50
 
51
- /**
52
- * The line under a row in Needs attention that itself needs attention: its
53
- * most urgent reason among `attention`, its Needs attention flags. Waits on
54
- * you, then failed, then offline, then finished; each keeps its prefix when
55
- * there is no text to follow it.
56
- */
57
- export function attentionNote(
58
- thread: PluginSidebarThread,
59
- notes: ThreadNotes | undefined,
60
- attention: ReadonlySet<Flag>,
61
- ): RowNote | null {
62
- if (attention.has("waits-on-you")) {
63
- return { prefix: PENDING_PREFIX[needsKindOf(notes) ?? "input"], text: notes?.pending?.text.trim() ?? "", tone: "attention" };
64
- }
65
- if (attention.has("unread-failed")) {
66
- const text = notes?.failed?.text.trim() ?? "";
67
- return { prefix: "Failed", text: text.toLowerCase() === "failed" ? "" : text, tone: "destructive" };
68
- }
69
- if (attention.has("queue-failed")) {
70
- return { prefix: "Failed", text: "queued message wasn't sent", tone: "destructive" };
71
- }
72
- if (attention.has("offline")) return { prefix: "Offline", text: thread.host?.name.trim() ?? "", tone: "attention" };
73
- if (attention.has("unread")) return { prefix: "Finished", text: lastReply(notes)?.text.trim() ?? "", tone: "muted" };
74
- return null;
75
- }
76
-
77
51
  /** A note as one line of text: "Failed: timeout", or "Failed" alone. */
78
52
  export function noteText(note: RowNote): string {
79
53
  return note.text === "" ? note.prefix : `${note.prefix}: ${note.text}`;
@@ -1,23 +1,7 @@
1
1
  // What the settings panel's controls show and write. Pure.
2
- import type { ChildAttention, Lifecycle, Preferences, SortField } from "@/shared/preferences";
2
+ import type { ChildAttention, Preferences, SortField } from "@/shared/preferences";
3
3
  import { effectiveDirection, effectiveSortField, naturalDirection } from "./sort";
4
4
 
5
- export type ThreadsShown = "active" | "archived" | "both";
6
-
7
- /** The Threads choice a saved lifecycle list stands for. */
8
- export function threadsShown(lifecycles: readonly Lifecycle[]): ThreadsShown {
9
- const active = lifecycles.includes("active");
10
- const archived = lifecycles.includes("archived");
11
- if (active && archived) return "both";
12
- return archived ? "archived" : "active";
13
- }
14
-
15
- /** The lifecycles a Threads choice saves; never empty. */
16
- export function lifecyclesFor(shown: ThreadsShown): Lifecycle[] {
17
- if (shown === "both") return ["active", "archived"];
18
- return [shown];
19
- }
20
-
21
5
  /** "Needs attention counts every child" is on when children count as `everything`. */
22
6
  export function countsEveryChild(childAttention: ChildAttention): boolean {
23
7
  return childAttention === "everything";