samagotchi 0.144.0 → 0.146.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -1
- data/docs/cli.md +1 -1
- data/docs/guardrails.md +7 -2
- data/docs/internals/bridge.md +3 -1
- data/docs/internals/engine.md +1 -1
- data/docs/internals/web-frontend.md +24 -3
- data/docs/memory.md +45 -0
- data/docs/sessions.md +1 -1
- data/lib/samagotchi/bundles/system/manifest.yml +1 -1
- data/lib/samagotchi/child_reports.rb +13 -6
- data/lib/samagotchi/guardrails/approval.rb +17 -4
- data/lib/samagotchi/guardrails/parent_approvals.rb +5 -1
- data/lib/samagotchi/guardrails/verdict.rb +5 -3
- data/lib/samagotchi/memory_command.rb +135 -7
- data/lib/samagotchi/memory_paths.rb +9 -0
- data/lib/samagotchi/memory_usage.rb +368 -0
- data/lib/samagotchi/relay.rb +2 -2
- data/lib/samagotchi/tool_activity.rb +3 -3
- data/lib/samagotchi/tool_output_cut.rb +12 -1
- data/lib/samagotchi/toolkit_suggest.rb +7 -4
- data/lib/samagotchi/tools/delegate.rb +88 -13
- data/lib/samagotchi/tools/memory.rb +12 -2
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/app.rb +1 -1
- data/lib/samagotchi/web/public/app.js +10 -2
- data/lib/samagotchi/web/public/composer_fold.js +5 -2
- data/lib/samagotchi/web/public/composer_grip.js +45 -2
- data/lib/samagotchi/web/public/index.html +8 -6
- data/lib/samagotchi/web/public/info_bar_model.js +6 -4
- data/lib/samagotchi/web/public/participant_annotate.js +2 -1
- data/lib/samagotchi/web/public/question_cards.js +59 -12
- data/lib/samagotchi/web/public/revise_stack.js +6 -5
- data/lib/samagotchi/web/public/stage_frame.js +19 -7
- data/lib/samagotchi/web/public/stage_model.js +2 -1
- data/lib/samagotchi/web/public/stage_view.js +39 -24
- data/lib/samagotchi/web/public/verify_preset.js +5 -1
- data/lib/samagotchi/web/public/worker_features.js +14 -0
- data/lib/samagotchi/working_set.rb +3 -2
- metadata +3 -1
|
@@ -18,6 +18,9 @@ module Samagotchi
|
|
|
18
18
|
class ToolkitSuggest
|
|
19
19
|
FILE = "toolkit_suggestions.jsonl"
|
|
20
20
|
QUESTION_ID = "toolkit"
|
|
21
|
+
# The defer sentinel: the choice "There is no task yet", asked as a
|
|
22
|
+
# criterion, never offered as a kit, and hidden from the web's picker.
|
|
23
|
+
UNDECIDED = "undecided"
|
|
21
24
|
# Its saved asks' name (SystemOne::Runs).
|
|
22
25
|
JUDGMENT = "toolkit.suggest"
|
|
23
26
|
PROMPT_MAX = 1500
|
|
@@ -42,7 +45,7 @@ module Samagotchi
|
|
|
42
45
|
# not the whole ask, and the ≥ 2 clause counts what is left.
|
|
43
46
|
def self.candidates(kits, default_name:)
|
|
44
47
|
kits.values.filter_map do |kit|
|
|
45
|
-
next if [default_name.to_s, Toolkit::REVIEW,
|
|
48
|
+
next if [default_name.to_s, Toolkit::REVIEW, UNDECIDED].include?(kit.name)
|
|
46
49
|
next if kit.description.to_s.empty?
|
|
47
50
|
next unless resolves?(kit.name, kits)
|
|
48
51
|
|
|
@@ -62,7 +65,7 @@ module Samagotchi
|
|
|
62
65
|
candidates = candidates(kits, default_name: default.name)
|
|
63
66
|
criteria = candidates.to_h { |kit| ["kit:#{kit.name}", "#{kit.name}: #{kit.description}"] }
|
|
64
67
|
criteria["default"] = "none of the other toolkits fits: the user's everyday default"
|
|
65
|
-
criteria[
|
|
68
|
+
criteria[UNDECIDED] = "There is no task yet; defer this choice"
|
|
66
69
|
question = SystemOne::Question.new(id: QUESTION_ID, type: :choice, instructions: INSTRUCTIONS, criteria: criteria)
|
|
67
70
|
[question, { project: project.to_s, prompt: prompt.to_s[0, PROMPT_MAX] }]
|
|
68
71
|
end
|
|
@@ -81,7 +84,7 @@ module Samagotchi
|
|
|
81
84
|
|
|
82
85
|
messages = Array(session.messages)
|
|
83
86
|
return true unless model_reply?(messages)
|
|
84
|
-
return false unless field(value(last_suggestion), :raw) ==
|
|
87
|
+
return false unless field(value(last_suggestion), :raw) == UNDECIDED
|
|
85
88
|
|
|
86
89
|
current_turn_number = turn_number(messages)
|
|
87
90
|
current_turn_number <= defer_turns.to_i && conversation_chars(messages) / CHARS_PER_TOKEN < defer_tokens.to_i
|
|
@@ -139,7 +142,7 @@ module Samagotchi
|
|
|
139
142
|
decided = raw == "default" || (candidate && confidence && confidence >= threshold.to_f)
|
|
140
143
|
would = if answer.nil?
|
|
141
144
|
"no_judgment"
|
|
142
|
-
elsif raw ==
|
|
145
|
+
elsif raw == UNDECIDED
|
|
143
146
|
"defer"
|
|
144
147
|
elsif raw == "default"
|
|
145
148
|
"default"
|
|
@@ -5,6 +5,7 @@ require_relative "../session"
|
|
|
5
5
|
require_relative "../config"
|
|
6
6
|
require_relative "../model_profile"
|
|
7
7
|
require_relative "../memory_paths"
|
|
8
|
+
require_relative "../guardrails/context"
|
|
8
9
|
require_relative "peers"
|
|
9
10
|
require_relative "delegate_wait"
|
|
10
11
|
require_relative "../child_reports"
|
|
@@ -27,6 +28,9 @@ module Samagotchi
|
|
|
27
28
|
NAME = "delegate"
|
|
28
29
|
MAX_CHILDREN_KEY = "session.max_children"
|
|
29
30
|
MAX_CHILDREN_DEFAULT = 4
|
|
31
|
+
# A path in a task: absolute, ~/ or ../, not glued to a word (a URL's
|
|
32
|
+
# /api is not one) and stopping at quotes, backticks or punctuation.
|
|
33
|
+
PATH_TOKEN = %r{(?<![\w./~-])(?:~/|\.\./|/(?!/))[^\s`'"<>()\[\]{},;&|]*}
|
|
30
34
|
# A child spawned this many seconds ago counts as running even before
|
|
31
35
|
# its worker holds the owner lock: two delegate calls in one model
|
|
32
36
|
# message come milliseconds apart, and the first child's worker is
|
|
@@ -60,19 +64,19 @@ module Samagotchi
|
|
|
60
64
|
|
|
61
65
|
cwd = cwd.to_s.strip
|
|
62
66
|
toolkit = toolkit.to_s.strip
|
|
63
|
-
child_id,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
child_id, warnings = if session.to_s.strip.empty?
|
|
68
|
+
start_child(task, parent: parent, model: model, cwd: cwd, toolkit: toolkit, state_dir: sd,
|
|
69
|
+
peers: peers)
|
|
70
|
+
elsif !cwd.empty?
|
|
71
|
+
"Error: cwd starts a new child; a follow-up with session keeps the child's folder"
|
|
72
|
+
elsif !toolkit.empty?
|
|
73
|
+
"Error: toolkit starts a new child; a follow-up keeps the child's toolkit"
|
|
74
|
+
else
|
|
75
|
+
follow_up(task, session: session.to_s.strip, parent: parent, state_dir: sd)
|
|
76
|
+
end
|
|
73
77
|
return child_id if child_id.start_with?("Error:")
|
|
74
78
|
|
|
75
|
-
note = warning
|
|
79
|
+
note = Array(warnings).map { |warning| "Warning: #{warning}\n" }.join
|
|
76
80
|
if wait
|
|
77
81
|
result = DelegateWait.call(child_id, peers: peers, timeout: timeout)
|
|
78
82
|
return RefText.wrap(note + result, result.respond_to?(:ref_path) ? result.ref_path : nil)
|
|
@@ -114,7 +118,8 @@ module Samagotchi
|
|
|
114
118
|
private_class_method :full_hint
|
|
115
119
|
|
|
116
120
|
# @param toolkit [String] a kit's name, "" for config's toolkit.child
|
|
117
|
-
# @return [String] the new child's id, or an Error: line
|
|
121
|
+
# @return [String, Array<String>] the new child's id, or an Error: line,
|
|
122
|
+
# and its warnings (each without the "Warning: " prefix)
|
|
118
123
|
def self.start_child(task, parent:, model:, cwd:, toolkit:, state_dir:, peers:)
|
|
119
124
|
if parent.parent_id
|
|
120
125
|
return "Error: this session is a delegate of #{parent.parent_id}; delegated sessions don't delegate further"
|
|
@@ -142,10 +147,80 @@ module Samagotchi
|
|
|
142
147
|
model_name: child_model(model, parent), memories: CHILD_MEMORIES,
|
|
143
148
|
parent_id: parent.id, delegate: true, setup: setup, state_dir: state_dir)
|
|
144
149
|
DelegateWait.mark_started(parent.id, child, state_dir: state_dir)
|
|
145
|
-
|
|
150
|
+
# The line for a task that names a worktree while the child runs in
|
|
151
|
+
# the parent's folder (no cwd: given): the child still starts.
|
|
152
|
+
[child.id, [child.model_warning, other_checkout(task, folder, parent: parent, child_id: child.id,
|
|
153
|
+
no_cwd: cwd.empty?)].compact]
|
|
146
154
|
end
|
|
147
155
|
private_class_method :start_child
|
|
148
156
|
|
|
157
|
+
# A new child with no cwd: its task may name another checkout of this
|
|
158
|
+
# repository (a worktree the parent meant to pass as cwd:), which makes
|
|
159
|
+
# every write there an ask for the user (child-boundary). One warning
|
|
160
|
+
# line, however many are named; nil when the task names none, or names
|
|
161
|
+
# only the checkout holding the child's folder (or a subfolder of it).
|
|
162
|
+
# Never raises: a started child must not come back as an Error:.
|
|
163
|
+
# @return [String, nil]
|
|
164
|
+
def self.other_checkout(task, folder, parent:, child_id:, no_cwd:)
|
|
165
|
+
return nil unless no_cwd
|
|
166
|
+
|
|
167
|
+
checkout = foreign_checkout(task, folder)
|
|
168
|
+
return nil unless checkout
|
|
169
|
+
|
|
170
|
+
Log.info(:worker, "delegate_other_checkout", parent: parent.id[0, 8])
|
|
171
|
+
"this child runs in #{folder}, but its task names #{checkout}. If it should work there, stop it " \
|
|
172
|
+
"(chi sessions stop #{child_id}) and call delegate again without session, with cwd: #{checkout}."
|
|
173
|
+
rescue StandardError
|
|
174
|
+
nil
|
|
175
|
+
end
|
|
176
|
+
private_class_method :other_checkout
|
|
177
|
+
|
|
178
|
+
# The checkout of +folder+'s repository that the task names and that is
|
|
179
|
+
# not the one holding +folder+: the first path token in the task that
|
|
180
|
+
# belongs to one (the deepest containing it), else nil. Reads files
|
|
181
|
+
# only, no git process, so a spec stubbing Process.spawn is unaffected.
|
|
182
|
+
# @return [String, nil] an absolute checkout folder
|
|
183
|
+
def self.foreign_checkout(task, folder)
|
|
184
|
+
common = MemoryPaths.common_git_dir(folder)
|
|
185
|
+
return nil unless common
|
|
186
|
+
|
|
187
|
+
checkouts = Guardrails::GitInfo.checkouts(common).map { |checkout| File.realpath(checkout) }
|
|
188
|
+
own = deepest_checkout(File.realpath(folder), checkouts)
|
|
189
|
+
task.to_s.scan(PATH_TOKEN) do |token|
|
|
190
|
+
path = existing_ancestor(File.expand_path(token.sub(/[.:!?]+\z/, ""), folder))
|
|
191
|
+
next if path.nil?
|
|
192
|
+
|
|
193
|
+
found = deepest_checkout(path, checkouts)
|
|
194
|
+
return found if found && found != own
|
|
195
|
+
end
|
|
196
|
+
nil
|
|
197
|
+
end
|
|
198
|
+
private_class_method :foreign_checkout
|
|
199
|
+
|
|
200
|
+
# The checkout containing +path+, matched by whole components (so
|
|
201
|
+
# /x/app is not found in /x/app-fix): the deepest, so a nested worktree's
|
|
202
|
+
# path belongs to that worktree, not to main; nil when none does.
|
|
203
|
+
def self.deepest_checkout(path, checkouts)
|
|
204
|
+
checkouts.select { |checkout| within?(path, checkout) }.max_by { |checkout| checkout.count("/") }
|
|
205
|
+
end
|
|
206
|
+
private_class_method :deepest_checkout
|
|
207
|
+
|
|
208
|
+
# +path+'s longest ancestor that exists, realpathed (a worktree not made
|
|
209
|
+
# yet still points at its parent folder); nil when nothing above it does.
|
|
210
|
+
def self.existing_ancestor(path)
|
|
211
|
+
dir = path
|
|
212
|
+
until File.exist?(dir)
|
|
213
|
+
parent = File.dirname(dir)
|
|
214
|
+
return nil if parent == dir
|
|
215
|
+
|
|
216
|
+
dir = parent
|
|
217
|
+
end
|
|
218
|
+
File.realpath(dir)
|
|
219
|
+
rescue StandardError
|
|
220
|
+
nil
|
|
221
|
+
end
|
|
222
|
+
private_class_method :existing_ancestor
|
|
223
|
+
|
|
149
224
|
# The Error: line for a toolkit name the parent doesn't know
|
|
150
225
|
# (Peers#toolkit_names: its built-in, config and plugin kits), nil
|
|
151
226
|
# when it knows it, none was given, or the peers can't tell (a bare
|
|
@@ -126,8 +126,7 @@ module Samagotchi
|
|
|
126
126
|
# @param env [Hash] the XDG env the memories dir resolves from
|
|
127
127
|
def self.scoped_index(scope, env: ENV)
|
|
128
128
|
dir = memories_dir(scope, env: env)
|
|
129
|
-
|
|
130
|
-
return File.read(index_path, encoding: "UTF-8") if File.exist?(index_path)
|
|
129
|
+
return read_text(File.join(dir, "#{MEMORY_INDEX}.md")) if File.file?(File.join(dir, "#{MEMORY_INDEX}.md"))
|
|
131
130
|
|
|
132
131
|
files = Dir.glob(File.join(dir, "*.md")).sort
|
|
133
132
|
return "No memories stored yet." if files.empty?
|
|
@@ -135,6 +134,17 @@ module Samagotchi
|
|
|
135
134
|
"Stored memories (no index yet):\n" + files.map { |f| File.basename(f, ".md") }.join("\n")
|
|
136
135
|
end
|
|
137
136
|
|
|
137
|
+
# A text file from a memories dir, safe to match: a hand-edited index
|
|
138
|
+
# can hold a byte that isn't valid UTF-8, and a regex on it raises.
|
|
139
|
+
def self.read_text(path)
|
|
140
|
+
return "" unless File.file?(path)
|
|
141
|
+
|
|
142
|
+
text = File.read(path, encoding: "UTF-8")
|
|
143
|
+
text.valid_encoding? ? text : text.scrub
|
|
144
|
+
rescue StandardError
|
|
145
|
+
""
|
|
146
|
+
end
|
|
147
|
+
|
|
138
148
|
def self.memory_path(entry_name, scope)
|
|
139
149
|
File.join(memories_dir(scope), "#{entry_name}.md")
|
|
140
150
|
end
|
data/lib/samagotchi/version.rb
CHANGED
data/lib/samagotchi/web/app.rb
CHANGED
|
@@ -1099,7 +1099,7 @@ module Samagotchi
|
|
|
1099
1099
|
|
|
1100
1100
|
# Kits the web never offers: the participants' boundary, a delegate
|
|
1101
1101
|
# child's, and ToolkitSuggest's defer sentinel.
|
|
1102
|
-
PICKER_HIDDEN_KITS = [Toolkit::REVIEW, Toolkit::CHILD,
|
|
1102
|
+
PICKER_HIDDEN_KITS = [Toolkit::REVIEW, Toolkit::CHILD, ToolkitSuggest::UNDECIDED].freeze
|
|
1103
1103
|
|
|
1104
1104
|
# The start page's toolkit picker: {default:, suggest:, kits: [{name,
|
|
1105
1105
|
# description?}]}. Built-in and config kits only (a bundle's load in
|
|
@@ -433,6 +433,8 @@ const questionCards = createQuestionCards({
|
|
|
433
433
|
renderMarkdown,
|
|
434
434
|
linkRefs: linkRefsIn,
|
|
435
435
|
pairRefs: pairRefsIn,
|
|
436
|
+
// The bar's chip reads questionCards.pendingQuestion() (sessionWaits).
|
|
437
|
+
onPending: () => store.touch("infoBar"),
|
|
436
438
|
});
|
|
437
439
|
// The history's bubbles (bubbles.js): output, end lines, every client's
|
|
438
440
|
// prompts, the recap, warnings and notices, command and note bubbles.
|
|
@@ -1508,11 +1510,17 @@ async function restartWorker() {
|
|
|
1508
1510
|
|
|
1509
1511
|
// The session bar (info_bar_model.js sessionBar): its buttons, and the
|
|
1510
1512
|
// info line rendered by info_bar.js.
|
|
1513
|
+
// The open session waits on the user: its card is up, or its summary says so
|
|
1514
|
+
// (not for a question answered here: the summary is a refresh behind).
|
|
1515
|
+
function sessionWaits() {
|
|
1516
|
+
const summary = waitingOn(store.sessions.find((s) => s.id === store.selected));
|
|
1517
|
+
return !!((summary && !questionCards.isResolved(summary.id)) || questionCards.pendingQuestion());
|
|
1518
|
+
}
|
|
1511
1519
|
function updateInfoBar() {
|
|
1512
1520
|
annotateBar?.refresh();
|
|
1513
1521
|
const { buttons, bar } = sessionBar({
|
|
1514
1522
|
id: store.selected, state: store.current, sessions: store.sessions, versions, cardTitle: (s) => lists.cardTitle(s),
|
|
1515
|
-
continuing: sessionActions.continuing, restarting: restartingIds, streaming: !!streamControl, running: liveTurn.running,
|
|
1523
|
+
continuing: sessionActions.continuing, restarting: restartingIds, streaming: !!streamControl, running: liveTurn.running, waiting: sessionWaits(),
|
|
1516
1524
|
workingSet: workingSet ? workingSet.chip() : undefined, participants: participantsControl.chip(),
|
|
1517
1525
|
});
|
|
1518
1526
|
const stopBtn = document.getElementById("infoStopBtn");
|
|
@@ -1947,7 +1955,7 @@ const composer = mountComposer({
|
|
|
1947
1955
|
fold: {
|
|
1948
1956
|
infoBarEl: $("#infoBar"),
|
|
1949
1957
|
session: () => store.selected,
|
|
1950
|
-
waiting:
|
|
1958
|
+
waiting: sessionWaits,
|
|
1951
1959
|
allViewOpen,
|
|
1952
1960
|
lightboxOpen: () => !lightboxEl.hidden,
|
|
1953
1961
|
},
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
// unfold is saved per browser (chi_composer_collapsed); an archived
|
|
4
4
|
// session opens folded for that visit; the page expanding it by itself (a
|
|
5
5
|
// focus, a restored line, a quote) opens it for the visit only. A visit is
|
|
6
|
-
// one select() call.
|
|
6
|
+
// one select() call. A card's text field with the focus on a narrow or touch
|
|
7
|
+
// screen folds it for that time, on top of all of these (+cardField+): the
|
|
8
|
+
// keyboard is up and the card needs the rows; nothing is saved.
|
|
7
9
|
|
|
8
10
|
export const COMPOSER_FOLD_KEY = "chi_composer_collapsed";
|
|
9
11
|
|
|
10
12
|
// Whether the composer is folded: the saved choice or an archived visit,
|
|
11
13
|
// unless this visit opened it.
|
|
12
|
-
export function composerFolded({ saved, archivedVisit, visitOpen }) {
|
|
14
|
+
export function composerFolded({ saved, archivedVisit, visitOpen, cardField = false }) {
|
|
15
|
+
if (cardField) return true;
|
|
13
16
|
if (visitOpen) return false;
|
|
14
17
|
return !!saved || !!archivedVisit;
|
|
15
18
|
}
|
|
@@ -7,6 +7,13 @@ import { readStored, removeStored, writeStored } from "./storage.js";
|
|
|
7
7
|
// the box's height (fitPrompt) and the grip's floor (+floor+ / +setFloor+), which
|
|
8
8
|
// fitPrompt reads; the floor is saved under GRIP_KEY.
|
|
9
9
|
export const GRIP_KEY = "chi_composer_floor";
|
|
10
|
+
// A card's text field with the focus folds the composer on these screens.
|
|
11
|
+
const CARD_FIELD_SCREEN = "(max-width: 600px), (hover: none) and (pointer: coarse)";
|
|
12
|
+
const CARD_FIELD = '.bubble.question input[type="text"], .bubble.continue input[type="text"]';
|
|
13
|
+
// Whether it still has the focus is looked at this often, twice before the
|
|
14
|
+
// composer comes back: a field an answer disables or removes fires no blur,
|
|
15
|
+
// and a tap on Submit must land before the card moves under the finger.
|
|
16
|
+
const CARD_FIELD_CHECK_MS = 150;
|
|
10
17
|
|
|
11
18
|
// +session+: the open session's id, or null (the start page). +draft+,
|
|
12
19
|
// +waiting+, +allViewOpen+, +lightboxOpen+: what the page shows now.
|
|
@@ -36,6 +43,9 @@ export function createComposerGrip({
|
|
|
36
43
|
// first getSession answer).
|
|
37
44
|
const newFoldVisit = () => ({ open: false, archived: false, decided: false });
|
|
38
45
|
let foldVisit = newFoldVisit();
|
|
46
|
+
// The card's text field folding the composer now (watchCardField), or null.
|
|
47
|
+
let cardField = null;
|
|
48
|
+
let cardFieldWatch = null;
|
|
39
49
|
|
|
40
50
|
function cancelPendingFold() {
|
|
41
51
|
if (!pendingFold) return;
|
|
@@ -175,7 +185,7 @@ export function createComposerGrip({
|
|
|
175
185
|
return readStored(COMPOSER_FOLD_KEY) === "1";
|
|
176
186
|
}
|
|
177
187
|
function isComposerFolded() {
|
|
178
|
-
return !!session() && composerFolded({ saved: composerFoldSaved(), archivedVisit: foldVisit.archived, visitOpen: foldVisit.open });
|
|
188
|
+
return !!session() && composerFolded({ saved: composerFoldSaved(), archivedVisit: foldVisit.archived, visitOpen: foldVisit.open, cardField: !!cardField });
|
|
179
189
|
}
|
|
180
190
|
function applyComposerFolded() {
|
|
181
191
|
const folded = isComposerFolded();
|
|
@@ -187,9 +197,37 @@ export function createComposerGrip({
|
|
|
187
197
|
if (was && !folded) fitPrompt();
|
|
188
198
|
drawFoldControls();
|
|
189
199
|
}
|
|
200
|
+
// A card's text field took the focus: the composer folds until it lets go.
|
|
201
|
+
// On top of the fold's state, which it never writes: the saved choice and
|
|
202
|
+
// the visit's come back as they were, and the box keeps its draft. Only the
|
|
203
|
+
// reader's own focus gets here while a draft is there: a card doesn't take
|
|
204
|
+
// the focus then (question_cards.js focusWhenIdle).
|
|
205
|
+
function watchCardField(field) {
|
|
206
|
+
releaseCardField();
|
|
207
|
+
cardField = field;
|
|
208
|
+
let missed = 0;
|
|
209
|
+
cardFieldWatch = setInterval(() => {
|
|
210
|
+
const held = doc.activeElement === field && !field.disabled && field.isConnected;
|
|
211
|
+
missed = held ? 0 : missed + 1;
|
|
212
|
+
if (missed < 2) return;
|
|
213
|
+
releaseCardField();
|
|
214
|
+
applyComposerFolded();
|
|
215
|
+
}, CARD_FIELD_CHECK_MS);
|
|
216
|
+
applyComposerFolded();
|
|
217
|
+
}
|
|
218
|
+
function releaseCardField() {
|
|
219
|
+
clearInterval(cardFieldWatch);
|
|
220
|
+
cardFieldWatch = null;
|
|
221
|
+
cardField = null;
|
|
222
|
+
}
|
|
223
|
+
doc.addEventListener("focusin", (e) => {
|
|
224
|
+
if (!session() || !e.target?.matches?.(CARD_FIELD) || !win.matchMedia?.(CARD_FIELD_SCREEN).matches) return;
|
|
225
|
+
watchCardField(e.target);
|
|
226
|
+
});
|
|
190
227
|
// The user's own fold or unfold (the grip, typing): saved, unless this
|
|
191
228
|
// is an archived visit (both are for the visit then).
|
|
192
229
|
function setComposerFolded(folded) {
|
|
230
|
+
releaseCardField();
|
|
193
231
|
if (foldVisit.archived) {
|
|
194
232
|
foldVisit.open = !folded;
|
|
195
233
|
} else {
|
|
@@ -200,7 +238,11 @@ export function createComposerGrip({
|
|
|
200
238
|
}
|
|
201
239
|
// The page opens it for this visit: nothing saved.
|
|
202
240
|
function openForVisit() {
|
|
203
|
-
|
|
241
|
+
releaseCardField();
|
|
242
|
+
if (!isComposerFolded()) {
|
|
243
|
+
applyComposerFolded();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
204
246
|
foldVisit.open = true;
|
|
205
247
|
applyComposerFolded();
|
|
206
248
|
}
|
|
@@ -264,6 +306,7 @@ export function createComposerGrip({
|
|
|
264
306
|
drawFoldControls,
|
|
265
307
|
// A new visit (select(), the start page): nothing opened, not decided.
|
|
266
308
|
newVisit() {
|
|
309
|
+
releaseCardField();
|
|
267
310
|
foldVisit = newFoldVisit();
|
|
268
311
|
applyComposerFolded();
|
|
269
312
|
},
|
|
@@ -393,10 +393,8 @@ button.system-one-wrong,.system-one-wrong.marked{flex:none;padding:1px 6px;borde
|
|
|
393
393
|
.outline-fold:hover{color:var(--text-muted)}
|
|
394
394
|
.turn-work.outline>.gen.folded.unfolded{margin-left:var(--step-indent)}
|
|
395
395
|
.gen-text{margin-top:6px;white-space:pre-wrap;word-break:break-word;font-size:15px;line-height:1.55}
|
|
396
|
-
/* The live step's narration box: the complete sentences so far, one per line, three visual lines high (3 × the 1.55 line-height), scrolled to the newest;
|
|
396
|
+
/* The live step's narration box: the complete sentences so far, one per line, three visual lines high (3 × the 1.55 line-height), scrolled to the newest; a new line appears at once (its fade was most of a streaming answer's animation cost, docs/internals/web-frontend.md, Frames). */
|
|
397
397
|
.gen-text.streaming>.narration{max-height:4.65em;overflow:auto;scrollbar-width:thin;white-space:normal}
|
|
398
|
-
.narration>.sentence{animation:fadeIn 160ms ease}
|
|
399
|
-
@media (prefers-reduced-motion:reduce){.narration>.sentence{animation:none}}
|
|
400
398
|
.gen:not(.live) .gen-text{font-size:14px;color:var(--text-2)}
|
|
401
399
|
.gen-text:empty{display:none}
|
|
402
400
|
.gen .activity-body{margin-top:6px}
|
|
@@ -528,7 +526,7 @@ button.system-one-wrong,.system-one-wrong.marked{flex:none;padding:1px 6px;borde
|
|
|
528
526
|
.question-relayed a{color:var(--text);font-weight:600}
|
|
529
527
|
.approval-tool{font-weight:700;color:var(--text);margin-bottom:4px}
|
|
530
528
|
.approval-what{margin:0 0 6px;padding:8px 10px;background:var(--bg-inset);border:1px solid var(--warn-border);border-radius:6px;white-space:pre-wrap;word-break:break-all;color:var(--warn-bright);font-size:12.5px}
|
|
531
|
-
.approval-where,.approval-why{font-size:12px;color:var(--text-muted);
|
|
529
|
+
.approval-where,.approval-why{font-size:12px;color:var(--text-muted);overflow-wrap:anywhere}
|
|
532
530
|
.approval-why{color:var(--warn-text)}
|
|
533
531
|
.approval-label{color:var(--text-faint)}
|
|
534
532
|
/* A diff (diff_view.js): the approval card's dry run and a tool row's change. */
|
|
@@ -815,7 +813,7 @@ body.stage-view .turn-stage{position:absolute;left:0;right:0;bottom:100%;margin-
|
|
|
815
813
|
its room, read from the top. */
|
|
816
814
|
.ts-asking{max-height:calc(var(--stage-max,60vh) * .35);overflow:auto;scrollbar-width:thin;white-space:pre-wrap;overflow-wrap:anywhere;font-size:14px;line-height:1.55;color:var(--narr);border-left:2px solid var(--border-strong);padding-left:10px}
|
|
817
815
|
/* The question room (stage_view.js drawRoom): a model's own question whose asking text overflows that cap. The slot loses its
|
|
818
|
-
cap and its own scroll, and the stage's one scroll covers the whole reply (the stage's cap rises
|
|
816
|
+
cap and its own scroll, and the stage's one scroll covers the whole reply (the stage's cap rises until the next step, stage_frame.js).
|
|
819
817
|
--stage-max also scales the extras, the cloud and the queued slot: a ceiling only, content that fit stays as it is. */
|
|
820
818
|
.turn-stage.question-room .ts-asking{max-height:none;overflow:visible}
|
|
821
819
|
.turn-stage.asking .ts-headline{display:none}
|
|
@@ -843,7 +841,7 @@ body.stage-view .turn-stage{position:absolute;left:0;right:0;bottom:100%;margin-
|
|
|
843
841
|
.turn-stage.waiting :is(.ts-extras,.ts-tail){max-height:none;overflow:visible}
|
|
844
842
|
/* The card under the live slots stays put from its arrival to the next step: waiting, the slots keep at least their running
|
|
845
843
|
height (the asking text in the headline's place, the tool row's and the trail's room left blank); answered, the height
|
|
846
|
-
they had while waiting (stage_view.js). */
|
|
844
|
+
they had while waiting. The next step lets it go with the frame (stage_view.js releaseHeldWait). */
|
|
847
845
|
.turn-stage.waiting .ts-live{min-height:var(--ts-live-h)}
|
|
848
846
|
.turn-stage.held-wait:not(.waiting) .ts-live{min-height:max(var(--ts-live-h),var(--live-held,0px))}
|
|
849
847
|
/* A 1 px mark at the tallest content's end, so the scroll extent never drops while a turn runs (stage_view.js fitFrame). */
|
|
@@ -1082,6 +1080,9 @@ button.ws-row:hover:not(:disabled){filter:none}@media(hover:hover){button.ws-row
|
|
|
1082
1080
|
.ts-defer{display:none}
|
|
1083
1081
|
.ts-cancel{padding:1px 8px}
|
|
1084
1082
|
.ts-trail-item{max-width:24ch}
|
|
1083
|
+
/* An approval's Submit in sight on a phone: its folder, reason and rows a little tighter. */
|
|
1084
|
+
.approval-where,.approval-why{line-height:1.35}
|
|
1085
|
+
.bubble.question.approval .question-option{padding:5px 8px}
|
|
1085
1086
|
}
|
|
1086
1087
|
@media (prefers-reduced-motion:reduce){.turn-stage.enter,.ts-arrive,.ts-headline.fresh,.ts-tick.running,.ts-mark,.ts-spin,.turn-work:not(.done) .activity-status.running::before{animation:none}.turn-stage.leaving,#center.reserve-easing #history{transition:none}}
|
|
1087
1088
|
#infoBar{display:flex;background:transparent;border-radius:0 0 16px 16px;color:var(--text-2);gap:10px;align-items:flex-start;flex-wrap:wrap;flex-shrink:0;transition:opacity 280ms ease}
|
|
@@ -1738,6 +1739,7 @@ body.all-view #allHead{display:flex}
|
|
|
1738
1739
|
.card .stopped-badge,.family-row .stopped-badge{font-size:11px;font-weight:600;padding:1px 7px;border-radius:999px;white-space:nowrap;flex-shrink:0;background:var(--warn);color:var(--bg)}
|
|
1739
1740
|
.status.running{background:var(--ok-bg);color:var(--ok-text)}
|
|
1740
1741
|
.status.idle{background:var(--bg-raised)}
|
|
1742
|
+
.status.waiting{background:var(--warn-bg);color:var(--warn-text)}
|
|
1741
1743
|
.status.completed{background:var(--accent-bg);color:var(--accent)}
|
|
1742
1744
|
.status.error{background:var(--danger-bg-dim);color:var(--danger-text)}
|
|
1743
1745
|
.card .owner,.family-row .owner{font-size:11px;padding:2px 6px;border-radius:999px}
|
|
@@ -65,11 +65,12 @@ export function infoButtons({ id, state, chain, archived, continuing, streaming
|
|
|
65
65
|
// @param badge workerBadgeFor's, or null
|
|
66
66
|
// @param restarting whether this session's Restart is under way
|
|
67
67
|
// @param running whether its turn runs (the session clock ticks)
|
|
68
|
+
// @param waiting whether the session waits on the user (app.js sessionWaits)
|
|
68
69
|
// @param workingSet web.working_set on: the chip's {n, changed} (n 0 while
|
|
69
70
|
// the set is empty); undefined: off (the mem chip shows)
|
|
70
71
|
// @param participants the participants chip (participants_panel.js
|
|
71
72
|
// chipModel), null before the list is read
|
|
72
|
-
export function infoBarModel({ id, state, sessions, chain, cardTitle, badge, restarting, running, workingSet = undefined, participants = null }) {
|
|
73
|
+
export function infoBarModel({ id, state, sessions, chain, cardTitle, badge, restarting, running, waiting = false, workingSet = undefined, participants = null }) {
|
|
73
74
|
const tokens = state.timing.tokens;
|
|
74
75
|
const ctxTip = ctxBarTip(tokens, state.timing.memoryIndex,
|
|
75
76
|
{ tokens: state.ctxWindow, source: state.ctxWindowSource, pct: state.ctxPct,
|
|
@@ -85,7 +86,8 @@ export function infoBarModel({ id, state, sessions, chain, cardTitle, badge, res
|
|
|
85
86
|
const parentChip = delegatedBy(state.parentId, sessions.find((x) => x.id === state.parentId) || null);
|
|
86
87
|
return {
|
|
87
88
|
id,
|
|
88
|
-
|
|
89
|
+
// Its turn runs but a card blocks it: the word `chi sessions list` has for it.
|
|
90
|
+
status: running && waiting ? "waiting" : state.status,
|
|
89
91
|
model: modelLabel(state.model, ...(state.served || [])),
|
|
90
92
|
// A link of a session chain: ← the previous link, → the next one (each
|
|
91
93
|
// only while the list holds it).
|
|
@@ -122,12 +124,12 @@ export function infoBarModel({ id, state, sessions, chain, cardTitle, badge, res
|
|
|
122
124
|
// The whole bar for the open session +id+ (null: the start page, no line).
|
|
123
125
|
// @param sessions the page's list; +continuing+, +restarting+: Sets of ids
|
|
124
126
|
// @return {buttons, bar}
|
|
125
|
-
export function sessionBar({ id, state, sessions, versions, cardTitle, continuing, restarting, streaming, running, workingSet = undefined, participants = null }) {
|
|
127
|
+
export function sessionBar({ id, state, sessions, versions, cardTitle, continuing, restarting, streaming, running, waiting = false, workingSet = undefined, participants = null }) {
|
|
126
128
|
const chain = id ? chainNeighbours(sessions, id, { continues: state.continues }) : { prev: null, next: null };
|
|
127
129
|
const archived = !!sessions.find((s) => s.id === id)?.archived;
|
|
128
130
|
const buttons = infoButtons({ id, state, chain, archived, continuing: continuing.has(id), streaming });
|
|
129
131
|
if (!id) return { buttons, bar: null };
|
|
130
132
|
const badge = workerBadgeFor(id, state, versions);
|
|
131
|
-
const bar = infoBarModel({ id, state, sessions, chain, cardTitle, badge, restarting: restarting.has(id), running, workingSet, participants });
|
|
133
|
+
const bar = infoBarModel({ id, state, sessions, chain, cardTitle, badge, restarting: restarting.has(id), running, waiting, workingSet, participants });
|
|
132
134
|
return { buttons, bar };
|
|
133
135
|
}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
// blank the page.
|
|
19
19
|
|
|
20
20
|
import { quoteBlock } from "./annotations.js";
|
|
21
|
+
import { isParticipantAuthor } from "./participant_model.js";
|
|
21
22
|
|
|
22
23
|
// Where a node on the participant page came from: { kind, root, … } where
|
|
23
24
|
// root is the element a selection is clipped to, or null.
|
|
@@ -69,7 +70,7 @@ export function participantQuote(text, source) {
|
|
|
69
70
|
// participant route's: mine, author, author_name, automatic).
|
|
70
71
|
export function messageAuthorData(message) {
|
|
71
72
|
if (message?.mine) return { by: "me" };
|
|
72
|
-
if (message?.author) return { by: "participant", name: message.author_name || "" };
|
|
73
|
+
if (isParticipantAuthor(message?.author)) return { by: "participant", name: message.author_name || "" };
|
|
73
74
|
if (message?.automatic) return { by: "automatic" };
|
|
74
75
|
return { by: "owner" };
|
|
75
76
|
}
|