Skip to content

Commit 45a0ec6

Browse files
pajomaclaude
andcommitted
docs(plans): plan for #230 smart-input week-boundary and 2-letter aliases
#230 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent cae1ea8 commit 45a0ec6

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Plan — Issue #230: Smart input week-text boundary and 2-letter weekday aliases
2+
3+
> **Spec:** [docs/specs/2026-06-01-fix-230-smart-input-week-and-weekday-aliases.md](../specs/2026-06-01-fix-230-smart-input-week-and-weekday-aliases.md)
4+
> **Issue:** [pajoma/vscode-journal#230](https://github.com/pajoma/vscode-journal/issues/230)
5+
> **Branch:** `feat/177-smart-input-tokenizer` (implemented alongside #177)
6+
> **Created:** 2026-06-01
7+
8+
## Approach
9+
10+
Both bugs are addressed in the #177 tokenizer branch. Bug 1 is already resolved by the tokenizer's architecture — `recognizeWeek` uses `(?=\s|$)` as a zero-width lookahead so no character is consumed from the following text. Bug 2 requires adding `mo`, `tu`, `we`, `th` to `weekdayVocab()` (plus `fr` is already covered by the German section). `getDayOfWeekForString` in `dates.ts` already maps all five 2-letter forms correctly; only the vocab recognizer needs updating.
11+
12+
**Trade-off:** `we` and `th` are common English words; adding them as standalone weekday tokens introduces the same ambiguity class as German `di`/`do`. This is accepted per spec: the tokenizer marks them `ambiguous` (≤3 chars), which triggers the yellow border feedback in the QuickPick.
13+
14+
## Steps
15+
16+
1. **Verify Bug 1 is resolved** — add regression test: `parseInput("task week Finalize Shoppinglist")``flags="task"`, `text="Finalize Shoppinglist"`, `hasWeek()=true`. No code change needed.
17+
18+
2. **Add 2-letter English aliases to `weekdayVocab()`** — append `'mo', 'tu', 'we', 'th', 'fr'` after the 3-letter English block (`mon/tue/wed/thu/fri/sat/sun`). Longest-first ordering preserved (3-letter tried before 2-letter). `fr` already present in German section; adding it to English section makes intent explicit and matches first (same result from `getDayOfWeekForString`).
19+
20+
3. **Invalidate pattern cache**`_weekdayPatterns` is built lazily from `weekdayVocab()`. Adding entries to the array changes the return value; since the cache is built per `MatchInput` instance, no reset needed.
21+
22+
4. **Add regression tests** to `src/test/suite/match-input-vocab.test.ts`:
23+
- `"task week Finalize Shoppinglist"` → Bug 1 regression
24+
- `"mo"`, `"tu"`, `"we"`, `"th"`, `"fr"` each → correct weekday offset (same as 3-letter form)
25+
- `"w15"` → week 15, no regression from `recognizeWeekNum` priority
26+
27+
## Test scenarios
28+
29+
| Scenario | Input | Expected |
30+
|----------|-------|----------|
31+
| Bug 1 regression — week+text | `"task week Finalize Shoppinglist"` | flag=task, text="Finalize Shoppinglist", hasWeek=true |
32+
| Bug 1 regression — week alone | `"week"` | hasWeek=true, no crash |
33+
| Bug 1 regression — w15 still numeric | `"w15"` | week=15 |
34+
| 2-letter alias mo | `"mo"` | same offset as `"mon"` |
35+
| 2-letter alias tu | `"tu"` | same offset as `"tue"` |
36+
| 2-letter alias we | `"we"` | same offset as `"wed"` |
37+
| 2-letter alias th | `"th"` | same offset as `"thu"` |
38+
| 2-letter alias fr | `"fr"` | same offset as `"fri"` |
39+
| No regression — task do | `"task do the shopping"` | flag=task, text="the shopping" (do = German Thursday) |
40+
41+
## Dependencies
42+
43+
- **Requires #177 tokenizer branch** — all changes land in `feat/177-smart-input-tokenizer`. This issue closes together with #177 in the same PR.
44+
45+
## Risk
46+
47+
| Risk | Mitigation |
48+
|------|-----------|
49+
| `we`/`th` false-positive on common words | Accepted per spec; tokenizer marks them `ambiguous`, yellow border visible to user |
50+
| `fr` duplication (English + German section) | `getDayOfWeekForString("fr", locale)` returns 5 (Friday) for all locales — result identical |
51+
| `_weekdayPatterns` cache stale | Cache is per-instance, built lazily on first `recognizeWeekday` call — no stale state possible |
52+
53+
## Rollback
54+
55+
Part of #177 PR. Revert the `weekdayVocab()` addition (two lines) if 2-letter aliases cause regressions after release.
56+
57+
## Reference spec
58+
59+
[docs/specs/2026-06-01-fix-230-smart-input-week-and-weekday-aliases.md](../specs/2026-06-01-fix-230-smart-input-week-and-weekday-aliases.md)

0 commit comments

Comments
 (0)