Skip to content

Commit

Permalink
Some refinements.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikh2000 authored and erikh2000 committed Jan 1, 2025
1 parent e096214 commit 5efd3f9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
18 changes: 18 additions & 0 deletions src/homeScreen/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import ConfirmSheetPasteDialog from "./dialogs/ConfirmSheetPasteDialog";
import ImportExampleDialog from "./dialogs/ImportExampleDialog";
import LLMDevPauseDialog from "@/homeScreen/dialogs/LLMDevPauseDialog";
import { LOAD_URL } from "@/common/urlUtil";
import { HorizontalScroll } from "@/components/sheetTable/SheetTable";
import { doesSheetHaveWritableColumns } from "@/sheets/sheetUtil";

function HomeScreen() {
const [sheet, setSheet] = useState<HoneSheet|null>(null);
Expand All @@ -37,13 +39,28 @@ function HomeScreen() {
const [job, setJob] = useState<ExecutionJob|null>(null);
const [modalDialog, setModalDialog] = useState<string|null>(null);
const [promptTemplate, setPromptTemplate] = useState<string>('');
const [sheetHorizontalScroll, setSheetHorizontalScroll] = useState<HorizontalScroll>(HorizontalScroll.CLEAR);
const [, setLocation] = useLocation();

useEffect(() => {
init(setAvailableSheets, setModalDialog, setLocation).then(() => { });
return deinit;
}, []);

useEffect(() => {
if (!sheet) return;
if (doesSheetHaveWritableColumns(sheet)) {
setSheetHorizontalScroll(HorizontalScroll.RIGHT); // To show newly added column.
return;
}
setSheetHorizontalScroll(HorizontalScroll.LEFT);
}, [sheet]);

useEffect(() => {
if (sheetHorizontalScroll === HorizontalScroll.CLEAR) return;
setSheetHorizontalScroll(HorizontalScroll.CLEAR); // Reset so it can be set again later.
}, [sheetHorizontalScroll]);

const promptPaneContent = !sheet ? null :
<PromptPane
sheet={sheet} className={styles.promptPane}
Expand All @@ -59,6 +76,7 @@ function HomeScreen() {
</div>
<SheetPane
sheet={sheet} className={styles.sheetPane} selectedRowNo={selectedRowNo}
horizontalScroll={sheetHorizontalScroll}
onRowSelect={setSelectedRowNo}
onImportSheet={() => setModalDialog(ImportOptionsDialog.name)}
onExportSheet={() => chooseExportType(setModalDialog)}
Expand Down
11 changes: 6 additions & 5 deletions src/homeScreen/SheetPane.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Pane, { ButtonDefinition } from "@/components/pane/Pane";
import { getComment } from "./interactions/comment";
import HoneSheet from "@/sheets/types/HoneSheet";
import SheetTable, { GeneratedFooterText } from "@/components/sheetTable/SheetTable";
import SheetTable, { GeneratedFooterText, HorizontalScroll } from "@/components/sheetTable/SheetTable";

type Props = {
sheet: HoneSheet|null,
className:string,
selectedRowNo:number,
horizontalScroll:HorizontalScroll,
onRowSelect:(rowNo:number)=>void
onExportSheet():void,
onImportSheet():void
Expand All @@ -16,16 +17,16 @@ function _noSheetLoadedContent() {
return <div>No sheet loaded.</div>;
}

function _sheetContent(sheet:HoneSheet|null, selectedRowNo:number, _onRowSelect:(rowNo:number)=>void) {
function _sheetContent(sheet:HoneSheet|null, selectedRowNo:number, _onRowSelect:(rowNo:number)=>void, horizontalScroll) {

Check failure on line 20 in src/homeScreen/SheetPane.tsx

View workflow job for this annotation

GitHub Actions / deploy

Parameter 'horizontalScroll' implicitly has an 'any' type.
if (!sheet) return _noSheetLoadedContent();
const onSelectCell = (_colNo:number, rowNo:number) => _onRowSelect(rowNo);
return <SheetTable
selectedRowNo={selectedRowNo} sheet={sheet} footerText={GeneratedFooterText.ROW_COUNT}
onSelectCell={onSelectCell} displayRowCount={20} />;
onSelectCell={onSelectCell} displayRowCount={20} horizontalScroll={horizontalScroll}/>;
}

function SheetPane({sheet, className, onImportSheet, selectedRowNo, onRowSelect, onExportSheet}:Props) {
const content = _sheetContent(sheet, selectedRowNo, onRowSelect);
function SheetPane({sheet, className, onImportSheet, selectedRowNo, onRowSelect, onExportSheet, horizontalScroll}:Props) {
const content = _sheetContent(sheet, selectedRowNo, onRowSelect, horizontalScroll);

const buttons:ButtonDefinition[] = [
{ text:'Import', onClick:() => onImportSheet() },
Expand Down
18 changes: 18 additions & 0 deletions src/homeScreen/dialogs/ExecuteDialog.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
.progress {
height: 3vh;
}

@keyframes shimmer {
0% {
background-position: -200%;
}
100% {
background-position: 200%;
}
}

.prompt {
display: inline-block;
background: linear-gradient(90deg, rgba(.5, .1, 0, 0.2), rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.2));
background-size: 200% auto;
color: transparent;
-webkit-background-clip: text;
animation: shimmer 1.5s infinite;
}
4 changes: 2 additions & 2 deletions src/homeScreen/dialogs/ExecuteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ function ExecuteDialog({onCancel, isOpen, job, onComplete, onUpdateJob}:Props) {
const middleContent = cancelRequestReceived
? <p>One moment<WaitingEllipsis trailing/></p>
: <>
<p>Current prompt: "{job.currentPrompt}"</p>
<p>Current prompt: <span className={styles.prompt}>{job.currentPrompt}</span></p>
<p>Response: <GeneratedText text={responseText} /></p>
<p>Time remaining:{job.timeRemainingText}</p>
<p>Time remaining: {job.timeRemainingText}</p>
</>

return ( // Intentionally not passing "onCancel" to ModalDialog as I don't want a click-away to cancel the job. User must click the "cancel" button.
Expand Down

0 comments on commit 5efd3f9

Please sign in to comment.