forked from ETS-Next-Gen/writing_observer
-
Notifications
You must be signed in to change notification settings - Fork 2
adding reconstruction codes for code review #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
saminur
wants to merge
3
commits into
master
Choose a base branch
from
samiReconstruction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| # Documentation Updates - Multi-Tab System | ||
|
|
||
| ## Overview | ||
| Updated documentation in response to reviewer feedback requesting more elaboration on how tabs work and what commands are associated with tabs. The information about how tabs operate is now thoroughly documented. | ||
|
|
||
| ## Files Enhanced | ||
|
|
||
| ### 1. **command_state.py** - Core Tab Management | ||
| - **TabState class**: Added comprehensive docstring explaining tab structure, metadata, and embedded elements | ||
| - **DocState class**: Added detailed explanation of: | ||
| - How tabs function in Google Docs (separate sections/pages) | ||
| - Complete command-to-tab mapping (which commands affect which aspects) | ||
| - Tab lifecycle and reconstruction workflow | ||
|
|
||
| - **apply_bundle() method**: Added explanation of bundle structure and how default_tab routing works | ||
|
|
||
| - **_apply_cmd() method**: Major enhancement with: | ||
| - Complete command routing explanation | ||
| - Full list of supported command types | ||
| - Documentation of how each command type affects tabs | ||
|
|
||
| #### Tab Metadata Commands (Now Documented) | ||
| - **MKCH** ("Make channel"): Initialize tab metadata with names | ||
| - Data structure: Deeply nested lists containing tab names | ||
| - When used: Document creation or tab addition | ||
| - Result: Sets human-readable tab names | ||
|
|
||
| - **UCP** ("Update caption"): Rename existing tabs | ||
| - Data structure: Tab ID + new name in nested format | ||
| - When used: User renames a tab | ||
| - Handles both specific tab ID and current tab context | ||
|
|
||
| - **AC** ("Add child"): Create new tabs | ||
| - Data structure: New tab ID + name data | ||
| - When used: User adds/duplicates a tab | ||
| - Initializes TabState and records creation timestamp | ||
|
|
||
| #### Text Editing Commands (Now Documented) | ||
| - **IS** ("Insert string"): Add text at position | ||
| - **DS** ("Delete substring"): Remove text in range | ||
| - **AS** ("Alter substring"): Replace text (delete + insert) | ||
| - All with 1-based indexing and placeholder awareness | ||
| - Detailed semantics and fallback behavior | ||
|
|
||
| #### Element Commands (Now Documented) | ||
| - **AE** ("Add element"): Register dropdowns, images, etc. | ||
| - Dropdown-definition: Holds available options | ||
| - Dropdown: Instance with selected value | ||
| - Other elements: Images (limited by log constraints) | ||
|
|
||
| - **TE** ("Tie element"): Embed element into text | ||
| - Special handling for dropdowns (deferred reconstruction) | ||
| - Placeholders for other elements (images, etc.) | ||
|
|
||
| #### Control Flow Commands | ||
| - **MLTI** ("Multi-command"): Wrapper containing sub-commands | ||
| - **NM** ("New mutation"): Routes commands to specific tabs via 'nmr' field | ||
|
|
||
| ### 2. **ReconstructionState.py** - Document-Level Tab Management | ||
| - **ReconstructionState class**: Added detailed docstring explaining: | ||
| - Multi-document state management | ||
| - Key responsibilities (tracking documents, routing events, persistence) | ||
| - Complete workflow (loading, processing, saving) | ||
|
|
||
| - **reconstruct_from_events() function**: Enhanced with: | ||
| - Multi-tab reconstruction logic explanation | ||
| - Event sorting and ordering importance | ||
| - Tab routing mechanism | ||
| - Command processing pipeline | ||
| - Metadata tracking per document | ||
|
|
||
| ### 3. **load_event.py** - Event and Tab Extraction | ||
| - **parse_tab_from_url() function**: Added comprehensive docstring: | ||
| - Multi-tab URL structure explanation | ||
| - Tab ID format and examples | ||
| - Default behavior when tab not found | ||
|
|
||
| - **GoogleDocsSaveEvent class**: Significantly expanded documentation: | ||
| - Multi-tab event structure | ||
| - Command bundle format | ||
| - Timing information usage | ||
| - Detailed attribute descriptions | ||
|
|
||
| ### 4. **main_reconstruction.py** - Tab Rendering | ||
| - **build_full_text() function**: Enhanced with: | ||
| - Multi-tab rendering strategy explanation | ||
| - Tab ordering logic (by first_timestamp) | ||
| - Element reconstruction approach | ||
| - Output format with examples | ||
| - Section separation and formatting | ||
|
|
||
| ## Key Concepts Now Documented | ||
|
|
||
| ### Tab Identification | ||
| - Tab IDs start with 't.' (e.g., 't.0', 't.95y...', 't.4n9p3wa3df6o') | ||
| - 't.0' is the default/initial tab | ||
| - Extracted from Google Docs URLs via 'tab=' parameter | ||
|
|
||
| ### Command Routing | ||
| - **URL routing**: Tab ID in URL's 'tab=' parameter | ||
| - **nm routing**: Tab ID in new mutation's 'nmr' field (Last 't.' string wins) | ||
| - **Explicit routing**: ucp and ac commands specify target tab | ||
| - **Default routing**: Text editing commands use current_tab parameter | ||
|
|
||
| ### Reconstruction Workflow | ||
| 1. Events sorted chronologically (server_time, timestamp) | ||
| 2. Commands routed to appropriate TabState | ||
| 3. Text modified, metadata tracked, elements registered | ||
| 4. After all events: expand_dropdowns() converts metadata to readable text | ||
| 5. Multi-tab sections rendered with headers and separators | ||
|
|
||
| ### Element Handling | ||
| - **Dropdowns**: Reconstructed as readable "DROPDOWN: Config – Value" | ||
| - **Images**: Shown as placeholders (binary data not in logs) | ||
| - **Deferred processing**: Metadata gathered first, then reconstructed | ||
|
|
||
| ## Benefits for System Integration | ||
|
|
||
| Developers can now understand: | ||
| 1. **How tabs work**: Independent sections within a document with separate content | ||
| 2. **Command mapping**: Which commands affect which tabs and tab properties | ||
| 3. **Event flow**: How events route to tabs for processing | ||
| 4. **Rendering**: How multi-tab content is presented in output | ||
| 5. **State persistence**: How reconstruction state captures tab information | ||
|
|
||
| This documentation provides the "crucial information for determining the best way these will operate within the system" as requested by the reviewer. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be combined with the line above it.
import { googledocs_id_from_url, tab_id_from_url } from './writing_common';