@bridgebrew/sessions 0.0.0-stage → 0.0.8
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.
- package/LICENSE +21 -0
- package/README.md +43 -2
- package/answers.ts +167 -0
- package/browser/branch-actions.tsx +166 -0
- package/browser/changes.tsx +415 -0
- package/browser/children.tsx +650 -0
- package/browser/conversation.tsx +2381 -0
- package/browser/decision-questions.tsx +191 -0
- package/browser/elapsed.tsx +44 -0
- package/browser/gallery.tsx +218 -0
- package/browser/index.tsx +3434 -0
- package/browser/media-origins.tsx +38 -0
- package/browser/mobile.tsx +663 -0
- package/browser/open-link.tsx +30 -0
- package/browser/pull-request.tsx +116 -0
- package/browser/questions.tsx +156 -0
- package/browser/session-scheduled.tsx +203 -0
- package/browser/subagent-view.tsx +136 -0
- package/browser/subagents.tsx +339 -0
- package/browser/tabs.tsx +228 -0
- package/browser/tsconfig.json +15 -0
- package/browser/views/view.tsx +1064 -0
- package/browser/views.tsx +166 -0
- package/contract.ts +287 -0
- package/delegations.ts +1975 -0
- package/diff.ts +88 -0
- package/docs/en/images.mdx +51 -0
- package/docs/en/index.mdx +22 -0
- package/docs/en/meta.json +4 -0
- package/docs/en/organize-sessions.mdx +53 -0
- package/docs/en/start-a-session.mdx +63 -0
- package/docs/meta.json +4 -0
- package/git.ts +223 -0
- package/listing.ts +382 -0
- package/package.json +1023 -4
- package/peers.ts +677 -0
- package/pull-request-watch.ts +282 -0
- package/pull-requests.ts +606 -0
- package/server.ts +5920 -0
- package/text.ts +19 -0
- package/tsconfig.json +3 -0
- package/viewer-activity.ts +57 -0
- package/views/examples.ts +153 -0
- package/views/library.ts +1116 -0
package/text.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Bridge's text and JSON helpers (`@bridge/kernel/text`, `@bridge/kernel/json`), copied: a plugin from outside Bridge installs none of its packages.
|
|
2
|
+
|
|
3
|
+
/** `text` cut to at most `max` UTF-16 units, never between the two halves of a surrogate pair (bridge#317). */
|
|
4
|
+
export const cutText = (text: string, max: number) => {
|
|
5
|
+
if (text.length <= max) return text;
|
|
6
|
+
if (max <= 0) return '';
|
|
7
|
+
const code = text.charCodeAt(max - 1);
|
|
8
|
+
return text.slice(0, code >= 0xd800 && code <= 0xdbff ? max - 1 : max);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** `text` on one line, within `max` characters (an ellipsis when cut). */
|
|
12
|
+
export const oneLine = (text: string, max: number) => {
|
|
13
|
+
const line = text.replace(/\s+/g, ' ').trim();
|
|
14
|
+
return line.length <= max ? line : `${cutText(line, max - 1).trimEnd()}…`;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** A plain object, not an array nor null (`@bridge/kernel/json`'s). */
|
|
18
|
+
export const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
19
|
+
typeof value === 'object' && value !== null && !Array.isArray(value);
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Research-069: a page tells Sessions when the user is on it, so an agent's page goes to the page last active only (never
|
|
2
|
+
// a background tab). Told on each watch connection (the server may have forgotten this page: its watch ended), when
|
|
3
|
+
// the page gets the focus back or its tab is shown again, on the first pointer down or key after it lost the focus, and
|
|
4
|
+
// when its tab goes to the background. Told means answered: a request that failed is told again on the next sign.
|
|
5
|
+
|
|
6
|
+
/** Starts telling `report` for this page; returns `connected` (call it on each watch connection) and `stop`. */
|
|
7
|
+
export function viewerActivity(report: (active: boolean) => Promise<unknown>) {
|
|
8
|
+
/** What the server answered it holds; `undefined`: not known (never told, lost the focus, a request failed). */
|
|
9
|
+
let told: boolean | undefined;
|
|
10
|
+
/** What a request on its way says. */
|
|
11
|
+
let sending: boolean | undefined;
|
|
12
|
+
const tell = (active: boolean) => {
|
|
13
|
+
if (sending === active || (sending === undefined && told === active)) return;
|
|
14
|
+
sending = active;
|
|
15
|
+
report(active).then(
|
|
16
|
+
() => {
|
|
17
|
+
if (sending !== active) return;
|
|
18
|
+
sending = undefined;
|
|
19
|
+
told = active;
|
|
20
|
+
},
|
|
21
|
+
() => {
|
|
22
|
+
if (sending !== active) return;
|
|
23
|
+
sending = undefined;
|
|
24
|
+
told = undefined;
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
const now = () => {
|
|
29
|
+
if (document.hidden) tell(false);
|
|
30
|
+
else if (document.hasFocus()) tell(true);
|
|
31
|
+
};
|
|
32
|
+
const used = () => {
|
|
33
|
+
if (!document.hidden) tell(true);
|
|
34
|
+
};
|
|
35
|
+
const left = () => {
|
|
36
|
+
told = undefined;
|
|
37
|
+
};
|
|
38
|
+
document.addEventListener('pointerdown', used, true);
|
|
39
|
+
document.addEventListener('keydown', used, true);
|
|
40
|
+
document.addEventListener('visibilitychange', now);
|
|
41
|
+
window.addEventListener('focus', used);
|
|
42
|
+
window.addEventListener('blur', left);
|
|
43
|
+
return {
|
|
44
|
+
connected() {
|
|
45
|
+
told = undefined;
|
|
46
|
+
sending = undefined;
|
|
47
|
+
now();
|
|
48
|
+
},
|
|
49
|
+
stop() {
|
|
50
|
+
document.removeEventListener('pointerdown', used, true);
|
|
51
|
+
document.removeEventListener('keydown', used, true);
|
|
52
|
+
document.removeEventListener('visibilitychange', now);
|
|
53
|
+
window.removeEventListener('focus', used);
|
|
54
|
+
window.removeEventListener('blur', left);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// research-036 (OpenUI POC): views an owner of a workspace would ask for, written in the language.
|
|
2
|
+
//
|
|
3
|
+
// Every program must pass `check()` (the test asserts it). Between them they use every component; the contacts search
|
|
4
|
+
// and the new-contact form read and write the Contacts plugin's own routes (bridge-plugins/contacts/server.ts).
|
|
5
|
+
|
|
6
|
+
export interface Example {
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
prompt: string;
|
|
10
|
+
program: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const examples: Example[] = [
|
|
14
|
+
{
|
|
15
|
+
id: 'team-table',
|
|
16
|
+
title: 'The team, at a glance',
|
|
17
|
+
prompt:
|
|
18
|
+
'Show me the team as a table with each person’s role, their status and how many open tasks they have.',
|
|
19
|
+
program: `root = Stack([title, tbl, footer], "md")
|
|
20
|
+
title = Heading("Team", 1)
|
|
21
|
+
tbl = Table([Col("Name", "1fr"), Col("Role", "1fr"), Col("Status", "120px"), Col("Open", "80px")], [[who1, "Design", st1, Badge(3)], [who2, "Engineering", st2, Badge(1)], [who3, "Support", st3, Badge(0)]])
|
|
22
|
+
who1 = Cluster([a1, Text("Ada Lovelace")])
|
|
23
|
+
a1 = Avatar("Ada Lovelace")
|
|
24
|
+
who2 = Cluster([a2, Text("Grace Hopper")])
|
|
25
|
+
a2 = Avatar("Grace Hopper")
|
|
26
|
+
who3 = Cluster([a3, Text("Linus Torvalds")])
|
|
27
|
+
a3 = Avatar("Linus Torvalds")
|
|
28
|
+
st1 = StatusIcon("in-progress")
|
|
29
|
+
st2 = StatusIcon("done")
|
|
30
|
+
st3 = StatusIcon("todo")
|
|
31
|
+
footer = Cluster([Text("Updated just now", "muted"), Kbd("R")], "between")`,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'contact-detail',
|
|
35
|
+
title: 'One contact, with their details and activity',
|
|
36
|
+
prompt:
|
|
37
|
+
'Open Ada Lovelace’s contact card: show her details and a tab with recent activity, and let me ask for a summary.',
|
|
38
|
+
program: `root = Card([head, tabs], "Ada Lovelace", "Engineering lead at Lovelace Ltd")
|
|
39
|
+
head = Cluster([who, tags], "between")
|
|
40
|
+
who = Cluster([avatar, meta])
|
|
41
|
+
avatar = Avatar("Ada Lovelace")
|
|
42
|
+
meta = Stack([Text("ada@example.com", "muted"), Text("London, United Kingdom", "muted")], "sm")
|
|
43
|
+
tags = Cluster([TagPill("design"), TagPill("engineering")], "end")
|
|
44
|
+
tabs = Tabs([details, activity])
|
|
45
|
+
details = Tab("Details", [props])
|
|
46
|
+
props = Properties([email, phone, status])
|
|
47
|
+
email = Property("Email", "ada@example.com")
|
|
48
|
+
phone = Property("Phone", "+44 20 7946 0000")
|
|
49
|
+
status = Property("Status", StatusIcon("in-progress"))
|
|
50
|
+
activity = Tab("Activity", [recent, ask])
|
|
51
|
+
recent = List([note1, note2])
|
|
52
|
+
note1 = ListItem("Reviewed the Q3 roadmap", "2 hours ago")
|
|
53
|
+
note2 = ListItem("Shipped the design tokens", "Yesterday")
|
|
54
|
+
ask = Buttons([Button("Summarise", @ToAssistant("Summarise this contact", {id: "ada"}), "outline")])`,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'contacts-search',
|
|
58
|
+
title: 'A contacts list filtered as I type',
|
|
59
|
+
prompt:
|
|
60
|
+
'Give me my contacts with a search box; filter them live as I type and show each person’s job title.',
|
|
61
|
+
program: `$q = ""
|
|
62
|
+
people = Query("bridge_read", {plugin: "contacts", path: "/people", query: {q: $q}}, {items: [], total: 0})
|
|
63
|
+
root = Stack([search, list, footer], "md")
|
|
64
|
+
search = Input("q", "Search contacts", "text", null, $q)
|
|
65
|
+
list = List(@Each(people.items, "p", ListItem(p.firstName + " " + p.lastName, p.jobTitle, Avatar(p.firstName + " " + p.lastName))))
|
|
66
|
+
footer = Cluster([Text(people.total + " contacts", "muted"), Icon("filter")])`,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'new-contact',
|
|
70
|
+
title: 'A form that creates a contact',
|
|
71
|
+
prompt:
|
|
72
|
+
'I want a form that adds a contact with a name, an email, a role and notes, checked before it saves.',
|
|
73
|
+
program: `$first = ""
|
|
74
|
+
$last = ""
|
|
75
|
+
$email = ""
|
|
76
|
+
$role = ""
|
|
77
|
+
$notes = ""
|
|
78
|
+
save = Mutation("bridge_write", {plugin: "contacts", method: "POST", path: "/people", body: {firstName: $first, lastName: $last, emails: [{label: "work", value: $email}], jobTitle: $role, notes: $notes}})
|
|
79
|
+
root = Card([heading, form, result], "New contact")
|
|
80
|
+
heading = Text("Add someone to the address book", "muted")
|
|
81
|
+
form = Form("new-contact", [names, emailField, roleField, notesField], Buttons([cancel, create]))
|
|
82
|
+
names = Cluster([Field("First name", Input("first", "Ada", "text", {required: true, minLength: 2}, $first)), Field("Last name", Input("last", "Lovelace", "text", null, $last))])
|
|
83
|
+
emailField = Field("Email", Input("email", "name@company.com", "email", {required: true, email: true}, $email))
|
|
84
|
+
roleField = Field("Role", Select("role", [Option("Designer", "Designer"), Option("Engineer", "Engineer"), Option("Support", "Support")], "Choose a role", $role))
|
|
85
|
+
notesField = Field("Notes", Textarea("notes", "Anything worth knowing", {maxLength: 400}, $notes), "At most 400 characters")
|
|
86
|
+
cancel = Button("Clear", @Reset($first, $last, $email, $role, $notes), "ghost")
|
|
87
|
+
create = Button("Create contact", Action([@Run(save), @Reset($first, $last, $email, $role, $notes)]), "primary")
|
|
88
|
+
result = save.status == "success" ? Text("Contact created", "muted") : save.status == "error" ? Text("Could not create it: " + save.error, "destructive") : null`,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'settings',
|
|
92
|
+
title: 'Workspace preferences',
|
|
93
|
+
prompt:
|
|
94
|
+
'Show the workspace settings: a weekly digest toggle, mention emails, list density, the default view and the theme.',
|
|
95
|
+
program: `$digest = true
|
|
96
|
+
$mentions = false
|
|
97
|
+
$density = 2
|
|
98
|
+
$view = "list"
|
|
99
|
+
$theme = "system"
|
|
100
|
+
root = Section("Workspace settings", [prefs, actions], "What the workspace does by default")
|
|
101
|
+
prefs = Card([digestField, mentionField, densityField, viewField, themeField])
|
|
102
|
+
digestField = Field("Weekly digest", Toggle("digest", "Send a Monday summary", $digest), "One email a week")
|
|
103
|
+
mentionField = Field("Mentions", Checkbox("mentions", "Email me when someone mentions me", $mentions))
|
|
104
|
+
densityField = Field("List density", Slider("density", 1, 3, 1, $density), "1 is compact, 3 is roomy")
|
|
105
|
+
viewField = Field("Default view", SegmentGroup("view", [Option("list", "List"), Option("board", "Board"), Option("calendar", "Calendar")], $view))
|
|
106
|
+
themeField = Field("Theme", Select("theme", [Option("light", "Light"), Option("dark", "Dark"), Option("system", "System")], "Choose a theme", $theme))
|
|
107
|
+
actions = Buttons([reset])
|
|
108
|
+
reset = Button("Reset to defaults", @Reset($digest, $mentions, $density, $view, $theme), "outline")`,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: 'project-status',
|
|
112
|
+
title: 'Project status overview',
|
|
113
|
+
prompt:
|
|
114
|
+
'How is Project Atlas going? Show the owner, the due date, the health, the next milestones and the current tasks.',
|
|
115
|
+
program: `root = Stack([head, summary, next, shortcuts], "md")
|
|
116
|
+
head = Cluster([Heading("Project Atlas", 1), Badge(4), StatusIcon("in-progress")], "between")
|
|
117
|
+
summary = Card([items, points])
|
|
118
|
+
items = Properties([owner, due, health])
|
|
119
|
+
owner = Property("Owner", Avatar("Grace Hopper"))
|
|
120
|
+
due = Property("Due", "30 October 2026")
|
|
121
|
+
health = Property("Health", StatusIcon("in-review"))
|
|
122
|
+
points = Stack([Heading("Milestones", 3), List([ListItem("Ship the design tokens", "Done", Icon("check")), ListItem("Cut the first release", "Next", Icon("star"))])], "sm")
|
|
123
|
+
next = List([one, two])
|
|
124
|
+
one = ListItem("Fix the login redirect", "Due today", StatusIcon("in-progress"), TagPill("bug"))
|
|
125
|
+
two = ListItem("Write the release notes", "Due Thursday", StatusIcon("todo"), TagPill("docs"))
|
|
126
|
+
shortcuts = Cluster([Text("Press", "muted"), Kbd("⌘K"), Text("to jump to a record", "muted")], "start")`,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'empty-inbox',
|
|
130
|
+
title: 'Nothing in the inbox',
|
|
131
|
+
prompt:
|
|
132
|
+
'The inbox is empty. Show a friendly empty state with a way to open contacts, and let me ask what the inbox is for.',
|
|
133
|
+
program: `root = Stack([head, empty], "md")
|
|
134
|
+
head = Section("Inbox", [Text("Nothing to triage", "muted")], "Mentions and assignments that need you")
|
|
135
|
+
empty = Card([state, actions])
|
|
136
|
+
state = EmptyState("Inbox zero", "New mentions and assignments will appear here.", "inbox")
|
|
137
|
+
actions = Buttons([open, explain])
|
|
138
|
+
open = Button("Open contacts", @OpenUrl("https://example.com/contacts"), "primary")
|
|
139
|
+
explain = Button("What is this?", @ToAssistant("Explain the inbox view"), "ghost")`,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
id: 'people-list',
|
|
143
|
+
title: 'People with access',
|
|
144
|
+
prompt:
|
|
145
|
+
'List everyone with access to the workspace, with avatars, their tags and how many things they own.',
|
|
146
|
+
program: `root = Section("People", [list, hint], "Everyone with access to the workspace")
|
|
147
|
+
list = List([ada, grace, linus])
|
|
148
|
+
ada = ListItem("Ada Lovelace", "ada@example.com", Avatar("Ada Lovelace"), Cluster([TagPill("design"), Badge(3)]))
|
|
149
|
+
grace = ListItem("Grace Hopper", "grace@example.com", Avatar("Grace Hopper"), Badge(12))
|
|
150
|
+
linus = ListItem("Linus Torvalds", "linus@example.com", Avatar("Linus Torvalds"), TagPill("infra"))
|
|
151
|
+
hint = Cluster([Text("Arrow keys move, Enter opens", "muted"), Kbd("↵")], "start")`,
|
|
152
|
+
},
|
|
153
|
+
];
|