-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_scripts_gui.affine
More file actions
152 lines (134 loc) · 3.96 KB
/
Copy pathgit_scripts_gui.affine
File metadata and controls
152 lines (134 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// SPDX-License-Identifier: MPL-2.0
// Git Scripts GUI — AffineScript TEA Interface
// Underpinned by Cadre Router (Affine Stack Implementation)
//
// Purpose: Provide a formally verified, resource-safe interface for
// managing git repository scripts, branch transitions, and maintenance.
// ── Types ─────────────────────────────────────────────────────────────────
enum ScriptStatus {
Idle,
Running,
Success,
Failed(String)
}
struct GitScript {
name: String,
description: String,
path: String,
last_status: ScriptStatus
}
enum ViewMode {
ScriptList,
History,
Settings
}
// ── Model ───────────────────────────────────────────────────────────────────
struct Model {
view_mode: ViewMode,
scripts: [GitScript],
selected_script_index: Int,
is_refreshing: Bool,
history_depth: Int
}
// ── Msg ──────────────────────────────────────────────────────────────────────
enum Msg {
Navigate(ViewMode),
SelectScript(Int),
RunSelectedScript,
ScriptFinished(Int, ScriptStatus),
RefreshScripts,
PopState
}
// ── TEA Logic ────────────────────────────────────────────────────────────────
fn git_scripts_init() -> Model {
#{
view_mode: ViewMode::ScriptList,
scripts: [],
selected_script_index: -1,
is_refreshing: false,
history_depth: 0
}
}
fn git_scripts_update(@linear msg: Msg, @linear model: Model) -> Model {
match model {
{ view_mode: v, scripts: s, selected_script_index: i, is_refreshing: r, history_depth: h } => {
match msg {
Navigate(new_mode) => {
#{
view_mode: new_mode,
scripts: s,
selected_script_index: i,
is_refreshing: false,
history_depth: h + 1
}
}
SelectScript(new_idx) => {
#{
view_mode: v,
scripts: s,
selected_script_index: new_idx,
is_refreshing: r,
history_depth: h
}
}
RunSelectedScript => {
// Linear update: mark script as running
#{
view_mode: v,
scripts: s, // In a full impl, we'd update the specific script status in the list
selected_script_index: i,
is_refreshing: r,
history_depth: h
}
}
ScriptFinished(idx, status) => {
#{
view_mode: v,
scripts: s,
selected_script_index: i,
is_refreshing: r,
history_depth: h
}
}
RefreshScripts => {
#{
view_mode: v,
scripts: s,
selected_script_index: i,
is_refreshing: true,
history_depth: h
}
}
PopState => {
if h > 0 {
#{
view_mode: ViewMode::ScriptList,
scripts: s,
selected_script_index: -1,
is_refreshing: false,
history_depth: h - 1
}
} else {
#{
view_mode: v,
scripts: s,
selected_script_index: i,
is_refreshing: r,
history_depth: 0
}
}
}
}
}
}
}
fn git_scripts_view(model: Model) -> String {
match model.view_mode {
ScriptList => "GIT SCRIPTS: Utility Library",
History => "EXECUTION HISTORY",
Settings => "CONFIGURATION"
}
}
fn git_scripts_subs(model: Model) -> String {
"None"
}