The activity sheet as the reference lays it out; Subagents by name
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
- ActivityContent(activity, …, actions): the sheet drawn from its facts, for the shots.
Context with "N until auto-compact" and Compact; Background tasks as cards (running
with elapsed and a stop square, nested "N under it", Finished folded); Room; Plan.
- A bottom sheet from a top-bar button on every chat, a new one included.
- The strip above the composer: running · queued · waiting · finished, while anything runs.
- Compact through POST /api/v2/chats/{id}/compact (provisional until the server's route).
- "Subagents" wherever a person reads it; 13 new strings in 8 languages.
- Shots 14-16 (activity, unfolded, new chat); ActivityTest for auto-compact and titles.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
21 files changed
+784
-262
No files matched your search
@@ -44,16 +44,46 @@ object ActivityLogic {
|
||||
}
|
||||
|
||||
/**
|
||||
* What the strip above the composer says, as counts in order: agents working, queued,
|
||||
* waiting. Empty when nothing is going -- then there is no strip.
|
||||
* What the strip above the composer says, as counts in order: running, queued, waiting,
|
||||
* then finished. Empty when nothing is going -- then there is no strip, whatever finished.
|
||||
*/
|
||||
fun stripCounts(summary: ActivitySummary): List<Pair<String, Int>> =
|
||||
listOf("working" to summary.working, "queued" to summary.queued, "waiting" to summary.waiting).filter { it.second > 0 }
|
||||
fun stripCounts(summary: ActivitySummary): List<Pair<String, Int>> {
|
||||
if (summary.working + summary.queued + summary.waiting == 0) return emptyList()
|
||||
return listOf(
|
||||
"working" to summary.working,
|
||||
"queued" to summary.queued,
|
||||
"waiting" to summary.waiting,
|
||||
"finished" to summary.finished,
|
||||
).filter { it.second > 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* How many tokens are left before the chat compacts itself: the window's [ContextUse.threshold]
|
||||
* per cent, less what is used. Null when it never will -- the threshold is 0 (off) or 100,
|
||||
* or the window is unknown -- since a count against an unknown window is a guess.
|
||||
*/
|
||||
fun untilAutoCompact(context: ContextUse): Int? {
|
||||
if (context.limit <= 0 || context.threshold !in 1..99) return null
|
||||
return (context.limit.toLong() * context.threshold / 100 - context.used).toInt().coerceAtLeast(0)
|
||||
}
|
||||
|
||||
/**
|
||||
* What a task is called in its row: a team's member by its name, a subagent or a command
|
||||
* by what it was asked to do (its role, else its brief), its id only when it has neither.
|
||||
*/
|
||||
fun title(agent: ActivityAgent): String = if (agent.kind == "member") {
|
||||
agent.name
|
||||
} else {
|
||||
agent.role.ifBlank { agent.brief }.ifBlank { agent.name }
|
||||
}
|
||||
|
||||
/** Every task under [agent], however deep. */
|
||||
fun descendants(agent: ActivityAgent): Int = agent.children.sumOf { 1 + descendants(it) }
|
||||
|
||||
/** The top level split as the panel shows it: those still going, then the ended ones. */
|
||||
fun split(agents: List<ActivityAgent>): Pair<List<ActivityAgent>, List<ActivityAgent>> = agents.partition { it.isActive }
|
||||
|
||||
/** Every agent of a forest with its helpers under it, in tree order, for drawing as rows. */
|
||||
/** Every agent of a forest with its subagents under it, in tree order, for drawing as rows. */
|
||||
fun flatten(agents: List<ActivityAgent>): List<ActivityAgent> = agents.flatMap { listOf(it) + flatten(it.children) }
|
||||
|
||||
/**
|
||||
|
||||
@@ -248,6 +248,13 @@ class ApiClient(val base: String, private val token: String, val http: OkHttpCli
|
||||
suspend fun stopAgent(chatId: String, kind: String, id: String): List<String> =
|
||||
send<Stopped>("POST", "/chats/$chatId/agents/${segment(kind)}/${segment(id)}/stop", null).stopped
|
||||
|
||||
/**
|
||||
* Summarise the earlier turns now and stop sending them (the activity sheet's Compact). The
|
||||
* server refuses in its own words (409) while a reply is being written or with nothing to
|
||||
* summarise; the transcript is read again after, for the divider it leaves.
|
||||
*/
|
||||
suspend fun compact(chatId: String) = empty(authed("$v2/chats/$chatId/compact").post(ByteArray(0).toRequestBody(null)).build())
|
||||
|
||||
suspend fun team(chatId: String, since: Int = 0): TeamView = get<TeamEnvelope>("/chats/$chatId/team?since=$since").team
|
||||
|
||||
suspend fun stopMember(chatId: String, name: String): List<String> = send<Stopped>("POST", "/chats/$chatId/team/${segment(name)}/stop", null).stopped
|
||||
|
||||
@@ -521,7 +521,7 @@ data class AgentStep(val tool: String = "", val label: String = "", val title: S
|
||||
|
||||
/**
|
||||
* One background agent: a team's member (`kind` member, [id] its name) or a job (`kind` job;
|
||||
* [type] `subagent` or `command`), with its own helpers in [children]. [role], [brief] and
|
||||
* [type] `subagent` or `command`), with its own subagents in [children]. [role], [brief] and
|
||||
* [text] are a model's words: shown as text, never as anything richer.
|
||||
*/
|
||||
@Serializable
|
||||
|
||||
Reference in new issue
Block a user