agentix-cli 0.181.1 → 0.182.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/README.md +2 -2
- package/apps/mac-voice/Sources/AgentXVoice/Config.swift +9 -0
- package/apps/mac-voice/Sources/AgentXVoice/MiniOrbs.swift +19 -6
- package/apps/mac-voice/Sources/AgentXVoice/OpenRequests.swift +260 -0
- package/apps/mac-voice/Sources/AgentXVoice/Panel.swift +72 -5
- package/apps/mac-voice/Sources/AgentXVoice/PillBusy.swift +22 -4
- package/apps/mac-voice/Sources/AgentXVoice/PillPlacement.swift +24 -0
- package/apps/mac-voice/Sources/AgentXVoice/RequestsWindow.swift +401 -0
- package/apps/mac-voice/Sources/AgentXVoice/SettingsWindow.swift +1 -0
- package/apps/mac-voice/Sources/AgentXVoice/StatusMenu.swift +22 -1
- package/apps/mac-voice/Sources/AgentXVoice/main.swift +263 -4
- package/dist/{App-UXX5TGFF.js → App-XWSSUYKF.js} +2 -2
- package/dist/{ChatApp-X635NOAE.js → ChatApp-UT2BRHYE.js} +2 -2
- package/dist/{absorb-eval-4ZPDWNBA.js → absorb-eval-SFGUURBD.js} +2 -2
- package/dist/{adapter-Z23K544D.js → adapter-UHR7FVM7.js} +2 -2
- package/dist/{agent-OBRH5BJZ.js → agent-5NTFSCEO.js} +2 -2
- package/dist/{board-dashboard-SFXVOICJ.js → board-dashboard-7HIME2W4.js} +2090 -2248
- package/dist/board-dashboard-7HIME2W4.js.map +1 -0
- package/dist/{chunk-SDINSYTN.js → chunk-343MPMLD.js} +2 -2
- package/dist/{chunk-WKU7YFDV.js → chunk-4KNHLHE3.js} +2 -2
- package/dist/{chunk-WZUY7VGL.js → chunk-4WSJKKSA.js} +2 -2
- package/dist/{chunk-ZSY6PFHD.js → chunk-5NGQQOVK.js} +2 -2
- package/dist/{chunk-FRVFRWFN.js → chunk-5YG2ZQQW.js} +2 -2
- package/dist/{chunk-N6VBEITO.js → chunk-7PQQZC6B.js} +2 -2
- package/dist/{chunk-N6VBEITO.js.map → chunk-7PQQZC6B.js.map} +1 -1
- package/dist/{chunk-7RVJWLIP.js → chunk-7WGJZLVJ.js} +2 -2
- package/dist/{chunk-CF7CPE7K.js → chunk-BY3AUZYM.js} +2 -2
- package/dist/{chunk-IRZYRLXQ.js → chunk-FDX4IGLK.js} +2 -2
- package/dist/{chunk-SD6UDSXV.js → chunk-FYFJ7IQJ.js} +2 -2
- package/dist/{chunk-HBQRVCLU.js → chunk-GEFZMDDX.js} +2 -2
- package/dist/{chunk-TZ7GB7FI.js → chunk-H2KOXGDX.js} +2 -2
- package/dist/{chunk-UFUQQ5J5.js → chunk-IFHVAHQM.js} +2 -2
- package/dist/{chunk-LZY6YN2J.js → chunk-IGBW4VVM.js} +2 -2
- package/dist/{chunk-OYCMFCME.js → chunk-JNWXHOJE.js} +2 -2
- package/dist/{chunk-KOY3EOPH.js → chunk-MD2HCGSC.js} +36 -36
- package/dist/chunk-MD2HCGSC.js.map +1 -0
- package/dist/{chunk-PCWXHXTM.js → chunk-NIPMVM3G.js} +2 -2
- package/dist/{chunk-DOBTHQ32.js → chunk-NRUUT5TL.js} +2 -2
- package/dist/{chunk-Z2UDWVZZ.js → chunk-OKADR5QO.js} +4 -4
- package/dist/chunk-OKADR5QO.js.map +1 -0
- package/dist/{chunk-IYITREE5.js → chunk-QB6UPODO.js} +2 -2
- package/dist/{chunk-VK3M3TVL.js → chunk-QGNV2HA4.js} +3 -3
- package/dist/chunk-QGNV2HA4.js.map +1 -0
- package/dist/{chunk-KVAWRQBA.js → chunk-R3CDFSNF.js} +67 -67
- package/dist/chunk-R3CDFSNF.js.map +1 -0
- package/dist/{chunk-HMEFQL5P.js → chunk-RDWDDPBI.js} +4 -3
- package/dist/chunk-RDWDDPBI.js.map +1 -0
- package/dist/{chunk-QJXGJMHM.js → chunk-XHJ5SVO5.js} +234 -234
- package/dist/chunk-XHJ5SVO5.js.map +1 -0
- package/dist/chunk-XI2HH5NR.js +36 -0
- package/dist/chunk-XI2HH5NR.js.map +1 -0
- package/dist/{chunk-J56YGKUO.js → chunk-Y4TVCWWF.js} +2 -2
- package/dist/{chunk-33DLG4I2.js → chunk-Y5TBOMHY.js} +5 -5
- package/dist/{chunk-UHTIZCKU.js → chunk-YSPBVLTZ.js} +2 -2
- package/dist/{chunk-NI2XD6P3.js → chunk-YX4R2VGD.js} +2 -2
- package/dist/{chunk-U5S6IP7Z.js → chunk-Z4XVPGPZ.js} +3 -3
- package/dist/{chunk-DMCMV4UJ.js → chunk-ZRALOFEG.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-ILPJFCTF.js → client-SQMU25PS.js} +2 -2
- package/dist/{config-JVWOL233.js → config-56NBA4SF.js} +2 -2
- package/dist/{config-mutate-WYCHP6VK.js → config-mutate-PD4O3HZ7.js} +2 -2
- package/dist/config-mutator-ITL64FBW.js +2 -0
- package/dist/{contributions-XD66HYWE.js → contributions-DKTJ623L.js} +2 -2
- package/dist/{doctor-DYTYJQYC.js → doctor-OI6GJZR5.js} +2 -2
- package/dist/{follow-up-tool-HPET6LZW.js → follow-up-tool-DYSLS6ZI.js} +2 -2
- package/dist/{hub-L5FFJPS3.js → hub-4HDMTSR7.js} +2 -2
- package/dist/index.d.ts +317 -216
- package/dist/index.js +1 -1
- package/dist/processes-M7YPWX7H.js +2 -0
- package/dist/{program-24C3VBSD.js → program-4GDIWCDM.js} +259 -259
- package/dist/program-4GDIWCDM.js.map +1 -0
- package/dist/{promote-XI6W27JK.js → promote-3272TZNI.js} +2 -2
- package/dist/{query-MGG5QKNC.js → query-7XM6V4QG.js} +2 -2
- package/dist/{query-settings-CALZYYWD.js → query-settings-HHVBIIVQ.js} +2 -2
- package/dist/{registry-XJWSLJ4O.js → registry-QL3AM3UH.js} +2 -2
- package/dist/{request-planner-JCRGGJUO.js → request-planner-WNEDEA7X.js} +2 -2
- package/dist/{review-candidates-OEBEEAEZ.js → review-candidates-TGPDJMWJ.js} +2 -2
- package/dist/{routing-CGH54RYG.js → routing-ALXY25NE.js} +2 -2
- package/dist/schedule-tool-22UBZXCG.js +2 -0
- package/dist/{scheduler-2K5YEV2U.js → scheduler-5PHNW243.js} +2 -2
- package/dist/{seat-DEL5YUOS.js → seat-ZYVVEILY.js} +2 -2
- package/dist/{select-MRTWSI7U.js → select-6QLEV6AC.js} +2 -2
- package/dist/{set-enabled-XTDCFCZY.js → set-enabled-SYYTKJPC.js} +2 -2
- package/dist/{sprint-tool-N7WPDX5J.js → sprint-tool-PYVHPHR2.js} +2 -2
- package/dist/{tool-BQEJOTF3.js → tool-GIYOYXXM.js} +2 -2
- package/dist/{tool-NZTJZDSB.js → tool-TDOUM3BJ.js} +2 -2
- package/dist/{tool-KZHWJ7BC.js → tool-ZKZ4KYJT.js} +2 -2
- package/dist/{wiki-YERCKD3E.js → wiki-ZRGLGMII.js} +2 -2
- package/dist/wiki-enrich-CTID7JQW.js +2 -0
- package/package.json +1 -1
- package/dist/board-dashboard-SFXVOICJ.js.map +0 -1
- package/dist/chunk-G6ZRPC6E.js +0 -36
- package/dist/chunk-G6ZRPC6E.js.map +0 -1
- package/dist/chunk-HMEFQL5P.js.map +0 -1
- package/dist/chunk-KOY3EOPH.js.map +0 -1
- package/dist/chunk-KVAWRQBA.js.map +0 -1
- package/dist/chunk-QJXGJMHM.js.map +0 -1
- package/dist/chunk-VK3M3TVL.js.map +0 -1
- package/dist/chunk-Z2UDWVZZ.js.map +0 -1
- package/dist/config-mutator-DKNHE6VP.js +0 -2
- package/dist/processes-EWARF6ZW.js +0 -2
- package/dist/program-24C3VBSD.js.map +0 -1
- package/dist/schedule-tool-UM3CAPDX.js +0 -2
- package/dist/wiki-enrich-K54LGNU3.js +0 -2
- /package/dist/{App-UXX5TGFF.js.map → App-XWSSUYKF.js.map} +0 -0
- /package/dist/{ChatApp-X635NOAE.js.map → ChatApp-UT2BRHYE.js.map} +0 -0
- /package/dist/{absorb-eval-4ZPDWNBA.js.map → absorb-eval-SFGUURBD.js.map} +0 -0
- /package/dist/{adapter-Z23K544D.js.map → adapter-UHR7FVM7.js.map} +0 -0
- /package/dist/{agent-OBRH5BJZ.js.map → agent-5NTFSCEO.js.map} +0 -0
- /package/dist/{chunk-SDINSYTN.js.map → chunk-343MPMLD.js.map} +0 -0
- /package/dist/{chunk-WKU7YFDV.js.map → chunk-4KNHLHE3.js.map} +0 -0
- /package/dist/{chunk-WZUY7VGL.js.map → chunk-4WSJKKSA.js.map} +0 -0
- /package/dist/{chunk-ZSY6PFHD.js.map → chunk-5NGQQOVK.js.map} +0 -0
- /package/dist/{chunk-FRVFRWFN.js.map → chunk-5YG2ZQQW.js.map} +0 -0
- /package/dist/{chunk-7RVJWLIP.js.map → chunk-7WGJZLVJ.js.map} +0 -0
- /package/dist/{chunk-CF7CPE7K.js.map → chunk-BY3AUZYM.js.map} +0 -0
- /package/dist/{chunk-IRZYRLXQ.js.map → chunk-FDX4IGLK.js.map} +0 -0
- /package/dist/{chunk-SD6UDSXV.js.map → chunk-FYFJ7IQJ.js.map} +0 -0
- /package/dist/{chunk-HBQRVCLU.js.map → chunk-GEFZMDDX.js.map} +0 -0
- /package/dist/{chunk-TZ7GB7FI.js.map → chunk-H2KOXGDX.js.map} +0 -0
- /package/dist/{chunk-UFUQQ5J5.js.map → chunk-IFHVAHQM.js.map} +0 -0
- /package/dist/{chunk-LZY6YN2J.js.map → chunk-IGBW4VVM.js.map} +0 -0
- /package/dist/{chunk-OYCMFCME.js.map → chunk-JNWXHOJE.js.map} +0 -0
- /package/dist/{chunk-PCWXHXTM.js.map → chunk-NIPMVM3G.js.map} +0 -0
- /package/dist/{chunk-DOBTHQ32.js.map → chunk-NRUUT5TL.js.map} +0 -0
- /package/dist/{chunk-IYITREE5.js.map → chunk-QB6UPODO.js.map} +0 -0
- /package/dist/{chunk-J56YGKUO.js.map → chunk-Y4TVCWWF.js.map} +0 -0
- /package/dist/{chunk-33DLG4I2.js.map → chunk-Y5TBOMHY.js.map} +0 -0
- /package/dist/{chunk-UHTIZCKU.js.map → chunk-YSPBVLTZ.js.map} +0 -0
- /package/dist/{chunk-NI2XD6P3.js.map → chunk-YX4R2VGD.js.map} +0 -0
- /package/dist/{chunk-U5S6IP7Z.js.map → chunk-Z4XVPGPZ.js.map} +0 -0
- /package/dist/{chunk-DMCMV4UJ.js.map → chunk-ZRALOFEG.js.map} +0 -0
- /package/dist/{client-ILPJFCTF.js.map → client-SQMU25PS.js.map} +0 -0
- /package/dist/{config-JVWOL233.js.map → config-56NBA4SF.js.map} +0 -0
- /package/dist/{config-mutate-WYCHP6VK.js.map → config-mutate-PD4O3HZ7.js.map} +0 -0
- /package/dist/{config-mutator-DKNHE6VP.js.map → config-mutator-ITL64FBW.js.map} +0 -0
- /package/dist/{contributions-XD66HYWE.js.map → contributions-DKTJ623L.js.map} +0 -0
- /package/dist/{doctor-DYTYJQYC.js.map → doctor-OI6GJZR5.js.map} +0 -0
- /package/dist/{follow-up-tool-HPET6LZW.js.map → follow-up-tool-DYSLS6ZI.js.map} +0 -0
- /package/dist/{hub-L5FFJPS3.js.map → hub-4HDMTSR7.js.map} +0 -0
- /package/dist/{processes-EWARF6ZW.js.map → processes-M7YPWX7H.js.map} +0 -0
- /package/dist/{promote-XI6W27JK.js.map → promote-3272TZNI.js.map} +0 -0
- /package/dist/{query-MGG5QKNC.js.map → query-7XM6V4QG.js.map} +0 -0
- /package/dist/{query-settings-CALZYYWD.js.map → query-settings-HHVBIIVQ.js.map} +0 -0
- /package/dist/{registry-XJWSLJ4O.js.map → registry-QL3AM3UH.js.map} +0 -0
- /package/dist/{request-planner-JCRGGJUO.js.map → request-planner-WNEDEA7X.js.map} +0 -0
- /package/dist/{review-candidates-OEBEEAEZ.js.map → review-candidates-TGPDJMWJ.js.map} +0 -0
- /package/dist/{routing-CGH54RYG.js.map → routing-ALXY25NE.js.map} +0 -0
- /package/dist/{schedule-tool-UM3CAPDX.js.map → schedule-tool-22UBZXCG.js.map} +0 -0
- /package/dist/{scheduler-2K5YEV2U.js.map → scheduler-5PHNW243.js.map} +0 -0
- /package/dist/{seat-DEL5YUOS.js.map → seat-ZYVVEILY.js.map} +0 -0
- /package/dist/{select-MRTWSI7U.js.map → select-6QLEV6AC.js.map} +0 -0
- /package/dist/{set-enabled-XTDCFCZY.js.map → set-enabled-SYYTKJPC.js.map} +0 -0
- /package/dist/{sprint-tool-N7WPDX5J.js.map → sprint-tool-PYVHPHR2.js.map} +0 -0
- /package/dist/{tool-BQEJOTF3.js.map → tool-GIYOYXXM.js.map} +0 -0
- /package/dist/{tool-NZTJZDSB.js.map → tool-TDOUM3BJ.js.map} +0 -0
- /package/dist/{tool-KZHWJ7BC.js.map → tool-ZKZ4KYJT.js.map} +0 -0
- /package/dist/{wiki-YERCKD3E.js.map → wiki-ZRGLGMII.js.map} +0 -0
- /package/dist/{wiki-enrich-K54LGNU3.js.map → wiki-enrich-CTID7JQW.js.map} +0 -0
package/README.md
CHANGED
|
@@ -112,9 +112,9 @@ What it costs depends on your model account (a Claude subscription, or an API ke
|
|
|
112
112
|
|
|
113
113
|
**What it costs.** Nothing: counting and caps run on your machine.
|
|
114
114
|
|
|
115
|
-
**First result you can see.** **Browser:** open
|
|
115
|
+
**First result you can see.** **Browser:** open your dashboard and select **Cost** in the Wall's nav. Each agent's row shows its spend against its cap, and **Monthly budgets** shows all agents, each project and each capped agent.
|
|
116
116
|
|
|
117
|
-

|
|
118
118
|
|
|
119
119
|
[Set a monthly budget](docs/help/costs.md#set-a-monthly-budget-for-an-agent)
|
|
120
120
|
|
|
@@ -43,6 +43,15 @@ enum Config {
|
|
|
43
43
|
set { UserDefaults.standard.set(newValue, forKey: "playMode") }
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/// "Play answers at once" in the menu: an answer plays as soon as it is
|
|
47
|
+
/// back, as before #1455. Off by default: it waits as "not heard" in the
|
|
48
|
+
/// open-requests list until picked. A UI choice for now; the setting in
|
|
49
|
+
/// agentx.json comes with the Settings window's Answers group.
|
|
50
|
+
static var playAnswersAtOnce: Bool {
|
|
51
|
+
get { UserDefaults.standard.bool(forKey: "playAnswersAtOnce") }
|
|
52
|
+
set { UserDefaults.standard.set(newValue, forKey: "playAnswersAtOnce") }
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
/// Where the pill was last dragged to (its bottom-left corner, in
|
|
47
56
|
/// screen points). Nil: the default corner.
|
|
48
57
|
static var pillOrigin: CGPoint? {
|
|
@@ -5,11 +5,14 @@ import SwiftUI
|
|
|
5
5
|
///
|
|
6
6
|
/// Each is a small glassy dot in the agent's colours with a cue for its
|
|
7
7
|
/// state: a ring going round while it thinks, a steady ring while its
|
|
8
|
-
/// answer waits to be spoken, a
|
|
9
|
-
///
|
|
10
|
-
///
|
|
11
|
-
///
|
|
12
|
-
///
|
|
8
|
+
/// answer waits to be spoken, a steady ring and a blue dot while its
|
|
9
|
+
/// answer waits to be heard (#1455), a red ring when it couldn't answer, a
|
|
10
|
+
/// gentle pulse while it speaks, and a count when more questions wait for
|
|
11
|
+
/// it. It moves only while shown on screen with something busy; Reduce
|
|
12
|
+
/// Motion or "Animated orb" off gives still orbs. Clicks go through to the
|
|
13
|
+
/// pill, which opens the open-requests list for a click on the row; it
|
|
14
|
+
/// never takes the keyboard, and hovering an orb names the agent and its
|
|
15
|
+
/// node.
|
|
13
16
|
@MainActor
|
|
14
17
|
final class MiniOrbsModel: ObservableObject {
|
|
15
18
|
struct Orb: Identifiable, Equatable {
|
|
@@ -82,6 +85,14 @@ struct MiniOrb: View {
|
|
|
82
85
|
.scaleEffect(orb.activity == .queued ? 0.72 : 0.78 * pulse)
|
|
83
86
|
.opacity(orb.activity == .queued ? 0.7 : 1)
|
|
84
87
|
cue
|
|
88
|
+
if orb.activity == .ready && orb.queued == 0 {
|
|
89
|
+
// Not heard yet: the same blue as the list's dot.
|
|
90
|
+
Circle()
|
|
91
|
+
.fill(RequestRow.blue)
|
|
92
|
+
.frame(width: 7, height: 7)
|
|
93
|
+
.overlay(Circle().strokeBorder(Color.white.opacity(0.85), lineWidth: 1))
|
|
94
|
+
.offset(x: 5, y: -6)
|
|
95
|
+
}
|
|
85
96
|
if orb.queued > 0 {
|
|
86
97
|
Text("\(min(orb.queued, 9))")
|
|
87
98
|
.font(.system(size: 7.5, weight: .bold).monospacedDigit())
|
|
@@ -102,8 +113,10 @@ struct MiniOrb: View {
|
|
|
102
113
|
.trim(from: 0, to: 0.3)
|
|
103
114
|
.stroke(Color(nsColor: ring), style: StrokeStyle(lineWidth: 1.6, lineCap: .round))
|
|
104
115
|
.rotationEffect(.radians(still ? -.pi / 2 : t * 3.4))
|
|
105
|
-
case .answering:
|
|
116
|
+
case .answering, .ready:
|
|
106
117
|
Circle().stroke(Color(nsColor: ring).opacity(0.85), lineWidth: 1.2)
|
|
118
|
+
case .failed:
|
|
119
|
+
Circle().stroke(RequestRow.red, lineWidth: 1.4)
|
|
107
120
|
case .speaking:
|
|
108
121
|
Circle().stroke(Color(nsColor: ring).opacity(0.5), lineWidth: 1)
|
|
109
122
|
.scaleEffect(still ? 1 : 0.94 + 0.06 * OrbMath.speakingEnvelope(at: t + 0.4))
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// The open-requests list (#1455): every question the widget has sent, from
|
|
4
|
+
/// the moment it goes until it has been heard.
|
|
5
|
+
///
|
|
6
|
+
/// Sending no longer holds the pill. A request runs on its own, its answer
|
|
7
|
+
/// waits as "not heard", and the owner picks it from the list to hear it.
|
|
8
|
+
/// One /ask per agent at a time stays the rule: a second request for an
|
|
9
|
+
/// agent that is still thinking waits behind the first and goes when it
|
|
10
|
+
/// answers.
|
|
11
|
+
///
|
|
12
|
+
/// Kept free of AppKit and SwiftUI so the tests can check it without a
|
|
13
|
+
/// window. The answers themselves live with the app; this holds what the
|
|
14
|
+
/// list and the pill show.
|
|
15
|
+
struct OpenRequests {
|
|
16
|
+
/// Where a request is.
|
|
17
|
+
enum Phase: Equatable {
|
|
18
|
+
/// Behind another request for the same agent.
|
|
19
|
+
case waiting
|
|
20
|
+
/// Asked; the agent is working on it.
|
|
21
|
+
case thinking
|
|
22
|
+
/// The answer is back.
|
|
23
|
+
case answered
|
|
24
|
+
/// The agent could not answer, and why, in words.
|
|
25
|
+
case failed(String)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
struct Request: Equatable, Identifiable {
|
|
29
|
+
let id: Int
|
|
30
|
+
let agentID: String
|
|
31
|
+
/// The words as heard.
|
|
32
|
+
let question: String
|
|
33
|
+
let sentAt: Date
|
|
34
|
+
var phase: Phase
|
|
35
|
+
/// When it started thinking, or when its answer came back.
|
|
36
|
+
var since: Date
|
|
37
|
+
/// Played or opened: its answer, or why it failed, has been seen.
|
|
38
|
+
var heard = false
|
|
39
|
+
|
|
40
|
+
/// An answer or a failure the owner has not seen yet.
|
|
41
|
+
var isNew: Bool {
|
|
42
|
+
switch phase {
|
|
43
|
+
case .answered, .failed: return !heard
|
|
44
|
+
case .waiting, .thinking: return false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// Still with the agent.
|
|
49
|
+
var isOpen: Bool { phase == .waiting || phase == .thinking }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// Oldest first, which is the order they were sent in.
|
|
53
|
+
private(set) var requests: [Request] = []
|
|
54
|
+
private var nextID = 1
|
|
55
|
+
|
|
56
|
+
/// Heard requests kept in the list. Closing a row by hand comes with
|
|
57
|
+
/// its own slice; until then the oldest heard ones leave by themselves.
|
|
58
|
+
static let keptHeard = 8
|
|
59
|
+
|
|
60
|
+
func request(_ id: Int) -> Request? { requests.first { $0.id == id } }
|
|
61
|
+
|
|
62
|
+
/// Add a request. It thinks at once, or waits when its agent already has
|
|
63
|
+
/// one out. Returns its id.
|
|
64
|
+
@discardableResult
|
|
65
|
+
mutating func add(agentID: String, question: String, at now: Date) -> Int {
|
|
66
|
+
let busy = requests.contains { $0.agentID == agentID && $0.isOpen }
|
|
67
|
+
let id = nextID
|
|
68
|
+
nextID += 1
|
|
69
|
+
requests.append(Request(id: id, agentID: agentID, question: question, sentAt: now,
|
|
70
|
+
phase: busy ? .waiting : .thinking, since: now))
|
|
71
|
+
return id
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// The answer came back.
|
|
75
|
+
mutating func answered(_ id: Int, at now: Date) {
|
|
76
|
+
update(id) { $0.phase = .answered; $0.since = now }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// The agent could not answer.
|
|
80
|
+
mutating func failed(_ id: Int, reason: String, at now: Date) {
|
|
81
|
+
update(id) { $0.phase = .failed(reason); $0.since = now }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// The oldest request waiting for `agentID`, now thinking, if there is
|
|
85
|
+
/// one and nothing else for that agent is.
|
|
86
|
+
mutating func startNext(for agentID: String, at now: Date) -> Int? {
|
|
87
|
+
guard !requests.contains(where: { $0.agentID == agentID && $0.phase == .thinking }),
|
|
88
|
+
let i = requests.firstIndex(where: { $0.agentID == agentID && $0.phase == .waiting }) else { return nil }
|
|
89
|
+
requests[i].phase = .thinking
|
|
90
|
+
requests[i].since = now
|
|
91
|
+
return requests[i].id
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/// Played, or opened. The oldest heard requests beyond `keptHeard` leave.
|
|
95
|
+
mutating func heard(_ id: Int) {
|
|
96
|
+
update(id) { $0.heard = true }
|
|
97
|
+
let heard = requests.filter { $0.heard && !$0.isOpen }
|
|
98
|
+
if heard.count > Self.keptHeard {
|
|
99
|
+
let gone = Set(heard.prefix(heard.count - Self.keptHeard).map(\.id))
|
|
100
|
+
requests.removeAll { gone.contains($0.id) }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// Gone without a trace: the daemon took the words for something else.
|
|
105
|
+
mutating func remove(_ id: Int) {
|
|
106
|
+
requests.removeAll { $0.id == id }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private mutating func update(_ id: Int, _ change: (inout Request) -> Void) {
|
|
110
|
+
guard let i = requests.firstIndex(where: { $0.id == id }) else { return }
|
|
111
|
+
change(&requests[i])
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// MARK: For the pill
|
|
115
|
+
|
|
116
|
+
/// Answers and failures not seen yet: the "1 new" on the pill.
|
|
117
|
+
var newCount: Int { requests.filter(\.isNew).count }
|
|
118
|
+
|
|
119
|
+
/// Agents with an answer waiting to be heard.
|
|
120
|
+
var readyAgents: [String] { agents { $0.phase == .answered && !$0.heard } }
|
|
121
|
+
|
|
122
|
+
/// Agents whose request failed, not seen yet.
|
|
123
|
+
var failedAgents: [String] {
|
|
124
|
+
agents {
|
|
125
|
+
if case .failed = $0.phase { return !$0.heard }
|
|
126
|
+
return false
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// Requests waiting behind another, per agent.
|
|
131
|
+
var waiting: [String: Int] {
|
|
132
|
+
requests.filter { $0.phase == .waiting }.reduce(into: [:]) { $0[$1.agentID, default: 0] += 1 }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private func agents(_ test: (Request) -> Bool) -> [String] {
|
|
136
|
+
var seen = Set<String>()
|
|
137
|
+
return requests.filter(test).map(\.agentID).filter { seen.insert($0).inserted }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/// The rows in the order drawn: by when each was sent, the newest next
|
|
141
|
+
/// to the pill. Rows never move when a state changes.
|
|
142
|
+
func rows(newestLast: Bool) -> [Request] {
|
|
143
|
+
newestLast ? requests : requests.reversed()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// MARK: Words
|
|
147
|
+
|
|
148
|
+
/// The first words of a request, for its row: one line, capitalised,
|
|
149
|
+
/// cut at a word with "…" when longer than `max` characters.
|
|
150
|
+
static func firstWords(_ text: String, max: Int = 48) -> String {
|
|
151
|
+
let flat = text.split(whereSeparator: \.isWhitespace).joined(separator: " ")
|
|
152
|
+
var words = flat.prefix(1).uppercased() + flat.dropFirst()
|
|
153
|
+
guard words.count > max else { return words }
|
|
154
|
+
let cut = words.prefix(max)
|
|
155
|
+
let end = cut.lastIndex(of: " ").map { cut[..<$0] } ?? cut
|
|
156
|
+
words = String(end).trimmingCharacters(in: CharacterSet(charactersIn: " ,.;:")) + "…"
|
|
157
|
+
return words
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/// "0:20", "1:12", "12:05".
|
|
161
|
+
static func clock(_ seconds: Int) -> String {
|
|
162
|
+
let s = max(0, seconds)
|
|
163
|
+
return "\(s / 60):" + String(format: "%02d", s % 60)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/// How long ago, for the row's corner: "now", "2 min", "3 h".
|
|
167
|
+
static func ago(_ seconds: Int) -> String {
|
|
168
|
+
let s = max(0, seconds)
|
|
169
|
+
if s < 60 { return "now" }
|
|
170
|
+
if s < 3600 { return "\(s / 60) min" }
|
|
171
|
+
return "\(s / 3600) h"
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/// The row's state, after the agent's name.
|
|
175
|
+
static func stateWords(_ r: Request, now: Date) -> String {
|
|
176
|
+
switch r.phase {
|
|
177
|
+
case .waiting: return "Waiting its turn"
|
|
178
|
+
case .thinking: return "Thinking, " + clock(Int(now.timeIntervalSince(r.since)))
|
|
179
|
+
case .answered: return r.heard ? "Heard" : "Answer ready"
|
|
180
|
+
case .failed: return "Couldn’t answer"
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/// What VoiceOver reads for a row. The actions (Listen, Show) are the
|
|
185
|
+
/// row's own and are read after it.
|
|
186
|
+
static func voiceOver(name: String, _ r: Request, now: Date) -> String {
|
|
187
|
+
let state: String
|
|
188
|
+
switch r.phase {
|
|
189
|
+
case .waiting: state = "Waiting its turn"
|
|
190
|
+
case .thinking:
|
|
191
|
+
let s = Int(now.timeIntervalSince(r.since))
|
|
192
|
+
state = s < 60 ? "Thinking" : "Thinking, \(s / 60) minute\(s / 60 == 1 ? "" : "s")"
|
|
193
|
+
case .answered: state = r.heard ? "Heard" : "Answer ready, not heard"
|
|
194
|
+
case .failed: state = r.heard ? "Couldn’t answer" : "Couldn’t answer, not seen"
|
|
195
|
+
}
|
|
196
|
+
let asked = flatLower(r.question)
|
|
197
|
+
let s = Int(now.timeIntervalSince(r.sentAt))
|
|
198
|
+
let when = s < 60 ? "Just now" : s < 3600 ? "\(s / 60) minute\(s / 60 == 1 ? "" : "s") ago" : "\(s / 3600) hour\(s / 3600 == 1 ? "" : "s") ago"
|
|
199
|
+
return "\(name). \(state). You asked: \(asked). \(when)."
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private static func flatLower(_ text: String) -> String {
|
|
203
|
+
let flat = text.split(whereSeparator: \.isWhitespace).joined(separator: " ")
|
|
204
|
+
let trimmed = flat.trimmingCharacters(in: CharacterSet(charactersIn: " .?!"))
|
|
205
|
+
return trimmed.prefix(1).lowercased() + trimmed.dropFirst()
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/// "1 new", "3 new".
|
|
209
|
+
static func newBadge(_ count: Int) -> String { "\(count) new" }
|
|
210
|
+
|
|
211
|
+
/// The pill's line just after a request goes.
|
|
212
|
+
static let sentNote = "Sent. Ask the next one"
|
|
213
|
+
|
|
214
|
+
/// The pill's line when an answer comes back and waits.
|
|
215
|
+
static func readyNote(name: String) -> String { "\(name) answered · hover or ⌘⌥O to hear it" }
|
|
216
|
+
|
|
217
|
+
/// The pill's line when a request fails.
|
|
218
|
+
static func failedNote(name: String) -> String { "\(name) couldn’t answer · ⌘⌥O to see why" }
|
|
219
|
+
|
|
220
|
+
/// How long those lines stay before the pill goes back to its own.
|
|
221
|
+
static let noteSeconds: TimeInterval = 4
|
|
222
|
+
|
|
223
|
+
// MARK: Picking a row
|
|
224
|
+
|
|
225
|
+
enum Pick: Equatable {
|
|
226
|
+
/// Play the answer and show its text: it is heard from now on.
|
|
227
|
+
case listen
|
|
228
|
+
/// Show the text again; Listen again plays it.
|
|
229
|
+
case show
|
|
230
|
+
/// Say why it failed.
|
|
231
|
+
case reason(String)
|
|
232
|
+
/// Still with the agent: nothing to hear yet.
|
|
233
|
+
case nothing
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
static func pick(_ r: Request) -> Pick {
|
|
237
|
+
switch r.phase {
|
|
238
|
+
case .waiting, .thinking: return .nothing
|
|
239
|
+
case .answered: return r.heard ? .show : .listen
|
|
240
|
+
case .failed(let why): return .reason(why)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/// The row selected after ↑ (`delta` -1) or ↓ (+1), from `selected`,
|
|
245
|
+
/// in `ids` as drawn top to bottom. Nothing selected: ↓ takes the top
|
|
246
|
+
/// row and ↑ the bottom one. It stops at either end.
|
|
247
|
+
static func move(_ selected: Int?, by delta: Int, in ids: [Int]) -> Int? {
|
|
248
|
+
guard !ids.isEmpty else { return nil }
|
|
249
|
+
guard let selected, let i = ids.firstIndex(of: selected) else {
|
|
250
|
+
return delta < 0 ? ids.last : ids.first
|
|
251
|
+
}
|
|
252
|
+
return ids[min(max(i + delta, 0), ids.count - 1)]
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/// The row selected when the list opens from the keyboard: the oldest
|
|
256
|
+
/// answer not heard yet, else the newest, next to the pill.
|
|
257
|
+
var firstSelection: Int? {
|
|
258
|
+
requests.first(where: \.isNew)?.id ?? requests.last?.id
|
|
259
|
+
}
|
|
260
|
+
}
|
|
@@ -25,6 +25,10 @@ final class Panel: NSPanel {
|
|
|
25
25
|
let miniOrbs = MiniOrbsHost()
|
|
26
26
|
/// Busy agents shown in the mini row; 0 hides it.
|
|
27
27
|
private(set) var busyCount = 0
|
|
28
|
+
/// "1 new": answers not heard yet (#1455), before the mini orbs.
|
|
29
|
+
private let newBadge = NSTextField(labelWithString: "")
|
|
30
|
+
/// Answers not heard yet; 0 hides the badge.
|
|
31
|
+
private(set) var newCount = 0
|
|
28
32
|
private let closeButton = NSButton()
|
|
29
33
|
/// Answer, Later and Decline while an agent rings; Hang up during the call.
|
|
30
34
|
let callBar = CallBar(frame: NSRect(x: 0, y: 15, width: 0, height: 24))
|
|
@@ -160,13 +164,25 @@ final class Panel: NSPanel {
|
|
|
160
164
|
let moved = hypot(now.x - start.x, now.y - start.y)
|
|
161
165
|
let onRow = convertToScreen(row.convert(row.bounds, to: nil)).contains(start)
|
|
162
166
|
// Reduced, a click opens the pill; it does not start talking.
|
|
167
|
+
// On the mini orbs or "1 new", it opens the open-requests list.
|
|
163
168
|
if moved < 4 && onRow {
|
|
164
|
-
if reduced { MainActor.assumeIsolated { open(clicked: true) } }
|
|
169
|
+
if reduced { MainActor.assumeIsolated { open(clicked: true) } }
|
|
170
|
+
else if onListPart(start) { onOpenList?() }
|
|
171
|
+
else { onClick?() }
|
|
165
172
|
}
|
|
166
173
|
}
|
|
167
174
|
super.mouseUp(with: event)
|
|
168
175
|
}
|
|
169
176
|
|
|
177
|
+
/// The mini orbs and "1 new", where a click opens the list rather
|
|
178
|
+
/// than talking.
|
|
179
|
+
private func onListPart(_ point: NSPoint) -> Bool {
|
|
180
|
+
let parts: [NSView] = [miniOrbs, newBadge]
|
|
181
|
+
return parts.contains { part in
|
|
182
|
+
!part.isHidden && convertToScreen(part.convert(part.bounds, to: nil)).insetBy(dx: -3, dy: -6).contains(point)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
170
186
|
enum State {
|
|
171
187
|
case idle, listening, thinking, speaking
|
|
172
188
|
/// Live activity from the daemon, with seconds elapsed — the
|
|
@@ -182,6 +198,9 @@ final class Panel: NSPanel {
|
|
|
182
198
|
case error(String)
|
|
183
199
|
/// An agent is calling: the words already name it and its reason.
|
|
184
200
|
case ringing(String)
|
|
201
|
+
/// A passing line at rest that already names who (#1455): "Writer ·
|
|
202
|
+
/// Sent. Ask the next one", "Ops answered · hover or ⌘⌥O to hear it".
|
|
203
|
+
case note(String)
|
|
185
204
|
/// In a call, between turns: a click talks.
|
|
186
205
|
case onCall
|
|
187
206
|
|
|
@@ -196,6 +215,7 @@ final class Panel: NSPanel {
|
|
|
196
215
|
case .working(let what, let secs): return "\(what) · \(secs)s"
|
|
197
216
|
case .error(let m): return m
|
|
198
217
|
case .ringing(let text): return text
|
|
218
|
+
case .note(let text): return text
|
|
199
219
|
case .onCall: return "On call · click to talk"
|
|
200
220
|
}
|
|
201
221
|
}
|
|
@@ -212,13 +232,14 @@ final class Panel: NSPanel {
|
|
|
212
232
|
case .error: return Brand.alert
|
|
213
233
|
case .ringing: return Brand.accent
|
|
214
234
|
case .onCall: return Brand.accentDeep
|
|
235
|
+
case .note: return Brand.primaryBright
|
|
215
236
|
}
|
|
216
237
|
}
|
|
217
238
|
|
|
218
239
|
/// What the character shows. A call between turns waits for you.
|
|
219
240
|
var activity: CharacterMath.Activity {
|
|
220
241
|
switch self {
|
|
221
|
-
case .idle, .error: return .idle
|
|
242
|
+
case .idle, .error, .note: return .idle
|
|
222
243
|
case .listening: return .listening
|
|
223
244
|
case .thinking, .working: return .thinking
|
|
224
245
|
case .speaking, .saying: return .speaking
|
|
@@ -243,7 +264,7 @@ final class Panel: NSPanel {
|
|
|
243
264
|
/// Idle and errors hold it still.
|
|
244
265
|
var orbPhase: OrbModel.Phase {
|
|
245
266
|
switch self {
|
|
246
|
-
case .idle, .error, .onCall: return .idle
|
|
267
|
+
case .idle, .error, .onCall, .note: return .idle
|
|
247
268
|
case .listening: return .listening
|
|
248
269
|
case .thinking, .working: return .thinking
|
|
249
270
|
// Ringing pulses, so the pill is seen as well as heard.
|
|
@@ -252,6 +273,14 @@ final class Panel: NSPanel {
|
|
|
252
273
|
}
|
|
253
274
|
}
|
|
254
275
|
|
|
276
|
+
/// A click on the mini orbs or on "1 new": open the open-requests
|
|
277
|
+
/// list (#1455). Set by the app.
|
|
278
|
+
var onOpenList: (() -> Void)?
|
|
279
|
+
|
|
280
|
+
/// The pointer came onto the pill (true) or left it. Set by the app,
|
|
281
|
+
/// which opens the open-requests list after a moment's hover.
|
|
282
|
+
var onHover: ((Bool) -> Void)?
|
|
283
|
+
|
|
255
284
|
/// Called when the pill is clicked. Set by the app.
|
|
256
285
|
///
|
|
257
286
|
/// The hotkey is faster once you know it, and invisible until then.
|
|
@@ -322,6 +351,16 @@ final class Panel: NSPanel {
|
|
|
322
351
|
row.addSubview(closeButton)
|
|
323
352
|
miniOrbs.isHidden = true
|
|
324
353
|
row.addSubview(miniOrbs)
|
|
354
|
+
newBadge.font = .systemFont(ofSize: 11, weight: .bold)
|
|
355
|
+
newBadge.textColor = .white
|
|
356
|
+
newBadge.alignment = .center
|
|
357
|
+
newBadge.wantsLayer = true
|
|
358
|
+
newBadge.drawsBackground = false
|
|
359
|
+
newBadge.layer?.backgroundColor = Brand.primaryBright.cgColor
|
|
360
|
+
newBadge.layer?.cornerRadius = 8
|
|
361
|
+
newBadge.isHidden = true
|
|
362
|
+
newBadge.toolTip = "Open requests (⌘⌥O)"
|
|
363
|
+
row.addSubview(newBadge)
|
|
325
364
|
row.addSubview(callBar)
|
|
326
365
|
surface.layoutContent = { [weak self] bounds in self?.layoutContent(bounds) }
|
|
327
366
|
MainActor.assumeIsolated { layoutContent(surface.bounds) }
|
|
@@ -357,8 +396,14 @@ final class Panel: NSPanel {
|
|
|
357
396
|
closeButton.frame.origin.x = bounds.width - 28
|
|
358
397
|
// The mini orbs sit between the words and the close button, and
|
|
359
398
|
// the words give up that room while they show.
|
|
360
|
-
|
|
399
|
+
var miniWidth = busyCount > 0 ? MiniOrbsHost.width(busyCount) : 0
|
|
361
400
|
miniOrbs.frame = NSRect(x: bounds.width - 28 - miniWidth, y: (h - 24) / 2, width: miniWidth, height: 24)
|
|
401
|
+
// "1 new" sits just before the mini orbs, and takes its room from the words.
|
|
402
|
+
if newCount > 0 {
|
|
403
|
+
let badge = Self.badgeWidth(newBadge.stringValue)
|
|
404
|
+
newBadge.frame = NSRect(x: miniOrbs.frame.minX - (miniWidth > 0 ? 4 : 0) - badge, y: (h - 16) / 2, width: badge, height: 16)
|
|
405
|
+
miniWidth += badge + (miniWidth > 0 ? 4 : 0)
|
|
406
|
+
}
|
|
362
407
|
// The call buttons sit left of those, and the words give way again.
|
|
363
408
|
let callWidth = CallBar.width(callBar.mode)
|
|
364
409
|
let callX = bounds.width - 28 - (miniWidth > 0 ? miniWidth + 4 : 0) - callWidth
|
|
@@ -443,6 +488,7 @@ final class Panel: NSPanel {
|
|
|
443
488
|
clip?.isHidden = circle
|
|
444
489
|
closeButton.isHidden = true
|
|
445
490
|
miniOrbs.isHidden = circle || busyCount == 0
|
|
491
|
+
newBadge.isHidden = circle || newCount == 0
|
|
446
492
|
// Shrunk to its dots, the bubble's shape and size are the
|
|
447
493
|
// character's to set (`attach`), and the full bubble comes back at
|
|
448
494
|
// once for what opens it.
|
|
@@ -576,11 +622,13 @@ final class Panel: NSPanel {
|
|
|
576
622
|
closeButton.isHidden = reduced
|
|
577
623
|
hovering = true
|
|
578
624
|
MainActor.assumeIsolated { armCollapse() }
|
|
625
|
+
onHover?(true)
|
|
579
626
|
}
|
|
580
627
|
override func mouseExited(with event: NSEvent) {
|
|
581
628
|
closeButton.isHidden = true
|
|
582
629
|
hovering = false
|
|
583
630
|
MainActor.assumeIsolated { armCollapse() }
|
|
631
|
+
onHover?(false)
|
|
584
632
|
}
|
|
585
633
|
|
|
586
634
|
/// Esc, once the pill has been clicked and so holds the keyboard.
|
|
@@ -651,7 +699,7 @@ final class Panel: NSPanel {
|
|
|
651
699
|
// Reduced, the orb is the assistant's place on screen: it stays, idle or not.
|
|
652
700
|
// Reduced with the character, the bubble is gone: the character shows the state.
|
|
653
701
|
// A caption shows like any words; away with none, the hint does not.
|
|
654
|
-
let quiet = state.isMeta && !expanded && busyCount == 0
|
|
702
|
+
let quiet = state.isMeta && !expanded && busyCount == 0 && newCount == 0
|
|
655
703
|
let gone = reduced && !showsOrb
|
|
656
704
|
if dismissed || concealed || gone || (quiet && idle == .nothing) || (quiet && idle == .hint && !alwaysVisible && !reduced) { hide() } else { show() }
|
|
657
705
|
// After showing or hiding: a still character draws its bubble's
|
|
@@ -703,6 +751,24 @@ final class Panel: NSPanel {
|
|
|
703
751
|
}
|
|
704
752
|
}
|
|
705
753
|
|
|
754
|
+
/// "1 new" on the pill (#1455): answers not heard yet, or none to
|
|
755
|
+
/// hide it. The pill stays on screen while it shows.
|
|
756
|
+
@MainActor
|
|
757
|
+
func showNew(_ count: Int) {
|
|
758
|
+
guard count != newCount else { return }
|
|
759
|
+
newCount = count
|
|
760
|
+
newBadge.stringValue = OpenRequests.newBadge(count)
|
|
761
|
+
newBadge.setAccessibilityLabel("\(count) answer\(count == 1 ? "" : "s") not heard. Open requests")
|
|
762
|
+
newBadge.isHidden = count == 0 || reduced
|
|
763
|
+
if let content = contentView { layoutContent(content.bounds) }
|
|
764
|
+
render(current)
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/// The badge's width for its words: the text and room either side.
|
|
768
|
+
private static func badgeWidth(_ text: String) -> CGFloat {
|
|
769
|
+
ceil((text as NSString).size(withAttributes: [.font: NSFont.systemFont(ofSize: 11, weight: .bold)]).width) + 14
|
|
770
|
+
}
|
|
771
|
+
|
|
706
772
|
/// "Nadia · Listening": who is listening or answering. Errors are the
|
|
707
773
|
/// widget's own, so they carry no name.
|
|
708
774
|
@MainActor
|
|
@@ -711,6 +777,7 @@ final class Panel: NSPanel {
|
|
|
711
777
|
if name.isEmpty { return state.text }
|
|
712
778
|
if case .error = state { return state.text }
|
|
713
779
|
if case .ringing = state { return state.text }
|
|
780
|
+
if case .note = state { return state.text }
|
|
714
781
|
return "\(name) · \(state.text)"
|
|
715
782
|
}
|
|
716
783
|
|
|
@@ -18,6 +18,11 @@ enum PillBusy {
|
|
|
18
18
|
case speaking
|
|
19
19
|
/// Its answer is back and waits in the speaking queue.
|
|
20
20
|
case answering
|
|
21
|
+
/// Its answer is back and waits to be heard: nothing plays until
|
|
22
|
+
/// the owner picks it from the open-requests list (#1455).
|
|
23
|
+
case ready
|
|
24
|
+
/// It could not answer, and the owner has not seen why yet.
|
|
25
|
+
case failed
|
|
21
26
|
/// A question to it is in flight.
|
|
22
27
|
case thinking
|
|
23
28
|
/// Only questions waiting for it: nothing asked yet.
|
|
@@ -27,6 +32,8 @@ enum PillBusy {
|
|
|
27
32
|
switch self {
|
|
28
33
|
case .speaking: return "speaking"
|
|
29
34
|
case .answering: return "answer waiting to be spoken"
|
|
35
|
+
case .ready: return "answer ready, not heard"
|
|
36
|
+
case .failed: return "couldn’t answer"
|
|
30
37
|
case .thinking: return "thinking"
|
|
31
38
|
case .queued: return "queued"
|
|
32
39
|
}
|
|
@@ -50,6 +57,10 @@ enum PillBusy {
|
|
|
50
57
|
var playing: String?
|
|
51
58
|
/// Agents with answers waiting in the daemon's speaking queue.
|
|
52
59
|
var toSpeak: [String] = []
|
|
60
|
+
/// Agents with an answer waiting to be heard (OpenRequests).
|
|
61
|
+
var ready: [String] = []
|
|
62
|
+
/// Agents whose request failed, not seen yet.
|
|
63
|
+
var failed: [String] = []
|
|
53
64
|
}
|
|
54
65
|
|
|
55
66
|
/// One item per busy agent. Agents already in `order` keep their
|
|
@@ -60,6 +71,8 @@ enum PillBusy {
|
|
|
60
71
|
ids.formUnion(s.waiting.filter { $0.value > 0 }.keys)
|
|
61
72
|
if let p = s.playing, !p.isEmpty { ids.insert(p) }
|
|
62
73
|
ids.formUnion(s.toSpeak.filter { !$0.isEmpty })
|
|
74
|
+
ids.formUnion(s.ready.filter { !$0.isEmpty })
|
|
75
|
+
ids.formUnion(s.failed.filter { !$0.isEmpty })
|
|
63
76
|
|
|
64
77
|
let kept = order.filter(ids.contains)
|
|
65
78
|
let fresh = ids.subtracting(kept).sorted()
|
|
@@ -67,6 +80,9 @@ enum PillBusy {
|
|
|
67
80
|
let activity: Activity
|
|
68
81
|
if s.playing == id { activity = .speaking }
|
|
69
82
|
else if s.toSpeak.contains(id) { activity = .answering }
|
|
83
|
+
// Something to hear or to see beats a request still thinking.
|
|
84
|
+
else if s.ready.contains(id) { activity = .ready }
|
|
85
|
+
else if s.failed.contains(id) { activity = .failed }
|
|
70
86
|
else if s.inFlight[id, default: 0] > 0 { activity = .thinking }
|
|
71
87
|
else { activity = .queued }
|
|
72
88
|
// In flight beyond the first also waits (a turn plus an aside).
|
|
@@ -75,12 +91,14 @@ enum PillBusy {
|
|
|
75
91
|
}
|
|
76
92
|
}
|
|
77
93
|
|
|
78
|
-
/// The row shows when more than one agent is busy,
|
|
79
|
-
///
|
|
80
|
-
///
|
|
81
|
-
///
|
|
94
|
+
/// The row shows when more than one agent is busy, when the one busy
|
|
95
|
+
/// agent has an answer to hear or a failure to see, or when it still
|
|
96
|
+
/// has a question out that the main orb is not showing: the pill
|
|
97
|
+
/// listens for the next while it thinks. One line being spoken on its
|
|
98
|
+
/// own is the main orb's, or a notification's.
|
|
82
99
|
static func showsRow(_ items: [Item], mainAgent: String, mainActive: Bool) -> Bool {
|
|
83
100
|
if items.count >= 2 { return true }
|
|
101
|
+
if let only = items.first, only.activity == .ready || only.activity == .failed { return true }
|
|
84
102
|
guard let only = items.first, only.activity == .thinking || only.activity == .queued else { return false }
|
|
85
103
|
return !mainActive || only.agentID != mainAgent
|
|
86
104
|
}
|
|
@@ -79,6 +79,30 @@ enum PillPlacement {
|
|
|
79
79
|
width: size.width, height: size.height)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/// The open-requests list (#1455): beside the widget at `pill`, on the
|
|
83
|
+
/// side with more room (above when equal), right edges lined up unless
|
|
84
|
+
/// that leaves the screen, `gap` points clear of it. As tall as its
|
|
85
|
+
/// rows want, `height`, but no taller than the room on that side.
|
|
86
|
+
struct List: Equatable {
|
|
87
|
+
let frame: CGRect
|
|
88
|
+
/// True: the list is above the pill, its newest row at the bottom.
|
|
89
|
+
let above: Bool
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static let listGap: CGFloat = 8
|
|
93
|
+
|
|
94
|
+
static func list(width: CGFloat, height: CGFloat, pill: CGRect, visible: CGRect) -> List {
|
|
95
|
+
let roomAbove = visible.maxY - pill.maxY - listGap
|
|
96
|
+
let roomBelow = pill.minY - visible.minY - listGap
|
|
97
|
+
let above = roomAbove >= roomBelow
|
|
98
|
+
let h = max(0, min(height, above ? roomAbove : roomBelow))
|
|
99
|
+
let alignRight = pill.maxX - width >= visible.minX
|
|
100
|
+
let frame = CGRect(x: alignRight ? pill.maxX - width : pill.minX,
|
|
101
|
+
y: above ? pill.maxY + listGap : pill.minY - listGap - h,
|
|
102
|
+
width: width, height: h)
|
|
103
|
+
return List(frame: inside(frame, visible), above: above)
|
|
104
|
+
}
|
|
105
|
+
|
|
82
106
|
/// How far the bubble reaches to the right of the character's middle,
|
|
83
107
|
/// and the gap above its head that the bubble's tail fills.
|
|
84
108
|
static let bubbleReach: CGFloat = 64
|