paseo-office 0.2.1 → 0.2.3
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/OVERVIEW.md +1 -1
- package/README.md +1 -1
- package/client/host-switches.tsx +32 -10
- package/client/notes-mode-row.tsx +140 -0
- package/client/office-state.ts +1 -0
- package/client/structure-view.tsx +2 -0
- package/client/team-name.tsx +81 -0
- package/client/tracker-connections.tsx +252 -0
- package/client/world/adapter.ts +34 -1
- package/client/world/world-api.ts +12 -1
- package/docs/office.md +54 -9
- package/index.server.ts +142 -8
- package/package.json +1 -1
- package/server/activity.ts +40 -3
- package/server/directory.ts +5 -1
- package/server/hub.ts +9 -0
- package/server/incidents-jira.ts +19 -7
- package/server/incidents-schedule.ts +10 -10
- package/server/incidents-sentry.ts +34 -8
- package/server/life-feed.ts +13 -0
- package/server/live-ports.ts +30 -11
- package/server/notes-schedule.ts +2 -0
- package/server/notes-writer.ts +9 -1
- package/server/paths.ts +5 -0
- package/server/tenure.ts +10 -0
- package/server/tracker-credentials.ts +141 -0
- package/server/world.generated.ts +1 -1
- package/server/writer-mode.ts +45 -0
- package/shared/contracts.ts +118 -1
- package/shared/model.ts +16 -1
- package/shared/settings.ts +3 -1
- package/shared/team-name.ts +23 -0
package/OVERVIEW.md
CHANGED
|
@@ -18,7 +18,7 @@ The settings gear controls the floor plan, backdrop, lighting and sound. Under *
|
|
|
18
18
|
|
|
19
19
|
**Archive idle sessions** is off by default. Enable it under **Office settings → Automation** if you want an open 3D floor to archive a session when its worker goes home. Workers can go home after resting for at least 30 minutes at night or after evening drinks. The session must still be idle, with no pending approval or working subagent. Archiving removes it from the active list and keeps its conversation history.
|
|
20
20
|
|
|
21
|
-
Stand-up notes need a host folder. Jira and Sentry alerts need project settings and host
|
|
21
|
+
Stand-up notes need a host folder. Jira and Sentry alerts need project settings and a connection: a Jira address, email and API token, and a Sentry auth token, entered in the settings or set in the host environment. Entered tokens are stored unencrypted on the host in a file only its user can read. Weather from a service needs a configured URL. Linux hosts can also show CPU, memory and processes.
|
|
22
22
|
|
|
23
23
|
## Data access
|
|
24
24
|
|
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ Boards, duties, team chat and stand-up state are stored under `$PASEO_HOME/offic
|
|
|
55
55
|
|
|
56
56
|
Agent prompts, tool results and scheduled assignments go through the agent’s configured provider. A **Whole group** chat message can go to one available session with up to six recent group or scene messages for context. **To**, mentions and replies address a particular session.
|
|
57
57
|
|
|
58
|
-
Jira and Sentry use project settings and
|
|
58
|
+
Jira and Sentry use project settings and a connection saved from the settings or read from the host environment. Saved tokens stay on the host, unencrypted, in a file only its user can read. A configured weather service receives requests while Office is open, at most once every 15 minutes. Its URL is visible in host settings. On stock hosts using fallback timers, scheduled work resumes after daemon restart when Office or an agent activates the plugin. Missed runs are skipped. [Plugin overview](https://github.com/allrested/paseo-office/blob/main/OVERVIEW.md) · [Implementation and storage](https://github.com/allrested/paseo-office/blob/main/docs/office.md)
|
|
59
59
|
|
|
60
60
|
## Development
|
|
61
61
|
|
package/client/host-switches.tsx
CHANGED
|
@@ -13,6 +13,8 @@ import { wakeSummary } from "./board-text.js";
|
|
|
13
13
|
import { FLOOR_PLAN_LABEL, FloorPlanRow } from "./floor-plan-row.js";
|
|
14
14
|
import { LabeledSwitch } from "./labeled-switch.js";
|
|
15
15
|
import { NOTES_DAYS_LABEL, NotesDays } from "./notes-days.js";
|
|
16
|
+
import { NOTES_MODE_LABEL, NotesModeRow } from "./notes-mode-row.js";
|
|
17
|
+
import { JiraConnection, SentryConnection } from "./tracker-connections.js";
|
|
16
18
|
import type { OfficeStyles } from "./styles.js";
|
|
17
19
|
import type { BoardActions } from "./use-board-actions.js";
|
|
18
20
|
|
|
@@ -28,6 +30,7 @@ type HostSetting =
|
|
|
28
30
|
| "Notes folder"
|
|
29
31
|
| "Time zone"
|
|
30
32
|
| typeof NOTES_DAYS_LABEL
|
|
33
|
+
| typeof NOTES_MODE_LABEL
|
|
31
34
|
| typeof FLOOR_PLAN_LABEL
|
|
32
35
|
| "Jira projects"
|
|
33
36
|
| "Sentry organisation"
|
|
@@ -36,11 +39,13 @@ type HostSetting =
|
|
|
36
39
|
| WeatherSetting;
|
|
37
40
|
|
|
38
41
|
/** What the incidents fields need to know from the host: never a token's value. */
|
|
39
|
-
type TrackerState = Pick<
|
|
42
|
+
type TrackerState = Pick<
|
|
43
|
+
IncidentsState,
|
|
44
|
+
"jiraReady" | "sentryReady" | "scheduleError" | "connections"
|
|
45
|
+
>;
|
|
40
46
|
|
|
41
|
-
const JIRA_UNSET =
|
|
42
|
-
|
|
43
|
-
const SENTRY_UNSET = "SENTRY_AUTH_TOKEN is not set on this host";
|
|
47
|
+
const JIRA_UNSET = "No Jira connection on this host: save one above";
|
|
48
|
+
const SENTRY_UNSET = "No Sentry token on this host: save one above";
|
|
44
49
|
|
|
45
50
|
/** The line under a tracker's field: `missing` while the field is set, nothing while it is empty. */
|
|
46
51
|
function unsetLine(value: string | null, missing: string | null): string | null {
|
|
@@ -163,6 +168,10 @@ export function HostSwitches({
|
|
|
163
168
|
(next: number[]) => change(NOTES_DAYS_LABEL, { notesDays: next }),
|
|
164
169
|
[change],
|
|
165
170
|
);
|
|
171
|
+
const saveMode = useCallback(
|
|
172
|
+
(next: string) => change(NOTES_MODE_LABEL, { notesMode: next }),
|
|
173
|
+
[change],
|
|
174
|
+
);
|
|
166
175
|
const savePlan = useCallback(
|
|
167
176
|
(next: FloorPlanChoice) => change(FLOOR_PLAN_LABEL, { floorPlan: next }),
|
|
168
177
|
[change],
|
|
@@ -258,6 +267,12 @@ export function HostSwitches({
|
|
|
258
267
|
problem={saveProblem(NOTES_DAYS_LABEL)}
|
|
259
268
|
styles={styles}
|
|
260
269
|
/>
|
|
270
|
+
<NotesModeRow
|
|
271
|
+
value={storedMode(stored)}
|
|
272
|
+
onSave={saveMode}
|
|
273
|
+
problem={saveProblem(NOTES_MODE_LABEL)}
|
|
274
|
+
styles={styles}
|
|
275
|
+
/>
|
|
261
276
|
</View>
|
|
262
277
|
{problems.length > 0 ? (
|
|
263
278
|
<View style={styles.headerProblems}>
|
|
@@ -294,6 +309,11 @@ export function HostSwitches({
|
|
|
294
309
|
);
|
|
295
310
|
}
|
|
296
311
|
|
|
312
|
+
/** The stored writer mode; null while the settings are read or cannot be read. */
|
|
313
|
+
function storedMode(values: HostValues | null): string | null {
|
|
314
|
+
return values === null ? null : values.notesMode;
|
|
315
|
+
}
|
|
316
|
+
|
|
297
317
|
type TrackerField = "jiraProjects" | "sentryOrg" | "sentryProjects" | "sentryUrl";
|
|
298
318
|
|
|
299
319
|
/** A tracker field's stored text; null while the settings are read or cannot be read. */
|
|
@@ -313,7 +333,7 @@ interface TrackerFieldsProps {
|
|
|
313
333
|
|
|
314
334
|
/**
|
|
315
335
|
* The trackers the incidents check reads, and its schedule's failure under them. A field set
|
|
316
|
-
* while the host
|
|
336
|
+
* while the host has no sign-in for the tracker says so; the token itself never comes back here.
|
|
317
337
|
*/
|
|
318
338
|
function TrackerFields({ values, incidents, change, saveProblem, styles }: TrackerFieldsProps) {
|
|
319
339
|
const saveJiraProjects = useCallback(
|
|
@@ -341,7 +361,7 @@ function TrackerFields({ values, incidents, change, saveProblem, styles }: Track
|
|
|
341
361
|
// Not known until the host has said: no line before then.
|
|
342
362
|
const jiraMissing = incidents?.jiraReady === false ? JIRA_UNSET : null;
|
|
343
363
|
const sentryMissing = incidents?.sentryReady === false ? SENTRY_UNSET : null;
|
|
344
|
-
// A refused save comes first; while the host refuses nothing, the
|
|
364
|
+
// A refused save comes first; while the host refuses nothing, the sign-in it lacks.
|
|
345
365
|
const jiraProblem = saveProblem("Jira projects") ?? unsetLine(jiraProjects, jiraMissing);
|
|
346
366
|
const sentryOrgProblem =
|
|
347
367
|
saveProblem("Sentry organisation") ?? unsetLine(sentryOrg, sentryMissing);
|
|
@@ -352,17 +372,19 @@ function TrackerFields({ values, incidents, change, saveProblem, styles }: Track
|
|
|
352
372
|
return (
|
|
353
373
|
<>
|
|
354
374
|
<View style={styles.headerFields}>
|
|
375
|
+
<JiraConnection connection={incidents?.connections?.jira} styles={styles} />
|
|
355
376
|
<SettingField
|
|
356
377
|
label="Jira projects"
|
|
357
|
-
hint="Project keys, comma separated.
|
|
378
|
+
hint="Project keys, comma separated. New bugs in them ring the incident alarm."
|
|
358
379
|
value={jiraProjects}
|
|
359
380
|
onSave={saveJiraProjects}
|
|
360
381
|
problem={jiraProblem}
|
|
361
382
|
styles={styles}
|
|
362
383
|
/>
|
|
384
|
+
<SentryConnection connection={incidents?.connections?.sentry} styles={styles} />
|
|
363
385
|
<SettingField
|
|
364
386
|
label="Sentry organisation"
|
|
365
|
-
hint="The organisation's slug.
|
|
387
|
+
hint="The organisation's slug."
|
|
366
388
|
value={sentryOrg}
|
|
367
389
|
onSave={saveSentryOrg}
|
|
368
390
|
problem={sentryOrgProblem}
|
|
@@ -370,7 +392,7 @@ function TrackerFields({ values, incidents, change, saveProblem, styles }: Track
|
|
|
370
392
|
/>
|
|
371
393
|
<SettingField
|
|
372
394
|
label="Sentry projects"
|
|
373
|
-
hint="Project slugs, comma separated.
|
|
395
|
+
hint="Project slugs, comma separated."
|
|
374
396
|
value={sentryProjects}
|
|
375
397
|
onSave={saveSentryProjects}
|
|
376
398
|
problem={sentryProjectsProblem}
|
|
@@ -378,7 +400,7 @@ function TrackerFields({ values, incidents, change, saveProblem, styles }: Track
|
|
|
378
400
|
/>
|
|
379
401
|
<SettingField
|
|
380
402
|
label="Sentry address"
|
|
381
|
-
hint="Where
|
|
403
|
+
hint="Where the Sentry token is sent. https, or http on the host itself."
|
|
382
404
|
value={sentryUrl}
|
|
383
405
|
onSave={saveSentryUrl}
|
|
384
406
|
problem={sentryUrlProblem}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
4
|
+
import { notesModesRpc, type WriterModes } from "../shared/contracts.js";
|
|
5
|
+
import { SegmentPill } from "./segment-pill.js";
|
|
6
|
+
import type { OfficeStyles } from "./styles.js";
|
|
7
|
+
|
|
8
|
+
/** The row's label, and the setting a refused save names. */
|
|
9
|
+
export const NOTES_MODE_LABEL = "Writer mode";
|
|
10
|
+
/** The pill for no mode set: the office picks, as it did before the setting. */
|
|
11
|
+
const OWN_CHOICE = "Office's choice";
|
|
12
|
+
const HINT =
|
|
13
|
+
"The mode the stand-up writer starts in. Nobody answers its questions at 8:00, so a mode that asks leaves the note unwritten.";
|
|
14
|
+
// The modes that ask for nothing: Claude's and Codex's.
|
|
15
|
+
const UNATTENDED: ReadonlySet<string> = new Set(["bypassPermissions", "full-access"]);
|
|
16
|
+
const UNATTENDED_HINT = "In this mode the writer runs any tool or command without asking.";
|
|
17
|
+
|
|
18
|
+
export interface NotesModeRowProps {
|
|
19
|
+
/** The stored mode's id, empty for none; null while the settings are read or cannot be read. */
|
|
20
|
+
value: string | null;
|
|
21
|
+
/** Resolves once the host has answered, and never rejects. */
|
|
22
|
+
onSave(next: string): Promise<unknown>;
|
|
23
|
+
problem: string | null;
|
|
24
|
+
styles: OfficeStyles;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type Asked = WriterModes | { problem: string } | null;
|
|
28
|
+
|
|
29
|
+
/** What stands under the pills beside the hint: the fallback, the warning, or why none is listed. */
|
|
30
|
+
function noteOf(asked: Asked, shown: string | null): string | null {
|
|
31
|
+
if (asked === null) return null;
|
|
32
|
+
if ("problem" in asked) return `The writer's modes cannot be listed: ${asked.problem}`;
|
|
33
|
+
if (asked.fellBack) {
|
|
34
|
+
const used = asked.modes.find((mode) => mode.id === asked.modeId)?.label ?? "its default";
|
|
35
|
+
return `${asked.provider} has no mode "${shown}": the writer starts in ${used}.`;
|
|
36
|
+
}
|
|
37
|
+
return shown !== null && UNATTENDED.has(shown) ? UNATTENDED_HINT : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The stand-up writer's mode, as pills of the modes its provider offers, by the provider's own
|
|
42
|
+
* names. The host is asked for them when the row shows and after each save, since the stored
|
|
43
|
+
* mode decides what it says of a fallback. A press shows, and the row takes no other, until the
|
|
44
|
+
* host has answered.
|
|
45
|
+
*/
|
|
46
|
+
export function NotesModeRow({ value, onSave, problem, styles }: NotesModeRowProps) {
|
|
47
|
+
const ask = useRpc(notesModesRpc);
|
|
48
|
+
const mounted = useRef(true);
|
|
49
|
+
const [asked, setAsked] = useState<Asked>(null);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
mounted.current = true;
|
|
52
|
+
return () => {
|
|
53
|
+
mounted.current = false;
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
// Kept in a ref: the row asks again when the stored mode changes, not when the call's identity does.
|
|
57
|
+
const asking = useRef(ask);
|
|
58
|
+
asking.current = ask;
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (value === null) return;
|
|
61
|
+
void asking.current({}).then(
|
|
62
|
+
(answer) => {
|
|
63
|
+
if (mounted.current) setAsked(answer.ok ? answer : { problem: answer.problem });
|
|
64
|
+
return undefined;
|
|
65
|
+
},
|
|
66
|
+
(error: unknown) => {
|
|
67
|
+
if (mounted.current) {
|
|
68
|
+
setAsked({ problem: error instanceof Error ? error.message : String(error) });
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
}, [value]);
|
|
73
|
+
const [wanted, setWanted] = useState<string | null>(null);
|
|
74
|
+
const shown = wanted ?? value;
|
|
75
|
+
const saving = useRef(false);
|
|
76
|
+
const choose = useCallback(
|
|
77
|
+
(next: string) => {
|
|
78
|
+
if (shown === null || saving.current || next === shown) return;
|
|
79
|
+
saving.current = true;
|
|
80
|
+
setWanted(next);
|
|
81
|
+
void onSave(next).finally(() => {
|
|
82
|
+
saving.current = false;
|
|
83
|
+
if (mounted.current) setWanted(null);
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
[shown, onSave],
|
|
87
|
+
);
|
|
88
|
+
const modes = asked !== null && "modes" in asked ? asked.modes : [];
|
|
89
|
+
// A stored mode this provider lacks still shows as a pill, so what is stored can be seen.
|
|
90
|
+
const stored = shown !== null && shown !== "" && !modes.some((mode) => mode.id === shown);
|
|
91
|
+
const disabled = shown === null || wanted !== null;
|
|
92
|
+
const note = wanted === null ? noteOf(asked, shown) : null;
|
|
93
|
+
return (
|
|
94
|
+
<View style={styles.headerField}>
|
|
95
|
+
<Text style={styles.sheetLabel}>{NOTES_MODE_LABEL}</Text>
|
|
96
|
+
<View
|
|
97
|
+
role="group"
|
|
98
|
+
aria-label={NOTES_MODE_LABEL}
|
|
99
|
+
style={disabled ? styles.segmentsDisabled : styles.segments}
|
|
100
|
+
>
|
|
101
|
+
<SegmentPill
|
|
102
|
+
value=""
|
|
103
|
+
name={OWN_CHOICE}
|
|
104
|
+
on={shown === ""}
|
|
105
|
+
disabled={disabled}
|
|
106
|
+
onPress={choose}
|
|
107
|
+
styles={styles}
|
|
108
|
+
/>
|
|
109
|
+
{modes.map((mode) => (
|
|
110
|
+
<SegmentPill
|
|
111
|
+
key={mode.id}
|
|
112
|
+
value={mode.id}
|
|
113
|
+
name={mode.label}
|
|
114
|
+
on={shown === mode.id}
|
|
115
|
+
disabled={disabled}
|
|
116
|
+
onPress={choose}
|
|
117
|
+
styles={styles}
|
|
118
|
+
/>
|
|
119
|
+
))}
|
|
120
|
+
{stored && shown !== null ? (
|
|
121
|
+
<SegmentPill
|
|
122
|
+
value={shown}
|
|
123
|
+
name={shown}
|
|
124
|
+
on
|
|
125
|
+
disabled={disabled}
|
|
126
|
+
onPress={choose}
|
|
127
|
+
styles={styles}
|
|
128
|
+
/>
|
|
129
|
+
) : null}
|
|
130
|
+
</View>
|
|
131
|
+
<Text style={styles.fieldHint}>{HINT}</Text>
|
|
132
|
+
{note === null ? null : <Text style={styles.fieldHint}>{note}</Text>}
|
|
133
|
+
{problem === null ? null : (
|
|
134
|
+
<Text accessibilityRole="alert" style={styles.actionError}>
|
|
135
|
+
{problem}
|
|
136
|
+
</Text>
|
|
137
|
+
)}
|
|
138
|
+
</View>
|
|
139
|
+
);
|
|
140
|
+
}
|
package/client/office-state.ts
CHANGED
|
@@ -26,6 +26,7 @@ export function applyOfficeEvent(state: OfficeSnapshot, event: OfficeEvent): Off
|
|
|
26
26
|
...state,
|
|
27
27
|
activity: event.activity,
|
|
28
28
|
doing: event.doing ?? {},
|
|
29
|
+
subagents: event.subagents,
|
|
29
30
|
checklists: event.checklists ?? {},
|
|
30
31
|
checklistProgress: event.checklistProgress,
|
|
31
32
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TeamName } from "./team-name.js";
|
|
1
2
|
import { useCallback, useEffect, useId, useMemo, useState } from "react";
|
|
2
3
|
import {
|
|
3
4
|
Platform,
|
|
@@ -241,6 +242,7 @@ function RoomCard({
|
|
|
241
242
|
{room.subtitle}
|
|
242
243
|
</Text>
|
|
243
244
|
) : null}
|
|
245
|
+
<TeamName room={room} styles={styles} />
|
|
244
246
|
</View>
|
|
245
247
|
{room.rows.length === 0 ? <Text style={styles.empty}>No agents</Text> : null}
|
|
246
248
|
{room.rows.map((row, index) => (
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { Pressable, Text, View } from "react-native";
|
|
3
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
4
|
+
import { TextInput } from "@getpaseo/plugin/client/ui";
|
|
5
|
+
import { teamRenameRpc } from "../shared/contracts.js";
|
|
6
|
+
import type { OfficeRoom } from "../shared/model.js";
|
|
7
|
+
import { TEAM_NAME_MAX } from "../shared/team-name.js";
|
|
8
|
+
import { ActionButton } from "./action-button.js";
|
|
9
|
+
import type { OfficeStyles } from "./styles.js";
|
|
10
|
+
|
|
11
|
+
interface TeamNameProps {
|
|
12
|
+
room: OfficeRoom;
|
|
13
|
+
styles: OfficeStyles;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const HINT = "The office's own name for this team. Empty goes back to the workspace's name.";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Gives a room's team a name of the office's own: a line under the room's title that opens a
|
|
20
|
+
* field. The workspace keeps its name in Paseo; while the team goes by another, the line says
|
|
21
|
+
* which workspace it is.
|
|
22
|
+
*/
|
|
23
|
+
export function TeamName({ room, styles }: TeamNameProps) {
|
|
24
|
+
const rename = useRpc(teamRenameRpc);
|
|
25
|
+
const [open, setOpen] = useState(false);
|
|
26
|
+
const [draft, setDraft] = useState("");
|
|
27
|
+
const workspace = room.workspace;
|
|
28
|
+
const own = workspace?.workspaceName;
|
|
29
|
+
const start = useCallback(() => {
|
|
30
|
+
// The field starts from the team's own name, empty while it goes by the workspace's.
|
|
31
|
+
setDraft(own === undefined ? "" : room.name);
|
|
32
|
+
setOpen(true);
|
|
33
|
+
}, [own, room.name]);
|
|
34
|
+
const cancel = useCallback(() => setOpen(false), []);
|
|
35
|
+
const save = useCallback(async () => {
|
|
36
|
+
if (!workspace) return;
|
|
37
|
+
const answer = await rename({ workspaceId: workspace.id, name: draft });
|
|
38
|
+
if (!answer.ok) throw new Error(answer.problem);
|
|
39
|
+
setOpen(false);
|
|
40
|
+
}, [rename, workspace, draft]);
|
|
41
|
+
if (!workspace) return null;
|
|
42
|
+
if (!open) {
|
|
43
|
+
return (
|
|
44
|
+
<Pressable
|
|
45
|
+
accessibilityRole="button"
|
|
46
|
+
accessibilityLabel={`Rename team ${room.name}`}
|
|
47
|
+
onPress={start}
|
|
48
|
+
>
|
|
49
|
+
<Text style={styles.fieldHint}>
|
|
50
|
+
{own === undefined ? "Rename team" : `Workspace ${own} · Rename team`}
|
|
51
|
+
</Text>
|
|
52
|
+
</Pressable>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return (
|
|
56
|
+
<View style={styles.headerField}>
|
|
57
|
+
<TextInput
|
|
58
|
+
accessibilityLabel="Team name"
|
|
59
|
+
accessibilityHint={HINT}
|
|
60
|
+
value={draft}
|
|
61
|
+
onChangeText={setDraft}
|
|
62
|
+
maxLength={TEAM_NAME_MAX}
|
|
63
|
+
placeholder={own ?? room.name}
|
|
64
|
+
autoCapitalize="none"
|
|
65
|
+
autoCorrect={false}
|
|
66
|
+
style={styles.fieldInput}
|
|
67
|
+
/>
|
|
68
|
+
<Text style={styles.fieldHint}>{HINT}</Text>
|
|
69
|
+
<View style={styles.actions}>
|
|
70
|
+
<ActionButton
|
|
71
|
+
label="Save team name"
|
|
72
|
+
pendingLabel="Saving..."
|
|
73
|
+
onPress={save}
|
|
74
|
+
primary
|
|
75
|
+
styles={styles}
|
|
76
|
+
/>
|
|
77
|
+
<ActionButton label="Cancel" pendingLabel="Cancel" onPress={cancel} styles={styles} />
|
|
78
|
+
</View>
|
|
79
|
+
</View>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
4
|
+
import { TextInput } from "@getpaseo/plugin/client/ui";
|
|
5
|
+
import {
|
|
6
|
+
trackersSaveRpc,
|
|
7
|
+
trackersTestRpc,
|
|
8
|
+
type IncidentsState,
|
|
9
|
+
type TrackerSource,
|
|
10
|
+
type TrackersResult,
|
|
11
|
+
} from "../shared/contracts.js";
|
|
12
|
+
import { ActionButton } from "./action-button.js";
|
|
13
|
+
import type { OfficeStyles } from "./styles.js";
|
|
14
|
+
|
|
15
|
+
type Connections = NonNullable<IncidentsState["connections"]>;
|
|
16
|
+
|
|
17
|
+
/** Where the host's sign-in comes from, as the line under a connection says it. */
|
|
18
|
+
export function sourceLine(name: string, source: TrackerSource | undefined): string | null {
|
|
19
|
+
switch (source) {
|
|
20
|
+
case "saved":
|
|
21
|
+
return `${name} connection saved on this host`;
|
|
22
|
+
case "env":
|
|
23
|
+
return `${name} connection from the host's environment; a saved one replaces it`;
|
|
24
|
+
case "none":
|
|
25
|
+
return `No ${name} connection on this host`;
|
|
26
|
+
default:
|
|
27
|
+
// Not known until the host has said: nothing is claimed before then.
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The host's answer as a button takes it: a refusal becomes the button's error. */
|
|
33
|
+
function accept(result: TrackersResult): void {
|
|
34
|
+
if (!result.ok) throw new Error(result.problem);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface FieldProps {
|
|
38
|
+
label: string;
|
|
39
|
+
hint: string;
|
|
40
|
+
value: string;
|
|
41
|
+
onChangeText(next: string): void;
|
|
42
|
+
secret?: boolean;
|
|
43
|
+
styles: OfficeStyles;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Typed text that is kept until a button sends it, unlike a setting's field. */
|
|
47
|
+
function ConnectionField({ label, hint, value, onChangeText, secret, styles }: FieldProps) {
|
|
48
|
+
return (
|
|
49
|
+
<View style={styles.headerField}>
|
|
50
|
+
<Text style={styles.sheetLabel}>{label}</Text>
|
|
51
|
+
<TextInput
|
|
52
|
+
accessibilityLabel={label}
|
|
53
|
+
accessibilityHint={hint}
|
|
54
|
+
value={value}
|
|
55
|
+
onChangeText={onChangeText}
|
|
56
|
+
secureTextEntry={secret === true}
|
|
57
|
+
autoCapitalize="none"
|
|
58
|
+
autoCorrect={false}
|
|
59
|
+
spellCheck={false}
|
|
60
|
+
style={styles.fieldInput}
|
|
61
|
+
/>
|
|
62
|
+
<Text style={styles.fieldHint}>{hint}</Text>
|
|
63
|
+
</View>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface ButtonsProps {
|
|
68
|
+
name: string;
|
|
69
|
+
source: TrackerSource | undefined;
|
|
70
|
+
/** What the last test or save came to; null before one, and after a change it no longer fits. */
|
|
71
|
+
note: string | null;
|
|
72
|
+
test(): Promise<void>;
|
|
73
|
+
save(): Promise<void>;
|
|
74
|
+
clear(): Promise<void>;
|
|
75
|
+
styles: OfficeStyles;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function ConnectionButtons({ name, source, note, test, save, clear, styles }: ButtonsProps) {
|
|
79
|
+
const line = note ?? sourceLine(name, source);
|
|
80
|
+
return (
|
|
81
|
+
<View style={styles.headerField}>
|
|
82
|
+
{line === null ? null : <Text style={styles.fieldHint}>{line}</Text>}
|
|
83
|
+
<View style={styles.actions}>
|
|
84
|
+
<ActionButton
|
|
85
|
+
label="Test connection"
|
|
86
|
+
pendingLabel="Testing..."
|
|
87
|
+
name={`Test ${name} connection`}
|
|
88
|
+
onPress={test}
|
|
89
|
+
styles={styles}
|
|
90
|
+
/>
|
|
91
|
+
<ActionButton
|
|
92
|
+
label="Save connection"
|
|
93
|
+
pendingLabel="Saving..."
|
|
94
|
+
name={`Save ${name} connection`}
|
|
95
|
+
onPress={save}
|
|
96
|
+
primary
|
|
97
|
+
styles={styles}
|
|
98
|
+
/>
|
|
99
|
+
{source === "saved" ? (
|
|
100
|
+
<ActionButton
|
|
101
|
+
label="Remove"
|
|
102
|
+
pendingLabel="Removing..."
|
|
103
|
+
name={`Remove saved ${name} connection`}
|
|
104
|
+
onPress={clear}
|
|
105
|
+
styles={styles}
|
|
106
|
+
/>
|
|
107
|
+
) : null}
|
|
108
|
+
</View>
|
|
109
|
+
</View>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface JiraProps {
|
|
114
|
+
/** Absent until the host has said where its sign-in comes from. */
|
|
115
|
+
connection: Connections["jira"] | undefined;
|
|
116
|
+
styles: OfficeStyles;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Jira's address, email and API token, saved on the host in a file only the daemon's user can
|
|
121
|
+
* read. The token goes to the host and never comes back: its field is empty for the one kept.
|
|
122
|
+
*/
|
|
123
|
+
export function JiraConnection({ connection, styles }: JiraProps) {
|
|
124
|
+
const callTest = useRpc(trackersTestRpc);
|
|
125
|
+
const callSave = useRpc(trackersSaveRpc);
|
|
126
|
+
// What is typed; null shows what the host holds.
|
|
127
|
+
const [baseUrl, setBaseUrl] = useState<string | null>(null);
|
|
128
|
+
const [email, setEmail] = useState<string | null>(null);
|
|
129
|
+
const [token, setToken] = useState("");
|
|
130
|
+
const [note, setNote] = useState<string | null>(null);
|
|
131
|
+
const typed = useCallback(
|
|
132
|
+
() => ({
|
|
133
|
+
baseUrl: baseUrl ?? connection?.baseUrl ?? "",
|
|
134
|
+
email: email ?? connection?.email ?? "",
|
|
135
|
+
token,
|
|
136
|
+
}),
|
|
137
|
+
[baseUrl, email, token, connection],
|
|
138
|
+
);
|
|
139
|
+
const test = useCallback(async () => {
|
|
140
|
+
setNote(null);
|
|
141
|
+
accept(await callTest({ tracker: "jira", ...typed() }));
|
|
142
|
+
setNote("Jira accepted the sign-in");
|
|
143
|
+
}, [callTest, typed]);
|
|
144
|
+
const save = useCallback(async () => {
|
|
145
|
+
setNote(null);
|
|
146
|
+
accept(await callSave({ action: "save-jira", ...typed() }));
|
|
147
|
+
setBaseUrl(null);
|
|
148
|
+
setEmail(null);
|
|
149
|
+
setToken("");
|
|
150
|
+
}, [callSave, typed]);
|
|
151
|
+
const clear = useCallback(async () => {
|
|
152
|
+
setNote(null);
|
|
153
|
+
accept(await callSave({ action: "clear", tracker: "jira" }));
|
|
154
|
+
setBaseUrl(null);
|
|
155
|
+
setEmail(null);
|
|
156
|
+
setToken("");
|
|
157
|
+
}, [callSave]);
|
|
158
|
+
const kept = connection?.source === "saved";
|
|
159
|
+
return (
|
|
160
|
+
<>
|
|
161
|
+
<ConnectionField
|
|
162
|
+
label="Jira address"
|
|
163
|
+
hint="Your Jira site, such as https://your-site.atlassian.net."
|
|
164
|
+
value={baseUrl ?? connection?.baseUrl ?? ""}
|
|
165
|
+
onChangeText={setBaseUrl}
|
|
166
|
+
styles={styles}
|
|
167
|
+
/>
|
|
168
|
+
<ConnectionField
|
|
169
|
+
label="Jira email"
|
|
170
|
+
hint="The Atlassian account the API token belongs to."
|
|
171
|
+
value={email ?? connection?.email ?? ""}
|
|
172
|
+
onChangeText={setEmail}
|
|
173
|
+
styles={styles}
|
|
174
|
+
/>
|
|
175
|
+
<ConnectionField
|
|
176
|
+
label="Jira API token"
|
|
177
|
+
hint={
|
|
178
|
+
kept
|
|
179
|
+
? "Leave empty to keep the saved token. Stored on the host for its user only; never shown again."
|
|
180
|
+
: "Stored on the host for its user only; never shown again."
|
|
181
|
+
}
|
|
182
|
+
value={token}
|
|
183
|
+
onChangeText={setToken}
|
|
184
|
+
secret
|
|
185
|
+
styles={styles}
|
|
186
|
+
/>
|
|
187
|
+
<ConnectionButtons
|
|
188
|
+
name="Jira"
|
|
189
|
+
source={connection?.source}
|
|
190
|
+
note={note}
|
|
191
|
+
test={test}
|
|
192
|
+
save={save}
|
|
193
|
+
clear={clear}
|
|
194
|
+
styles={styles}
|
|
195
|
+
/>
|
|
196
|
+
</>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
interface SentryProps {
|
|
201
|
+
connection: Connections["sentry"] | undefined;
|
|
202
|
+
styles: OfficeStyles;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Sentry's auth token, kept as Jira's. A test asks the organisation and address set below. */
|
|
206
|
+
export function SentryConnection({ connection, styles }: SentryProps) {
|
|
207
|
+
const callTest = useRpc(trackersTestRpc);
|
|
208
|
+
const callSave = useRpc(trackersSaveRpc);
|
|
209
|
+
const [token, setToken] = useState("");
|
|
210
|
+
const [note, setNote] = useState<string | null>(null);
|
|
211
|
+
const test = useCallback(async () => {
|
|
212
|
+
setNote(null);
|
|
213
|
+
accept(await callTest({ tracker: "sentry", token }));
|
|
214
|
+
setNote("Sentry accepted the token");
|
|
215
|
+
}, [callTest, token]);
|
|
216
|
+
const save = useCallback(async () => {
|
|
217
|
+
setNote(null);
|
|
218
|
+
accept(await callSave({ action: "save-sentry", token }));
|
|
219
|
+
setToken("");
|
|
220
|
+
}, [callSave, token]);
|
|
221
|
+
const clear = useCallback(async () => {
|
|
222
|
+
setNote(null);
|
|
223
|
+
accept(await callSave({ action: "clear", tracker: "sentry" }));
|
|
224
|
+
setToken("");
|
|
225
|
+
}, [callSave]);
|
|
226
|
+
const kept = connection?.source === "saved";
|
|
227
|
+
return (
|
|
228
|
+
<>
|
|
229
|
+
<ConnectionField
|
|
230
|
+
label="Sentry auth token"
|
|
231
|
+
hint={
|
|
232
|
+
kept
|
|
233
|
+
? "A token is saved; type a new one to replace it. Stored on the host for its user only; never shown again."
|
|
234
|
+
: "Stored on the host for its user only; never shown again."
|
|
235
|
+
}
|
|
236
|
+
value={token}
|
|
237
|
+
onChangeText={setToken}
|
|
238
|
+
secret
|
|
239
|
+
styles={styles}
|
|
240
|
+
/>
|
|
241
|
+
<ConnectionButtons
|
|
242
|
+
name="Sentry"
|
|
243
|
+
source={connection?.source}
|
|
244
|
+
note={note}
|
|
245
|
+
test={test}
|
|
246
|
+
save={save}
|
|
247
|
+
clear={clear}
|
|
248
|
+
styles={styles}
|
|
249
|
+
/>
|
|
250
|
+
</>
|
|
251
|
+
);
|
|
252
|
+
}
|