Repository navigation
Composer: $task makes a task and starts a chat for it #69
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
Merged
Merged
Changes from all commits
Commits
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,64 @@ | ||
| // The strip atop the composer while `$task` has made the box a task line: what the | ||
| // words were read as (due day, priority, folder, as the Tasks page's quick-add line | ||
| // shows them), each with a × that keeps the word as text, and a × that turns the | ||
| // box back into a message. | ||
| import React from 'react' | ||
| import type { Project } from './types' | ||
| import type { Hint } from '../todos/parse' | ||
| import { hintKey } from '../todos/parse' | ||
| import { dueText } from '../todos/format' | ||
| import { folderFor, folderLabel } from '../todos/folders' | ||
| import { FolderIcon } from '../work/FolderField' | ||
| import { TI } from './ui' | ||
| import { IconChecklist, IconCalendar, IconFlag, IconLoader2, IconX } from './icons' | ||
|
|
||
| const PRIORITY = { 4: 'P1', 3: 'P2', 2: 'P3', 1: 'P4' } as const | ||
|
|
||
| export default function NewTaskBar({ hints, folderId, typedFolder, projects, now, busy, onIgnore, onLeave }: { | ||
| hints: readonly Hint[] | ||
| /** Where the task will be filed (typed with #folder, else where the chat is being started). */ | ||
| folderId: string | null | ||
| /** The folder came from a #word, so its chip can be undone like the others. */ | ||
| typedFolder: boolean | ||
| projects: readonly Project[] | ||
| now: Date | ||
| busy: boolean | ||
| onIgnore: (key: string) => void | ||
| onLeave: () => void | ||
| }) { | ||
| const folder = folderFor(folderId, projects) | ||
| const keep = (e: React.MouseEvent) => e.preventDefault() | ||
| return ( | ||
| <div className="vc-newtask" aria-label="New task"> | ||
| <span className="vc-newtask-tag"> | ||
| {busy ? <TI icon={IconLoader2} size={14} className="vc-spin" /> : <TI icon={IconChecklist} size={14} />} | ||
| New task | ||
| <button type="button" aria-label="Write a message instead" title="Write a message instead" onMouseDown={keep} onClick={onLeave} disabled={busy}> | ||
| <TI icon={IconX} size={11} /> | ||
| </button> | ||
| </span> | ||
| {hints.filter((h) => h.kind !== 'folder').map((h) => ( | ||
| <span key={`${h.kind}-${h.start}`} className={`vc-newtask-chip ${h.kind}`}> | ||
| <TI icon={h.kind === 'due' ? IconCalendar : IconFlag} size={12} /> | ||
| {h.kind === 'due' && h.dueDate ? dueText(h.dueDate, now) : h.priority ? PRIORITY[h.priority] : h.text} | ||
| <button type="button" aria-label={`Keep “${h.text}” as text`} onMouseDown={keep} onClick={() => onIgnore(hintKey(h))}> | ||
| <TI icon={IconX} size={11} /> | ||
| </button> | ||
| </span> | ||
| ))} | ||
| <span className="vc-newtask-chip folder" title={typedFolder ? undefined : 'Where this chat is; type #folder for another'}> | ||
| <FolderIcon project={folder} size={12} /> | ||
| {folderLabel(folderId, projects)} | ||
| {typedFolder && (() => { | ||
| const h = hints.find((x) => x.kind === 'folder')! | ||
| return ( | ||
| <button type="button" aria-label={`Keep “${h.text}” as text`} onMouseDown={keep} onClick={() => onIgnore(hintKey(h))}> | ||
| <TI icon={IconX} size={11} /> | ||
| </button> | ||
| ) | ||
| })()} | ||
| </span> | ||
| <span className="vc-newtask-help">↵ adds it and starts a chat</span> | ||
| </div> | ||
| ) | ||
| } |
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.
If a
$taskline containing a relative date such astodayortomorrowis left open across midnight, this memo retains theDatefrom the last text or project change. Pressing Enter afterward submits the previous day's computeddueDate, whereas the Tasks page refreshes itsnowvalue every minute. Include a local-day key in the dependencies or parse again at submission time.Useful? React with 👍 / 👎.