shotgun-sh 0.2.11.dev7__py3-none-any.whl → 0.2.23.dev1__py3-none-any.whl
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.
Potentially problematic release.
This version of shotgun-sh might be problematic. Click here for more details.
- shotgun/agents/agent_manager.py +25 -11
- shotgun/agents/config/README.md +89 -0
- shotgun/agents/config/__init__.py +10 -1
- shotgun/agents/config/manager.py +287 -32
- shotgun/agents/config/models.py +26 -1
- shotgun/agents/config/provider.py +27 -0
- shotgun/agents/config/streaming_test.py +119 -0
- shotgun/agents/error/__init__.py +11 -0
- shotgun/agents/error/models.py +19 -0
- shotgun/agents/history/token_counting/anthropic.py +8 -0
- shotgun/agents/runner.py +230 -0
- shotgun/build_constants.py +1 -1
- shotgun/cli/context.py +43 -0
- shotgun/cli/error_handler.py +24 -0
- shotgun/cli/export.py +34 -34
- shotgun/cli/plan.py +34 -34
- shotgun/cli/research.py +17 -9
- shotgun/cli/specify.py +20 -19
- shotgun/cli/tasks.py +34 -34
- shotgun/exceptions.py +323 -0
- shotgun/llm_proxy/__init__.py +17 -0
- shotgun/llm_proxy/client.py +215 -0
- shotgun/llm_proxy/models.py +137 -0
- shotgun/logging_config.py +42 -0
- shotgun/main.py +2 -0
- shotgun/posthog_telemetry.py +18 -25
- shotgun/prompts/agents/partials/common_agent_system_prompt.j2 +3 -2
- shotgun/sdk/codebase.py +14 -3
- shotgun/sentry_telemetry.py +140 -2
- shotgun/settings.py +5 -0
- shotgun/tui/app.py +35 -10
- shotgun/tui/screens/chat/chat_screen.py +192 -91
- shotgun/tui/screens/chat/codebase_index_prompt_screen.py +62 -11
- shotgun/tui/screens/chat_screen/command_providers.py +3 -2
- shotgun/tui/screens/chat_screen/hint_message.py +76 -1
- shotgun/tui/screens/chat_screen/history/chat_history.py +37 -2
- shotgun/tui/screens/directory_setup.py +45 -41
- shotgun/tui/screens/feedback.py +10 -3
- shotgun/tui/screens/github_issue.py +11 -2
- shotgun/tui/screens/model_picker.py +8 -1
- shotgun/tui/screens/pipx_migration.py +12 -6
- shotgun/tui/screens/provider_config.py +25 -8
- shotgun/tui/screens/shotgun_auth.py +0 -10
- shotgun/tui/screens/welcome.py +32 -0
- shotgun/tui/widgets/widget_coordinator.py +3 -2
- shotgun_sh-0.2.23.dev1.dist-info/METADATA +472 -0
- {shotgun_sh-0.2.11.dev7.dist-info → shotgun_sh-0.2.23.dev1.dist-info}/RECORD +50 -42
- shotgun_sh-0.2.11.dev7.dist-info/METADATA +0 -130
- {shotgun_sh-0.2.11.dev7.dist-info → shotgun_sh-0.2.23.dev1.dist-info}/WHEEL +0 -0
- {shotgun_sh-0.2.11.dev7.dist-info → shotgun_sh-0.2.23.dev1.dist-info}/entry_points.txt +0 -0
- {shotgun_sh-0.2.11.dev7.dist-info → shotgun_sh-0.2.23.dev1.dist-info}/licenses/LICENSE +0 -0
|
@@ -47,7 +47,6 @@ class ChatHistory(Widget):
|
|
|
47
47
|
super().__init__()
|
|
48
48
|
self.items: Sequence[ModelMessage | HintMessage] = []
|
|
49
49
|
self.vertical_tail: VerticalTail | None = None
|
|
50
|
-
self.partial_response = None
|
|
51
50
|
self._rendered_count = 0 # Track how many messages have been mounted
|
|
52
51
|
|
|
53
52
|
def compose(self) -> ComposeResult:
|
|
@@ -63,7 +62,7 @@ class ChatHistory(Widget):
|
|
|
63
62
|
yield HintMessageWidget(item)
|
|
64
63
|
elif isinstance(item, ModelResponse):
|
|
65
64
|
yield AgentResponseWidget(item)
|
|
66
|
-
yield PartialResponseWidget(
|
|
65
|
+
yield PartialResponseWidget(None).data_bind(
|
|
67
66
|
item=ChatHistory.partial_response
|
|
68
67
|
)
|
|
69
68
|
|
|
@@ -93,6 +92,42 @@ class ChatHistory(Widget):
|
|
|
93
92
|
self.items = messages
|
|
94
93
|
filtered = list(self.filtered_items())
|
|
95
94
|
|
|
95
|
+
# Handle case where streaming inflated _rendered_count but final messages differ
|
|
96
|
+
# This happens when error replaces ModelResponse with HintMessage
|
|
97
|
+
if len(filtered) <= self._rendered_count and filtered:
|
|
98
|
+
# Check if the last rendered item type differs from what should be there
|
|
99
|
+
# Children: [UserQuestion, AgentResponse, ..., PartialResponse]
|
|
100
|
+
# We need to check the item before PartialResponseWidget
|
|
101
|
+
num_children = len(self.vertical_tail.children)
|
|
102
|
+
if num_children > 1: # Has items besides PartialResponseWidget
|
|
103
|
+
last_widget = self.vertical_tail.children[-2] # Item before Partial
|
|
104
|
+
last_filtered = filtered[-1]
|
|
105
|
+
|
|
106
|
+
# Check type mismatch
|
|
107
|
+
type_mismatch = (
|
|
108
|
+
(
|
|
109
|
+
isinstance(last_widget, AgentResponseWidget)
|
|
110
|
+
and isinstance(last_filtered, HintMessage)
|
|
111
|
+
)
|
|
112
|
+
or (
|
|
113
|
+
isinstance(last_widget, HintMessageWidget)
|
|
114
|
+
and isinstance(last_filtered, ModelResponse)
|
|
115
|
+
)
|
|
116
|
+
or (
|
|
117
|
+
isinstance(last_widget, AgentResponseWidget)
|
|
118
|
+
and isinstance(last_filtered, ModelRequest)
|
|
119
|
+
)
|
|
120
|
+
or (
|
|
121
|
+
isinstance(last_widget, UserQuestionWidget)
|
|
122
|
+
and not isinstance(last_filtered, ModelRequest)
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
if type_mismatch:
|
|
127
|
+
# Remove the mismatched widget and adjust count
|
|
128
|
+
last_widget.remove()
|
|
129
|
+
self._rendered_count = len(filtered) - 1
|
|
130
|
+
|
|
96
131
|
# Only mount new messages that haven't been rendered yet
|
|
97
132
|
if len(filtered) > self._rendered_count:
|
|
98
133
|
new_messages = filtered[self._rendered_count :]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Screen for
|
|
1
|
+
"""Screen for displaying .shotgun directory creation errors."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -8,13 +8,20 @@ from textual import on
|
|
|
8
8
|
from textual.app import ComposeResult
|
|
9
9
|
from textual.containers import Horizontal, Vertical
|
|
10
10
|
from textual.screen import Screen
|
|
11
|
-
from textual.widgets import Button, Static
|
|
12
|
-
|
|
13
|
-
from shotgun.utils.file_system_utils import ensure_shotgun_directory_exists
|
|
11
|
+
from textual.widgets import Button, Label, Static
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
class DirectorySetupScreen(Screen[None]):
|
|
17
|
-
"""
|
|
15
|
+
"""Display an error when .shotgun directory creation fails."""
|
|
16
|
+
|
|
17
|
+
def __init__(self, error_message: str) -> None:
|
|
18
|
+
"""Initialize the error screen.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
error_message: The error message to display to the user.
|
|
22
|
+
"""
|
|
23
|
+
super().__init__()
|
|
24
|
+
self.error_message = error_message
|
|
18
25
|
|
|
19
26
|
CSS = """
|
|
20
27
|
DirectorySetupScreen {
|
|
@@ -56,58 +63,55 @@ class DirectorySetupScreen(Screen[None]):
|
|
|
56
63
|
#directory-actions > * {
|
|
57
64
|
margin-right: 2;
|
|
58
65
|
}
|
|
66
|
+
|
|
67
|
+
#directory-status {
|
|
68
|
+
height: auto;
|
|
69
|
+
padding: 0 1;
|
|
70
|
+
min-height: 1;
|
|
71
|
+
color: $error;
|
|
72
|
+
text-align: center;
|
|
73
|
+
}
|
|
59
74
|
"""
|
|
60
75
|
|
|
61
76
|
BINDINGS = [
|
|
62
|
-
("enter", "
|
|
77
|
+
("enter", "retry", "Retry"),
|
|
63
78
|
("escape", "cancel", "Exit"),
|
|
64
79
|
]
|
|
65
80
|
|
|
66
81
|
def compose(self) -> ComposeResult:
|
|
67
82
|
with Vertical(id="titlebox"):
|
|
68
|
-
yield Static(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
yield Static(
|
|
72
|
-
|
|
73
|
-
yield
|
|
74
|
-
|
|
83
|
+
yield Static(
|
|
84
|
+
"Failed to create .shotgun directory", id="directory-setup-title"
|
|
85
|
+
)
|
|
86
|
+
yield Static("Shotgun was unable to create the .shotgun directory in:\n")
|
|
87
|
+
yield Static(f"[$foreground-muted]({Path.cwd().resolve()})[/]\n")
|
|
88
|
+
yield Static(f"[bold red]Error:[/] {self.error_message}\n")
|
|
89
|
+
yield Static(
|
|
90
|
+
"This directory is required for storing workspace data. "
|
|
91
|
+
"Please check permissions and try again."
|
|
75
92
|
)
|
|
76
|
-
|
|
93
|
+
yield Label("", id="directory-status")
|
|
94
|
+
with Horizontal(id="directory-actions"):
|
|
95
|
+
yield Button("Retry \\[ENTER]", variant="primary", id="retry")
|
|
96
|
+
yield Button("Exit \\[ESC]", variant="default", id="exit")
|
|
77
97
|
|
|
78
98
|
def on_mount(self) -> None:
|
|
79
|
-
self.set_focus(self.query_one("#
|
|
99
|
+
self.set_focus(self.query_one("#retry", Button))
|
|
80
100
|
|
|
81
|
-
def
|
|
82
|
-
|
|
101
|
+
def action_retry(self) -> None:
|
|
102
|
+
"""Retry by dismissing the screen, which will trigger refresh_startup_screen."""
|
|
103
|
+
self.dismiss()
|
|
83
104
|
|
|
84
105
|
def action_cancel(self) -> None:
|
|
85
|
-
|
|
106
|
+
"""Exit the application."""
|
|
107
|
+
self.app.exit()
|
|
86
108
|
|
|
87
|
-
@on(Button.Pressed, "#
|
|
88
|
-
def
|
|
89
|
-
|
|
109
|
+
@on(Button.Pressed, "#retry")
|
|
110
|
+
def _on_retry_pressed(self) -> None:
|
|
111
|
+
"""Retry by dismissing the screen."""
|
|
112
|
+
self.dismiss()
|
|
90
113
|
|
|
91
114
|
@on(Button.Pressed, "#exit")
|
|
92
115
|
def _on_exit_pressed(self) -> None:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def _initialize_directory(self) -> None:
|
|
96
|
-
try:
|
|
97
|
-
path = ensure_shotgun_directory_exists()
|
|
98
|
-
except Exception as exc: # pragma: no cover - defensive; textual path
|
|
99
|
-
self.notify(f"Failed to initialize directory: {exc}", severity="error")
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
# Double-check a directory now exists; guard against unexpected filesystem state.
|
|
103
|
-
if not path.is_dir():
|
|
104
|
-
self.notify(
|
|
105
|
-
"Unable to initialize .shotgun directory due to filesystem conflict.",
|
|
106
|
-
severity="error",
|
|
107
|
-
)
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
self.dismiss()
|
|
111
|
-
|
|
112
|
-
def _exit_application(self) -> None:
|
|
116
|
+
"""Exit the application."""
|
|
113
117
|
self.app.exit()
|
shotgun/tui/screens/feedback.py
CHANGED
|
@@ -76,6 +76,13 @@ class FeedbackScreen(Screen[Feedback | None]):
|
|
|
76
76
|
#feedback-type-list {
|
|
77
77
|
padding: 1;
|
|
78
78
|
}
|
|
79
|
+
|
|
80
|
+
#feedback-status {
|
|
81
|
+
height: auto;
|
|
82
|
+
padding: 0 1;
|
|
83
|
+
min-height: 1;
|
|
84
|
+
color: $error;
|
|
85
|
+
}
|
|
79
86
|
"""
|
|
80
87
|
|
|
81
88
|
BINDINGS = [
|
|
@@ -96,6 +103,7 @@ class FeedbackScreen(Screen[Feedback | None]):
|
|
|
96
103
|
"",
|
|
97
104
|
id="feedback-description",
|
|
98
105
|
)
|
|
106
|
+
yield Label("", id="feedback-status")
|
|
99
107
|
with Horizontal(id="feedback-actions"):
|
|
100
108
|
yield Button("Submit", variant="primary", id="submit")
|
|
101
109
|
yield Button("Cancel \\[ESC]", id="cancel")
|
|
@@ -176,9 +184,8 @@ class FeedbackScreen(Screen[Feedback | None]):
|
|
|
176
184
|
description = text_area.text.strip()
|
|
177
185
|
|
|
178
186
|
if not description:
|
|
179
|
-
self.
|
|
180
|
-
|
|
181
|
-
)
|
|
187
|
+
status_label = self.query_one("#feedback-status", Label)
|
|
188
|
+
status_label.update("❌ Please enter a description before submitting.")
|
|
182
189
|
return
|
|
183
190
|
|
|
184
191
|
app = cast("ShotgunApp", self.app)
|
|
@@ -6,7 +6,7 @@ from textual import on
|
|
|
6
6
|
from textual.app import ComposeResult
|
|
7
7
|
from textual.containers import Container, Vertical
|
|
8
8
|
from textual.screen import ModalScreen
|
|
9
|
-
from textual.widgets import Button, Markdown, Static
|
|
9
|
+
from textual.widgets import Button, Label, Markdown, Static
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class GitHubIssueScreen(ModalScreen[None]):
|
|
@@ -47,6 +47,13 @@ class GitHubIssueScreen(ModalScreen[None]):
|
|
|
47
47
|
margin: 1 1;
|
|
48
48
|
min-width: 20;
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
#issue-status {
|
|
52
|
+
height: auto;
|
|
53
|
+
padding: 1;
|
|
54
|
+
min-height: 1;
|
|
55
|
+
text-align: center;
|
|
56
|
+
}
|
|
50
57
|
"""
|
|
51
58
|
|
|
52
59
|
BINDINGS = [
|
|
@@ -85,6 +92,7 @@ We review all issues and will respond as soon as possible!
|
|
|
85
92
|
id="issue-markdown",
|
|
86
93
|
)
|
|
87
94
|
with Vertical(id="issue-buttons"):
|
|
95
|
+
yield Label("", id="issue-status")
|
|
88
96
|
yield Button(
|
|
89
97
|
"🐙 Open GitHub Issues", id="github-button", variant="primary"
|
|
90
98
|
)
|
|
@@ -94,7 +102,8 @@ We review all issues and will respond as soon as possible!
|
|
|
94
102
|
def handle_github(self) -> None:
|
|
95
103
|
"""Open GitHub issues page in browser."""
|
|
96
104
|
webbrowser.open("https://github.com/shotgun-sh/shotgun/issues")
|
|
97
|
-
self.
|
|
105
|
+
status_label = self.query_one("#issue-status", Label)
|
|
106
|
+
status_label.update("✓ Opening GitHub Issues in your browser...")
|
|
98
107
|
|
|
99
108
|
@on(Button.Pressed, "#close-button")
|
|
100
109
|
def handle_close(self) -> None:
|
|
@@ -72,6 +72,11 @@ class ModelPickerScreen(Screen[ModelConfigUpdated | None]):
|
|
|
72
72
|
padding: 1 0;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
#model-picker-status {
|
|
76
|
+
height: auto;
|
|
77
|
+
padding: 0 1;
|
|
78
|
+
color: $error;
|
|
79
|
+
}
|
|
75
80
|
#model-actions {
|
|
76
81
|
padding: 1;
|
|
77
82
|
}
|
|
@@ -94,6 +99,7 @@ class ModelPickerScreen(Screen[ModelConfigUpdated | None]):
|
|
|
94
99
|
id="model-picker-summary",
|
|
95
100
|
)
|
|
96
101
|
yield ListView(id="model-list")
|
|
102
|
+
yield Label("", id="model-picker-status")
|
|
97
103
|
with Horizontal(id="model-actions"):
|
|
98
104
|
yield Button("Select \\[ENTER]", variant="primary", id="select")
|
|
99
105
|
yield Button("Done \\[ESC]", id="done")
|
|
@@ -349,4 +355,5 @@ class ModelPickerScreen(Screen[ModelConfigUpdated | None]):
|
|
|
349
355
|
)
|
|
350
356
|
)
|
|
351
357
|
except Exception as exc: # pragma: no cover - defensive; textual path
|
|
352
|
-
self.
|
|
358
|
+
status_label = self.query_one("#model-picker-status", Label)
|
|
359
|
+
status_label.update(f"❌ Failed to select model: {exc}")
|
|
@@ -8,7 +8,7 @@ from textual import on
|
|
|
8
8
|
from textual.app import ComposeResult
|
|
9
9
|
from textual.containers import Container, Horizontal, VerticalScroll
|
|
10
10
|
from textual.screen import ModalScreen
|
|
11
|
-
from textual.widgets import Button, Markdown
|
|
11
|
+
from textual.widgets import Button, Label, Markdown
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
14
|
pass
|
|
@@ -51,6 +51,13 @@ class PipxMigrationScreen(ModalScreen[None]):
|
|
|
51
51
|
margin: 0 1;
|
|
52
52
|
min-width: 20;
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
#migration-status {
|
|
56
|
+
height: auto;
|
|
57
|
+
padding: 1;
|
|
58
|
+
min-height: 1;
|
|
59
|
+
text-align: center;
|
|
60
|
+
}
|
|
54
61
|
"""
|
|
55
62
|
|
|
56
63
|
BINDINGS = [
|
|
@@ -106,6 +113,7 @@ Or install permanently: `uv tool install shotgun-sh`
|
|
|
106
113
|
)
|
|
107
114
|
|
|
108
115
|
with Container(id="buttons-container"):
|
|
116
|
+
yield Label("", id="migration-status")
|
|
109
117
|
with Horizontal(id="action-buttons"):
|
|
110
118
|
yield Button(
|
|
111
119
|
"Copy Instructions to Clipboard",
|
|
@@ -136,16 +144,14 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
136
144
|
|
|
137
145
|
# Step 3: Run shotgun with uvx
|
|
138
146
|
uvx shotgun-sh"""
|
|
147
|
+
status_label = self.query_one("#migration-status", Label)
|
|
139
148
|
try:
|
|
140
149
|
import pyperclip # type: ignore[import-untyped] # noqa: PGH003
|
|
141
150
|
|
|
142
151
|
pyperclip.copy(instructions)
|
|
143
|
-
|
|
152
|
+
status_label.update("✓ Copied migration instructions to clipboard!")
|
|
144
153
|
except ImportError:
|
|
145
|
-
|
|
146
|
-
"Clipboard not available. See instructions above.",
|
|
147
|
-
severity="warning",
|
|
148
|
-
)
|
|
154
|
+
status_label.update("⚠️ Clipboard not available. See instructions above.")
|
|
149
155
|
|
|
150
156
|
@on(Button.Pressed, "#continue")
|
|
151
157
|
def _continue(self) -> None:
|
|
@@ -77,6 +77,14 @@ class ProviderConfigScreen(Screen[None]):
|
|
|
77
77
|
#provider-list {
|
|
78
78
|
padding: 1;
|
|
79
79
|
}
|
|
80
|
+
#provider-status {
|
|
81
|
+
height: auto;
|
|
82
|
+
padding: 0 1;
|
|
83
|
+
min-height: 1;
|
|
84
|
+
}
|
|
85
|
+
#provider-status.error {
|
|
86
|
+
color: $error;
|
|
87
|
+
}
|
|
80
88
|
"""
|
|
81
89
|
|
|
82
90
|
BINDINGS = [
|
|
@@ -103,6 +111,7 @@ class ProviderConfigScreen(Screen[None]):
|
|
|
103
111
|
password=True,
|
|
104
112
|
id="api-key",
|
|
105
113
|
)
|
|
114
|
+
yield Label("", id="provider-status")
|
|
106
115
|
with Horizontal(id="provider-actions"):
|
|
107
116
|
yield Button("Save key \\[ENTER]", variant="primary", id="save")
|
|
108
117
|
yield Button("Authenticate", variant="success", id="authenticate")
|
|
@@ -280,9 +289,11 @@ class ProviderConfigScreen(Screen[None]):
|
|
|
280
289
|
"""Async implementation of API key saving."""
|
|
281
290
|
input_widget = self.query_one("#api-key", Input)
|
|
282
291
|
api_key = input_widget.value.strip()
|
|
292
|
+
status_label = self.query_one("#provider-status", Label)
|
|
283
293
|
|
|
284
294
|
if not api_key:
|
|
285
|
-
|
|
295
|
+
status_label.update("❌ Enter an API key before saving.")
|
|
296
|
+
status_label.add_class("error")
|
|
286
297
|
return
|
|
287
298
|
|
|
288
299
|
try:
|
|
@@ -291,25 +302,29 @@ class ProviderConfigScreen(Screen[None]):
|
|
|
291
302
|
api_key=api_key,
|
|
292
303
|
)
|
|
293
304
|
except Exception as exc: # pragma: no cover - defensive; textual path
|
|
294
|
-
|
|
305
|
+
status_label.update(f"❌ Failed to save key: {exc}")
|
|
306
|
+
status_label.add_class("error")
|
|
295
307
|
return
|
|
296
308
|
|
|
297
309
|
input_widget.value = ""
|
|
298
310
|
await self.refresh_provider_status()
|
|
299
311
|
await self._update_done_button_visibility()
|
|
300
|
-
|
|
301
|
-
f"Saved API key for {self._provider_display_name(self.selected_provider)}."
|
|
312
|
+
status_label.update(
|
|
313
|
+
f"✓ Saved API key for {self._provider_display_name(self.selected_provider)}."
|
|
302
314
|
)
|
|
315
|
+
status_label.remove_class("error")
|
|
303
316
|
|
|
304
317
|
def _clear_api_key(self) -> None:
|
|
305
318
|
self.run_worker(self._do_clear_api_key(), exclusive=True)
|
|
306
319
|
|
|
307
320
|
async def _do_clear_api_key(self) -> None:
|
|
308
321
|
"""Async implementation of API key clearing."""
|
|
322
|
+
status_label = self.query_one("#provider-status", Label)
|
|
309
323
|
try:
|
|
310
324
|
await self.config_manager.clear_provider_key(self.selected_provider)
|
|
311
325
|
except Exception as exc: # pragma: no cover - defensive; textual path
|
|
312
|
-
|
|
326
|
+
status_label.update(f"❌ Failed to clear key: {exc}")
|
|
327
|
+
status_label.add_class("error")
|
|
313
328
|
return
|
|
314
329
|
|
|
315
330
|
await self.refresh_provider_status()
|
|
@@ -321,9 +336,10 @@ class ProviderConfigScreen(Screen[None]):
|
|
|
321
336
|
auth_button = self.query_one("#authenticate", Button)
|
|
322
337
|
auth_button.display = True
|
|
323
338
|
|
|
324
|
-
|
|
325
|
-
f"Cleared API key for {self._provider_display_name(self.selected_provider)}."
|
|
339
|
+
status_label.update(
|
|
340
|
+
f"✓ Cleared API key for {self._provider_display_name(self.selected_provider)}."
|
|
326
341
|
)
|
|
342
|
+
status_label.remove_class("error")
|
|
327
343
|
|
|
328
344
|
async def _start_shotgun_auth(self) -> None:
|
|
329
345
|
"""Launch Shotgun Account authentication flow."""
|
|
@@ -335,4 +351,5 @@ class ProviderConfigScreen(Screen[None]):
|
|
|
335
351
|
# Refresh provider status after auth completes
|
|
336
352
|
if result:
|
|
337
353
|
await self.refresh_provider_status()
|
|
338
|
-
#
|
|
354
|
+
# Auto-dismiss provider config screen after successful auth
|
|
355
|
+
self.dismiss()
|
|
@@ -182,12 +182,10 @@ class ShotgunAuthScreen(Screen[bool]):
|
|
|
182
182
|
self.query_one("#status", Label).update(
|
|
183
183
|
f"❌ Error: Failed to create authentication token\n{e}"
|
|
184
184
|
)
|
|
185
|
-
self.notify("Failed to start authentication", severity="error")
|
|
186
185
|
|
|
187
186
|
except Exception as e:
|
|
188
187
|
logger.error("Unexpected error during auth flow: %s", e)
|
|
189
188
|
self.query_one("#status", Label).update(f"❌ Unexpected error: {e}")
|
|
190
|
-
self.notify("Authentication failed", severity="error")
|
|
191
189
|
|
|
192
190
|
async def _poll_token_status(self) -> None:
|
|
193
191
|
"""Poll token status until completed or expired."""
|
|
@@ -224,17 +222,12 @@ class ShotgunAuthScreen(Screen[bool]):
|
|
|
224
222
|
"✅ Authentication successful! Saving credentials..."
|
|
225
223
|
)
|
|
226
224
|
await asyncio.sleep(1)
|
|
227
|
-
self.notify(
|
|
228
|
-
"Shotgun Account configured successfully!",
|
|
229
|
-
severity="information",
|
|
230
|
-
)
|
|
231
225
|
self.dismiss(True)
|
|
232
226
|
else:
|
|
233
227
|
logger.error("Completed but missing keys")
|
|
234
228
|
self.query_one("#status", Label).update(
|
|
235
229
|
"❌ Error: Authentication completed but keys are missing"
|
|
236
230
|
)
|
|
237
|
-
self.notify("Authentication failed", severity="error")
|
|
238
231
|
await asyncio.sleep(3)
|
|
239
232
|
self.dismiss(False)
|
|
240
233
|
return
|
|
@@ -250,7 +243,6 @@ class ShotgunAuthScreen(Screen[bool]):
|
|
|
250
243
|
"❌ Authentication token expired (30 minutes)\n"
|
|
251
244
|
"Please try again."
|
|
252
245
|
)
|
|
253
|
-
self.notify("Authentication token expired", severity="error")
|
|
254
246
|
await asyncio.sleep(3)
|
|
255
247
|
self.dismiss(False)
|
|
256
248
|
return
|
|
@@ -269,7 +261,6 @@ class ShotgunAuthScreen(Screen[bool]):
|
|
|
269
261
|
self.query_one("#status", Label).update(
|
|
270
262
|
"❌ Authentication token expired"
|
|
271
263
|
)
|
|
272
|
-
self.notify("Authentication token expired", severity="error")
|
|
273
264
|
await asyncio.sleep(3)
|
|
274
265
|
self.dismiss(False)
|
|
275
266
|
return
|
|
@@ -290,6 +281,5 @@ class ShotgunAuthScreen(Screen[bool]):
|
|
|
290
281
|
self.query_one("#status", Label).update(
|
|
291
282
|
"❌ Authentication timeout (30 minutes)\nPlease try again."
|
|
292
283
|
)
|
|
293
|
-
self.notify("Authentication timeout", severity="error")
|
|
294
284
|
await asyncio.sleep(3)
|
|
295
285
|
self.dismiss(False)
|
shotgun/tui/screens/welcome.py
CHANGED
|
@@ -85,6 +85,21 @@ class WelcomeScreen(Screen[None]):
|
|
|
85
85
|
margin: 1 0 0 0;
|
|
86
86
|
width: 100%;
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
#migration-warning {
|
|
90
|
+
width: 80%;
|
|
91
|
+
height: auto;
|
|
92
|
+
padding: 2;
|
|
93
|
+
margin: 1 0;
|
|
94
|
+
border: solid $warning;
|
|
95
|
+
background: $warning 20%;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#migration-warning-title {
|
|
99
|
+
text-style: bold;
|
|
100
|
+
color: $warning;
|
|
101
|
+
padding: 0 0 1 0;
|
|
102
|
+
}
|
|
88
103
|
"""
|
|
89
104
|
|
|
90
105
|
BINDINGS = [
|
|
@@ -99,6 +114,23 @@ class WelcomeScreen(Screen[None]):
|
|
|
99
114
|
id="welcome-subtitle",
|
|
100
115
|
)
|
|
101
116
|
|
|
117
|
+
# Show migration warning if migration failed
|
|
118
|
+
app = cast("ShotgunApp", self.app)
|
|
119
|
+
# Note: This is a synchronous call in compose, but config should already be loaded
|
|
120
|
+
if hasattr(app, "config_manager") and app.config_manager._config:
|
|
121
|
+
config = app.config_manager._config
|
|
122
|
+
if config.migration_failed:
|
|
123
|
+
with Vertical(id="migration-warning"):
|
|
124
|
+
yield Static(
|
|
125
|
+
"⚠️ Configuration Migration Failed",
|
|
126
|
+
id="migration-warning-title",
|
|
127
|
+
)
|
|
128
|
+
backup_msg = "Your previous configuration couldn't be migrated automatically."
|
|
129
|
+
if config.migration_backup_path:
|
|
130
|
+
backup_msg += f"\n\nYour old configuration (including API keys) has been backed up to:\n{config.migration_backup_path}"
|
|
131
|
+
backup_msg += "\n\nYou'll need to reconfigure Shotgun by choosing an option below."
|
|
132
|
+
yield Markdown(backup_msg)
|
|
133
|
+
|
|
102
134
|
with Container(id="options-container"):
|
|
103
135
|
with Horizontal(id="options"):
|
|
104
136
|
# Left box - Shotgun Account
|
|
@@ -166,8 +166,9 @@ class WidgetCoordinator:
|
|
|
166
166
|
|
|
167
167
|
try:
|
|
168
168
|
chat_history = self.screen.query_one(ChatHistory)
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
# Set the reactive attribute to trigger the PartialResponseWidget update
|
|
170
|
+
chat_history.partial_response = message
|
|
171
|
+
# Also update the full message list
|
|
171
172
|
chat_history.update_messages(messages)
|
|
172
173
|
except Exception as e:
|
|
173
174
|
logger.exception(f"Failed to set partial response: {e}")
|