Skip to content

Conversation

@MangelRyujin
Copy link
Contributor

@MangelRyujin MangelRyujin commented Sep 9, 2025

Summary by CodeRabbit

  • New Features

    • Social Entry fields now use labeled inputs (Name, Email, City, Homepage) with preserved placeholders and synced values.
  • UI Improvements

    • Labels and inputs are displayed side by side for clearer, more consistent form layout.
  • Bug Fixes

    • Improved reliability when selecting a file from the list view.
  • Chores

    • Project version bumped to 0.2.10.

@coderabbitai
Copy link

coderabbitai bot commented Sep 9, 2025

Walkthrough

Adds a new LabeledInput UI component and refactors SocialEntry to use it for four fields. Updates on_list_view_selected to read selected filename from item_text_widget.content instead of item_text_widget.renderable. Also bumps project version in pyproject.toml. All changes are in src/edit_python_pe/main.py and pyproject.toml.

Changes

Cohort / File(s) Summary
UI Component: LabeledInput
src/edit_python_pe/main.py
Added LabeledInput(Vertical) class with a side-by-side label+input layout, CSS, and a value property that proxies to the internal Input. Constructor: __init__(label, placeholder="", value="", **kwargs).
SocialEntry refactor to LabeledInput
src/edit_python_pe/main.py
Replaced four plain Input fields (name_input, email_input, city_input, homepage_input) with LabeledInput instances using PLACEHOLDER_* constants (label text includes trailing colon) and preserved placeholders.
List selection content access
src/edit_python_pe/main.py
In on_list_view_selected, switched selected item text access from item_text_widget.renderable to item_text_widget.content.
Version bump
pyproject.toml
Project version updated from 0.2.9 to 0.2.10 in the [project] section.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant SocialEntry
  participant LabeledInput
  participant Input as InternalInput
  participant ListViewItem

  Note over LabeledInput,Input: New component: label + input, .value proxy

  User->>SocialEntry: Open form / edit fields
  SocialEntry->>LabeledInput: Instantiate(label, placeholder, value)
  LabeledInput->>Input: Create internal Input
  User->>Input: Type text
  Input-->>LabeledInput: on_change (text)
  LabeledInput-->>SocialEntry: .value reflects input

  User->>ListViewItem: Select file item
  ListViewItem-->>SocialEntry: item_text_widget.content (used for filename)
  Note right of SocialEntry: Uses .content instead of .renderable
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks (1 passed, 1 warning, 1 inconclusive)

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ❓ Inconclusive There is no pull request description provided here to evaluate its relevance or detail against the changeset, so it is unclear whether the description appropriately describes the changes. Please provide or update the pull request description so it clearly outlines the purpose and scope of the changes for reviewer context.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title “feat: add labels to all the inputs fields” directly reflects the main change of introducing labeled inputs and replacing plain input fields, clearly summarizing the core enhancement. It is concise, focused on the primary feature, and aligns with the changes made to the input components.

Poem

I hopped through forms with tidy glee,
A label hugged an input — now side-by-side are we.
Four fields wear name-tags, neat and bright,
Filenames read true, content brings the light.
🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f269544 and cb88a26.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • pyproject.toml
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/edit_python_pe/main.py (1)

29-41: Optional: Style the provided .label class or remove it
You add classes="label" but no CSS targets it. Minor polish.

Apply:

@@
         LabeledInput Input {
             width: 75%;
         }
+        LabeledInput .label {
+            text-align: right;
+            padding-right: 1;
+        }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 44c0c48 and f269544.

📒 Files selected for processing (1)
  • src/edit_python_pe/main.py (3 hunks)
🔇 Additional comments (2)
src/edit_python_pe/main.py (2)

172-183: Nice refactor to labeled fields
Clearer UX; placeholders preserved. Once LabeledInput.value is fixed, save flow should work as expected.


284-285: Keep compatibility with Textual’s Static API (content vs renderable)
Guard for both attributes to avoid breakage across versions.

Apply:

-        filename = item_text_widget.content
+        filename = getattr(item_text_widget, "content", None)
+        if filename is None:
+            filename = getattr(item_text_widget, "renderable", "")
+        if not isinstance(filename, str):
+            filename = str(filename)

Comment on lines +27 to +41
class LabeledInput(Vertical):

DEFAULT_CSS = """
LabeledInput {
height: auto;
}
LabeledInput Static {
width: 25%;
}
LabeledInput Input {
width: 100%;
}
"""
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.

Comment on lines +51 to +65
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

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.

@jpchauvel jpchauvel merged commit 211d517 into pythonpe:main Sep 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants