[Tiny] commit the index.html/js so that command center works on pip install#985
[Tiny] commit the index.html/js so that command center works on pip install#985jeff-hykin merged 4 commits intodevfrom
Conversation
Greptile OverviewGreptile SummaryThis PR attempts to make the command center work on Critical Issues Found1. Incorrect
|
| Filename | Score | Overview |
|---|---|---|
| dimos/web/websocket_vis/websocket_vis_module.py | 0/5 | Attempts to use get_data() incorrectly with full path instead of simple filename; removes critical /assets route needed for serving React app JavaScript/CSS files |
| data/.lfs/command_center.html.tar.gz | 2/5 | Adds LFS archive for command center, but the code won't find it due to incorrect path usage in get_data() call |
Sequence Diagram
sequenceDiagram
participant User
participant Browser
participant Server as WebsocketVisModule
participant GetData as get_data()
participant LFS as Git LFS Storage
User->>Browser: Navigate to /command-center
Browser->>Server: GET /command-center
Note over Server: Line 223: Incorrect path usage
Server->>GetData: get_data(_COMMAND_CENTER_DIR / "index.html")
Note over GetData: Looks for data/.lfs/dimos/web/.../index.html.tar.gz
GetData--XServer: FileNotFoundError (wrong path)
Server->>Browser: 503 "Command center not built"
Browser->>User: Error page displayed
Note over Server,LFS: What SHOULD happen:
Server->>GetData: get_data("command_center.html")
GetData->>LFS: Pull data/.lfs/command_center.html.tar.gz
LFS-->>GetData: Archive data
GetData->>GetData: Extract to data/command_center.html/
GetData-->>Server: Path(data/command_center.html/)
Server->>Browser: 200 OK (index.html)
Browser->>Server: GET /assets/main-DEBhvAzS.js
Note over Server: ❌ /assets route removed (lines 233-236)
Server--XBrowser: 404 Not Found
Browser->>User: Blank page (JS failed to load)
| *.foxe | ||
| /dist | ||
| /dist-standalone | ||
| /node_modules | ||
| !/package.json | ||
| !/package-lock.json |
There was a problem hiding this comment.
CRITICAL: This PR will not achieve its stated goal of making command center work on pip install.
The PR removes dist-standalone from .gitignore to commit the build artifacts, but the MANIFEST.in file at the repository root has these exclusion rules:
recursive-exclude dimos/web/command-center-extension *
prune dimos/web/command-center-extension
These rules exclude ALL files under dimos/web/command-center-extension/ from the pip distribution package, including the newly committed dist-standalone/ directory.
To fix this issue, you need to either:
- Update MANIFEST.in to explicitly include the dist-standalone directory:
# In MANIFEST.in, change from:
recursive-exclude dimos/web/command-center-extension *
prune dimos/web/command-center-extension
# To:
recursive-exclude dimos/web/command-center-extension *
prune dimos/web/command-center-extension
recursive-include dimos/web/command-center-extension/dist-standalone *
- OR update pyproject.toml to explicitly include the command center assets in package-data:
[tool.setuptools.package-data]
"dimos.web.command-center-extension.dist-standalone" = ["*"]Without this fix, when users run pip install dimos, the command center files will NOT be included in the package, and accessing http://localhost:{port}/command-center will return a 503 error with message "Command center not built."
| body { background: #1a1a2e; font-family: -apple-system, system-ui, sans-serif; } | ||
| #root { width: 100%; height: 100%; } | ||
| </style> | ||
| <script type="module" crossorigin src="/assets/main-DEBhvAzS.js"></script> |
There was a problem hiding this comment.
WARNING: Hardcoded asset hash will cause maintenance issues.
The JavaScript bundle reference includes a content-based hash (main-DEBhvAzS.js). This hash is generated by Vite during the build process and will change whenever:
- Dependencies are updated
- Source code changes
- Build configuration changes
Problems this causes:
- Every rebuild will generate a different hash, requiring a new commit of both
index.htmland the JS file - The old
main-DEBhvAzS.jsfile will become stale but remain in the repository - This will bloat the repository with multiple versions of the 426KB minified bundle
Better approaches:
- Use a fixed filename by configuring Vite to disable hashing for the standalone build:
// In vite.config.ts
build: {
rollupOptions: {
output: {
entryFileNames: 'assets/main.js', // Fixed filename
chunkFileNames: 'assets/[name].js',
assetFileNames: 'assets/[name].[ext]'
}
}
}- OR build during pip install using a setup.py post-install script (though this requires Node.js to be available at install time)
The fixed filename approach is recommended as it prevents repository bloat while still allowing the artifacts to be committed.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| @@ -0,0 +1,111 @@ | |||
| (function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const f of document.querySelectorAll('link[rel="modulepreload"]'))l(f);new MutationObserver(f=>{for(const p of f)if(p.type==="childList")for(const g of p.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&l(g)}).observe(document,{childList:!0,subtree:!0});function r(f){const p={};return f.integrity&&(p.integrity=f.integrity),f.referrerPolicy&&(p.referrerPolicy=f.referrerPolicy),f.crossOrigin==="use-credentials"?p.credentials="include":f.crossOrigin==="anonymous"?p.credentials="omit":p.credentials="same-origin",p}function l(f){if(f.ep)return;f.ep=!0;const p=r(f);fetch(f.href,p)}})();function Xp(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var qc={exports:{}},Ks={},Gc={exports:{}},Ot={};/** | |||
There was a problem hiding this comment.
Do we want this included in the python package? If so needs to update tool.setuptools.package-data
d59b20f to
ced2782
Compare
| async def serve_command_center(request): # type: ignore[no-untyped-def] | ||
| """Serve the command center 2D visualization (built React app).""" | ||
| index_file = _COMMAND_CENTER_DIR / "index.html" | ||
| index_file = get_data(_COMMAND_CENTER_DIR / "index.html") |
There was a problem hiding this comment.
The get_data() function expects a simple filename (like "command_center.html"), not a full path with subdirectories.
When you pass _COMMAND_CENTER_DIR / "index.html" (which is dimos/web/command-center-extension/dist-standalone/index.html), the function will look for:
data/dimos/web/command-center-extension/dist-standalone/index.html(doesn't exist)- Then try to pull
data/.lfs/dimos/web/command-center-extension/dist-standalone/index.html.tar.gz(doesn't exist)
But the actual LFS file is data/.lfs/command_center.html.tar.gz.
According to the data.md documentation, the correct pattern is:
# Correct usage
index_file = get_data("command_center.html") # Returns path to extracted directory
# Then access: index_file / "index.html"This critical bug means the command center will always return a 503 error with the "not built" message, even after the LFS file is pulled and extracted.
Additional Comments (1)
The built React app's Even if the
The original code correctly served assets from extracted_dir = get_data("command_center.html")
if extracted_dir.exists():
routes.append(
Mount(
"/assets",
app=StaticFiles(directory=extracted_dir / "assets"),
name="assets",
)
) |
No description provided.