paseo-plugin-secure-input 0.3.0 → 0.4.1
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 +2 -2
- package/README.md +11 -11
- package/SECURITY.md +7 -7
- package/client/card.tsx +6 -3
- package/client/codes.ts +9 -26
- package/client/diagnostics-rows.ts +32 -47
- package/client/dialog-state.ts +1 -1
- package/client/dialog.tsx +11 -9
- package/client/fields.tsx +19 -15
- package/client/file-entry.ts +14 -14
- package/client/form-state.ts +13 -19
- package/client/messages.ts +312 -0
- package/client/outcome.ts +3 -3
- package/client/presentation.ts +13 -39
- package/client/self-test.ts +6 -8
- package/client/settings.tsx +24 -22
- package/npm-shrinkwrap.json +2 -2
- package/package.json +7 -6
- package/paseo-plugin.json +1 -1
- package/server/core/continuation.ts +1 -1
- package/server/paseo/hooks.ts +14 -14
- package/server/paseo/plugin.ts +1 -1
- package/server/paseo/tools.ts +15 -2
- package/shared/limits.ts +2 -2
- package/skills/secure-input/SKILL.md +3 -3
- package/client/text.ts +0 -47
package/OVERVIEW.md
CHANGED
|
@@ -6,7 +6,7 @@ secure-input lets an agent ask you for a password, an API key, a token or a whol
|
|
|
6
6
|
- **The form**: a hidden row for each key, with an eye to show the value, and rows of your own for keys the agent did not name. A file row takes a whole file of up to 128 KiB, binary included: picked or dropped on the desktop, pasted on the desktop and on the phone. ✕ declines the request.
|
|
7
7
|
- **The Secure input settings screen**: a check that seals the largest submission one request can carry on this device and has the plugin open it, the plugin's state, and a button that deletes every set of files at once.
|
|
8
8
|
|
|
9
|
-
The
|
|
9
|
+
The pill, the form and the settings screen follow the app's language: English, Korean or Ukrainian, and English for any other. Paseo has no Ukrainian setting yet.
|
|
10
10
|
|
|
11
11
|
## What the agent sees
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ The agent has four tools, which Paseo serves beside its own: `request_secret` to
|
|
|
14
14
|
|
|
15
15
|
## Setup
|
|
16
16
|
|
|
17
|
-
- Paseo 0.
|
|
17
|
+
- Paseo 0.15.0 or later on the daemon and in the app: an older app does not load the pill, the form or the settings screen. A macOS or Linux daemon with Node.js 22.12 or later; live validation has been on macOS.
|
|
18
18
|
- Paseo must give its tools to agents (`daemon.mcp.injectIntoAgents`): while that is off, no agent has the plugin's tools.
|
|
19
19
|
- Link the skill where your agents read skills, as the [README](https://github.com/dutchakdev/paseo-plugin-secure-input#install) shows.
|
|
20
20
|
- Answer from the app over the relay or Tailscale: a direct LAN connection with a password is not encrypted.
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
secure-input is a [Paseo](https://paseo.sh) plugin: an agent asks you for a password, an API key, a token or a whole credentials file in a form in the Paseo app instead of in the chat. The app seals what you enter, the daemon writes each value to a short-lived file that only your OS user can read, and the agent gets only the paths, with a skill that has it move each file's content without reading it (which holds as far as the agent follows the skill). The
|
|
3
|
+
secure-input is a [Paseo](https://paseo.sh) plugin: an agent asks you for a password, an API key, a token or a whole credentials file in a form in the Paseo app instead of in the chat. The app seals what you enter, the daemon writes each value to a short-lived file that only your OS user can read, and the agent gets only the paths, with a skill that has it move each file's content without reading it (which holds as far as the agent follows the skill). The pill, the form and the settings screen follow the app's language: English, Korean or Ukrainian, and English for any other. Paseo has no Ukrainian setting yet.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
Paseo **0.
|
|
7
|
+
Paseo **0.15.0 or later** on the daemon and in every app you answer from: an older app shows no pill, and `paseo plugin ls` cannot tell you. The daemon needs Node.js 22.12 or later. The Paseo 0.18.1 SDK and daemon were checked, including RPCs and agent lifecycle hooks. Check both versions:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
paseo daemon status # daemonVersion
|
|
@@ -36,7 +36,7 @@ ln -sn ../../.agents/skills/secure-input ~/.claude/skills/secure-input
|
|
|
36
36
|
|
|
37
37
|
`ln -sn` replaces nothing: a name that is taken fails with `File exists` or, if it is a real directory, gets the link inside it; look with `ls -ld` first.
|
|
38
38
|
|
|
39
|
-
Then, on each device you answer from, open **Secure input** in the plugin's settings and press
|
|
39
|
+
Then, on each device you answer from, open **Secure input** in the plugin's settings and press «Check», which seals a submission of the largest size and has the plugin open it. Answer over the relay or Tailscale: a direct LAN connection with a password is not encrypted.
|
|
40
40
|
|
|
41
41
|
## How it works
|
|
42
42
|
|
|
@@ -61,25 +61,25 @@ The form shows no reason: the agent says why it asks in its own message. Deletio
|
|
|
61
61
|
|
|
62
62
|
## What the agent gets
|
|
63
63
|
|
|
64
|
-
The agent has four tools beside Paseo's own: `request_secret` (named keys, or none; it answers `"status": "pending"`, and the paths follow in a message), `request_status`, `cancel_request` and `release_secret`, which agents see as `mcp__paseo__request_secret`, `mcp__paseo__request_status`, `mcp__paseo__cancel_request` and `mcp__paseo__release_secret`. A text value is one line of at most 64 KiB; a file is at most 128 KiB, binary included, checked as JSON or PEM when the agent asks for that. One pending request per agent; a request nobody answers expires after 8 hours. The skill holds the input and the rules the agent follows.
|
|
64
|
+
The agent has four tools beside Paseo's own: `request_secret` (named keys, or none; it answers `"status": "pending"`, and the paths follow in a message), `request_status`, `cancel_request` and `release_secret`, which agents see as `mcp__paseo__request_secret`, `mcp__paseo__request_status`, `mcp__paseo__cancel_request` and `mcp__paseo__release_secret`. A text value is one line of at most 64 KiB; a file is at most 128 KiB, binary included, checked as JSON or PEM when the agent asks for that. One pending request per agent; a request nobody answers expires after 8 hours. A background agent (Paseo 0.16), whose chat nobody sees, is refused at once and sent to whoever started it. The skill holds the input and the rules the agent follows.
|
|
65
65
|
|
|
66
66
|
## What you see
|
|
67
67
|
|
|
68
|
-
A pill in the agent's chat holds the key names, never a value:
|
|
68
|
+
A pill in the agent's chat holds the key names, never a value: «Secret for the agent» or «Secrets for the agent» while it waits for you, green «Delivered» once delivered and grey once the files are gone, struck through when declined, cancelled, expired or refused, and red «Suspicious submission» when a second, different submission came after delivery. Pressing the waiting pill opens the form over the chat: a hidden row per key with an eye to show it, dim names on optional keys, **+** for a row of your own (the paperclip makes it a file row), ✕ at the top to decline. A form holds at most 32 rows, including yours; → stays disabled while a required field or a row you added is incomplete, or while there is nothing to send. Closing the form any other way declines nothing and throws away what you typed. A file row takes a file picked or dropped on the desktop, or pasted on the desktop and the phone (Paseo gives plugins no file picker there); the plugin reads no clipboard. The form shows neither the agent's reason nor its labels.
|
|
69
69
|
|
|
70
|
-
**Secure input**, in the plugin's settings, runs
|
|
70
|
+
**Secure input**, in the plugin's settings, runs «Check», shows the sets on the daemon and the requests that wait («Secrets on the server», «Waiting requests», «Errors»), and has «Delete all secret files now», which tries to delete every set; some may already be gone when «Could not delete» appears, so check «Secrets on the server» for what remains.
|
|
71
71
|
|
|
72
72
|
## When files go
|
|
73
73
|
|
|
74
74
|
Each delivery is `<data>/drop/si-secret-<requestId>/` with a file per key you filled in. The plugin tries to delete it at the first of these; a crash or a failed removal can leave files behind ([SECURITY.md](SECURITY.md#crashes-stops-and-restarts)):
|
|
75
75
|
|
|
76
76
|
- The agent calls `release_secret`, or deletes the directory itself.
|
|
77
|
-
- The end, with any outcome, of the agent's turn that its delivery message starts.
|
|
77
|
+
- The end, with any outcome, of the agent's turn that its delivery message starts. If the message joins a running turn, the files go at the end of the agent's next turn or at the deadline, whichever comes first.
|
|
78
78
|
- The agent is archived.
|
|
79
79
|
- 15 minutes after the write; on a machine that slept through that, within a minute of waking.
|
|
80
80
|
- The plugin starts, and sweeps `drop/`.
|
|
81
81
|
- The plugin stops, and tries to sweep `drop/`.
|
|
82
|
-
- You press
|
|
82
|
+
- You press «Delete all secret files now» in the settings.
|
|
83
83
|
|
|
84
84
|
An agent busy for more than 15 minutes after you submit loses the files at their deadline and, once idle, is told to ask again.
|
|
85
85
|
|
|
@@ -92,11 +92,11 @@ What you enter leaves the app only sealed to a one-time key of the request. The
|
|
|
92
92
|
| Symptom | Cause and fix |
|
|
93
93
|
|---|---|
|
|
94
94
|
| The agent says it has no `request_secret` tool | `daemon.mcp.injectIntoAgents` is off ([Install](#install)); the provider's configuration switches Paseo's tools off; or the session opened before the plugin ran. A Codex agent may have to look in `ALL_TOOLS` |
|
|
95
|
-
| The agent reports `the plugin did not start (…)` | The start-up failed and the tools refuse until it succeeds.
|
|
96
|
-
| No pill in the chat, or no **Secure input** screen | The app is older than the plugin requires ([Install](#install)), or the plugin does not run: `paseo plugin ls`, `paseo plugin logs secure-input`. The plugin retries a pill that did not land;
|
|
95
|
+
| The agent reports `the plugin did not start (…)` | The start-up failed and the tools refuse until it succeeds. «Plugin» reads «Did not start» with the reason, and so does `paseo plugin logs secure-input`: for example the data directory, `${PASEO_HOME:-~/.paseo}/secure-input`, or `drop/` in it, is not a private directory of your user. Remove the cause and reload the plugin. `the plugin is busy; retry in a few seconds` is a disk that stalls: nothing was done, and the agent can ask again |
|
|
96
|
+
| No pill in the chat, or no **Secure input** screen | The app is older than the plugin requires ([Install](#install)), or the plugin does not run: `paseo plugin ls`, `paseo plugin logs secure-input`. The plugin retries a pill that did not land; «Errors» shows it meanwhile |
|
|
97
97
|
| The agent stops to ask for permission | Your harness may ask before plugin calls and file transfers. Approve only when the task and destination match what you authorised |
|
|
98
98
|
| The agent never continued after you submitted | Its message waits until the daemon says the agent is idle; [SECURITY.md](SECURITY.md#crashes-stops-and-restarts) says how long and how it can be lost. Tell the agent to continue: it can call `request_status` |
|
|
99
|
-
|
|
|
99
|
+
| «Secrets on the server» is red | Something in `drop/` could not be deleted, and the plugin retries ([SECURITY.md](SECURITY.md#crashes-stops-and-restarts)). Press «Delete all secret files now», or delete `drop/` by hand |
|
|
100
100
|
|
|
101
101
|
## Development
|
|
102
102
|
|
package/SECURITY.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
Over the relay or Tailscale, with an honest but careless agent:
|
|
6
6
|
|
|
7
7
|
- **On its way, a value is sealed.** What you type, pick, drop or paste leaves the app only as ciphertext, sealed to a one-time key of the request (X25519, HKDF-SHA256, ChaCha20-Poly1305) and bound to the request's id and to a digest of the keys it declared and whether each is optional. A file travels as base64url inside the same sealed payload. If sealing fails, nothing is sent.
|
|
8
|
-
- **On the daemon, a value is a short-lived file.** On disk it exists in the clear only under `drop/`: as `<data>/drop/si-secret-<requestId>/<KEY>`, a file of mode `0600` in a directory of mode `0700`, or, after a failed write, under a temporary name there. The plugin deletes a set 15 minutes after the write at the latest while the machine is awake, and within a minute of waking when it slept through that; earlier when the agent releases it, at the end of the turn its delivery message starts, when the agent is archived, and at every start and stop of the plugin. A crash, a stalled disk or a failed removal can keep it longer ([below](#crashes-stops-and-restarts)).
|
|
8
|
+
- **On the daemon, a value is a short-lived file.** On disk it exists in the clear only under `drop/`: as `<data>/drop/si-secret-<requestId>/<KEY>`, a file of mode `0600` in a directory of mode `0700`, or, after a failed write, under a temporary name there. The plugin deletes a set 15 minutes after the write at the latest while the machine is awake, and within a minute of waking when it slept through that; earlier when the agent releases it, at the end of the turn its delivery message starts (or at the end of the next turn if the message joins a running turn), when the agent is archived, and at every start and stop of the plugin. A crash, a stalled disk or a failed removal can keep it longer ([below](#crashes-stops-and-restarts)).
|
|
9
9
|
- **Outputs and metadata.** No tool result, message to the agent, pill, status, RPC answer, log line, error, `requests.json` or `outbox.json` holds a value; the agent is given paths. Plaintext also exists for a while in app and daemon memory (below).
|
|
10
10
|
- **The daemon names who asks.** A request belongs to the agent identity Paseo supplies with the tool call; nothing the call itself says is read. Of the four tools, status, cancel and release answer any other agent, its parent included, as if the request did not exist. On Paseo 0.14.0-beta.1 a local process with access to the daemon can impersonate an agent ([below](#a-hostile-process-that-runs-as-you)); the plugin cannot verify that the named agent made the call.
|
|
11
11
|
|
|
@@ -35,8 +35,8 @@ An agent with a shell runs as your OS user, controls its workspace, and can read
|
|
|
35
35
|
| Condition | What happens |
|
|
36
36
|
|---|---|
|
|
37
37
|
| A process impersonates an agent | On Paseo 0.14.0-beta.1 a local process with access to the daemon can call the tools as another agent: create a request, and its pill, in that agent's chat, a card that asks you for a secret on behalf of an agent that never asked; and look at, cancel or release that agent's requests. The plugin cannot verify that the named agent made the call; only Paseo can close this. Provide a secret only for a task and destination you recognise |
|
|
38
|
-
| Any owner session of the daemon calls the plugin's RPCs; automated callers can use them too | A handler is not told who is calling, so an RPC call does not prove that you approved the request. Such a caller can read a request's view (its keys, labels and public key; never a value), submit its own values before you do, decline a request, or send three submissions that cannot be opened and so close it (`retry_limit`). If it submits first, the files hold its values; your own submission is then refused, the pill turns red,
|
|
39
|
-
| A caller of `secure-input.drop.clear` | Deletes every set at once, as
|
|
38
|
+
| Any owner session of the daemon calls the plugin's RPCs; automated callers can use them too | A handler is not told who is calling, so an RPC call does not prove that you approved the request. Such a caller can read a request's view (its keys, labels and public key; never a value), submit its own values before you do, decline a request, or send three submissions that cannot be opened and so close it (`retry_limit`). If it submits first, the files hold its values; your own submission is then refused, the pill turns red, «Suspicious submission», and the agent is told to have you check what it did with the values and to rotate the secret |
|
|
39
|
+
| A caller of `secure-input.drop.clear` | Deletes every set at once, as «Delete all secret files now» does. Agents lose the files they had not moved yet, and one whose delivery message still waits is told that the user deleted them. The RPC returns counts of released requests and remaining entries |
|
|
40
40
|
| A process plants `requests.json` or `outbox.json` | Both are read as hostile input: capped, never through a link, and entry by entry against a strict schema with no field a value could go into. A planted outbox entry can at most make the plugin send one of its fixed messages again, to the agent whose request it names, once per restart. A planted record that passes the schema is loaded; one that claims to wait or to be delivered is ended by the next start (`expired`, or `released` by `restart`), with a pill of its key names in the chat of the agent it names. Nothing can be opened or written for it: the key never existed in this run |
|
|
41
41
|
| A process plants entries or links in `drop/` | The start's sweep removes everything in `drop/`. A link is unlinked as a link and never followed, and removal goes at most 8 levels deep; what is deeper is left and reported. A `drop/` that is itself a link, or not a directory of your user, fails the start-up; put in its place while the plugin runs, it is refused by every write and every removal, and what was to go stays reported until it can go. Anything at a set's path but an empty directory fails that write (`write_failed`) |
|
|
42
42
|
| A process swaps a directory for a link in the instant before a removal | Node has no `unlinkat` or `openat`, so every removal goes by path. Before each entry the plugin looks at the entry's directory again and goes on only if it is still the directory it read (the same device and inode); `drop/` itself is held to this too. A swap that lands between that look and the call it guards is not caught: an `unlink` then removes a file of that name wherever the link leads, and a directory's removal goes on where the link leads, at most 8 levels deep. A write holds `drop/` when it begins and looks at it again right before the rename that puts the set in place. A process that can win these races can read or delete what they reach by itself |
|
|
@@ -50,11 +50,11 @@ An agent with a shell runs as your OS user, controls its workspace, and can read
|
|
|
50
50
|
| The plugin or the daemon is killed, or the machine loses power, while a set exists | The set stays in `drop/` until the plugin next starts: while it does not run, nothing deletes the set, not even 15 minutes after the write. A start sweeps `drop/` first, once it has made sure the data directory is its own and before anything else that can fail. What the sweep cannot remove is reported, and each such entry is tried again once a minute until it goes; the sweep itself is not repeated, since it would take the sets delivered since. A plugin that never starts again leaves the set where it is |
|
|
51
51
|
| The plugin is stopped | Paseo 0.14 gives a stopping plugin 2 seconds before it sends SIGTERM. Within them the plugin wipes the keys of the requests that wait, releases every set as `stop`, saves, and sweeps `drop/`: the releases and the save get at most 1 second, and the sweep after them at most 500 milliseconds, whatever the work queue is still doing. What the sweep cannot remove in that time stays for the next start. A record whose release the stop could not save reads `restart` at the next start |
|
|
52
52
|
| The stop comes while the start-up hangs (a disk that stalls) | The stop waits up to 5 seconds for the start-up, longer than the 2 seconds Paseo gives the stop, and then goes on without it. Such a start-up has delivered no set, since every tool call waits for the start-up, so what can be cut short is only the sweep of what an earlier run left, which the next start makes |
|
|
53
|
-
| A write fails, and its clean-up cannot remove what it staged | The request is rejected (`write_failed`), and the half-written set stays in `drop/` under its temporary name, `si-secret-<requestId>.<random>.tmp`.
|
|
54
|
-
| A removal fails | The request stays `delivered` and
|
|
53
|
+
| A write fails, and its clean-up cannot remove what it staged | The request is rejected (`write_failed`), and the half-written set stays in `drop/` under its temporary name, `si-secret-<requestId>.<random>.tmp`. «Secrets on the server» turns red, and the entry is tried again once a minute until it goes; the stop, the next start and «Delete all secret files now» take it too. Nobody is given its path |
|
|
54
|
+
| A removal fails | The request stays `delivered` and «Secrets on the server» turns red. A delivered set is tried again at its deadline, and after that once a minute; the end of a later delivery turn of its agent tries sooner. What a start or a failed write left is tried again once a minute. «Delete all secret files now» tries again now; so does deleting `drop/` by hand |
|
|
55
55
|
| A disk that stalls holds up the plugin's work queue | Every deletion but the stop's sweep waits in that queue, the deadline's included, so for as long as the disk stalls a set can outlive its deadline. A tool call waits there for its turn for at most 10 seconds and is then refused, `the plugin is busy; retry in a few seconds`; what it asked for is not done later. An operation that has begun is waited for to the end |
|
|
56
56
|
| The plugin restarts while a request waits for you | The request becomes `expired`, because the key to open it lived in memory only. The agent is told that the restart ended it, as soon as a hook runs or the app reconnects |
|
|
57
|
-
| The plugin restarts while a set exists | The start's sweep removes it, and the request reads `released` (`restart`). A delivery message that still waits becomes the message that the files went when the plugin restarted; one already sent is not sent again. A set the sweep cannot remove keeps its request `delivered`, and
|
|
57
|
+
| The plugin restarts while a set exists | The start's sweep removes it, and the request reads `released` (`restart`). A delivery message that still waits becomes the message that the files went when the plugin restarted; one already sent is not sent again. A set the sweep cannot remove keeps its request `delivered`, and «Secrets on the server» red, until it goes; a delivery message that goes out meanwhile gives the paths of the files that are still there |
|
|
58
58
|
| A message to the agent is late or lost | A message for a busy agent waits for the agent to become idle, within the bounds below; a failed or unanswered idle check leaves it waiting. The plugin checks that the agent is idle and then sends, so a turn can start between the two. The message then joins that turn where the agent's provider can steer it, and replaces that turn where it cannot. Files named by a message that joined a turn go at the end of the agent's next turn rather than that one, or at their deadline. Each send is attempted at most once; a message can be lost when the plugin dies before it was saved, or dies or is stopped between taking it out of `outbox.json` and the end of the send; when the send fails or is not answered in time; when it waited past the queue's age or count limit, or the clock was set back while it waited; when the agent is archived; when the plugin no longer has the request it is about (`requests.json` unreadable at a start, or the request evicted from the history); when a stop ran out of its time before the change of state was saved; or when `outbox.json` was replaced by something the plugin did not write. A message about delivered files is not sent at all when the agent released those files first. After a send that the daemon refused, a later turn does not delete the files: they stay until their deadline, and `request_status` gives their paths. A send left unanswered counts as delivered, and the end of the agent's next turn deletes them. The agent may then need a nudge from you |
|
|
59
59
|
| The plugin is stopped while messages or pills wait | No further pill is put on a timeline, and no agent is asked whether it is idle. A message that was not sent stays in `outbox.json` for the next start. A change of state whose save was still under way when the stop ran out of its time is saved and announced by nobody: no message for it, and the pill goes on showing the state before it. The form behind the pill shows the true state |
|
|
60
60
|
| A pill cannot be put on the agent's timeline | The pill is the only way to the form, so it is tried again once a minute and whenever the daemon next calls the plugin, until it lands, and only once in five minutes while the daemon has left three appends of it unanswered. Until then nobody can answer the request |
|
|
@@ -75,7 +75,7 @@ The bounds of the message queue:
|
|
|
75
75
|
|---|---|
|
|
76
76
|
| A direct LAN connection with a password | The WebSocket is not encrypted. An active attacker can swap the request's key and read what you type. Enter secrets over the relay or Tailscale only |
|
|
77
77
|
| Someone sees the size of what you send | The sealed submission is padded to a multiple of 1 KiB. An observer can still infer a size range, and for a request with one value the approximate length of that value |
|
|
78
|
-
| The app is older than the plugin requires (0.
|
|
78
|
+
| The app is older than the plugin requires (0.15.0) | The plugin runs on the daemon, but the pill, the form and the settings screen do not load, so that device cannot answer requests. `paseo plugin ls` does not show it |
|
|
79
79
|
| The reply to your submission is lost, and you press → again with other values | The form first reads the request again, and sends nothing if the request has been answered. That narrows the window: a first submission still waiting in the plugin can win after that reading, and your second one is then refused and flagged as a second, different submission, though both were yours. With unchanged values the form sends the same sealed data again, which is never flagged |
|
|
80
80
|
| Linux | Developed and run on macOS. Linux is declared supported, and the test suite passes on it; the plugin has not been run on a Linux daemon |
|
|
81
81
|
|
package/client/card.tsx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { PluginTimelineItemProps } from "@getpaseo/plugin/client";
|
|
2
|
+
import { useTranslation } from "@getpaseo/plugin/client";
|
|
2
3
|
import { Icon } from "@getpaseo/plugin/client/ui";
|
|
3
4
|
import { useState } from "react";
|
|
4
5
|
import { Pressable, Text } from "react-native";
|
|
5
6
|
import type { CardData } from "../shared/card";
|
|
6
7
|
import { RequestDialog } from "./dialog";
|
|
7
8
|
import { MONO } from "./fields";
|
|
8
|
-
import {
|
|
9
|
+
import { messages } from "./messages";
|
|
10
|
+
import { PILL_HEIGHT, pill, pillColor } from "./presentation";
|
|
9
11
|
import { tone } from "./tone";
|
|
10
12
|
|
|
11
13
|
/** The moment the form was opened, or null while it is closed. */
|
|
@@ -19,16 +21,17 @@ type Opening = number | null;
|
|
|
19
21
|
* host has already checked `item.data` against the strict schema given at registration.
|
|
20
22
|
*/
|
|
21
23
|
export function RequestCard({ item, theme, host, layout }: PluginTimelineItemProps<CardData>) {
|
|
24
|
+
const { t } = useTranslation(messages);
|
|
22
25
|
const colors = tone(theme.colors);
|
|
23
26
|
const [session, setSession] = useState<Opening>(null);
|
|
24
|
-
const look = pill(item.data);
|
|
27
|
+
const look = pill(t, item.data);
|
|
25
28
|
const { color, opacity } = pillColor(look.tone, colors);
|
|
26
29
|
|
|
27
30
|
return (
|
|
28
31
|
<>
|
|
29
32
|
<Pressable
|
|
30
33
|
accessibilityRole={look.pressable ? "button" : undefined}
|
|
31
|
-
accessibilityLabel={look.pressable ?
|
|
34
|
+
accessibilityLabel={look.pressable ? t("a11y.enter") : undefined}
|
|
32
35
|
disabled={!look.pressable}
|
|
33
36
|
onPress={() => setSession(Date.now())}
|
|
34
37
|
style={{
|
package/client/codes.ts
CHANGED
|
@@ -1,32 +1,15 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import { afterFailedAttempts, attemptsFailed } from "./text";
|
|
4
|
-
|
|
5
|
-
/** The end of the sentence about a refusal that counts: the limit is the plugin's own number, said in words. */
|
|
6
|
-
const CLOSES_AFTER = `${afterFailedAttempts(MAX_RETRIES)} запит закривається.`;
|
|
1
|
+
import { ERROR_CODES, type ErrorCode } from "../shared/errors";
|
|
2
|
+
import type { messages, Translate } from "./messages";
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
|
-
* One
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* One key for every code the plugin can answer with, so a new code is a compile error until English has its sentence.
|
|
6
|
+
* The settings screen says them, with the code, about a start-up or a hook that failed. The form says none of them:
|
|
7
|
+
* every refusal there is one of its two lines (`./outcome`). A map keeps a name from the prototype (`constructor`,
|
|
8
|
+
* `__proto__`) from finding a sentence.
|
|
12
9
|
*/
|
|
13
|
-
|
|
14
|
-
invalid_request: "Запит або надіслані значення не вдалося прочитати.",
|
|
15
|
-
request_already_pending: "Від агента вже є ще один відкритий запит.",
|
|
16
|
-
unknown_agent: "Плагін не зміг визначити, який агент надіслав запит.",
|
|
17
|
-
service_unavailable: "Плагін зараз не може прийняти запит.",
|
|
18
|
-
write_failed: "Файл не вдалося записати.",
|
|
19
|
-
retry_limit: `${attemptsFailed(MAX_RETRIES)}: зашифровані значення не вдалося розкрити.`,
|
|
20
|
-
request_closed: "Запит уже було закрито, коли ви відповіли (наприклад, плагін перезапускали).",
|
|
21
|
-
decrypt_failed: `Плагін не зміг розкрити зашифровані значення — можливе втручання в канал. Перевірте, що з'єднання йде через relay або Tailscale, і спробуйте ще раз. ${CLOSES_AFTER}`,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const UNKNOWN_SENTENCE = "Невідома помилка.";
|
|
25
|
-
|
|
26
|
-
/** A map, so a name from the prototype (`constructor`, `__proto__`) finds nothing. */
|
|
27
|
-
const SENTENCES: ReadonlyMap<string, string> = new Map(Object.entries(CODE_SENTENCE));
|
|
10
|
+
const CODE_KEYS: ReadonlyMap<string, `codes.${keyof typeof messages.resources.en.codes}`> = new Map(ERROR_CODES.map((code) => [code, `codes.${code}`] as const));
|
|
28
11
|
|
|
29
12
|
/** The sentence first; the code after it, in parentheses, for whoever the human asks for help. */
|
|
30
|
-
export function describeCode(code: ErrorCode): string {
|
|
31
|
-
return `${
|
|
13
|
+
export function describeCode(t: Translate, code: ErrorCode): string {
|
|
14
|
+
return `${t(CODE_KEYS.get(code) ?? "codes.unknown")} (${code})`;
|
|
32
15
|
}
|
|
@@ -1,36 +1,23 @@
|
|
|
1
1
|
import type { Diagnostics } from "../shared/contracts";
|
|
2
2
|
import { ERROR_CODES, type ErrorCode } from "../shared/errors";
|
|
3
3
|
import { describeCode } from "./codes";
|
|
4
|
+
import type { Translate } from "./messages";
|
|
4
5
|
import type { Tone } from "./tone";
|
|
5
6
|
|
|
6
7
|
/** What the settings screen says of how the values travel: the construction `shared/seal.ts` really uses, and nothing else. */
|
|
7
8
|
export const SETTINGS_BADGE = "X25519 · HKDF-SHA256 · ChaCha20-Poly1305";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
-
* by these words, so the button and the sentence cannot name it differently.
|
|
12
|
-
*/
|
|
13
|
-
export const DELETE_ALL = "Видалити всі файли секретів зараз";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The line under that button when the deletion itself was refused (the plugin is stopping, or `drop/` could not be swept):
|
|
17
|
-
* fixed words, and nothing of what the refusal said. What is left shows in the rows, read again after the press.
|
|
18
|
-
*/
|
|
19
|
-
export const DELETE_FAILED = "Не вдалося видалити";
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* One line of the «Стан» section. The dot is green (`ok`), amber (`warn`: something to see, nothing to fix) or red
|
|
11
|
+
* One line of the «Status» section. The dot is green (`ok`), amber (`warn`: something to see, nothing to fix) or red
|
|
23
12
|
* (`bad`: something to do), and only a red row has an explanation under it.
|
|
24
13
|
*/
|
|
25
14
|
export interface StatusRow {
|
|
26
|
-
label: "
|
|
15
|
+
label: "status.plugin" | "status.files" | "status.pending" | "status.errors";
|
|
27
16
|
value: string;
|
|
28
17
|
dot: "ok" | "warn" | "bad";
|
|
29
18
|
explanation: string | null;
|
|
30
19
|
}
|
|
31
20
|
|
|
32
|
-
const NONE = "Немає";
|
|
33
|
-
|
|
34
21
|
const ok = (label: StatusRow["label"], value: string): StatusRow => ({ label, value, dot: "ok", explanation: null });
|
|
35
22
|
const warn = (label: StatusRow["label"], value: string): StatusRow => ({ label, value, dot: "warn", explanation: null });
|
|
36
23
|
const bad = (label: StatusRow["label"], value: string, explanation: string): StatusRow => ({ label, value, dot: "bad", explanation });
|
|
@@ -48,73 +35,71 @@ function isKnownCode(code: string): code is ErrorCode {
|
|
|
48
35
|
return KNOWN_CODES.has(code);
|
|
49
36
|
}
|
|
50
37
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
function pluginRow(data: Diagnostics): StatusRow {
|
|
38
|
+
function pluginRow(t: Translate, data: Diagnostics): StatusRow {
|
|
54
39
|
if (data.startup !== null) {
|
|
55
40
|
const { code, detail } = data.startup;
|
|
56
|
-
const sentence = code === "unexpected" ?
|
|
57
|
-
return bad("
|
|
41
|
+
const sentence = code === "unexpected" ? t("status.unexpected") : describeCode(t, code);
|
|
42
|
+
return bad("status.plugin", t("status.notStarted"), detail === "" ? sentence : `${sentence} — ${detail}`);
|
|
58
43
|
}
|
|
59
44
|
// The daemon's API arrives with the first call, and messages are held back until the start-up has read the requests.
|
|
60
|
-
if (!data.attached || data.messagesHeld) return warn("
|
|
61
|
-
return ok("
|
|
45
|
+
if (!data.attached || data.messagesHeld) return warn("status.plugin", t("status.starting"));
|
|
46
|
+
return ok("status.plugin", t("status.running"));
|
|
62
47
|
}
|
|
63
48
|
|
|
64
|
-
function filesRow(data: Diagnostics): StatusRow {
|
|
49
|
+
function filesRow(t: Translate, data: Diagnostics): StatusRow {
|
|
65
50
|
const { delivered, nextDeleteBy } = data.requests;
|
|
66
51
|
if (data.registry.drop === "failing") {
|
|
67
52
|
return bad(
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
"status.files",
|
|
54
|
+
t("status.notAllDeleted", { delivered }),
|
|
55
|
+
t("status.deleteFailedHint", { action: t("settings.deleteAll"), dir: data.dataDir }),
|
|
71
56
|
);
|
|
72
57
|
}
|
|
73
|
-
if (delivered === 0) return ok("
|
|
58
|
+
if (delivered === 0) return ok("status.files", t("status.none"));
|
|
74
59
|
// The contract allows a deadline of none beside a set; the count is true all the same.
|
|
75
|
-
if (nextDeleteBy === null) return warn("
|
|
76
|
-
return warn("
|
|
60
|
+
if (nextDeleteBy === null) return warn("status.files", String(delivered));
|
|
61
|
+
return warn("status.files", t("status.nextGoesAt", { delivered, time: clockTime(nextDeleteBy) }));
|
|
77
62
|
}
|
|
78
63
|
|
|
79
|
-
function waitingRow(data: Diagnostics): StatusRow {
|
|
64
|
+
function waitingRow(t: Translate, data: Diagnostics): StatusRow {
|
|
80
65
|
const { pending } = data.requests;
|
|
81
|
-
return pending > 0 ? warn("
|
|
66
|
+
return pending > 0 ? warn("status.pending", String(pending)) : ok("status.pending", t("status.none"));
|
|
82
67
|
}
|
|
83
68
|
|
|
84
69
|
const HOOK_FAILURE = /^([^:\s][^:]*): ([a-z_]+)$/;
|
|
85
70
|
|
|
86
71
|
/** `<hook>: <code>` with the sentence for a code the plugin knows; anything else is shown as it was kept. */
|
|
87
|
-
function hookFailure(kept: string): string {
|
|
72
|
+
function hookFailure(t: Translate, kept: string): string {
|
|
88
73
|
const parts = HOOK_FAILURE.exec(kept);
|
|
89
74
|
const hook = parts?.[1];
|
|
90
75
|
const code = parts?.[2];
|
|
91
76
|
if (hook === undefined || code === undefined) return kept;
|
|
92
|
-
if (code === "unexpected") return `${hook}: ${
|
|
93
|
-
return isKnownCode(code) ? `${hook}: ${describeCode(code)}` : kept;
|
|
77
|
+
if (code === "unexpected") return `${hook}: ${t("status.unexpected")}`;
|
|
78
|
+
return isKnownCode(code) ? `${hook}: ${describeCode(t, code)}` : kept;
|
|
94
79
|
}
|
|
95
80
|
|
|
96
81
|
/** The first thing that is the matter, in the order of the table, or null. */
|
|
97
|
-
function firstProblem(data: Diagnostics): string | null {
|
|
98
|
-
if (data.registry.persistence === "failing") return "
|
|
99
|
-
if (data.registry.stored === "unreadable") return "
|
|
100
|
-
if (data.outbox.persistence === "failing") return "
|
|
101
|
-
if (data.cardsOwed > 0) return
|
|
102
|
-
if (data.lastHookFailure !== null) return hookFailure(data.lastHookFailure);
|
|
82
|
+
function firstProblem(t: Translate, data: Diagnostics): string | null {
|
|
83
|
+
if (data.registry.persistence === "failing") return t("status.saveRequestsFailed");
|
|
84
|
+
if (data.registry.stored === "unreadable") return t("status.requestsUnreadable");
|
|
85
|
+
if (data.outbox.persistence === "failing") return t("status.saveMessagesFailed");
|
|
86
|
+
if (data.cardsOwed > 0) return t("status.cardsOwed", { cards: data.cardsOwed });
|
|
87
|
+
if (data.lastHookFailure !== null) return hookFailure(t, data.lastHookFailure);
|
|
103
88
|
return null;
|
|
104
89
|
}
|
|
105
90
|
|
|
106
|
-
function problemsRow(data: Diagnostics): StatusRow {
|
|
107
|
-
const problem = firstProblem(data);
|
|
108
|
-
return problem === null ? ok("
|
|
91
|
+
function problemsRow(t: Translate, data: Diagnostics): StatusRow {
|
|
92
|
+
const problem = firstProblem(t, data);
|
|
93
|
+
return problem === null ? ok("status.errors", t("status.none")) : bad("status.errors", t("status.some"), problem);
|
|
109
94
|
}
|
|
110
95
|
|
|
111
96
|
/**
|
|
112
|
-
* The four lines of the
|
|
97
|
+
* The four lines of the «Status» section, from what the plugin says of itself. Read-only: nothing here changes anything. Not
|
|
113
98
|
* every number of the contract has a line: the counts of entries left out of the stored requests and of the outbox
|
|
114
99
|
* (`registry.dropped`, `outbox.unsaved`, `outbox.dropped`) are kept in the contract and are not shown.
|
|
115
100
|
*/
|
|
116
|
-
export function statusRows(data: Diagnostics): StatusRow[] {
|
|
117
|
-
return [pluginRow(data), filesRow(data), waitingRow(data), problemsRow(data)];
|
|
101
|
+
export function statusRows(t: Translate, data: Diagnostics): StatusRow[] {
|
|
102
|
+
return [pluginRow(t, data), filesRow(t, data), waitingRow(t, data), problemsRow(t, data)];
|
|
118
103
|
}
|
|
119
104
|
|
|
120
105
|
/**
|
package/client/dialog-state.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface DialogState {
|
|
|
13
13
|
/** The request is closed: «→» is disabled for as long as the form is open, and what was typed stays. */
|
|
14
14
|
closed: boolean;
|
|
15
15
|
/** The one line at the top of the form, or none. */
|
|
16
|
-
top:
|
|
16
|
+
top: Next["top"];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/** A form that has just been opened: nothing read yet. */
|
package/client/dialog.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PluginHostProps } from "@getpaseo/plugin/client";
|
|
2
|
-
import { useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { useRpc, useTranslation } from "@getpaseo/plugin/client";
|
|
3
3
|
import { Icon, Modal } from "@getpaseo/plugin/client/ui";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { Text, View } from "react-native";
|
|
@@ -12,7 +12,8 @@ import { takeFile, wipeFile, type FileValue } from "./file-entry";
|
|
|
12
12
|
import { ANNOUNCED, FileRow, IconButton, MONO, RowLine, TextRow } from "./fields";
|
|
13
13
|
import { addRow, checkForm, clearFile, fillFile, formFromView, removeRow, setName, setText, toFileRow, wipeForm, type FormState } from "./form-state";
|
|
14
14
|
import { afterDecline, afterLostReply } from "./outcome";
|
|
15
|
-
import {
|
|
15
|
+
import { messages } from "./messages";
|
|
16
|
+
import { FORM_BADGE, dialogScreen, formTitle } from "./presentation";
|
|
16
17
|
import { sealEntries } from "./sealing";
|
|
17
18
|
import { submitEntries, type SubmitDeps, type SubmitOutcome } from "./submit";
|
|
18
19
|
import { tone } from "./tone";
|
|
@@ -50,6 +51,7 @@ function useHeld<T>(initial: () => T): [T, { readonly current: T }, (next: T) =>
|
|
|
50
51
|
* human, by an answer, or unmounted with its row by the chat's list), it takes no file's bytes along: they are wiped.
|
|
51
52
|
*/
|
|
52
53
|
export function RequestDialog({ requestId, session, onClose, theme, layout }: DialogProps) {
|
|
54
|
+
const { t } = useTranslation(messages);
|
|
53
55
|
const colors = tone(theme.colors);
|
|
54
56
|
const get = useRpc(getRequest);
|
|
55
57
|
const fulfill = useRpc(fulfillRequest);
|
|
@@ -147,7 +149,7 @@ export function RequestDialog({ requestId, session, onClose, theme, layout }: Di
|
|
|
147
149
|
const deps: SubmitDeps = { get, fulfill, seal: sealEntries };
|
|
148
150
|
|
|
149
151
|
function pressArrow() {
|
|
150
|
-
const { entries } = checkForm(formRef.current);
|
|
152
|
+
const { entries } = checkForm(t, formRef.current);
|
|
151
153
|
const action = arrowAction(stateRef.current, entries !== null);
|
|
152
154
|
if (action === "read") {
|
|
153
155
|
void run("arrow", async () => {
|
|
@@ -198,14 +200,14 @@ export function RequestDialog({ requestId, session, onClose, theme, layout }: Di
|
|
|
198
200
|
// A file dropped on the form but not on a file row is taken by nothing, and goes nowhere else either.
|
|
199
201
|
useFileDrop(body, wipeFile);
|
|
200
202
|
|
|
201
|
-
const checked = useMemo(() => checkForm(form), [form]);
|
|
203
|
+
const checked = useMemo(() => checkForm(t, form), [t, form]);
|
|
202
204
|
const labels = useMemo(() => new Map((state.view?.fields ?? []).map((field) => [field.key, field.label] as const)), [state.view]);
|
|
203
205
|
const screen = dialogScreen(state);
|
|
204
206
|
const locked = busy !== null;
|
|
205
207
|
const arrowReady = busy === null && arrowAction(state, checked.entries !== null) !== null;
|
|
206
208
|
|
|
207
209
|
return (
|
|
208
|
-
<Modal title={formTitle(form.rows.length)} icon={<Icon name="ShieldCheck" size={18} color={colors.accent} />} open onOpenChange={(open) => (open ? undefined : close())}>
|
|
210
|
+
<Modal title={formTitle(t, form.rows.length)} icon={<Icon name="ShieldCheck" size={18} color={colors.accent} />} open onOpenChange={(open) => (open ? undefined : close())}>
|
|
209
211
|
{/* The host's own scrolling body: the sheet on a phone, with its swipe down and its keyboard handling, and on the desktop a box no taller than the form. */}
|
|
210
212
|
<Modal.Content contentContainerStyle={{ padding: layout.compact ? 16 : 20, gap: 0 }}>
|
|
211
213
|
<View ref={body} style={{ gap: 8 }}>
|
|
@@ -214,14 +216,14 @@ export function RequestDialog({ requestId, session, onClose, theme, layout }: Di
|
|
|
214
216
|
<Text style={{ color: colors.accent, fontFamily: MONO, fontSize: 11 }}>{FORM_BADGE}</Text>
|
|
215
217
|
</View>
|
|
216
218
|
<View style={{ flex: 1 }} />
|
|
217
|
-
<IconButton icon="X" label={
|
|
219
|
+
<IconButton icon="X" label={t("a11y.decline")} color={colors.muted} disabled={locked} onPress={pressDecline} />
|
|
218
220
|
</View>
|
|
219
221
|
|
|
220
222
|
{state.top === null ? null : (
|
|
221
223
|
<View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
|
|
222
224
|
<Icon name="CircleAlert" size={14} color={colors.danger} />
|
|
223
225
|
<Text {...ANNOUNCED} style={{ color: colors.danger, fontSize: 12, flexShrink: 1 }}>
|
|
224
|
-
{state.top}
|
|
226
|
+
{t(state.top)}
|
|
225
227
|
</Text>
|
|
226
228
|
</View>
|
|
227
229
|
)}
|
|
@@ -266,7 +268,7 @@ export function RequestDialog({ requestId, session, onClose, theme, layout }: Di
|
|
|
266
268
|
{screen === "form" ? (
|
|
267
269
|
<IconButton
|
|
268
270
|
icon="Plus"
|
|
269
|
-
label={
|
|
271
|
+
label={t("a11y.add")}
|
|
270
272
|
color={colors.muted}
|
|
271
273
|
fill={colors.raised}
|
|
272
274
|
disabled={locked || form.rows.length >= LIMITS.fields}
|
|
@@ -276,7 +278,7 @@ export function RequestDialog({ requestId, session, onClose, theme, layout }: Di
|
|
|
276
278
|
<View style={{ flex: 1, alignItems: "center" }}>{screen === "form" && checked.total !== null ? <RowLine text={checked.total} colors={colors} /> : null}</View>
|
|
277
279
|
<IconButton
|
|
278
280
|
icon="ArrowRight"
|
|
279
|
-
label={
|
|
281
|
+
label={t("a11y.submit")}
|
|
280
282
|
color={colors.onAccent}
|
|
281
283
|
fill={colors.accent}
|
|
282
284
|
busy={busy === "arrow"}
|
package/client/fields.tsx
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { useTranslation } from "@getpaseo/plugin/client";
|
|
1
2
|
import { Icon, TextInput } from "@getpaseo/plugin/client/ui";
|
|
2
3
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
4
|
import { ActivityIndicator, Platform, Pressable, Text, View } from "react-native";
|
|
4
5
|
import { checkedFile, fileLine, fromPasted, takeFile, type FileValue } from "./file-entry";
|
|
5
6
|
import type { FormRow } from "./form-state";
|
|
6
|
-
import {
|
|
7
|
+
import { messages, type Translate } from "./messages";
|
|
8
|
+
import { KEY_PLACEHOLDER, eye } from "./presentation";
|
|
7
9
|
import type { Tone } from "./tone";
|
|
8
10
|
import { canPickFiles, pickFile, useFileDrop } from "./web";
|
|
9
11
|
|
|
@@ -52,7 +54,7 @@ interface IconButtonProps {
|
|
|
52
54
|
busy?: boolean;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
/** A control with an icon and no words: what it does is its accessibility label, in
|
|
57
|
+
/** A control with an icon and no words: what it does is its accessibility label, in the app's language, and the field it is for its hint. */
|
|
56
58
|
export function IconButton({ icon, label, hint, color, onPress, disabled = false, fill, busy = false }: IconButtonProps) {
|
|
57
59
|
return (
|
|
58
60
|
<Pressable
|
|
@@ -96,12 +98,12 @@ function KeyText({ row, colors }: { row: FormRow; colors: Tone }) {
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
/** The name of a key the human adds. A name is not a secret, so it is shown as typed; a screen reader is told what it is. */
|
|
99
|
-
function NameInput({ row, colors, locked, onName }: { row: FormRow; colors: Tone; locked: boolean; onName(key: string): void }) {
|
|
101
|
+
function NameInput({ t, row, colors, locked, onName }: { t: Translate; row: FormRow; colors: Tone; locked: boolean; onName(key: string): void }) {
|
|
100
102
|
return (
|
|
101
103
|
<TextInput
|
|
102
104
|
value={row.key}
|
|
103
105
|
onChangeText={onName}
|
|
104
|
-
accessibilityLabel={
|
|
106
|
+
accessibilityLabel={t("a11y.name")}
|
|
105
107
|
placeholder={KEY_PLACEHOLDER}
|
|
106
108
|
placeholderTextColor={colors.muted}
|
|
107
109
|
editable={!locked}
|
|
@@ -137,13 +139,14 @@ interface TextRowProps extends RowProps {
|
|
|
137
139
|
* of the row takes a press, the eye included.
|
|
138
140
|
*/
|
|
139
141
|
export function TextRow({ row, hint, error, colors, locked, onText, onName, onToFile, onRemove }: TextRowProps) {
|
|
142
|
+
const { t } = useTranslation(messages);
|
|
140
143
|
const [shown, setShown] = useState(false);
|
|
141
|
-
const look = eye(shown);
|
|
144
|
+
const look = eye(t, shown);
|
|
142
145
|
const text = row.value.kind === "text" ? row.value.text : "";
|
|
143
146
|
return (
|
|
144
147
|
<View style={{ gap: 4, opacity: locked ? 0.5 : 1 }}>
|
|
145
148
|
<View style={boxStyle(colors, error !== null)}>
|
|
146
|
-
{row.declared ? <KeyText row={row} colors={colors} /> : <NameInput row={row} colors={colors} locked={locked} onName={onName} />}
|
|
149
|
+
{row.declared ? <KeyText row={row} colors={colors} /> : <NameInput t={t} row={row} colors={colors} locked={locked} onName={onName} />}
|
|
147
150
|
<TextInput
|
|
148
151
|
value={text}
|
|
149
152
|
onChangeText={onText}
|
|
@@ -157,8 +160,8 @@ export function TextRow({ row, hint, error, colors, locked, onText, onName, onTo
|
|
|
157
160
|
<IconButton icon={look.icon} label={look.label} color={colors.muted} disabled={locked} onPress={() => setShown((current) => !current)} />
|
|
158
161
|
{row.declared ? null : (
|
|
159
162
|
<>
|
|
160
|
-
<IconButton icon="Paperclip" label={
|
|
161
|
-
<IconButton icon="X" label={
|
|
163
|
+
<IconButton icon="Paperclip" label={t("a11y.pick")} color={colors.muted} disabled={locked} onPress={onToFile} />
|
|
164
|
+
<IconButton icon="X" label={t("a11y.remove")} color={colors.muted} disabled={locked} onPress={onRemove} />
|
|
162
165
|
</>
|
|
163
166
|
)}
|
|
164
167
|
</View>
|
|
@@ -180,6 +183,7 @@ interface FileRowProps extends RowProps {
|
|
|
180
183
|
* loses focus its text becomes the file and the area closes. The agent's label is the hint of each of its controls.
|
|
181
184
|
*/
|
|
182
185
|
export function FileRow({ row, hint, error, colors, locked, onName, onFile, onClearFile, onRemove }: FileRowProps) {
|
|
186
|
+
const { t } = useTranslation(messages);
|
|
183
187
|
const box = useRef<View>(null);
|
|
184
188
|
const alive = useRef(true);
|
|
185
189
|
useEffect(() => {
|
|
@@ -191,7 +195,7 @@ export function FileRow({ row, hint, error, colors, locked, onName, onFile, onCl
|
|
|
191
195
|
const [pasting, setPasting] = useState(false);
|
|
192
196
|
const [pasted, setPasted] = useState("");
|
|
193
197
|
const file = row.value.kind === "file" ? row.value.file : null;
|
|
194
|
-
const line = useMemo(() => (file === null ? null : fileLine(file, row.format, checkedFile(file, row.format))), [file, row.format]);
|
|
198
|
+
const line = useMemo(() => (file === null ? null : fileLine(t, file, row.format, checkedFile(file, row.format))), [t, file, row.format]);
|
|
195
199
|
|
|
196
200
|
// A file is handed on only while the row is unlocked and mounted, and wiped otherwise (`takeFile`).
|
|
197
201
|
const take = (value: FileValue) =>
|
|
@@ -217,30 +221,30 @@ export function FileRow({ row, hint, error, colors, locked, onName, onFile, onCl
|
|
|
217
221
|
return (
|
|
218
222
|
<View style={{ gap: 4, opacity: locked ? 0.5 : 1 }}>
|
|
219
223
|
<View ref={box} style={boxStyle(colors, error !== null, file === null)}>
|
|
220
|
-
{row.declared ? <KeyText row={row} colors={colors} /> : <NameInput row={row} colors={colors} locked={locked} onName={onName} />}
|
|
224
|
+
{row.declared ? <KeyText row={row} colors={colors} /> : <NameInput t={t} row={row} colors={colors} locked={locked} onName={onName} />}
|
|
221
225
|
{row.format === "any" ? null : <Text style={{ color: colors.muted, opacity: 0.7, fontFamily: MONO, fontSize: 11 }}>{row.format}</Text>}
|
|
222
226
|
{line === null ? (
|
|
223
227
|
<>
|
|
224
228
|
<View style={{ flex: 1 }} />
|
|
225
|
-
{canPickFiles ? <IconButton icon="Paperclip" label={
|
|
226
|
-
<IconButton icon="ClipboardPaste" label={
|
|
229
|
+
{canPickFiles ? <IconButton icon="Paperclip" label={t("a11y.pick")} hint={hint} color={colors.muted} disabled={locked} onPress={pick} /> : null}
|
|
230
|
+
<IconButton icon="ClipboardPaste" label={t("a11y.paste")} hint={hint} color={colors.muted} disabled={locked} onPress={() => setPasting(true)} />
|
|
227
231
|
</>
|
|
228
232
|
) : (
|
|
229
233
|
<>
|
|
230
234
|
<Text numberOfLines={1} style={{ flex: 1, color: colors.text, fontSize: 12 }}>
|
|
231
235
|
{line}
|
|
232
236
|
</Text>
|
|
233
|
-
<IconButton icon="X" label={
|
|
237
|
+
<IconButton icon="X" label={t("a11y.removeFile")} hint={hint} color={colors.muted} disabled={locked} onPress={onClearFile} />
|
|
234
238
|
</>
|
|
235
239
|
)}
|
|
236
|
-
{row.declared ? null : <IconButton icon="X" label={
|
|
240
|
+
{row.declared ? null : <IconButton icon="X" label={t("a11y.remove")} color={colors.muted} disabled={locked} onPress={onRemove} />}
|
|
237
241
|
</View>
|
|
238
242
|
{pasting ? (
|
|
239
243
|
<TextInput
|
|
240
244
|
value={pasted}
|
|
241
245
|
onChangeText={setPasted}
|
|
242
246
|
onBlur={endPaste}
|
|
243
|
-
accessibilityLabel={
|
|
247
|
+
accessibilityLabel={t("a11y.pasteArea")}
|
|
244
248
|
accessibilityHint={hint === "" ? undefined : hint}
|
|
245
249
|
multiline
|
|
246
250
|
autoFocus
|