paseo-office 0.0.0-stage → 0.2.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.
- package/LICENSE +32 -0
- package/README.md +144 -2
- package/client/action-button.tsx +124 -0
- package/client/activity-feed-text.ts +84 -0
- package/client/activity-feed.ts +339 -0
- package/client/activity-panel.tsx +306 -0
- package/client/agent-card.tsx +230 -0
- package/client/agent-picker-text.ts +97 -0
- package/client/agent-picker.tsx +160 -0
- package/client/app-locale.ts +14 -0
- package/client/ask-text.ts +75 -0
- package/client/attention-strip.tsx +194 -0
- package/client/beside.ts +42 -0
- package/client/board-sheet.tsx +419 -0
- package/client/board-text.ts +95 -0
- package/client/brand.ts +29 -0
- package/client/chat-acts.ts +24 -0
- package/client/chat-panel.tsx +832 -0
- package/client/chat-seen.ts +63 -0
- package/client/chat-text.ts +230 -0
- package/client/choice-pills.tsx +75 -0
- package/client/column-model.ts +68 -0
- package/client/column-sheet.tsx +157 -0
- package/client/context-text.ts +130 -0
- package/client/conversation-model.ts +149 -0
- package/client/floor-plan-row.tsx +84 -0
- package/client/focus-request.ts +6 -0
- package/client/follow-end.ts +28 -0
- package/client/fullscreen-header.tsx +123 -0
- package/client/host-switches.tsx +357 -0
- package/client/incidents-card.tsx +125 -0
- package/client/incidents-text.ts +81 -0
- package/client/janitor-card.tsx +165 -0
- package/client/labeled-switch.tsx +49 -0
- package/client/language-switch.tsx +57 -0
- package/client/library-card.tsx +327 -0
- package/client/library-text.ts +166 -0
- package/client/list-text.ts +177 -0
- package/client/lobby-board.tsx +355 -0
- package/client/luminance.ts +38 -0
- package/client/machine-card.tsx +220 -0
- package/client/new-agent-form.tsx +261 -0
- package/client/new-agent-model.ts +165 -0
- package/client/notes-card.tsx +320 -0
- package/client/notes-days.tsx +94 -0
- package/client/notes-text.ts +153 -0
- package/client/office-column.tsx +448 -0
- package/client/office-link.ts +47 -0
- package/client/office-settings.tsx +68 -0
- package/client/office-state.ts +78 -0
- package/client/office-surface.tsx +1786 -0
- package/client/permission-actions.tsx +123 -0
- package/client/pixel/actors.ts +294 -0
- package/client/pixel/art.ts +778 -0
- package/client/pixel/floor-plan.ts +282 -0
- package/client/pixel/pixel-office.tsx +1286 -0
- package/client/pixel/room.ts +62 -0
- package/client/pixel/sprite-view.tsx +71 -0
- package/client/pixel/sprite.ts +75 -0
- package/client/pixel/ticker.ts +40 -0
- package/client/qa-card.tsx +210 -0
- package/client/qa-text.ts +189 -0
- package/client/review-card.tsx +187 -0
- package/client/review-text.ts +207 -0
- package/client/room-board.tsx +65 -0
- package/client/segment-pill.tsx +58 -0
- package/client/session-pane.tsx +116 -0
- package/client/session-panel.tsx +377 -0
- package/client/session-styles.ts +140 -0
- package/client/session-text.ts +38 -0
- package/client/sessions-panel.tsx +289 -0
- package/client/sessions-text.ts +140 -0
- package/client/setting-field.tsx +71 -0
- package/client/settings-text.ts +25 -0
- package/client/standup-card.tsx +241 -0
- package/client/structure-view.tsx +425 -0
- package/client/styles.ts +1319 -0
- package/client/tab-reveal.ts +54 -0
- package/client/use-agent-actions.ts +35 -0
- package/client/use-board-actions.ts +57 -0
- package/client/use-column.ts +95 -0
- package/client/use-conversation.ts +246 -0
- package/client/use-device-switch.ts +79 -0
- package/client/use-incidents.ts +17 -0
- package/client/use-janitor.ts +19 -0
- package/client/use-library.ts +83 -0
- package/client/use-machine.ts +39 -0
- package/client/use-new-agent.ts +168 -0
- package/client/use-office.ts +66 -0
- package/client/use-qa.ts +25 -0
- package/client/use-reply-drafts.ts +34 -0
- package/client/use-reviews.ts +68 -0
- package/client/use-script-log.ts +27 -0
- package/client/use-sound.ts +8 -0
- package/client/use-standup.ts +46 -0
- package/client/use-street.ts +13 -0
- package/client/view-switch.tsx +83 -0
- package/client/weather-settings.tsx +84 -0
- package/client/weather-text.ts +31 -0
- package/client/web-env.web.ts +69 -0
- package/client/world/adapter.ts +421 -0
- package/client/world/rung-incidents.ts +25 -0
- package/client/world/script-frame-kit.ts +41 -0
- package/client/world/street-events.ts +18 -0
- package/client/world/use-floor-plan.ts +34 -0
- package/client/world/use-incident-alarm.ts +81 -0
- package/client/world/use-life.ts +40 -0
- package/client/world/use-scene-words.ts +76 -0
- package/client/world/use-street-kit.ts +28 -0
- package/client/world/use-world-feed.ts +174 -0
- package/client/world/words-loader.ts +35 -0
- package/client/world/world-api.ts +252 -0
- package/client/world/world-bridge-page.ts +46 -0
- package/client/world/world-bridge.ts +104 -0
- package/client/world/world-frame.web.ts +103 -0
- package/client/world/world-loader.ts +59 -0
- package/client/world/world-loading.tsx +11 -0
- package/client/world/world-view-native.tsx +204 -0
- package/client/world/world-view-shared.ts +170 -0
- package/client/world/world-view.tsx +276 -0
- package/docs/office.md +642 -0
- package/icon.png +0 -0
- package/index.client.tsx +59 -0
- package/index.server.ts +670 -0
- package/package.json +66 -4
- package/paseo-plugin.json +7 -0
- package/server/activity.ts +421 -0
- package/server/agent-tools.ts +153 -0
- package/server/board-service.ts +284 -0
- package/server/board-store.ts +115 -0
- package/server/chat-service.ts +446 -0
- package/server/chat-store.ts +122 -0
- package/server/directory.ts +392 -0
- package/server/errors.ts +3 -0
- package/server/fake-clock.ts +60 -0
- package/server/fake-schedules.ts +61 -0
- package/server/hub.ts +547 -0
- package/server/incidents-check.ts +213 -0
- package/server/incidents-http.ts +115 -0
- package/server/incidents-jira.ts +129 -0
- package/server/incidents-schedule.ts +87 -0
- package/server/incidents-sentry.ts +97 -0
- package/server/incidents-store.ts +122 -0
- package/server/janitor.ts +53 -0
- package/server/life-feed.ts +143 -0
- package/server/life-store.ts +93 -0
- package/server/lift-service.ts +75 -0
- package/server/live-ports.ts +214 -0
- package/server/local-schedules.ts +262 -0
- package/server/machine/cleanup.ts +98 -0
- package/server/machine/fake-proc.ts +87 -0
- package/server/machine/live-ports.ts +98 -0
- package/server/machine/machine.ts +79 -0
- package/server/machine/proc.ts +238 -0
- package/server/machine/reading.ts +70 -0
- package/server/machine/watch.ts +121 -0
- package/server/mention-queue.ts +215 -0
- package/server/notes-files.ts +92 -0
- package/server/notes-prompt.ts +70 -0
- package/server/notes-schedule.ts +113 -0
- package/server/notes-writer.ts +356 -0
- package/server/office.ts +191 -0
- package/server/paseo-directory.ts +114 -0
- package/server/paseo-holder.ts +37 -0
- package/server/paths.ts +72 -0
- package/server/prompt-text.ts +12 -0
- package/server/repo-age.ts +26 -0
- package/server/schedule-follower.ts +80 -0
- package/server/script-log.ts +61 -0
- package/server/skills.ts +197 -0
- package/server/street-kit.generated.ts +2 -0
- package/server/street-watch.ts +143 -0
- package/server/subagent-names.ts +88 -0
- package/server/tenure.ts +184 -0
- package/server/timers.ts +25 -0
- package/server/weather-read.ts +132 -0
- package/server/weather-service.ts +158 -0
- package/server/words.generated.ts +3 -0
- package/server/world-script.ts +18 -0
- package/server/world-words.ts +17 -0
- package/server/world.generated.ts +3 -0
- package/shared/chat-words.ts +80 -0
- package/shared/contracts.ts +709 -0
- package/shared/host-extras.ts +21 -0
- package/shared/life-lines.ts +330 -0
- package/shared/machine-text.ts +152 -0
- package/shared/model.ts +306 -0
- package/shared/names.ts +41 -0
- package/shared/scene-language.ts +26 -0
- package/shared/settings.ts +206 -0
- package/shared/standup-report.ts +8 -0
- package/shared/standup-text.ts +252 -0
- package/shared/upstream/README.md +3 -0
- package/shared/upstream/chat-engine.d.ts +97 -0
- package/shared/upstream/chat-engine.js +231 -0
- package/shared/upstream/chat.d.ts +12 -0
- package/shared/upstream/chat.js +387 -0
- package/shared/weather.ts +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 allrested
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Third-party software in this repository keeps its own licence:
|
|
26
|
+
|
|
27
|
+
- vendor/my-office/ is my-office (https://github.com/khanh020905/my-office),
|
|
28
|
+
MIT, Copyright (c) 2026 khanh020905. Its licence is vendor/my-office/LICENSE.
|
|
29
|
+
The files under shared/upstream/ are taken from it too.
|
|
30
|
+
- vendor/my-office/three/ is three.js, MIT, Copyright © 2010-2023 three.js
|
|
31
|
+
authors. Its licence is vendor/my-office/three/LICENSE.
|
|
32
|
+
- server/world.generated.ts is built from both and carries both notices.
|
package/README.md
CHANGED
|
@@ -1,3 +1,145 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Office 3D
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A community port of [my-office](https://github.com/khanh020905/my-office) for
|
|
4
|
+
[Paseo](https://github.com/getpaseo/paseo): your agents at their desks, in 3D.
|
|
5
|
+
|
|
6
|
+
It is based on my-office by [khanh020905](https://github.com/khanh020905), with the author's
|
|
7
|
+
permission, and is not an official version of it. Report issues with this Paseo plugin in
|
|
8
|
+
[this repository's issue tracker](https://github.com/allrested/paseo-office/issues), not in
|
|
9
|
+
my-office's.
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
- Shows every agent on the host as a floor: in 3D, in 2D pixel art, or as a list. Each workspace
|
|
14
|
+
is a room, and each agent sits at a desk and walks to the kind of work it is doing. The 3D floor
|
|
15
|
+
offers Company floor, Cozy room and Headquarters in Settings. Headquarters seats 44 agents. Its four department rooms fill as teams outgrow the six desk areas on the main floor.
|
|
16
|
+
- The indoor staff deliver parcels, make rounds and tally reported spending. The teams have duty rosters, promotions and farewells.
|
|
17
|
+
- The optional street outside has walk-in shops, traffic and six staff scenes. Shops and vehicles carry made-up names and locally drawn signs. The cafés, pharmacy and phone shop share the generic store fittings.
|
|
18
|
+
- Dresses the 3D floor for Halloween, Christmas and Lunar New Year by the date. Weather can follow a hand-picked sky, the season or a service you choose.
|
|
19
|
+
- Shows 3D signs, labels and speech in English, Vietnamese, Thai or Indonesian. Choose a language
|
|
20
|
+
on the settings page. Automatic follows the app’s language when supported. Paseo 0.16.2 offers
|
|
21
|
+
none of the three non-English scene languages, so select one explicitly to use it.
|
|
22
|
+
- Puts a column beside the floor: Attention (who needs you, and the office's cards), Sessions,
|
|
23
|
+
Activity, and a team Chat where an `@` prompts an agent. An agent's session opens as a tab of
|
|
24
|
+
the column, with its conversation, a reply box, permission answers and Stop. The Sessions tab
|
|
25
|
+
starts an agent: a workspace, a provider and model, and a first prompt.
|
|
26
|
+
- Select **Full screen** beside the view switch to work inside the office. On a wide screen,
|
|
27
|
+
Sessions sits on the left, the floor in the center, and activity or the open conversation
|
|
28
|
+
on the right. Select **Sessions** or **Details** in the toolbar to hide or show that side.
|
|
29
|
+
Hide both for an edge-to-edge floor, or open a conversation to reply and answer permission requests.
|
|
30
|
+
- Gives each room a board of tasks and notes. Agents read and post with three tools, and a post
|
|
31
|
+
that names an idle agent wakes it.
|
|
32
|
+
- Writes the day's stand-up entry at 8:00 on the days you choose, Monday to Friday by default: an
|
|
33
|
+
agent on the host gets the office's stand-up report and writes a `## DD Month YYYY` entry into
|
|
34
|
+
`daily-standup-YYYYMM.md` in a folder of notes you choose, following the stand-up notes
|
|
35
|
+
instructions for that folder, which may sit in its own or a parent folder's `AGENTS.md` or
|
|
36
|
+
`CLAUDE.md`.
|
|
37
|
+
- Rings an incident alarm for a new Jira bug or Sentry issue in the projects you name.
|
|
38
|
+
- Plays my-office's sounds in the 3D floor: off until you turn on Sound in the settings or with the
|
|
39
|
+
speaker button on the floor's toolbar.
|
|
40
|
+
- Takes a photo of the 3D floor, in the app's light or held to day or night for the photo, and on
|
|
41
|
+
a desktop or in a browser records a 15-second clip of it; a tour of the floor's things shows
|
|
42
|
+
once on a desktop.
|
|
43
|
+
- Reads the host (on Linux): memory, CPU, and what each agent left running, with a way to clean it
|
|
44
|
+
up.
|
|
45
|
+
|
|
46
|
+
[docs/office.md](docs/office.md) says how each part works.
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
You need Paseo 0.16.0 or newer; the plugin is tested on 0.16.2. Installed plugins must be turned on
|
|
51
|
+
in `config.json` under the host's Paseo home (`$PASEO_HOME/config.json`, by default
|
|
52
|
+
`~/.paseo/config.json`):
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{ "pluginsEnabled": true }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The daemon reads that key when it starts. On a running daemon, apply the change with
|
|
59
|
+
`paseo daemon reload` or restart the daemon.
|
|
60
|
+
|
|
61
|
+
Then install it on the host:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
paseo plugin install git:allrested/paseo-office
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The host supplies the plugin SDK and `zod`, so installing runs no build and needs no
|
|
68
|
+
`node_modules`.
|
|
69
|
+
|
|
70
|
+
The settings are in Settings > Plugins > Office 3D. The gear over the floor opens them too.
|
|
71
|
+
|
|
72
|
+
## What works where
|
|
73
|
+
|
|
74
|
+
| Where | What you get |
|
|
75
|
+
| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
76
|
+
| Desktop app and browsers | The 3D floor, the 2D floor and the list; Photo mode, clips and the tour |
|
|
77
|
+
| The phone app with a script frame | The 3D floor without Photo mode, clips and the tour |
|
|
78
|
+
| The store phone app | The 2D floor and the list: its plugin frame runs no script |
|
|
79
|
+
| Sound | A browser and the desktop app, where the frame lets audio start; the phone's script frame: see [docs/verified.md](docs/verified.md) |
|
|
80
|
+
| The street outside | Available in 3D. Enabled by default on wide web layouts and disabled by default on phones. |
|
|
81
|
+
| Stock Paseo 0.16 | A session opens in the office in every app. Its SDK has no `cancel()` or `closeRuntime()` for an agent: no Stop on a session, and the Host card does not close an idle agent's runtime |
|
|
82
|
+
|
|
83
|
+
[docs/verified.md](docs/verified.md) says what was seen on a stock Paseo 0.16.2, and what was not.
|
|
84
|
+
|
|
85
|
+
The stand-up notes and the incidents check run on the plugin's own timers. After a daemon
|
|
86
|
+
restart, a run waits until the office is opened or an agent opens or ends a turn. A run missed
|
|
87
|
+
while the daemon was down is not made up.
|
|
88
|
+
|
|
89
|
+
The column, agent cards, settings, team chat (including @Director), whiteboard rows and host
|
|
90
|
+
notifications stay in English. Thai and Indonesian use the English karaoke songs. Vietnamese
|
|
91
|
+
and Thai also use English for the port’s custom lines. The sound-unavailable message and
|
|
92
|
+
photo lighting group title are English in every language.
|
|
93
|
+
|
|
94
|
+
## What it reads and where it sends it
|
|
95
|
+
|
|
96
|
+
- It reads agents, workspaces, status, spending when the provider reports it, and each agent’s kind
|
|
97
|
+
of activity. On the host it runs Git once per workspace folder to read the first commit date.
|
|
98
|
+
- The 3D scene receives people, kinds of activity, spending, repository birthdays, team tenure,
|
|
99
|
+
and the lift’s servicing time and build sticker. It receives no file names, commands or prompts and makes no
|
|
100
|
+
network calls. It sends chat moments with a name or count, and reports farewells and promotions.
|
|
101
|
+
- With the street enabled, the device receives the bundled Kenney Car Kit (CC0). While a street
|
|
102
|
+
is open, the host checks local Git tags and the installed Claude CLI version. New tags can
|
|
103
|
+
trigger the photo booth. The pickleball scene uses check results already available to Paseo.
|
|
104
|
+
- English travels with the scene. For each other language the host sends one dictionary on request
|
|
105
|
+
to the device that chose it (about 82–130 KB). The device keeps those words for the life of the page.
|
|
106
|
+
- A clip is recorded inside the page and saved as a download on the device; nothing is sent. The
|
|
107
|
+
scene keeps on the device, under keys that start with `office-`, which team sits where, the
|
|
108
|
+
plants, the graphics level, the Sound switch, that the tour was seen, and the clip's shape and
|
|
109
|
+
music choice, the duty roster with team members’ names, the fire drill day, and team farewells and returns. The column keeps when this device last had the chat open (`office-chat-seen`).
|
|
110
|
+
- With Settings > Weather > From a service and an address set, the host reads that address while an
|
|
111
|
+
office is open, at most once in 15 minutes. The request sets only the `Accept` header. The
|
|
112
|
+
scene receives a weather code, temperature and cloud share. The host stores the address,
|
|
113
|
+
including any key in its query, in `<PASEO_HOME>/plugin-settings/office/office.json`.
|
|
114
|
+
Anyone who can open the settings page can see it there.
|
|
115
|
+
- It calls Jira and Sentry only when their settings are filled in, with tokens from the host's
|
|
116
|
+
environment (`ATLASSIAN_*`, `SENTRY_AUTH_TOKEN`). The tracker settings never hold a token.
|
|
117
|
+
- The stand-up notes writer, a wake and a chat `@` send the board's text, the chat message and the
|
|
118
|
+
notes' prompt to the host's own agents, and so to whichever provider runs them.
|
|
119
|
+
- It stores boards, the chat, the stand-up notes' state and incidents under the host's Paseo home,
|
|
120
|
+
in `office/`, alongside the team ledger (`tenure.json`) and lift build (`lift.json`).
|
|
121
|
+
|
|
122
|
+
## Based on
|
|
123
|
+
|
|
124
|
+
The 3D scene is my-office at commit
|
|
125
|
+
[`b68228871fe30cd2c759a2c919337a9a9d1f5644`](https://github.com/khanh020905/my-office/tree/b68228871fe30cd2c759a2c919337a9a9d1f5644)
|
|
126
|
+
(v0.6.0), with three.js 0.160.0. [vendor/SOURCES.md](vendor/SOURCES.md) says what is taken, what
|
|
127
|
+
stands in for the rest, and how to take a newer my-office.
|
|
128
|
+
|
|
129
|
+
Upstream supplies the Vietnamese and Thai text, with real brand names replaced. The Indonesian
|
|
130
|
+
text was written for this port in my-office’s locale format.
|
|
131
|
+
|
|
132
|
+
## Develop
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
npm install
|
|
136
|
+
npm run typecheck
|
|
137
|
+
npm test
|
|
138
|
+
npm run test:scripts # the scripts under scripts/
|
|
139
|
+
npm run lint
|
|
140
|
+
npm run build:world # after any change under vendor/
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Licence
|
|
144
|
+
|
|
145
|
+
MIT. my-office and three.js keep their own MIT licences; see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Pressable,
|
|
4
|
+
Text,
|
|
5
|
+
View,
|
|
6
|
+
type PressableStateCallbackType,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import type { OfficeStyles } from "./styles.js";
|
|
10
|
+
|
|
11
|
+
export interface ActionButtonProps {
|
|
12
|
+
label: string;
|
|
13
|
+
/** Shown while the action runs, e.g. "Sending...". */
|
|
14
|
+
pendingLabel: string;
|
|
15
|
+
onPress(): void | Promise<void>;
|
|
16
|
+
styles: OfficeStyles;
|
|
17
|
+
primary?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Same as server/errors.ts errorMessage; client code may not import server/.
|
|
22
|
+
function messageOf(error: unknown): string {
|
|
23
|
+
return error instanceof Error ? error.message : String(error);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A label is imperative ("Send"), so its failure reads "Unable to send: ...". A message that
|
|
28
|
+
* already starts "Unable to" (the board service's errors) is shown as it is, not prefixed twice,
|
|
29
|
+
* and an error that says nothing leaves no colon behind.
|
|
30
|
+
*/
|
|
31
|
+
export function failureText(label: string, error: unknown): string {
|
|
32
|
+
const message = messageOf(error).trim();
|
|
33
|
+
if (message.startsWith("Unable to")) return message;
|
|
34
|
+
const failure = `Unable to ${label.charAt(0).toLowerCase()}${label.slice(1)}`;
|
|
35
|
+
return message === "" ? failure : `${failure}: ${message}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function buttonStyle(
|
|
39
|
+
styles: OfficeStyles,
|
|
40
|
+
primary: boolean,
|
|
41
|
+
dim: boolean,
|
|
42
|
+
pressed: boolean,
|
|
43
|
+
): ViewStyle {
|
|
44
|
+
if (primary) {
|
|
45
|
+
if (dim) return styles.buttonPrimaryDisabled;
|
|
46
|
+
return pressed ? styles.buttonPrimaryPressed : styles.buttonPrimary;
|
|
47
|
+
}
|
|
48
|
+
if (dim) return styles.buttonDisabled;
|
|
49
|
+
return pressed ? styles.buttonPressed : styles.button;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A button that shows its own pending state and keeps its error in place (docs/testing.md). */
|
|
53
|
+
export function ActionButton({
|
|
54
|
+
label,
|
|
55
|
+
pendingLabel,
|
|
56
|
+
onPress,
|
|
57
|
+
styles,
|
|
58
|
+
primary = false,
|
|
59
|
+
disabled = false,
|
|
60
|
+
}: ActionButtonProps) {
|
|
61
|
+
const [pending, setPending] = useState(false);
|
|
62
|
+
const [error, setError] = useState<string | null>(null);
|
|
63
|
+
const mounted = useRef(true);
|
|
64
|
+
// Set before the first await, so a second tap before the re-render cannot fire twice.
|
|
65
|
+
const inFlight = useRef(false);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
mounted.current = true;
|
|
68
|
+
return () => {
|
|
69
|
+
mounted.current = false;
|
|
70
|
+
};
|
|
71
|
+
}, []);
|
|
72
|
+
const press = useCallback(() => {
|
|
73
|
+
if (inFlight.current) return;
|
|
74
|
+
inFlight.current = true;
|
|
75
|
+
setPending(true);
|
|
76
|
+
setError(null);
|
|
77
|
+
Promise.resolve()
|
|
78
|
+
.then(() => onPress())
|
|
79
|
+
.then(
|
|
80
|
+
() => {
|
|
81
|
+
inFlight.current = false;
|
|
82
|
+
if (mounted.current) setPending(false);
|
|
83
|
+
return undefined;
|
|
84
|
+
},
|
|
85
|
+
(failure: unknown) => {
|
|
86
|
+
inFlight.current = false;
|
|
87
|
+
if (!mounted.current) return;
|
|
88
|
+
setPending(false);
|
|
89
|
+
setError(failureText(label, failure));
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
}, [label, onPress]);
|
|
93
|
+
const dim = disabled || pending;
|
|
94
|
+
const style = useCallback(
|
|
95
|
+
({ pressed }: PressableStateCallbackType) => buttonStyle(styles, primary, dim, pressed),
|
|
96
|
+
[styles, primary, dim],
|
|
97
|
+
);
|
|
98
|
+
const shown = pending ? pendingLabel : label;
|
|
99
|
+
return (
|
|
100
|
+
<View style={styles.actionButton}>
|
|
101
|
+
<Pressable
|
|
102
|
+
accessibilityRole="button"
|
|
103
|
+
accessibilityLabel={shown}
|
|
104
|
+
disabled={dim}
|
|
105
|
+
onPress={press}
|
|
106
|
+
style={style}
|
|
107
|
+
>
|
|
108
|
+
{primary ? null : <View style={styles.buttonFill} />}
|
|
109
|
+
<Text style={primary ? styles.buttonPrimaryText : styles.buttonText} numberOfLines={1}>
|
|
110
|
+
{shown}
|
|
111
|
+
</Text>
|
|
112
|
+
{/* "Approve" turning into "Approving..." would widen the button and move its neighbour. */}
|
|
113
|
+
<Text aria-hidden style={styles.buttonSpacer} numberOfLines={1}>
|
|
114
|
+
{pending ? label : pendingLabel}
|
|
115
|
+
</Text>
|
|
116
|
+
</Pressable>
|
|
117
|
+
{error ? (
|
|
118
|
+
<Text accessibilityRole="alert" style={styles.actionError}>
|
|
119
|
+
{error}
|
|
120
|
+
</Text>
|
|
121
|
+
) : null}
|
|
122
|
+
</View>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// The words the feed says, and nothing else: an event's text is built from this file alone, so
|
|
2
|
+
// no file name, command, prompt or permission detail can reach the screen. `activity-feed.ts`
|
|
3
|
+
// imports this module, never the other way round.
|
|
4
|
+
import type { PermissionKind } from "../shared/contracts.js";
|
|
5
|
+
import type { ActivityKind } from "../shared/names.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* What an event is: the office's step kinds, and the five moments around them. It lives here
|
|
9
|
+
* because every one of them needs a word, and the feed module takes its list from this file.
|
|
10
|
+
*/
|
|
11
|
+
export type FeedKind =
|
|
12
|
+
| ActivityKind
|
|
13
|
+
| "started"
|
|
14
|
+
| "finished"
|
|
15
|
+
| "permission"
|
|
16
|
+
| "error"
|
|
17
|
+
| "subagent-started";
|
|
18
|
+
|
|
19
|
+
/** The feed's first line, before the office has changed under it. */
|
|
20
|
+
export const FEED_EMPTY = "Nothing yet since the office opened.";
|
|
21
|
+
|
|
22
|
+
/** The feed has events, but the tab and the chips hide every card. */
|
|
23
|
+
export const FEED_NO_MATCH = "No activity matches.";
|
|
24
|
+
|
|
25
|
+
/** A step's word: what the agent is at, in the office's own kind and no detail of the call. */
|
|
26
|
+
const STEP_WORDS: Readonly<Record<ActivityKind, string>> = {
|
|
27
|
+
read: "Reading",
|
|
28
|
+
search: "Searching",
|
|
29
|
+
skill: "Using a skill",
|
|
30
|
+
edit: "Editing",
|
|
31
|
+
write: "Writing",
|
|
32
|
+
command: "Running a command",
|
|
33
|
+
web: "Searching the web",
|
|
34
|
+
tool: "Using a tool",
|
|
35
|
+
subagent: "Starting a sub-agent",
|
|
36
|
+
plan: "Updating the plan",
|
|
37
|
+
test: "Running tests",
|
|
38
|
+
commit: "Committing",
|
|
39
|
+
push: "Pushing",
|
|
40
|
+
deploy: "Deploying",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export interface EventTextExtra {
|
|
44
|
+
/** A permission's short title, or a sub-agent's name; absent when there is nothing to name. */
|
|
45
|
+
title?: string;
|
|
46
|
+
/** A permission's kind, which decides whether its title may be shown. */
|
|
47
|
+
permissionKind?: PermissionKind;
|
|
48
|
+
/** A step that ended badly: its word gets " failed". */
|
|
49
|
+
failed?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A permission's line. Only a tool's or a mode's title is a short name; a question's title is the
|
|
54
|
+
* question itself (Claude's AskUserQuestion) and a plan's can be prose too, so those, and a kind
|
|
55
|
+
* not given, get their words alone.
|
|
56
|
+
*/
|
|
57
|
+
function permissionText({ title, permissionKind }: EventTextExtra): string {
|
|
58
|
+
if (permissionKind === "question") return "Has a question";
|
|
59
|
+
if (permissionKind === "plan") return "Has a plan to review";
|
|
60
|
+
const named = permissionKind === "tool" || permissionKind === "mode" ? (title?.trim() ?? "") : "";
|
|
61
|
+
return named === "" ? "Needs permission" : `Needs permission: ${named}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** What one event says. */
|
|
65
|
+
export function eventText(kind: FeedKind, extra: EventTextExtra = {}): string {
|
|
66
|
+
switch (kind) {
|
|
67
|
+
case "started":
|
|
68
|
+
return "Started working";
|
|
69
|
+
case "finished":
|
|
70
|
+
return "Finished";
|
|
71
|
+
case "error":
|
|
72
|
+
return "Stopped on an error";
|
|
73
|
+
case "permission":
|
|
74
|
+
return permissionText(extra);
|
|
75
|
+
case "subagent-started": {
|
|
76
|
+
const title = extra.title?.trim() ?? "";
|
|
77
|
+
return title === "" ? "A sub-agent started" : `Started ${title}`;
|
|
78
|
+
}
|
|
79
|
+
default: {
|
|
80
|
+
const word = STEP_WORDS[kind];
|
|
81
|
+
return extra.failed === true ? `${word} failed` : word;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|