samagotchi 0.180.0 → 0.181.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 +46 -1
- data/bin/chi +10 -0
- data/docs/architecture.md +1 -1
- data/docs/bundles.md +7 -2
- data/docs/cli.md +16 -9
- data/docs/configuration.md +24 -4
- data/docs/internals/anthropic.md +4 -3
- data/docs/internals/background-tasks.md +2 -0
- data/docs/internals/block-renderers.md +9 -6
- data/docs/internals/objectives.md +9 -4
- data/docs/internals/web-frontend.md +67 -7
- data/docs/internals/working-set.md +24 -5
- data/docs/memory.md +3 -0
- data/docs/plugins.md +11 -4
- data/docs/sessions.md +1 -1
- data/docs/testing.md +1 -1
- data/lib/samagotchi/bundle_command.rb +4 -1
- data/lib/samagotchi/bundles/known-names/manifest.yml +2 -2
- data/lib/samagotchi/bundles/known-names/plugin.rb +4 -3
- data/lib/samagotchi/bundles/system/config_modification_protocol.md +3 -2
- data/lib/samagotchi/bundles/system/manifest.yml +2 -2
- data/lib/samagotchi/client.rb +8 -1
- data/lib/samagotchi/config.rb +6 -1
- data/lib/samagotchi/core_notice.rb +44 -0
- data/lib/samagotchi/host_address.rb +7 -0
- data/lib/samagotchi/host_config.rb +8 -5
- data/lib/samagotchi/host_registry.rb +26 -8
- data/lib/samagotchi/kernel_loop.rb +3 -2
- data/lib/samagotchi/llm/adapter_common.rb +3 -2
- data/lib/samagotchi/llm/adapters.rb +2 -1
- data/lib/samagotchi/llm/anthropic_assembly.rb +5 -0
- data/lib/samagotchi/llm/anthropic_messages.rb +6 -2
- data/lib/samagotchi/llm/chat_loop.rb +6 -5
- data/lib/samagotchi/llm/errors.rb +41 -3
- data/lib/samagotchi/llm/http.rb +85 -22
- data/lib/samagotchi/llm/openai_chat.rb +20 -3
- data/lib/samagotchi/memory_bundle/status.rb +2 -1
- data/lib/samagotchi/objectives.rb +7 -2
- data/lib/samagotchi/owner_lock.rb +2 -0
- data/lib/samagotchi/plugin/api.rb +4 -1
- data/lib/samagotchi/plugin/context.rb +9 -0
- data/lib/samagotchi/plugin/peer.rb +32 -15
- data/lib/samagotchi/plugin/tool_spec.rb +13 -2
- data/lib/samagotchi/row_refs.rb +14 -3
- data/lib/samagotchi/session_chain/delete.rb +6 -6
- data/lib/samagotchi/session_manager/removal.rb +2 -2
- data/lib/samagotchi/tool_ids.rb +19 -0
- data/lib/samagotchi/tool_runner.rb +8 -4
- data/lib/samagotchi/tools/registry.rb +3 -2
- data/lib/samagotchi/tools/task_runtime.rb +34 -0
- data/lib/samagotchi/turn_stages/objectives.rb +10 -5
- data/lib/samagotchi/version.rb +1 -1
- data/lib/samagotchi/web/public/app.js +10 -14
- data/lib/samagotchi/web/public/block_host.js +20 -20
- data/lib/samagotchi/web/public/block_renderers.css +5 -5
- data/lib/samagotchi/web/public/context_chips.js +3 -4
- data/lib/samagotchi/web/public/images.js +1 -1
- data/lib/samagotchi/web/public/index.html +24 -5
- data/lib/samagotchi/web/public/objectives_strip.js +16 -6
- data/lib/samagotchi/web/public/pan_zoom.js +121 -0
- data/lib/samagotchi/web/public/peer_chip.js +3 -3
- data/lib/samagotchi/web/public/peer_data.js +27 -15
- data/lib/samagotchi/web/public/picture_viewer.js +304 -0
- data/lib/samagotchi/web/public/popover_modal.js +3 -2
- data/lib/samagotchi/web/public/session_view.js +4 -0
- data/lib/samagotchi/web/public/working_set.js +9 -3
- data/lib/samagotchi/web/public/working_set_view.js +28 -11
- data/lib/samagotchi/web/public/ws_cards.js +36 -10
- data/lib/samagotchi/web/public/ws_markdown.js +129 -0
- data/lib/samagotchi/web/public/ws_order.js +48 -0
- data/lib/samagotchi/web/public/ws_peek.js +22 -5
- data/lib/samagotchi/web/public/ws_preview.css +41 -1
- data/lib/samagotchi/web/public/ws_reader.js +35 -6
- data/lib/samagotchi/web/public/ws_sections.js +24 -15
- metadata +6 -1
|
@@ -280,11 +280,11 @@ module Samagotchi
|
|
|
280
280
|
end
|
|
281
281
|
end
|
|
282
282
|
|
|
283
|
-
# The block under the owner lock (kind deleting,
|
|
284
|
-
#
|
|
285
|
-
# under each, held until the block returns: a worker that
|
|
286
|
-
# or a start claimed meanwhile, refuses before anything
|
|
287
|
-
# none takes one midway.
|
|
283
|
+
# The block under the owner lock (kind deleting, with a brief
|
|
284
|
+
# probe-sized wait) of every id with a folder, the starting marker
|
|
285
|
+
# read again under each, held until the block returns: a worker that
|
|
286
|
+
# holds one, or a start claimed meanwhile, refuses before anything
|
|
287
|
+
# goes, and none takes one midway.
|
|
288
288
|
# @raise [SessionManager::DeleteRefused] :worker_running
|
|
289
289
|
def locked(ids, state_dir)
|
|
290
290
|
locks = []
|
|
@@ -292,7 +292,7 @@ module Samagotchi
|
|
|
292
292
|
dir = Session.session_dir(sid, state_dir: state_dir)
|
|
293
293
|
next unless Dir.exist?(dir)
|
|
294
294
|
|
|
295
|
-
lock = OwnerLock.acquire(dir, kind: OwnerLock::DELETING, wait:
|
|
295
|
+
lock = OwnerLock.acquire(dir, kind: OwnerLock::DELETING, wait: OwnerLock::PROBE_WAIT)
|
|
296
296
|
raise SessionManager::DeleteRefused.new(sid, :worker_running) unless lock
|
|
297
297
|
|
|
298
298
|
locks << lock
|
|
@@ -426,7 +426,7 @@ module Samagotchi
|
|
|
426
426
|
# worker takes the session in the middle; the starting marker is read
|
|
427
427
|
# again under it (a resume that claimed the start since the caller's
|
|
428
428
|
# check keeps the session; one after it sees the lock held). Taken
|
|
429
|
-
#
|
|
429
|
+
# briefly, so a worker that took it since the check keeps the session.
|
|
430
430
|
# The lock file goes with the directory; a worker starting after that
|
|
431
431
|
# makes a new one, and finds no session (Session.load). The delete and
|
|
432
432
|
# the retention sweep and failed-continue cleanup use #remove_files.
|
|
@@ -443,7 +443,7 @@ module Samagotchi
|
|
|
443
443
|
# refused after another of the batch went).
|
|
444
444
|
def remove_session_files(id, path, dir, state_dir:, still: nil, locked: false,
|
|
445
445
|
running_tasks: RunningTasks::Policy::IGNORE)
|
|
446
|
-
lock = !locked && Dir.exist?(dir) ? OwnerLock.acquire(dir, kind: OwnerLock::DELETING, wait:
|
|
446
|
+
lock = !locked && Dir.exist?(dir) ? OwnerLock.acquire(dir, kind: OwnerLock::DELETING, wait: OwnerLock::PROBE_WAIT) : nil
|
|
447
447
|
raise DeleteRefused.new(id, :worker_running) if !locked && Dir.exist?(dir) && lock.nil?
|
|
448
448
|
raise DeleteRefused.new(id, :worker_running) if StartingMarker.fresh?(id, state_dir: state_dir)
|
|
449
449
|
raise DeleteRefused.new(id, :changed) if still && !still.call
|
data/lib/samagotchi/tool_ids.rb
CHANGED
|
@@ -34,6 +34,10 @@ module Samagotchi
|
|
|
34
34
|
module ToolIds
|
|
35
35
|
PATTERN = /\At(\d+)\z/
|
|
36
36
|
DERIVED_PREFIX = "e"
|
|
37
|
+
# Thread.current key: the id of the run whose tool handler runs on
|
|
38
|
+
# this thread (ToolRunner#dispatch, #with_current), what a plugin's
|
|
39
|
+
# handler reads as ctx.tool_id.
|
|
40
|
+
CURRENT = :samagotchi_current_tool_id
|
|
37
41
|
|
|
38
42
|
# One run's id in an entry: the id, the run's position (0-based) and
|
|
39
43
|
# whether it was derived.
|
|
@@ -43,6 +47,21 @@ module Samagotchi
|
|
|
43
47
|
|
|
44
48
|
module_function
|
|
45
49
|
|
|
50
|
+
# The id of the run whose handler runs on this thread (#with_current),
|
|
51
|
+
# nil outside one: another thread, a run with no id.
|
|
52
|
+
# @return [String, nil]
|
|
53
|
+
def current = Thread.current[CURRENT]
|
|
54
|
+
|
|
55
|
+
# Run +block+ with #current as +id+ (nil too), the previous one back
|
|
56
|
+
# after it.
|
|
57
|
+
def with_current(id)
|
|
58
|
+
previous = Thread.current[CURRENT]
|
|
59
|
+
Thread.current[CURRENT] = id
|
|
60
|
+
yield
|
|
61
|
+
ensure
|
|
62
|
+
Thread.current[CURRENT] = previous
|
|
63
|
+
end
|
|
64
|
+
|
|
46
65
|
# +count+ ids for runs about to go on +conversation+.
|
|
47
66
|
# @return [Array<String>]
|
|
48
67
|
def next_ids(conversation, count)
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative "tool_activity"
|
|
4
4
|
require_relative "tool_row_fields"
|
|
5
5
|
require_relative "row_refs"
|
|
6
|
+
require_relative "tool_ids"
|
|
6
7
|
require_relative "file_ref"
|
|
7
8
|
require_relative "guardrails"
|
|
8
9
|
require_relative "vision_context"
|
|
@@ -123,7 +124,8 @@ module Samagotchi
|
|
|
123
124
|
# plugin tool's refs); the worker runs in its session's working
|
|
124
125
|
# directory.
|
|
125
126
|
fields = ToolRowFields.for(call[:name], call, cwd: Dir.pwd)
|
|
126
|
-
refs = RowRefs.for(tools && !call[:name].nil? ? tools[call[:name]]&.refs : nil, call, cwd: session_cwd(context)
|
|
127
|
+
refs = RowRefs.for(tools && !call[:name].nil? ? tools[call[:name]]&.refs : nil, call, cwd: session_cwd(context),
|
|
128
|
+
tool_id: tool_id)
|
|
127
129
|
fields[:refs] = refs unless refs.empty?
|
|
128
130
|
started.merge!(fields)
|
|
129
131
|
# The row's clock: tool_call_completed's duration_ms runs from here.
|
|
@@ -147,7 +149,7 @@ module Samagotchi
|
|
|
147
149
|
result = denied(call, verdict, context)
|
|
148
150
|
else
|
|
149
151
|
dispatched_at = @clock.call
|
|
150
|
-
result = dispatch(call, context)
|
|
152
|
+
result = dispatch(call, context, tool_id)
|
|
151
153
|
elapsed_ms = ((@clock.call - dispatched_at) * 1000).round
|
|
152
154
|
end
|
|
153
155
|
diff = file_change(call, before)
|
|
@@ -594,8 +596,10 @@ module Samagotchi
|
|
|
594
596
|
|
|
595
597
|
# KernelLoop#dispatch turns tool errors into "[name] Error: …" itself;
|
|
596
598
|
# this rescue only catches a failing dispatcher.
|
|
597
|
-
|
|
598
|
-
|
|
599
|
+
# The handler runs on this thread with +tool_id+ as ToolIds.current (a
|
|
600
|
+
# plugin's ctx.tool_id), the id its row's refs got too.
|
|
601
|
+
def dispatch(call, context, tool_id = nil)
|
|
602
|
+
ToolIds.with_current(tool_id) { @kernel.dispatch_tool_call(call, context) }
|
|
599
603
|
rescue StandardError => e
|
|
600
604
|
{ output: "[#{call[:name]}] Error: #{e.class}: #{e.message}", activity: nil }
|
|
601
605
|
end
|
|
@@ -32,8 +32,9 @@ module Samagotchi
|
|
|
32
32
|
# @!attribute targets [#call, nil] (call, surface) → what guardrail
|
|
33
33
|
# rules match. #register takes a one-argument preview or targets
|
|
34
34
|
# (call only, a plugin's) and gives it this form (.per_call)
|
|
35
|
-
# @!attribute refs [#call, nil] call
|
|
36
|
-
#
|
|
35
|
+
# @!attribute refs [#call, nil] call (and the run's tool id, when it
|
|
36
|
+
# takes two args: RowRefs.call_with_id) → the row's refs (a
|
|
37
|
+
# plugin's refs:, RowRefs checks what it gives)
|
|
37
38
|
# @!attribute source [String] "core", or the bundle that added it
|
|
38
39
|
# @!attribute layer [Symbol, nil] the LLM context layer the tool
|
|
39
40
|
# belongs to (LLMContextStrategy): offered only in a turn running
|
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require "fileutils"
|
|
4
4
|
require "json"
|
|
5
|
+
require "open3"
|
|
6
|
+
require "pathname"
|
|
5
7
|
require "securerandom"
|
|
6
8
|
require "shellwords"
|
|
7
9
|
require "time"
|
|
8
10
|
require_relative "../atomic_file"
|
|
11
|
+
require_relative "../git_env"
|
|
9
12
|
require_relative "../log"
|
|
10
13
|
require_relative "../process_group"
|
|
11
14
|
require_relative "../spawn_env"
|
|
@@ -77,6 +80,7 @@ module Samagotchi
|
|
|
77
80
|
exit_code_path = File.expand_path(File.join(task_dir, TaskFiles::EXIT_CODE_FILENAME))
|
|
78
81
|
|
|
79
82
|
FileUtils.mkdir_p(task_dir)
|
|
83
|
+
exclude_task_dir
|
|
80
84
|
|
|
81
85
|
# The child writes to it; the ensure below closes the parent's copy.
|
|
82
86
|
output_io = File.open(output_path, "a") # rubocop:disable Style/FileOpen
|
|
@@ -327,6 +331,7 @@ module Samagotchi
|
|
|
327
331
|
record = task.with(command: task.command.to_s.strip, cwd: File.expand_path(cwd.to_s.empty? ? Dir.pwd : cwd),
|
|
328
332
|
pid_started: ProcessGroup.start_time(pid), handed_over_by: ToolNames::Execute::NAME)
|
|
329
333
|
write_record(record)
|
|
334
|
+
exclude_task_dir
|
|
330
335
|
[record, nil]
|
|
331
336
|
rescue StandardError => e
|
|
332
337
|
[nil, "Error: #{e.message}"]
|
|
@@ -535,6 +540,35 @@ module Samagotchi
|
|
|
535
540
|
FileUtils.mkdir_p(TaskFiles.tasks_dir)
|
|
536
541
|
end
|
|
537
542
|
|
|
543
|
+
def exclude_task_dir
|
|
544
|
+
dir = File.realpath(TaskFiles.root || Dir.pwd)
|
|
545
|
+
out, err, status = Open3.capture3(GitEnv::UNSET, "git", "-C", dir, "rev-parse",
|
|
546
|
+
"--show-toplevel", "--git-common-dir")
|
|
547
|
+
unless status.success?
|
|
548
|
+
Log.warn(:turn, "task_exclude_failed", msg: err.strip) unless err.include?("not a git repository")
|
|
549
|
+
return
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
root, common = out.lines.map(&:chomp)
|
|
553
|
+
relative = Pathname.new(dir).relative_path_from(Pathname.new(File.realpath(root))).to_s
|
|
554
|
+
path = relative == "." ? TaskFiles::TASKS_DIR : File.join(relative, TaskFiles::TASKS_DIR)
|
|
555
|
+
raise ArgumentError, "task path contains a newline" if path.match?(/[\r\n]/)
|
|
556
|
+
|
|
557
|
+
pattern = "/#{path.gsub(/([\\*?\[\]])/, '\\\\\1')}/"
|
|
558
|
+
exclude = File.join(File.expand_path(common, dir), "info", "exclude")
|
|
559
|
+
FileUtils.mkdir_p(File.dirname(exclude))
|
|
560
|
+
File.open(exclude, File::RDWR | File::CREAT, 0o666) do |file|
|
|
561
|
+
file.flock(File::LOCK_EX)
|
|
562
|
+
contents = file.read
|
|
563
|
+
next if contents.lines.any? { |line| line.chomp == pattern }
|
|
564
|
+
|
|
565
|
+
file.write("\n") unless contents.empty? || contents.end_with?("\n")
|
|
566
|
+
file.write("#{pattern}\n")
|
|
567
|
+
end
|
|
568
|
+
rescue StandardError => e
|
|
569
|
+
Log.warn(:turn, "task_exclude_failed", error: e.class.name, msg: e.message)
|
|
570
|
+
end
|
|
571
|
+
|
|
538
572
|
def generate_task_id
|
|
539
573
|
loop do
|
|
540
574
|
candidate = "#{Time.now.utc.strftime("%Y%m%d%H%M%S")}-#{SecureRandom.hex(4)}"
|
|
@@ -100,16 +100,21 @@ module Samagotchi
|
|
|
100
100
|
# The session's objectives as the page draws them (Engine#objectives_view),
|
|
101
101
|
# when that differs from the last announced: after an edit (its file
|
|
102
102
|
# written, pending), once a list note is in, at a turn's end (its moves)
|
|
103
|
-
# and after a rollback. A
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
#
|
|
103
|
+
# and after a rollback. A list going away (a rollback or a turn's kept
|
|
104
|
+
# messages past its note) announces once, without items, so the page
|
|
105
|
+
# clears; a session with no list before and after announces nothing.
|
|
106
|
+
# The caller (Engine#announce_objectives) holds the event lock, the one
|
|
107
|
+
# guard of the last view, announces the event and logs a failure: it
|
|
108
|
+
# only informs, never fails a turn.
|
|
107
109
|
# @param view [Hash, nil] the view from Engine#objectives_view
|
|
108
110
|
# @return [Hash, nil] the :objectives_updated event to announce, nil when the view is the same
|
|
109
111
|
def announce(session, view:)
|
|
110
|
-
return if view
|
|
112
|
+
return if view == @announced
|
|
111
113
|
|
|
112
114
|
@announced = view
|
|
115
|
+
# Written out: **nil raises on Ruby 3.3.
|
|
116
|
+
return { type: :objectives_updated, session_id: session.id, items: nil } if view.nil?
|
|
117
|
+
|
|
113
118
|
{ type: :objectives_updated, session_id: session.id, **view }
|
|
114
119
|
end
|
|
115
120
|
|
data/lib/samagotchi/version.rb
CHANGED
|
@@ -131,6 +131,7 @@ import { createMarkdownTip } from "./markdown_tip.js";
|
|
|
131
131
|
import { IMAGES_NOT_HERE } from "./images.js";
|
|
132
132
|
import { withoutStaleParams } from "./stale_params.js";
|
|
133
133
|
import { createViewer } from "./viewer.js";
|
|
134
|
+
import { createPictureViewer, thumbPicture } from "./picture_viewer.js";
|
|
134
135
|
import { createParticipantMain } from "./participant_main.js";
|
|
135
136
|
import { createPeers } from "./peer_data.js";
|
|
136
137
|
import { peerStatusCommand } from "./peer_chip.js";
|
|
@@ -154,6 +155,7 @@ onAuthLost(authLost);
|
|
|
154
155
|
const $ = (s) => document.querySelector(s);
|
|
155
156
|
// Who looks and what they may do (viewer.js): every owner-only control and call asks it.
|
|
156
157
|
const viewer = createViewer(document.body);
|
|
158
|
+
const pictures = createPictureViewer({ el: $("#lightbox") }); // a picture over the page (picture_viewer.js)
|
|
157
159
|
const topStripEl = $("#topStrip");
|
|
158
160
|
const allListEl = $("#allList");
|
|
159
161
|
const historyEl = $("#history");
|
|
@@ -358,7 +360,7 @@ const { renderMarkdown, pairRefsIn, linkRefsIn, applyFinalMarkdown } = markdownP
|
|
|
358
360
|
const wsLine = viewer.can("session_controls") ? (line) => (store.selected ? sendCommand(store.selected, line, { clientId }) : null) : null;
|
|
359
361
|
// What chi has of an item (the owner's): the rows' peek and the reader over the stage (ws_reader.js).
|
|
360
362
|
const wsPreview = document.body.dataset.workingSet === "1" && viewer.can("working_set_items")
|
|
361
|
-
? createWorkingSetPreview({ centerEl: $("#center"), session: () => store.selected, state: () => store.current, sendLine: wsLine }) : null;
|
|
363
|
+
? createWorkingSetPreview({ centerEl: $("#center"), session: () => store.selected, state: () => store.current, sendLine: wsLine, renderMarkdown }) : null;
|
|
362
364
|
const workingSet = document.body.dataset.workingSet === "1" && viewer.can("working_set")
|
|
363
365
|
? createWorkingSet({
|
|
364
366
|
historyEl, stageRoot: () => turnDom.root, state: () => store.current, session: () => store.selected, infoEl: infoTextEl,
|
|
@@ -547,7 +549,7 @@ turnRoots().forEach((root) => root.addEventListener("click", cards.onCardAction)
|
|
|
547
549
|
const sessionView = createSessionView({
|
|
548
550
|
store, historyEl, getSession,
|
|
549
551
|
liveTurn, turnDom, questionCards, shownTexts, objectives, featureGates, markdownTip, workingSet, wsPreview, gapClock,
|
|
550
|
-
bubbles, cards, markdown: markdownPlace, cardRegistry, peerLinks,
|
|
552
|
+
bubbles, cards, markdown: markdownPlace, cardRegistry, peerLinks, pictures,
|
|
551
553
|
capabilities: () => pageCapabilities,
|
|
552
554
|
page: {
|
|
553
555
|
setReviseAnchor, renderInitRow, setMarkdownWarning, setCapabilities, findInTurnRoots, appendToHistory,
|
|
@@ -847,7 +849,7 @@ function applyView() {
|
|
|
847
849
|
// Its chip was in the list just hidden (the strip, or all sessions).
|
|
848
850
|
lists.chainPop.close();
|
|
849
851
|
if (open) {
|
|
850
|
-
lists.familyPop.close(); // the strip
|
|
852
|
+
lists.familyPop.close(); pictures.close(); // the strip and #center (the picture viewer's parent) are hidden there
|
|
851
853
|
// The list is live; only its order can lag (upserts keep cards in
|
|
852
854
|
// place), so the all view opens in the server's order.
|
|
853
855
|
// A new list: the lists' redraw draws the all view (lists.render).
|
|
@@ -1358,7 +1360,6 @@ viewer.control($("#newBtn"), "sessions")?.addEventListener("click", () => {
|
|
|
1358
1360
|
startPage.loadModels({ asked: true });
|
|
1359
1361
|
});
|
|
1360
1362
|
|
|
1361
|
-
const lightboxEl = $("#lightbox");
|
|
1362
1363
|
|
|
1363
1364
|
// The empty box: one line in a session, three on the start page.
|
|
1364
1365
|
function promptMinPx() {
|
|
@@ -1394,7 +1395,7 @@ const composer = mountComposer({
|
|
|
1394
1395
|
session: () => store.selected,
|
|
1395
1396
|
waiting: sessionWaits,
|
|
1396
1397
|
allViewOpen,
|
|
1397
|
-
lightboxOpen: () =>
|
|
1398
|
+
lightboxOpen: () => pictures.isOpen(),
|
|
1398
1399
|
},
|
|
1399
1400
|
});
|
|
1400
1401
|
// Bound here, not hoisted: no top-level code above this line may call them.
|
|
@@ -1427,17 +1428,11 @@ const unqueue = createUnqueue({
|
|
|
1427
1428
|
return true;
|
|
1428
1429
|
},
|
|
1429
1430
|
});
|
|
1430
|
-
turnRoots().forEach((root) => root.addEventListener("click", (e) => { unqueue.onClick(e); }));
|
|
1431
1431
|
turnRoots().forEach((root) => root.addEventListener("click", (e) => {
|
|
1432
|
+
unqueue.onClick(e);
|
|
1432
1433
|
const img = e.target.closest("img.thumb");
|
|
1433
|
-
if (
|
|
1434
|
-
lightboxEl.querySelector("img").src = img.src;
|
|
1435
|
-
lightboxEl.hidden = false;
|
|
1434
|
+
if (img) pictures.open(thumbPicture(img));
|
|
1436
1435
|
}));
|
|
1437
|
-
lightboxEl.addEventListener("click", () => { lightboxEl.hidden = true; });
|
|
1438
|
-
document.addEventListener("keydown", (e) => {
|
|
1439
|
-
if (e.key === "Escape" && !lightboxEl.hidden) lightboxEl.hidden = true;
|
|
1440
|
-
});
|
|
1441
1436
|
|
|
1442
1437
|
// The / autocomplete (command_list.js): the session's commands while the
|
|
1443
1438
|
// composer holds one "/word".
|
|
@@ -1548,7 +1543,8 @@ turnRoots().forEach((root) => installCopy(root));
|
|
|
1548
1543
|
// chi-ui blocks (inline_widgets.js) are a core drawer, ahead of the bundles'
|
|
1549
1544
|
// renderers; a picks' Fill reply only fills the composer.
|
|
1550
1545
|
const widgets = createWidgetDrawer({ roots: turnRoots(), composerText: () => promptEl.value, fillComposer });
|
|
1551
|
-
createBlockHost({ roots: turnRoots(), sessionId: () => store.selected, drawers: [widgets], renderers: viewer.can("block_renderers") });
|
|
1546
|
+
createBlockHost({ roots: turnRoots(), sessionId: () => store.selected, drawers: [widgets], renderers: viewer.can("block_renderers"), openPicture: (p, o) => pictures.open(p, o) });
|
|
1547
|
+
window.matchMedia?.("(prefers-color-scheme: dark)").addEventListener?.("change", () => pictures.close()); // a redrawn diagram's old picture
|
|
1552
1548
|
// A steps block, a thinking block and the recap open and close by hand
|
|
1553
1549
|
// with their height animated (details_motion.js), in the history and on
|
|
1554
1550
|
// the stage.
|
|
@@ -37,9 +37,9 @@ const NOT_AN_IMAGE = "the renderer's SVG can't be shown as an image";
|
|
|
37
37
|
// this tall and scrolls sideways instead.
|
|
38
38
|
const MIN_SHOWN_HEIGHT = 120;
|
|
39
39
|
|
|
40
|
-
// The zoom button's words: the picture
|
|
41
|
-
|
|
42
|
-
const
|
|
40
|
+
// The zoom button's words: it opens the picture in the viewer (picture_viewer.js),
|
|
41
|
+
// as a click on the picture does.
|
|
42
|
+
const OPEN_IN_VIEWER = "Open in the viewer";
|
|
43
43
|
|
|
44
44
|
const ZOOM_ICON = html`<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><circle cx="7" cy="7" r="4.25" fill="none" stroke="currentColor" stroke-width="1.4"/><path d="m10.2 10.2 3.3 3.3" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"/></svg>`;
|
|
45
45
|
const ICON = html`<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M5.5 4 2 8l3.5 4M10.5 4 14 8l-3.5 4" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
|
@@ -133,10 +133,12 @@ function guardedStorage(get) {
|
|
|
133
133
|
|
|
134
134
|
// The drawer of a bundle's renderers (block_watch.js has the contract): one
|
|
135
135
|
// frame per language, waiting for /api/block_renderers to say who draws what.
|
|
136
|
-
// @param roots the turn roots, for the view held and the
|
|
136
|
+
// @param roots the turn roots, for the view held and the viewer's click
|
|
137
|
+
// @param openPicture (picture, {opener}) => shows a picture full screen (app.js's
|
|
138
|
+
// picture viewer); null (an older app.js): a click on a picture does nothing
|
|
137
139
|
// The rest are createBlockHost's.
|
|
138
140
|
export function createFrameDrawer({
|
|
139
|
-
roots, listRenderers = fetchRendererList, fetchFile = fetchRendererFile, makeFrame = createBlockFrame,
|
|
141
|
+
roots, openPicture = null, listRenderers = fetchRendererList, fetchFile = fetchRendererFile, makeFrame = createBlockFrame,
|
|
140
142
|
decodeImage = async (url) => { const img = new win.Image(); img.src = url; await img.decode(); return { width: img.naturalWidth, height: img.naturalHeight }; },
|
|
141
143
|
decodeTimeoutMs = DECODE_TIMEOUT_MS, theme = currentTheme,
|
|
142
144
|
doc = document, win = window, storage = guardedStorage(() => globalThis.sessionStorage),
|
|
@@ -224,8 +226,9 @@ export function createFrameDrawer({
|
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
// The picture's name says where its words are: the source <pre> is hidden, so a
|
|
227
|
-
// screen reader reaches it through the toggle.
|
|
228
|
-
// keyboard (a click on the picture does the same); it shows
|
|
229
|
+
// screen reader reaches it through the toggle. Opening it in the viewer is a
|
|
230
|
+
// button too, for the keyboard (a click on the picture does the same); it shows
|
|
231
|
+
// on keyboard focus only.
|
|
229
232
|
function makeFigure(picture, themeName, lang) {
|
|
230
233
|
const figure = doc.createElement("figure");
|
|
231
234
|
figure.className = DRAWN;
|
|
@@ -239,8 +242,9 @@ export function createFrameDrawer({
|
|
|
239
242
|
scroll.append(img);
|
|
240
243
|
const zoom = button("block-zoom", ZOOM_ICON);
|
|
241
244
|
const toggle = button("block-toggle", ICON);
|
|
245
|
+
zoom.setAttribute("aria-label", OPEN_IN_VIEWER);
|
|
246
|
+
zoom.title = OPEN_IN_VIEWER;
|
|
242
247
|
figure.append(scroll, zoom, toggle);
|
|
243
|
-
setZoomed(figure, false);
|
|
244
248
|
return figure;
|
|
245
249
|
}
|
|
246
250
|
|
|
@@ -252,15 +256,6 @@ export function createFrameDrawer({
|
|
|
252
256
|
return el;
|
|
253
257
|
}
|
|
254
258
|
|
|
255
|
-
function setZoomed(figure, on) {
|
|
256
|
-
figure.classList.toggle("natural", on);
|
|
257
|
-
const zoom = figure.querySelector(":scope > .block-zoom");
|
|
258
|
-
if (!zoom) return;
|
|
259
|
-
zoom.setAttribute("aria-pressed", on ? "true" : "false");
|
|
260
|
-
zoom.setAttribute("aria-label", on ? ZOOM_OUT : ZOOM_IN);
|
|
261
|
-
zoom.title = on ? ZOOM_OUT : ZOOM_IN;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
259
|
function showPicture(img, { url, width, height }) {
|
|
265
260
|
if (width && height) {
|
|
266
261
|
img.setAttribute("width", width);
|
|
@@ -368,11 +363,15 @@ export function createFrameDrawer({
|
|
|
368
363
|
root.addEventListener("mousedown", (e) => {
|
|
369
364
|
if (e.target.closest?.(".block-zoom")) e.preventDefault();
|
|
370
365
|
});
|
|
371
|
-
// Delegated, so a Revise clone's work too
|
|
366
|
+
// Delegated, so a Revise clone's work too: the picture in the viewer, at its
|
|
367
|
+
// size from the viewBox (showPicture's attributes), the focus back on the button.
|
|
372
368
|
root.addEventListener("click", (e) => {
|
|
373
|
-
if (!e.target.closest?.(".block-zoom, .block-img")) return;
|
|
369
|
+
if (!openPicture || !e.target.closest?.(".block-zoom, .block-img")) return;
|
|
374
370
|
const figure = e.target.closest(`.${DRAWN}`);
|
|
375
|
-
|
|
371
|
+
const img = figure?.querySelector(".block-img");
|
|
372
|
+
if (!img) return;
|
|
373
|
+
const size = (name) => Number(img.getAttribute(name)) || null;
|
|
374
|
+
openPicture({ url: img.src, width: size("width"), height: size("height"), alt: img.alt }, { opener: figure.querySelector(":scope > .block-zoom") });
|
|
376
375
|
});
|
|
377
376
|
}
|
|
378
377
|
|
|
@@ -392,6 +391,7 @@ export function createFrameDrawer({
|
|
|
392
391
|
// @param sessionId () => the open session's id: the frames go on a change, to
|
|
393
392
|
// limit what they hold (docs/internals/block-renderers.md, residual risk)
|
|
394
393
|
// @param drawers core drawers, asked before the bundle renderers
|
|
394
|
+
// +openPicture+: shows a drawn picture full screen (createFrameDrawer's).
|
|
395
395
|
// The rest are seams for the specs.
|
|
396
396
|
// +renderers+: false for a viewer without the bundles' renderers (viewer.js):
|
|
397
397
|
// the core +drawers+ only, and GET /api/block_renderers is never asked.
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
/* A drawn fenced block (block_host.js): the picture scales to the column, a click
|
|
1
|
+
/* A drawn fenced block (block_host.js): the picture scales to the column, a click opens it in the picture viewer (picture_viewer.js); the toggle shows the source, in the block's place. In a .code-wrap the copy button sits top-right, so the toggle sits left of it. The zoom button, the keyboard's way to the viewer, shows on keyboard focus only, left of the toggle. */
|
|
2
2
|
.block-drawn{position:relative;margin:0 0 12px;white-space:normal}
|
|
3
3
|
.code-wrap>.block-drawn{margin:0}
|
|
4
4
|
.code-wrap>.block-drawn.source{height:0}
|
|
5
5
|
.block-drawn:last-child{margin-bottom:0}
|
|
6
6
|
.block-scroll{overflow-x:auto;padding:4px 0}
|
|
7
|
-
/* max-height
|
|
7
|
+
/* max-height is block_host.js MAX_PICTURE_SIDE: a backstop, so no parsing or decoding surprise reaches the browser's 33M px. A very wide picture keeps its min-width (block_host.js minShownWidth) and scrolls sideways. */
|
|
8
8
|
.block-img{display:block;max-width:100%;max-height:50000px;object-fit:contain;height:auto;margin:0 auto;cursor:zoom-in}
|
|
9
|
-
.block-drawn.natural .block-img{max-width:50000px;margin:0;cursor:zoom-out}
|
|
10
9
|
.block-drawn.source .block-scroll{display:none}
|
|
11
10
|
/* A chi-ui widget (inline_widgets.js): its host holds the shadow root, whose own sheet is widgets.css; the source hides it as the picture. */
|
|
12
11
|
.block-drawn.source>.widget-host{display:none}
|
|
@@ -17,8 +16,9 @@
|
|
|
17
16
|
.block-drawn.source>.block-zoom{display:none}
|
|
18
17
|
.block-zoom:not(:focus-visible){pointer-events:none}
|
|
19
18
|
.block-toggle svg,.block-zoom svg{display:block}
|
|
20
|
-
.block-
|
|
21
|
-
.block-
|
|
19
|
+
.block-toggle:focus-visible,.block-zoom:focus-visible,.block-drawn.source>.block-toggle{opacity:1}
|
|
20
|
+
@media(hover:hover){.block-drawn:hover>.block-toggle,.code-wrap:hover>.block-drawn>.block-toggle{opacity:1}.block-toggle:hover:not(:disabled),.block-zoom:hover:not(:disabled){filter:none;color:var(--text-bright)}}
|
|
21
|
+
@media(hover:none){.block-drawn>.block-toggle{opacity:.5}.block-drawn>.block-toggle:active,.block-drawn>.block-toggle:focus-visible{opacity:1}}
|
|
22
22
|
.block-drawn.source:not(:last-child){margin:0}
|
|
23
23
|
/* Its words are the attribute's, so a bubble's text stays the answer's (block_host.js fail). */
|
|
24
24
|
.block-note{margin:4px 0 12px;font-size:12px;color:var(--text-3);white-space:normal}
|
|
@@ -166,11 +166,10 @@ export function createContextChips({ el, api, toast = () => {}, peers = () => nu
|
|
|
166
166
|
draw();
|
|
167
167
|
// An open popover follows its row, but not while it shows the text.
|
|
168
168
|
follow();
|
|
169
|
-
// The peers' exchanges for the chips: at a session's open (the
|
|
170
|
-
// conversation's
|
|
171
|
-
// comes (a pairing while the session is open).
|
|
169
|
+
// The peers' exchanges for the chips: at a session's open (reuse the
|
|
170
|
+
// conversation's read if loaded or in flight), and when a peer comes.
|
|
172
171
|
const names = groups().map((group) => group.name).join(" ");
|
|
173
|
-
if (names && (loading || names !== peerNames)) peers()?.refresh?.();
|
|
172
|
+
if (names && (loading || names !== peerNames)) peers()?.refresh?.({ reuse: loading });
|
|
174
173
|
peerNames = names;
|
|
175
174
|
}
|
|
176
175
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Images in the web UI: pasted or dropped into the composer as chips, sent
|
|
2
2
|
// with a turn as refs (uploaded first), shown as thumbnails in the bubbles
|
|
3
|
-
// and tool rows, opened
|
|
3
|
+
// and tool rows, opened in the picture viewer (picture_viewer.js). No DOM here beyond what the
|
|
4
4
|
// callers pass (the templates are lit-html's), so it runs under `node --test`.
|
|
5
5
|
import { html, nothing } from "./vendor/lit-html.js";
|
|
6
6
|
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
/* Icon masks shared by the phone info bar and the all view's cards (the stroke only shapes the mask; the icon takes currentColor); the image icon is composer.css's. */
|
|
30
30
|
:root{--icon-archive:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='2.75' width='12' height='3.5' rx='1'/%3E%3Cpath d='M3.25 6.25v6a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1v-6M6.5 9h3'/%3E%3C/svg%3E");--icon-unarchive:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='2.75' width='12' height='3.5' rx='1'/%3E%3Cpath d='M3.25 6.25v6a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1v-6M8 11.5V8.25M6.5 9.75 8 8.25l1.5 1.5'/%3E%3C/svg%3E")}
|
|
31
31
|
/* The phone's safe areas (the notch, the status bar, the home indicator; 0 elsewhere): main's padding, the bottom
|
|
32
|
-
sheets, the update sheet, the toast and the
|
|
32
|
+
sheets, the update sheet, the toast and the picture viewer keep clear of them. One name per side, so the e2e can set them. */
|
|
33
33
|
:root{--safe-t:env(safe-area-inset-top,0px);--safe-r:env(safe-area-inset-right,0px);--safe-b:env(safe-area-inset-bottom,0px);--safe-l:env(safe-area-inset-left,0px)}
|
|
34
34
|
*{box-sizing:border-box;margin:0;padding:0}
|
|
35
35
|
/* No iOS text autosizing: it grows text in a box sized for the text as written (it clipped the session cards). */
|
|
@@ -795,10 +795,28 @@ body.has-session #history{padding-bottom:calc(var(--dock-h,160px) + 16px + var(-
|
|
|
795
795
|
.thumb{max-height:120px;max-width:200px;border-radius:6px;border:1px solid var(--border-strong);cursor:zoom-in;object-fit:contain;background:var(--bg)}
|
|
796
796
|
.activity-row .thumbs{flex-basis:100%;margin-left:var(--row-gutter)}
|
|
797
797
|
@media(max-width:600px){.activity-row .thumbs{margin-left:0}}
|
|
798
|
-
/* The
|
|
799
|
-
#lightbox{position:fixed;inset:0;z-index:50;background:var(--
|
|
798
|
+
/* The picture viewer (picture_viewer.js): an opaque surface in the page's background (a diagram's ink is the theme's text colour, which a dark backdrop hides on the light theme). Its padding is the safe areas, read as the fit's insets; the picture is placed at 0,0 by its box's size and translate, not by flex. touch-action:none: the page under it never scrolls or zooms. */
|
|
799
|
+
#lightbox{position:fixed;inset:0;z-index:50;background:var(--bg);overflow:hidden;touch-action:none;cursor:grab;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;outline:none;box-sizing:border-box;padding:var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l)}
|
|
800
|
+
#lightbox.dragging{cursor:grabbing}
|
|
800
801
|
#lightbox[hidden]{display:none}
|
|
801
|
-
#lightbox
|
|
802
|
+
#lightbox .pv-pic{position:absolute;left:0;top:0}
|
|
803
|
+
#lightbox .pv-pic.waiting{visibility:hidden}
|
|
804
|
+
/* No native image drag (it would cancel the pointer) and no iOS long-press sheet during a slow pan. */
|
|
805
|
+
#lightbox img{display:block;width:100%;height:100%;-webkit-user-drag:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;pointer-events:none}
|
|
806
|
+
/* ✕ top right, the bar bottom centre, glass cards a little more solid than the page's (they sit over any picture, a white screenshot too), both clear of the notch, the side insets and the home indicator; the standalone phone app's ✕ also clears iOS's blurred band under the clock. */
|
|
807
|
+
#lightbox .pv-close{position:absolute;top:calc(var(--safe-t) + 10px);right:calc(var(--safe-r) + 10px)}
|
|
808
|
+
@media (display-mode:standalone) and (max-width:600px){#lightbox .pv-close{top:calc(var(--safe-t) + 22px)}}
|
|
809
|
+
#lightbox .pv-bar{position:absolute;left:calc((100% + var(--safe-l) - var(--safe-r)) / 2);bottom:calc(var(--safe-b) + 14px);transform:translateX(-50%);display:flex;align-items:center;gap:2px;padding:3px;cursor:default}
|
|
810
|
+
#lightbox .pv-close,#lightbox .pv-bar{z-index:1;border-radius:12px;background:color-mix(in srgb,var(--bg-panel) 88%,transparent);-webkit-backdrop-filter:blur(18px) saturate(1.35);backdrop-filter:blur(18px) saturate(1.35);border:1px solid var(--glass-border);box-shadow:inset 0 1px 0 var(--glass-highlight),var(--glass-shadow)}
|
|
811
|
+
@media (prefers-reduced-transparency:reduce){#lightbox .pv-close,#lightbox .pv-bar{background:var(--bg-panel);-webkit-backdrop-filter:none;backdrop-filter:none}}
|
|
812
|
+
body.no-glass #lightbox :is(.pv-close,.pv-bar){background:var(--bg-panel);-webkit-backdrop-filter:none;backdrop-filter:none}
|
|
813
|
+
#lightbox .pv-btn{display:inline-flex;align-items:center;justify-content:center;min-width:36px;height:36px;padding:0 8px;border-radius:9px;background:transparent;color:var(--text);font-size:13px}
|
|
814
|
+
#lightbox .pv-fit{color:var(--text-2)}
|
|
815
|
+
#lightbox .pv-btn svg{display:block}
|
|
816
|
+
@media (pointer:coarse){#lightbox .pv-btn{min-width:44px;height:44px}}
|
|
817
|
+
@media(hover:hover){#lightbox .pv-btn:hover{background:var(--bg-raised);filter:none}}
|
|
818
|
+
#lightbox .pv-pct{min-width:52px;text-align:center;font-size:13px;font-variant-numeric:tabular-nums;color:var(--text-2)}
|
|
819
|
+
#lightbox .pv-sep{width:1px;height:18px;margin:0 3px;background:var(--border-strong)}
|
|
802
820
|
/* The model picker (the start page, and a fresh chain link: start_page.js syncModelPick): reads as a label, "host:model ▾", left of Start; a button under a drawn caret that opens a searchable list (model_picker.js). Its name ellipsizes within max-width. */
|
|
803
821
|
#composer .actions-col .model-pick{order:0;position:relative;display:inline-block;max-width:min(50%,380px);height:28px;min-height:28px;padding:0 22px 0 8px;border-radius:8px;overflow:hidden;background:transparent;color:var(--text-muted);font-size:12px;line-height:28px;text-align:left;text-overflow:ellipsis;transition:background .12s ease,color .12s ease}
|
|
804
822
|
/* The start page's row stays one row (Start never wraps): the model name gives way first, down to its min-width, then the override chips ellipsize (100000x their shrink weight: at 1000x their share of the shrink was still a fraction of a pixel, enough for an ellipsis). Scoped off the session composer and a fresh link's button. */
|
|
@@ -1180,8 +1198,9 @@ button.ws-step:hover:not(:disabled){filter:none}@media(hover:hover){button.ws-st
|
|
|
1180
1198
|
.ws-sec-head{display:flex;align-items:center;gap:8px;width:100%;min-height:30px;box-sizing:border-box;margin-top:6px;padding:0 6px;border:0;border-top:1px solid var(--border);border-radius:0;background:transparent;font-family:ui-sans-serif,system-ui,sans-serif;font-size:12px;color:var(--ws-muted);text-align:left;cursor:pointer}
|
|
1181
1199
|
.ws-sec-head:hover:not(:disabled){filter:none}@media(hover:hover){.ws-sec-head:hover{background:var(--bg-hover)}}
|
|
1182
1200
|
.ws-sec-head .k{flex:none;width:12px;text-align:center;color:var(--ws-faint)}
|
|
1183
|
-
.ws-sec-head .t{font-weight:600;color:var(--text-2)}
|
|
1201
|
+
.ws-sec-head .t{flex:none;white-space:nowrap;font-weight:600;color:var(--text-2)}
|
|
1184
1202
|
.ws-sec-head .n{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ws-faint)}
|
|
1203
|
+
.ws-sec-head .w{flex:none;white-space:nowrap;color:var(--warn-text)}
|
|
1185
1204
|
.ws-sec-head .tk{flex:none;margin-left:auto;font-size:11px;color:var(--ws-faint);font-variant-numeric:tabular-nums}
|
|
1186
1205
|
.ws-sec .ws-sub{margin-top:2px;padding-left:6px}
|
|
1187
1206
|
.ws-row.part .t{margin-right:auto;font-family:ui-sans-serif,system-ui,sans-serif}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// The session's objectives above the conversation: the fold's current state
|
|
2
2
|
// (Objectives.view), from the session read (seed) and live from the stream's
|
|
3
|
-
// objectives_updated (update). No list
|
|
4
|
-
// the
|
|
3
|
+
// objectives_updated (update). No list, or one with only dropped objectives:
|
|
4
|
+
// the element stays hidden, nothing on the page (while its edit list is open
|
|
5
|
+
// the strip stays as the list's anchor, so an Undo just shown doesn't go
|
|
6
|
+
// under the finger; it goes when the list closes). A tap opens the edit list (chip_popover.js: a bottom sheet on a
|
|
5
7
|
// phone): add, done, drop, undo and a new text, each a /objectives line on the
|
|
6
8
|
// command route, the one way to an edit, so its refusals are the command's. No
|
|
7
9
|
// message and no turn; the worker's next event redraws (every tab's), and a
|
|
@@ -41,9 +43,14 @@ export function createObjectivesStrip({ el, session = () => null, running = () =
|
|
|
41
43
|
return html`<button type="button" class=${`obj-chip obj-open ${item.status}${first ? " first" : ""}`} data-id=${item.id} title=${item.text} aria-expanded="false"><span class="obj-id">${item.id}</span><span class="obj-text">${item.status === DONE ? "✓ " : ""}${item.text}</span></button>`;
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
// Something still meant: an active or a done objective.
|
|
47
|
+
const meant = () => !!list && stripItems(list).length > 0;
|
|
48
|
+
// The strip is drawn: something meant, or its edit list open.
|
|
49
|
+
const shown = () => meant() || (!!list && shell.isOpen());
|
|
50
|
+
|
|
44
51
|
function draw() {
|
|
45
|
-
el.hidden = !
|
|
46
|
-
if (
|
|
52
|
+
el.hidden = !shown();
|
|
53
|
+
if (el.hidden) {
|
|
47
54
|
render(nothing, el);
|
|
48
55
|
return;
|
|
49
56
|
}
|
|
@@ -135,7 +142,7 @@ export function createObjectivesStrip({ el, session = () => null, running = () =
|
|
|
135
142
|
};
|
|
136
143
|
|
|
137
144
|
const shell = createChipPopover({
|
|
138
|
-
id: "objectivesPanel", className: "ctx-popover obj-panel", width: 560, el, anchor: ".obj-open", summary: () => list,
|
|
145
|
+
id: "objectivesPanel", className: "ctx-popover obj-panel", width: 560, el, anchor: ".obj-open", summary: () => (shown() ? list : null),
|
|
139
146
|
session, label: "Objectives", sheet: true, sheetShare: SHEET_TALL, doc, win,
|
|
140
147
|
show: () => render(panelTemplate(), shell.pop),
|
|
141
148
|
onOpen: () => {
|
|
@@ -146,6 +153,8 @@ export function createObjectivesStrip({ el, session = () => null, running = () =
|
|
|
146
153
|
onClose: () => {
|
|
147
154
|
editing = null;
|
|
148
155
|
told.clear();
|
|
156
|
+
// An only-dropped list's strip goes with its edit list.
|
|
157
|
+
draw();
|
|
149
158
|
},
|
|
150
159
|
onSubmit: (form) => {
|
|
151
160
|
const text = form.elements.text.value;
|
|
@@ -253,7 +262,8 @@ export function createObjectivesStrip({ el, session = () => null, running = () =
|
|
|
253
262
|
take(null);
|
|
254
263
|
},
|
|
255
264
|
notYet,
|
|
256
|
-
|
|
265
|
+
// Something still meant (an only-dropped list is none).
|
|
266
|
+
hasList: meant,
|
|
257
267
|
hasActive: () => hasActive(list),
|
|
258
268
|
// An objective's last move as the view has it (its state, its backing), null with none.
|
|
259
269
|
moveOf: (id) => list?.items?.find((i) => i.id === id)?.move ?? null,
|