Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pm-stack/console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ late.

### Phones

The Android app's home-screen widget reads a short summary (three counts
The Android app's home-screen widget reads a short summary (four counts
and the top line of each list) with a token of its own, since it cannot
use the browser's sign-in. Linking passes no secret through an address:
the phone shows the signed-in owner a hash, the owner approves it under
Expand Down
6 changes: 3 additions & 3 deletions pm-stack/console/android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Around the site, the app uses what only an installed app has:

| What | How it is used | Code |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
| Home-screen widget | In progress, queued next, needs me, and the task being worked on. Each number opens its screen | `StatusWidget`, `Fleet` |
| Home-screen widget | In progress, queued next, needs me, unread instructions, and the task being worked on. Each number opens its screen | `StatusWidget`, `Fleet` |
| Dictation | Long-press the icon and choose Dictate, or tap the "Ask the fleet" quick-settings tile: the words land in the Ask box | `DictateActivity`, `AskTileService` |
| Share and selection | Share text from any app, or select text and choose "Ask the fleet": it lands in the Ask box | `ShareActivity` |
| Long-press shortcuts | Dictate, Ask, Needs me, Now. They move the open app to that screen and do not reload it | `OpenActivity`, `res/xml/shortcuts` |
| Share and selection | Share text from any app, or select text and choose "Ask the fleet": it lands in the Ask box. An enroll command lands in provisioning on the Agents screen instead | `ShareActivity`, `Links` |
| Long-press shortcuts | Dictate, Ask, Needs me, Now, Messages. They move the open app to that screen and do not reload it | `OpenActivity`, `res/xml/shortcuts` |
| Notifications | The site's notifications arrive as the app's own, with its mark in the status bar; the app asks for the permission itself | the helper library's activities |
| Links | `https://pm.security.cab/...` links open in the app | the launcher activity's intent filter |

Expand Down
10 changes: 7 additions & 3 deletions pm-stack/console/android/app/src/twa/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<meta-data
android:name="android.support.customtabs.trusted.NAVIGATION_BAR_COLOR"
android:resource="@color/bar" />
<!-- Long-press the icon: Dictate, Ask, Needs me, Now. -->
<!-- Long-press the icon: Dictate, Ask, Needs me, Now, Messages. -->
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
Expand Down Expand Up @@ -74,11 +74,14 @@
<action android:name="today.developing.pmconsole.OPEN_NEEDS" />
<action android:name="today.developing.pmconsole.OPEN_NOW" />
<action android:name="today.developing.pmconsole.OPEN_NEXT" />
<action android:name="today.developing.pmconsole.OPEN_MESSAGES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<!-- Text shared from another app, or selected anywhere, lands in the Ask box. -->
<!-- Text shared from another app, or selected anywhere, lands in the
Ask box — unless it is an enroll command, which lands in
provisioning on the Agents screen. -->
<activity
android:name=".ShareActivity"
android:excludeFromRecents="true"
Expand Down Expand Up @@ -129,7 +132,8 @@
</intent-filter>
</activity>

<!-- The home-screen widget: in progress, queued, needs me, and the task being worked on. -->
<!-- The home-screen widget: in progress, queued, needs me, unread
instructions, and the task being worked on. -->
<receiver
android:name=".StatusWidget"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,34 @@ static Intent ask(Context context, CharSequence words) {
}
return open(context, "ask/say=" + Uri.encode(text));
}

/**
* Whether shared text is an enroll command (#14377): a
* `fleet agent enroll … --bootstrap <token>` line, as the
* console's provisioning form shows it. The token is opaque — it
* has no shape of its own — so a command is known by its words:
* it must name the enroll step and carry a bootstrap token. The
* console reads the binding out of it the same way.
*/
static boolean enrollCommand(CharSequence text) {
if (text == null) {
return false;
}
String shared = text.toString();
return shared.contains("enroll") && shared.contains("--bootstrap");
}

/**
* Open provisioning on the Agents screen with an enroll command
* that was shared to the phone. The command travels after the
* "#" like words for the Ask box do: it stays on the phone, and
* the console shows it there once, as it shows a mint.
*/
static Intent provision(Context context, CharSequence words) {
String text = words.toString().trim();
if (text.length() > MAX_TEXT) {
text = text.substring(0, MAX_TEXT);
}
return open(context, "more/agents/enroll=" + Uri.encode(text));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ protected void onCreate(Bundle savedInstanceState) {
finish();
}

/** The screen an action names; anything unknown opens Now. */
/** The screen an action names; anything unknown opens Now.
* Messages is the console's `#more/messages` (#14377): the name
* the shortcut carries is not the route, so it is translated. */
static String screen(String action) {
if (action != null && action.startsWith(PREFIX)) {
String name = action.substring(PREFIX.length()).toLowerCase(Locale.ROOT);
if (name.equals("ask") || name.equals("needs") || name.equals("next")) {
return name;
}
if (name.equals("messages")) {
return "more/messages";
}
}
return "now";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
/**
* Receives text from anywhere on the phone: "Share" in another app, or
* "Ask the fleet" in the menu that appears when text is selected. The
* text lands in the Ask box, ready to edit and send.
* text lands in the Ask box, ready to edit and send — unless it is an
* enroll command, which lands in provisioning on the Agents screen
* instead (#14377): a bootstrap token pasted into an Ask would file
* it as a task and leave the new agent unenrolled.
*/
public class ShareActivity extends Activity {
@Override
Expand All @@ -25,7 +28,7 @@ protected void onCreate(Bundle savedInstanceState) {
text = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
}
if (text != null && text.toString().trim().length() > 0) {
startActivity(Links.ask(this, text));
startActivity(Links.enrollCommand(text) ? Links.provision(this, text) : Links.ask(this, text));
} else {
startActivity(Links.open(this, "ask"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

/**
* The home-screen widget: how many tasks are in progress, how many are
* queued, how many things need the owner, and what is being worked on
* now. Each number opens its screen; the microphone starts dictation.
* queued, how many things need the owner, how many instructions are
* unread, and what is being worked on now. Each number opens its
* screen; the microphone starts dictation.
*
* <p>It is drawn from the last summary read, then the summary is read
* again: every half hour, whenever the app is opened, and on a tap of
Expand Down Expand Up @@ -115,11 +116,13 @@ static void draw(Context context) {
views.setTextViewText(R.id.widget_now_n, count(summary, "now", "count"));
views.setTextViewText(R.id.widget_next_n, count(summary, "next", "count"));
views.setTextViewText(R.id.widget_needs_n, count(summary, "needs", "total"));
views.setTextViewText(R.id.widget_messages_n, count(summary, "messages", "unreadInstructions"));
views.setTextViewText(R.id.widget_line, line(context, summary));
views.setTextViewText(R.id.widget_asof, asOf(context, summary));
views.setOnClickPendingIntent(R.id.widget_now, PendingIntent.getActivity(context, 1, Links.open(context, "now"), flags));
views.setOnClickPendingIntent(R.id.widget_next, PendingIntent.getActivity(context, 2, Links.open(context, "next"), flags));
views.setOnClickPendingIntent(R.id.widget_needs, PendingIntent.getActivity(context, 3, Links.open(context, "needs"), flags));
views.setOnClickPendingIntent(R.id.widget_messages, PendingIntent.getActivity(context, 8, Links.open(context, "more/messages"), flags));
views.setOnClickPendingIntent(R.id.widget_root, PendingIntent.getActivity(context, 4, Links.open(context, "now"), flags));
} else {
views.setViewVisibility(R.id.widget_counts, View.GONE);
Expand Down
14 changes: 14 additions & 0 deletions pm-stack/console/android/app/src/twa/res/drawable/ic_messages.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#00000000"
android:pathData="M4,6h16a1,1 0,0 1,1 1v10a1,1 0,0 1,-1 1H4a1,1 0,0 1,-1 -1V7a1,1 0,0 1,1 -1zM3,7l9,6 9,-6"
android:strokeColor="#FFFFFFFF"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:strokeWidth="2" />
</vector>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- The home-screen widget: three numbers, each opening its screen, and
<!-- The home-screen widget: four numbers, each opening its screen, and
the task being worked on now. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_root"
Expand Down Expand Up @@ -130,6 +130,29 @@
android:textColor="@color/widget_dim"
android:textSize="12sp" />
</LinearLayout>

<LinearLayout
android:id="@+id/widget_messages"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:id="@+id/widget_messages_n"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/widget_text"
android:textSize="24sp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sc_messages"
android:textColor="@color/widget_dim"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>

<TextView
Expand Down
4 changes: 3 additions & 1 deletion pm-stack/console/android/app/src/twa/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
<string name="sc_needs_long">What needs me</string>
<string name="sc_now">Now</string>
<string name="sc_now_long">What is in progress</string>
<string name="sc_messages">Messages</string>
<string name="sc_messages_long">The fleet\'s messages</string>
<string name="widget_title">PM</string>
<string name="widget_label">PM status</string>
<string name="widget_description">In progress, queued next and what needs you, with the task being worked on now.</string>
<string name="widget_description">In progress, queued next, what needs you and how many instructions are unread, with the task being worked on now.</string>
<string name="widget_next">Next</string>
<string name="widget_refresh">Read again</string>
<string name="widget_unlinked">Tap to link this phone, so the counts can show here.</string>
Expand Down
11 changes: 11 additions & 0 deletions pm-stack/console/android/app/src/twa/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,15 @@
android:targetClass="today.developing.pmconsole.OpenActivity"
android:targetPackage="today.developing.pmconsole" />
</shortcut>
<shortcut
android:enabled="true"
android:icon="@drawable/ic_messages"
android:shortcutId="messages"
android:shortcutLongLabel="@string/sc_messages_long"
android:shortcutShortLabel="@string/sc_messages">
<intent
android:action="today.developing.pmconsole.OPEN_MESSAGES"
android:targetClass="today.developing.pmconsole.OpenActivity"
android:targetPackage="today.developing.pmconsole" />
</shortcut>
</shortcuts>
8 changes: 6 additions & 2 deletions pm-stack/console/edge/src/direct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ import { memoryShelf, type Shelf, Trends } from "../../src/trends.ts";
/** Sections the edge reads itself. `agents` is read through the
* bridge, so it is only the edge's while it holds the PM bridge
* credential (edge.ts `owned` says which of these are its, case by
* case); the rest are GitHub's and the queue store's. */
export const DIRECT_READ_SECTIONS = ["board", "prs", "priorities", "asks", "census", "done", "agents"] as const;
* case); the pipeline's unread-instruction count is the bridge's
* the same way (#14377); the rest are GitHub's and the queue store's. */
export const DIRECT_READ_SECTIONS = ["board", "prs", "priorities", "asks", "census", "done", "agents", "pipeline"] as const;
/** Actions the edge runs itself: each is one or a few calls to GitHub
* or the queue store, and needs nothing a machine has. */
export const DIRECT_ACTIONS = [
Expand Down Expand Up @@ -84,6 +85,7 @@ export const READ_FROM: Record<(typeof DIRECT_READ_SECTIONS)[number], Outward["t
census: ["github"],
done: ["queue", "github"],
agents: ["bridge"],
pipeline: ["bridge"],
};

export interface DirectSecrets {
Expand Down Expand Up @@ -1023,6 +1025,8 @@ export async function directRead(section: string, ops: Ops, work: Work): Promise
return work.done();
case "agents":
return ops.agents();
case "pipeline":
return ops.unreadInstructions();
default:
throw new Error(`not a section the edge reads itself: ${section}`);
}
Expand Down
10 changes: 7 additions & 3 deletions pm-stack/console/edge/src/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const SECTIONS: Record<string, number> = {
priorities: 180_000,
done: 120_000,
agents: 75_000,
pipeline: 75_000,
services: 45_000,
more: 2 * 60 * 60_000,
};
Expand Down Expand Up @@ -1549,7 +1550,9 @@ export class Edge {
// The agents list is the bridge's: read here only while this
// side holds the PM bridge credential (#14373). Without it a
// machine goes on reporting the list, as it did before.
(name !== "agents" || this.bridgeReady()),
(name !== "agents" || this.bridgeReady()) &&
// The pipeline count is the bridge's the same way (#14377).
(name !== "pipeline" || this.bridgeReady()),
);
}

Expand Down Expand Up @@ -1749,11 +1752,12 @@ export class Edge {
for (const name of DIRECT_READ_SECTIONS) {
// The agents section is the bridge's: with no PM bridge
// credential held there is no path here to prove, and the
// section is a machine's, as it was before (#14373). Every
// section is a machine's, as it was before (#14373). The
// pipeline count is the bridge's the same way (#14377). Every
// other section is checked even while it is a machine's for
// being refused: the check is how this side finds it can read
// the section itself again.
if (name === "agents" && !this.bridgeReady()) continue;
if ((name === "agents" || name === "pipeline") && !this.bridgeReady()) continue;
try {
await directRead(name, direct.ops, direct.work);
kinds[name] = { ok: true };
Expand Down
Loading