The passuk states ששת ימים תעבוד ועשית כל מלאכתך you shall work for six days and you shall do all your work. The Ramban explains that the first part of the passuk refers to working in the field for six days, and the second part refers to doing work for oneself, such as food preparations. Rashi explains the words ועשית כל מלאכתך, that when Shabbos comes it should be in your eyes as though all your work is done, so that you won’t come to think about work on Shabbos.
The Gemara brings a story of a pious person who had a breach in the fence of his field and he thought about it and decided to fence it up. He remembered that it was Shabbos and he therefore held back from fixing the breach. A miracle happened and a tzlaf tree grew in the field, and from it he and his household were supported. Rashi explains that the tzlaf tree is a very big tree with many leaves, and it has three different types of fruits to eat. The Iyun Yaakov explains that the tzlaf tree grew inside the field, and the Ben Yehoyadah explains that it grew in place of the wall, in order to close the breach. This pious man wanted to protect his field from animals and people coming in and eating its produce so he thought to fence it up to guard the field. Once he realized it was Shabbos and that it was improper to think about what to do, he refrained, and left his field open. Hashem performed a miracle with the tzlaf tree to close the opening of his field, which was what he held back from doing.
The Gemara brings that although actions for business are forbidden on Shabbos, thoughts about business are permitted, as it states ממצוא חפצך ודבר דבר, one must refrain from speaking about things, but thoughts are permitted. The Maharshal asks, if so what was the need for the person to refrain from closing the breach? The Maharshal answers that since he was an honorable and pious person, he needed to be more stringent. He refrained from bringing his thoughts into reality, since he did not want to benefit from it.
The Taz brings bshem the Yerushalmi that he didn’t just think about what to do, rather on Shabbos he asked advice about how to fence it up during the week, thinking that it was allowed. Afterwards he realized it was improper, so he refrained from using the advice and did not fence it so as not to benefit from his actions.
The Tur brings that although it is permissible for a person to think about his work, still there is a mitzvah of oneg Shabbos not to think about it at all. This is as the passuk states ששת ימים תעבוד ועשית כל מלאכתך. It is impossible for a person to complete all his work in just one week! Rather the passuk reflects that a person should think about his work as though it is completed, and there is no greater oneg than this!
May we be careful on Shabbos about what we do, say and even think, and be zoche to the greatest oneg Shabbos!