Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
log_navigation.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <portals/model_position.hpp>
6
7#include <optional>
8#include <thread>
9
10namespace portals {
11class ManagedScene;
12struct LogLine;
13
14namespace detail {
15struct LogNavigationSession;
16}
17
18namespace ui::detail {
19struct ExternalLogAccess;
20}
21
27public:
29 virtual ModelResource resource() const noexcept = 0;
36 virtual std::expected<ModelBookmark, SourceError> capture(const SourceReadCommand &command,
37 const WindowRow<LogLine> &row, BookmarkOptions options,
38 std::stop_token stop = {}) const = 0;
39
47 virtual std::expected<PositionReply, SourceError> resolveLog(const PositionRequest &request,
48 std::weak_ptr<const WindowNotifier<LogLine>> readiness,
49 std::stop_token stop = {}) const {
50 (void)readiness;
51
52 return resolve(request, stop);
53 }
54
59 virtual std::expected<SourceAnchor, SourceError> readAnchor(const PositionReply &reply, SourceStamp session) const {
60 (void)session;
61
62 if (reply.position.kind != PositionKind::ITEM) {
63 return std::unexpected(SourceError::UNSUPPORTED);
64 }
65
67 }
68};
69
80
87
90 std::size_t maxBytes{256 * 1024};
92};
93
96 std::optional<ModelBookmark> bookmark;
97 std::size_t byteInRecord{};
98 bool following{};
99};
100
106public:
107 LogNavigation() = default;
109 std::expected<LogRestoreStatus, SourceError> status() const;
113 std::expected<std::optional<LogReadingCheckpoint>, SourceError> checkpoint(ModelResource resource) const;
119 std::expected<void, SourceError> reset(ModelResource resource) const;
120
121private:
122 friend class ManagedScene;
123 friend struct ui::detail::ExternalLogAccess;
124 std::expected<std::shared_ptr<detail::LogNavigationSession>, SourceError> lock() const;
125 std::weak_ptr<detail::LogNavigationSession> session_;
126 std::thread::id owner_{};
127};
128} // namespace portals
Bounded worker extension for log positions; unrelated to total extent. The provider owns its logical ...
Definition log_navigation.hpp:26
virtual std::expected< ModelBookmark, SourceError > capture(const SourceReadCommand &command, const WindowRow< LogLine > &row, BookmarkOptions options, std::stop_token stop={}) const =0
virtual ModelResource resource() const noexcept=0
virtual std::expected< PositionReply, SourceError > resolveLog(const PositionRequest &request, std::weak_ptr< const WindowNotifier< LogLine > > readiness, std::stop_token stop={}) const
Definition log_navigation.hpp:47
virtual std::expected< SourceAnchor, SourceError > readAnchor(const PositionReply &reply, SourceStamp session) const
Definition log_navigation.hpp:59
std::expected< std::optional< LogReadingCheckpoint >, SourceError > checkpoint(ModelResource resource) const
LogNavigation()=default
Empty handle; queries return CLOSED.
std::expected< void, SourceError > reset(ModelResource resource) const
std::expected< LogRestoreStatus, SourceError > status() const
Additive lifecycle owner over one existing Application subtree. UI affine and nonmovable....
Definition managed.hpp:530
Copyable bookmark owning metadata only; never retains model, snapshot, view or page....
Definition model_position.hpp:66
Bounded provider extension independent of views, schedulers, and total extent. Implementations must n...
Definition model_position.hpp:163
virtual std::expected< PositionReply, SourceError > resolve(const PositionRequest &request, std::stop_token stop={}) const =0
Copyable worker endpoint; retains only worker-safe state, never a UI source owner.
Definition window_source.hpp:1239
Public Portals API.
Definition action.hpp:8
@ ROW
Capability-gated stable-identity lookup.
Definition window_source.hpp:56
@ ITEM
Full RowId with a version-qualified ordinal hint.
Definition model_position.hpp:36
PositionResolution
Successful protocol outcomes; absence of support differs from missing history.
Definition model_position.hpp:123
@ EXACT
The same item or a proven mapped gap/mark is present.
Definition model_position.hpp:124
LogRestoreReason
Recoverable restore diagnostics; no outcome implicitly enables following.
Definition log_navigation.hpp:71
@ HISTORY_UNAVAILABLE
Supported historical data cannot be recovered.
Definition log_navigation.hpp:75
@ DELETED_SEGMENT
Provider proved deletion and selected a surviving neighbor.
Definition log_navigation.hpp:77
@ ANCHOR_MISMATCH
Bounded anchor validation failed.
Definition log_navigation.hpp:76
@ CHECKPOINT_CAPACITY
Metadata admission failed before replacement.
Definition log_navigation.hpp:78
@ NONE
Exact restoration or no restore was requested.
Definition log_navigation.hpp:72
@ RESOURCE_MISMATCH
Resource, lineage or native identity is incompatible.
Definition log_navigation.hpp:74
@ UNSUPPORTED
The application explicitly excludes this annotated phase.
Definition key_binding.hpp:44
SourceError
Source protocol and admission failures, independent of a provider's storage format.
Definition source_budget.hpp:14
@ UNSUPPORTED
A required optional capability is unavailable.
Definition source_budget.hpp:23
@ NONE
Caption only, including a single-glyph action button.
Definition controls.hpp:157
Checked bookmark capacity, independent of logical source length.
Definition model_position.hpp:57
Configurable metadata bounds; no source-count limit or LRU eviction.
Definition log_navigation.hpp:89
std::size_t maxBytes
Aggregate session metadata capacity, including accounting allowances.
Definition log_navigation.hpp:90
BookmarkOptions bookmarks
Maximum metadata for one owning bookmark; default 4096 bytes.
Definition log_navigation.hpp:91
Immutable UTF-8 record with its original byte position; separators are excluded.
Definition log_file.hpp:18
Owning saved logical reading position; contains no source or view references.
Definition log_navigation.hpp:95
bool following
Independent per-resource follow mode.
Definition log_navigation.hpp:98
std::optional< ModelBookmark > bookmark
Last valid native position; preserved on unavailable resolution.
Definition log_navigation.hpp:96
std::size_t byteInRecord
Grapheme-aligned UTF-8 coordinate inside the logical record.
Definition log_navigation.hpp:97
Observed status belonging to a navigation session, not a widget.
Definition log_navigation.hpp:82
PositionResolution resolution
Provider outcome.
Definition log_navigation.hpp:83
std::optional< SourceError > error
Optional typed operation failure.
Definition log_navigation.hpp:85
LogRestoreReason reason
Why restoration could not be exact.
Definition log_navigation.hpp:84
PositionKind kind
Provider operation to resolve.
Definition model_position.hpp:49
RowId row
Full item identity; empty for GAP/TEXT.
Definition model_position.hpp:50
Logical resource namespace, distinct from its current delivery session. Reuse an existing SourceStamp...
Definition model_position.hpp:21
Owning resolution receipt; meaningful only for its matching live request.
Definition model_position.hpp:142
ModelPosition position
Meaningful for EXACT/NEAREST, empty for EMPTY.
Definition model_position.hpp:148
Immutable qualified navigation request; does not start work by itself.
Definition model_position.hpp:134
Owning navigation intent, including optional capability-gated operations.
Definition window_source.hpp:66
Immutable worker command; maxRows is an upper bound, never an extent.
Definition window_source.hpp:90
Immutable source namespace; replacement sessions must share their old budget root.
Definition window_source.hpp:27
Immutable typed row; use arena storage for all dynamically owned payload.
Definition window_source.hpp:101