Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "edit-python-pe"
version = "0.2.9"
version = "0.2.10"
description = "Allows member and project profile editing onto python.pe git repository"
readme = "README.md"
authors = [
Expand Down
56 changes: 52 additions & 4 deletions src/edit_python_pe/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,46 @@
load_file_into_form)


class LabeledInput(Vertical):

DEFAULT_CSS = """
LabeledInput {
height: auto;

}
LabeledInput Static {
width: 25%;

}
LabeledInput Input {
width: 100%;
}
"""
Comment on lines +27 to +41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Side-by-side label/input won’t happen with Vertical; use Horizontal (or grid)
Current container stacks children; the widths won’t place them inline.

Apply:

- class LabeledInput(Vertical):
+ class LabeledInput(Horizontal):
@@
-    DEFAULT_CSS = """
-        LabeledInput {
-            height: auto;
-           
-        }
+    DEFAULT_CSS = """
+        LabeledInput {
+            height: auto;
+        }
         LabeledInput Static {
             width: 25%;
 
         }
         LabeledInput Input {
-            width: 100%;
+            width: 75%;
         }
     """
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class LabeledInput(Vertical):
DEFAULT_CSS = """
LabeledInput {
height: auto;
}
LabeledInput Static {
width: 25%;
}
LabeledInput Input {
width: 100%;
}
"""
class LabeledInput(Horizontal):
DEFAULT_CSS = """
LabeledInput {
height: auto;
}
LabeledInput Static {
width: 25%;
}
LabeledInput Input {
width: 75%;
}
"""
🤖 Prompt for AI Agents
In src/edit_python_pe/main.py around lines 27 to 41, the LabeledInput currently
subclasses Vertical which stacks children vertically so the label and input
widths will never sit side-by-side; change the container to Horizontal (or a
Grid) so children can be laid out inline, update the class inheritance from
Vertical to Horizontal (or Grid) and adjust DEFAULT_CSS selectors if needed
(e.g., target Horizontal Static and Input or grid columns) so the label receives
~25% width and the input 75%/100% of remaining space; ensure any spacing/padding
rules still apply for proper alignment.


def __init__(
self, label: str, placeholder: str = "", value: str = "", **kwargs
):
super().__init__(**kwargs)
self.label = label
self.placeholder = placeholder
self._value = value

def compose(self) -> ComposeResult:
yield Static(self.label, classes="label")
yield Input(
id="input", placeholder=self.placeholder, value=self._value
)

@property
def value(self):
return self._value

@value.setter
def value(self, v: str):
self._value = v
self.query_one(selector="#input").value = v

Comment on lines +51 to +65
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix value desync: LabeledInput.value doesn’t reflect user edits, causing saves to miss typed data

Getter returns the cached _value instead of the live Input.value. Setter relies on a DOM id lookup. This will persist empty strings even after typing.

Apply:

@@
-    def compose(self) -> ComposeResult:
-        yield Static(self.label, classes="label")
-        yield Input(
-            id="input", placeholder=self.placeholder, value=self._value
-        )
+    def compose(self) -> ComposeResult:
+        yield Static(self.label, classes="label")
+        self._input = Input(placeholder=self.placeholder, value=self._value)
+        yield self._input
@@
-    @property
-    def value(self):
-        return self._value
+    @property
+    def value(self) -> str:
+        # Reflect current field contents
+        return self._input.value if hasattr(self, "_input") else self._value
@@
-    @value.setter
-    def value(self, v: str):
-        self._value = v
-        self.query_one(selector="#input").value = v
+    @value.setter
+    def value(self, v: str) -> None:
+        if hasattr(self, "_input"):
+            self._input.value = v
+        self._value = v
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def compose(self) -> ComposeResult:
yield Static(self.label, classes="label")
yield Input(
id="input", placeholder=self.placeholder, value=self._value
)
@property
def value(self):
return self._value
@value.setter
def value(self, v: str):
self._value = v
self.query_one(selector="#input").value = v
def compose(self) -> ComposeResult:
yield Static(self.label, classes="label")
self._input = Input(placeholder=self.placeholder, value=self._value)
yield self._input
@property
def value(self) -> str:
# Reflect current field contents
return self._input.value if hasattr(self, "_input") else self._value
@value.setter
def value(self, v: str) -> None:
if hasattr(self, "_input"):
self._input.value = v
self._value = v
🤖 Prompt for AI Agents
In src/edit_python_pe/main.py around lines 51 to 65, the LabeledInput.value
getter returns the cached _value and the setter updates the DOM via a brittle id
lookup, causing desync with user edits; change the getter to return the live
Input widget value (query the Input widget and return its .value if present,
falling back to _value) and update the setter to set both the internal _value
and the Input widget's .value using a typed widget lookup (handle the case where
the widget isn't mounted to avoid exceptions) so in-memory state and the
displayed input always stay in sync.


class SocialEntry(Horizontal):
DEFAULT_CSS = """
SocialEntry Select {
Expand Down Expand Up @@ -129,10 +169,18 @@ def on_mount(self) -> None:

# 2) Build the form portion, hidden at first
self.form_header = Static(FORM_HEADER, classes="header")
self.name_input = Input(placeholder=PLACEHOLDER_NAME)
self.email_input = Input(placeholder=PLACEHOLDER_EMAIL)
self.city_input = Input(placeholder=PLACEHOLDER_CITY)
self.homepage_input = Input(placeholder=PLACEHOLDER_HOMEPAGE)
self.name_input = LabeledInput(
f"{PLACEHOLDER_NAME}:", placeholder=PLACEHOLDER_NAME
)
self.email_input = LabeledInput(
f"{PLACEHOLDER_EMAIL}:", placeholder=PLACEHOLDER_EMAIL
)
self.city_input = LabeledInput(
f"{PLACEHOLDER_CITY}:", placeholder=PLACEHOLDER_CITY
)
self.homepage_input = LabeledInput(
f"{PLACEHOLDER_HOMEPAGE}:", placeholder=PLACEHOLDER_HOMEPAGE
)

self.who_area = TextArea()
self.python_area = TextArea()
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.